Commit 92bffdfd authored by hongguangwu's avatar hongguangwu

Merge remote-tracking branch 'origin/develop' into develop

parents 2a963ced 794049d1
...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.ldap.util; ...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.ldap.util;
import com.unboundid.ldap.sdk.*; import com.unboundid.ldap.sdk.*;
import com.unboundid.ldap.sdk.controls.SubentriesRequestControl; import com.unboundid.ldap.sdk.controls.SubentriesRequestControl;
import com.unboundid.util.Base64;
import com.yifu.cloud.plus.v1.yifu.common.ldap.config.LdapProperties; import com.yifu.cloud.plus.v1.yifu.common.ldap.config.LdapProperties;
import com.yifu.cloud.plus.v1.yifu.common.ldap.entity.PersonVo; import com.yifu.cloud.plus.v1.yifu.common.ldap.entity.PersonVo;
import com.yifu.cloud.plus.v1.yifu.common.ldap.mapper.PersonAttributesMapper; import com.yifu.cloud.plus.v1.yifu.common.ldap.mapper.PersonAttributesMapper;
...@@ -10,15 +11,10 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,15 +11,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.ldap.core.LdapTemplate; import org.springframework.ldap.core.LdapTemplate;
import javax.naming.Context; import java.security.MessageDigest;
import javax.naming.NamingEnumeration; import java.security.NoSuchAlgorithmException;
import javax.naming.NamingException; import java.text.ParseException;
import javax.naming.directory.SearchControls;
import javax.naming.ldap.Control;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List; import java.util.List;
import static org.springframework.ldap.query.LdapQueryBuilder.query; import static org.springframework.ldap.query.LdapQueryBuilder.query;
...@@ -33,10 +29,6 @@ public class LdapUtil { ...@@ -33,10 +29,6 @@ public class LdapUtil {
@Autowired @Autowired
private LdapProperties ldapProperties; private LdapProperties ldapProperties;
private static LdapContext ctx = null;
private static final Control[] connCtls = null;
/** /**
* @return List<SearchResultEntry> * @return List<SearchResultEntry>
* @author huyc * @author huyc
...@@ -64,71 +56,31 @@ public class LdapUtil { ...@@ -64,71 +56,31 @@ public class LdapUtil {
} }
// 校验用户名密码的方法 // 校验用户名密码的方法
public Boolean authenticate(String usr, String pwd) { public Boolean authenticate(String usr, String pwd) throws NoSuchAlgorithmException {
boolean valide;
if (pwd == null || "".equals(pwd)) if (pwd == null || "".equals(pwd))
return false; return false;
if (ctx == null) {
getCtx();
}
String userDN = getUserDN(usr);
if ("".equals(userDN) || userDN == null) {
return false;
}
try {
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDN);
ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, pwd);
ctx.reconnect(connCtls);
valide = true;
closeCtx();
} catch (NamingException e) {
log.error(userDN + " is not authenticated");
valide = false;
}
return valide;
}
public void getCtx() {
if (ctx != null) {
return;
}
Hashtable<String, String> env = new Hashtable<>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://" + ldapProperties.getUrl() + ":" + ldapProperties.getPort() +
"/" + ldapProperties.getDn());
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, ldapProperties.getUserName());
env.put(Context.SECURITY_CREDENTIALS, ldapProperties.getPassword());
try { try {
// 链接ldap List<SearchResultEntry> entryList = this.getAllPersonNamesWithTraditionalWay();
ctx = new InitialLdapContext(env, connCtls); byte[] ldapPw = new byte[0];
} catch (NamingException e) { for (SearchResultEntry resultEntry: entryList){
e.printStackTrace(); if (resultEntry.getDN().contains("uid="+usr)) {
String password = resultEntry.getAttributeValue("userPassword");
if (null != password) {
String ldapPwd1 = password.substring(5);
ldapPw = Base64.decode(ldapPwd1);
break;
} else {
return false;
} }
} }
public void closeCtx() throws NamingException {
if (ctx != null)
ctx.close();
} }
MessageDigest md5 = MessageDigest.getInstance("MD5");
public String getUserDN(String uid) { md5.update(pwd.getBytes());
StringBuilder userDN = new StringBuilder(); byte[] m = md5.digest();
try { return MessageDigest.isEqual(m, ldapPw);
SearchControls constraints = new SearchControls(); } catch (ParseException e) {
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); log.error(" is not authenticated");
NamingEnumeration<?> en = ctx.search("", "uid=" + uid, constraints);
while (en != null && en.hasMoreElements()) {
Object obj = en.nextElement();
if (obj instanceof javax.naming.directory.SearchResult) {
javax.naming.directory.SearchResult si = (javax.naming.directory.SearchResult) obj;
userDN.append(si.getName());
userDN.append(",").append(ldapProperties.getDn());
} }
} return false;
} catch (Exception e) {
e.printStackTrace();
}
return userDN.toString();
} }
} }
...@@ -2588,6 +2588,15 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -2588,6 +2588,15 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
dispatch.setSettleDomainCode(setInfoVo.getDepartNo()); dispatch.setSettleDomainCode(setInfoVo.getDepartNo());
dispatch.setBelongUnit(setInfoVo.getCustomerId()); dispatch.setBelongUnit(setInfoVo.getCustomerId());
dispatch.setBelongUnitName(setInfoVo.getCustomerName()); dispatch.setBelongUnitName(setInfoVo.getCustomerName());
TEmployeeProject temp = new TEmployeeProject();
temp.setDeptId(dispatch.getSettleDomain());
temp.setEmpId(dispatch.getEmpId());
R<TEmployeeProject> res = archivesDaprUtil.getTEmployeeProjectById(temp);
if (Common.isNotNull(res)){
if (Common.isNotNull(res.getData().getWorkingHours())) {
dispatch.setWorkingHours(res.getData().getWorkingHours());
}
}
} }
StringBuffer temp = new StringBuffer(); StringBuffer temp = new StringBuffer();
if (Common.isNotNull(excel.getSocialReduceDate())){ if (Common.isNotNull(excel.getSocialReduceDate())){
......
...@@ -2332,8 +2332,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2332,8 +2332,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
socialParam.setFd_3af9ee3aa9c84a(CommonConstants.EMPTY_STRING); socialParam.setFd_3af9ee3aa9c84a(CommonConstants.EMPTY_STRING);
} }
//实缴合计 //实缴合计
if (Common.isNotNull(library.getSumAll())) { if (Common.isNotNull(library.getSocialSum())) {
socialParam.setFd_3af9ee3c6bfc74(library.getSumAll().toString()); socialParam.setFd_3af9ee3c6bfc74(library.getSocialSum().toString());
} else { } else {
socialParam.setFd_3af9ee3c6bfc74(CommonConstants.EMPTY_STRING); socialParam.setFd_3af9ee3c6bfc74(CommonConstants.EMPTY_STRING);
} }
......
...@@ -42,6 +42,7 @@ import org.springframework.validation.BindingResult; ...@@ -42,6 +42,7 @@ import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -254,7 +255,7 @@ public class UserController { ...@@ -254,7 +255,7 @@ public class UserController {
*/ */
@SysLog("登录验证") @SysLog("登录验证")
@PostMapping("/ldapLogin") @PostMapping("/ldapLogin")
public R<Boolean> loginAuthentication(@RequestParam String userName,@RequestParam String password) { public R<Boolean> loginAuthentication(@RequestParam String userName,@RequestParam String password) throws NoSuchAlgorithmException {
return userService.loginAuthentication(userName,password); return userService.loginAuthentication(userName,password);
} }
......
...@@ -19,6 +19,7 @@ package com.yifu.cloud.plus.v1.yifu.admin.mapper; ...@@ -19,6 +19,7 @@ package com.yifu.cloud.plus.v1.yifu.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -41,4 +42,9 @@ public interface SysDeptMapper extends BaseMapper<SysDept> { ...@@ -41,4 +42,9 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
List<String> selectDnList(); List<String> selectDnList();
SysDept selectCountId(@Param("deptId")Long deptId);
int updateDeptById(@Param("dept") SysDept dept);
SysDept selectDeptDn(@Param("deptDn")String deptDn);
} }
...@@ -27,6 +27,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserVO; ...@@ -27,6 +27,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserVO;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import java.security.NoSuchAlgorithmException;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -132,6 +133,6 @@ public interface SysUserService extends IService<SysUser> { ...@@ -132,6 +133,6 @@ public interface SysUserService extends IService<SysUser> {
* 从ldap中验证登录用户 * 从ldap中验证登录用户
* @return R * @return R
*/ */
R<Boolean> loginAuthentication(String userName, String password); R<Boolean> loginAuthentication(String userName, String password) throws NoSuchAlgorithmException;
} }
...@@ -60,8 +60,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl ...@@ -60,8 +60,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
private final LdapUtil ldapUtil; private final LdapUtil ldapUtil;
private final SysDeptMapper sysDeptMapper;
private final SysUserMapper sysUserMapper; private final SysUserMapper sysUserMapper;
/** /**
...@@ -188,11 +186,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl ...@@ -188,11 +186,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
//获取ldap所有的dn //获取ldap所有的dn
List<String> entryDnList = entryList.stream().map(SearchResultEntry::getDN).collect(Collectors.toList()); List<String> entryDnList = entryList.stream().map(SearchResultEntry::getDN).collect(Collectors.toList());
//获取本地dept表中所有的dn //获取本地dept表中所有的dn
List<String> dnList = sysDeptMapper.selectDnList(); List<String> dnList = baseMapper.selectDnList();
List<String> delList = dnList.stream().filter(p-> !entryDnList.contains(p)).collect(Collectors.toList()); List<String> delList = dnList.stream().filter(p-> !entryDnList.contains(p)).collect(Collectors.toList());
//删除ldap中不存在的dn的数据 //删除ldap中不存在的dn的数据
if (!delList.isEmpty()) { if (!delList.isEmpty()) {
sysDeptMapper.delete(Wrappers.<SysDept>query().lambda().in(SysDept::getDeptDn, delList)); baseMapper.delete(Wrappers.<SysDept>query().lambda().in(SysDept::getDeptDn, delList));
} }
List<Map<String,Object>> updUserList = new ArrayList<>(); List<Map<String,Object>> updUserList = new ArrayList<>();
for (SearchResultEntry entry : entryList) { for (SearchResultEntry entry : entryList) {
...@@ -206,27 +204,43 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl ...@@ -206,27 +204,43 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
String deptName = saveDnList.get(0).replace("ou=", ""); String deptName = saveDnList.get(0).replace("ou=", "");
int size = saveDnList.size(); int size = saveDnList.size();
if (size == 1) { if (size == 1) {
SysDept sysDept = this.getOne(Wrappers.<SysDept>query().lambda().eq(SysDept::getDeptDn, dn)); SysDept sysDept = baseMapper.selectDeptDn(dn);
if (null == sysDept) { if (null == sysDept) {
if (StringUtils.isEmpty(userId)) {
SysDept ins = baseMapper.selectCountId(Long.valueOf(entry.getAttributeValue("x-ouid")));
if (Common.isNotNull(ins)) {
ins.setName(deptName);
ins.setDeptDn(dn);
baseMapper.updateDeptById(ins);
} else {
SysDept insertSysDept = new SysDept(); SysDept insertSysDept = new SysDept();
insertSysDept.setName(deptName); insertSysDept.setName(deptName);
insertSysDept.setParentId(0L); insertSysDept.setParentId(0L);
insertSysDept.setDeptDn(dn);
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) { if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) {
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid"))); insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid")));
} }
insertSysDept.setDeptDn(dn); baseMapper.insert(insertSysDept);
this.save(insertSysDept); }
}
} else { } else {
sysDept.setName(deptName); sysDept.setName(deptName);
this.updateDeptById(sysDept); baseMapper.updateDeptById(sysDept);
} }
} else { } else {
try { try {
SysDept sysDept = this.getOne(Wrappers.<SysDept>query().lambda().eq(SysDept::getDeptDn, dn.substring(dn.indexOf("ou=", 2), dn.length()))); SysDept sysDept = this.getOne(Wrappers.<SysDept>query().lambda().eq(SysDept::getDeptDn, dn.substring(dn.indexOf("ou=", 2), dn.length())));
if (null != sysDept) { if (null != sysDept) {
SysDept sysDeptCount = this.getOne(Wrappers.<SysDept>query().lambda().eq(SysDept::getDeptDn, dn)); SysDept sysDeptCount = baseMapper.selectDeptDn(dn);
if (null == sysDeptCount) { if (null == sysDeptCount) {
if (StringUtils.isEmpty(userId)) { if (StringUtils.isEmpty(userId)) {
SysDept ins = baseMapper.selectCountId(Long.valueOf(entry.getAttributeValue("x-ouid")));
if (Common.isNotNull(ins)) {
ins.setName(deptName);
ins.setDeptDn(dn);
ins.setParentId(sysDept.getDeptId());
baseMapper.updateDeptById(ins);
} else {
SysDept insertSysDept = new SysDept(); SysDept insertSysDept = new SysDept();
insertSysDept.setName(deptName); insertSysDept.setName(deptName);
insertSysDept.setParentId(sysDept.getDeptId()); insertSysDept.setParentId(sysDept.getDeptId());
...@@ -234,7 +248,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl ...@@ -234,7 +248,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) { if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) {
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid"))); insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid")));
} }
this.save(insertSysDept); baseMapper.insert(insertSysDept);
}
} }
} else { } else {
if (!StringUtils.isEmpty(userId)) { if (!StringUtils.isEmpty(userId)) {
...@@ -246,7 +261,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl ...@@ -246,7 +261,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
}else { }else {
sysDeptCount.setName(deptName); sysDeptCount.setName(deptName);
sysDeptCount.setParentId(sysDept.getDeptId()); sysDeptCount.setParentId(sysDept.getDeptId());
this.updateDeptById(sysDeptCount); sysDeptCount.setDeptDn(dn);
baseMapper.updateDeptById(sysDeptCount);
} }
} }
} }
......
...@@ -55,6 +55,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -55,6 +55,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import java.security.NoSuchAlgorithmException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -82,8 +83,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -82,8 +83,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
private final LdapUtil ldapUtil; private final LdapUtil ldapUtil;
private final SysUserMapper sysUserMapper;
/** /**
* 保存用户信息 * 保存用户信息
* @param userDto DTO 对象 * @param userDto DTO 对象
...@@ -431,10 +430,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -431,10 +430,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
} }
} }
if (!updateList.isEmpty()) { if (!updateList.isEmpty()) {
sysUserMapper.batchUpdateUser(updateList); baseMapper.batchUpdateUser(updateList);
} }
if (!insertList.isEmpty()) { if (!insertList.isEmpty()) {
sysUserMapper.batchInsertUser(insertList); baseMapper.batchInsertUser(insertList);
} }
} }
List<SearchResultEntry> entryList = ldapUtil.getAllPersonNamesWithTraditionalWay(); List<SearchResultEntry> entryList = ldapUtil.getAllPersonNamesWithTraditionalWay();
...@@ -455,12 +454,19 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -455,12 +454,19 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
userId = dn.substring(4, dn.indexOf(",", 1)); userId = dn.substring(4, dn.indexOf(",", 1));
dn = dn.substring(dn.indexOf(",", 1) + 1); dn = dn.substring(dn.indexOf(",", 1) + 1);
} }
List<String> saveDnList = Arrays.stream(dn.split(",")).filter(e -> (e.contains("ou=") && !e.equals("ou=wanxin"))).collect(Collectors.toList()); List<String> saveDnList = Arrays.asList(dn.split(",")).stream().filter(e -> (e.contains("ou=") && !e.equals("ou=wanxin"))).collect(Collectors.toList());
String deptName = saveDnList.get(0).replace("ou=", ""); String deptName = saveDnList.get(0).replace("ou=", "");
int size = saveDnList.size(); int size = saveDnList.size();
if (size == 1) { if (size == 1) {
SysDept sysDept = sysDeptMapper.selectOne(Wrappers.<SysDept>query().lambda().eq(SysDept::getDeptDn, dn)); SysDept sysDept = sysDeptMapper.selectDeptDn(dn);
if (null == sysDept) { if (null == sysDept) {
if (StringUtils.isEmpty(userId)) {
SysDept ins = sysDeptMapper.selectCountId(Long.valueOf(entry.getAttributeValue("x-ouid")));
if (Common.isNotNull(ins)) {
ins.setName(deptName);
ins.setDeptDn(dn);
sysDeptMapper.updateDeptById(ins);
} else {
SysDept insertSysDept = new SysDept(); SysDept insertSysDept = new SysDept();
insertSysDept.setName(deptName); insertSysDept.setName(deptName);
insertSysDept.setParentId(0L); insertSysDept.setParentId(0L);
...@@ -469,16 +475,25 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -469,16 +475,25 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid"))); insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid")));
} }
sysDeptMapper.insert(insertSysDept); sysDeptMapper.insert(insertSysDept);
}
}
} else { } else {
sysDept.setName(deptName); sysDept.setName(deptName);
sysDeptMapper.updateById(sysDept); sysDeptMapper.updateDeptById(sysDept);
} }
} else { } else {
SysDept sysDept = sysDeptMapper.selectOne(Wrappers.<SysDept>query().lambda().eq(SysDept::getDeptDn, dn.substring(dn.indexOf("ou=", 2), dn.length()))); SysDept sysDept = sysDeptMapper.selectOne(Wrappers.<SysDept>query().lambda().eq(SysDept::getDeptDn, dn.substring(dn.indexOf("ou=", 2), dn.length())));
if (null != sysDept) { if (null != sysDept) {
SysDept sysDeptCount = sysDeptMapper.selectOne(Wrappers.<SysDept>query().lambda().eq(SysDept::getDeptDn, dn)); SysDept sysDeptCount = sysDeptMapper.selectDeptDn(dn);
if (null == sysDeptCount) { if (null == sysDeptCount) {
if (StringUtils.isEmpty(userId)) { if (StringUtils.isEmpty(userId)) {
SysDept ins = sysDeptMapper.selectCountId(Long.valueOf(entry.getAttributeValue("x-ouid")));
if (Common.isNotNull(ins)) {
ins.setName(deptName);
ins.setDeptDn(dn);
ins.setParentId(sysDept.getDeptId());
sysDeptMapper.updateDeptById(ins);
} else {
SysDept insertSysDept = new SysDept(); SysDept insertSysDept = new SysDept();
insertSysDept.setName(deptName); insertSysDept.setName(deptName);
insertSysDept.setParentId(sysDept.getDeptId()); insertSysDept.setParentId(sysDept.getDeptId());
...@@ -488,6 +503,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -488,6 +503,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
} }
sysDeptMapper.insert(insertSysDept); sysDeptMapper.insert(insertSysDept);
} }
}
} else { } else {
if (!StringUtils.isEmpty(userId)) { if (!StringUtils.isEmpty(userId)) {
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
...@@ -497,15 +513,18 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -497,15 +513,18 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
updUserList.add(map); updUserList.add(map);
}else { }else {
sysDeptCount.setName(deptName); sysDeptCount.setName(deptName);
sysDeptCount.setDeptDn(dn);
sysDeptCount.setParentId(sysDept.getDeptId()); sysDeptCount.setParentId(sysDept.getDeptId());
sysDeptMapper.updateById(sysDeptCount); sysDeptMapper.updateDeptById(sysDeptCount);
} }
} }
} }
} }
} }
//更新用户信息 //更新用户信息
sysUserMapper.updateUser(updUserList); if (!updUserList.isEmpty()) {
baseMapper.updateUser(updUserList);
}
}catch (Exception e) { }catch (Exception e) {
log.info("用户部门信息同步异常:" + e.getMessage()); log.info("用户部门信息同步异常:" + e.getMessage());
return R.failed("用户部门信息同步异常!"); return R.failed("用户部门信息同步异常!");
...@@ -518,8 +537,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -518,8 +537,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
* @return R * @return R
*/ */
@Override @Override
public R<Boolean> loginAuthentication(String userName, String password) { public R<Boolean> loginAuthentication(String userName, String password) throws NoSuchAlgorithmException {
if (ldapUtil.authenticate(userName,password)) { if (Boolean.TRUE.equals(ldapUtil.authenticate(userName,password))) {
return R.ok(); return R.ok();
} }
return R.failed("验证不通过"); return R.failed("验证不通过");
......
...@@ -38,4 +38,33 @@ ...@@ -38,4 +38,33 @@
WHERE a.del_flag = 0 WHERE a.del_flag = 0
AND a.dept_dn IS NOT NULL AND a.dept_dn IS NOT NULL
</select> </select>
<select id="selectCountId" resultType="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept">
SELECT
*
from sys_dept a
<where>
a.dept_id = #{deptId}
</where>
</select>
<select id="selectDeptDn" resultType="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept">
SELECT
*
from sys_dept a
<where>
a.dept_dn = #{deptDn}
</where>
</select>
<update id="updateDeptById">
update sys_dept
<trim prefix="set" suffixOverrides=",">
<if test="dept.name != null">name=#{dept.name},</if>
<if test="dept.parentId != null">parent_id=#{dept.parentId},</if>
<if test="dept.deptDn != null">dept_dn=#{dept.deptDn},</if>
update_time = now()
</trim>
WHERE dept_id=#{dept.deptId}
</update>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment