Commit 0b8b24ca authored by fangxinjiang's avatar fangxinjiang

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

parents afdd390b 92bffdfd
...@@ -13,6 +13,7 @@ import org.hibernate.validator.constraints.Length; ...@@ -13,6 +13,7 @@ import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
/** /**
* 客户数据权限表 * 客户数据权限表
...@@ -92,6 +93,11 @@ public class TCutsomerDataPermisson implements Serializable { ...@@ -92,6 +93,11 @@ public class TCutsomerDataPermisson implements Serializable {
private String userDeptName; private String userDeptName;
@ExcelIgnore @ExcelIgnore
@Schema(description = "授权来源0ekp,1mvp,2mvp复制", name = "type") @Schema(description = "授权来源0ekp,1mvp,2mvp复制")
private String type; private String type;
@TableField(exist = false)
@ExcelIgnore
@Schema(description = "导出选中的行id数组")
private List<String> idList;
} }
...@@ -14,7 +14,6 @@ import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils; ...@@ -14,7 +14,6 @@ import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays; import java.util.Arrays;
...@@ -83,7 +82,7 @@ public class TCutsomerDataPermissonController { ...@@ -83,7 +82,7 @@ public class TCutsomerDataPermissonController {
**/ **/
@Operation(description = "权限复制 权限同项目分配客服(wxhr:tsettledomain_assign_customerservice)") @Operation(description = "权限复制 权限同项目分配客服(wxhr:tsettledomain_assign_customerservice)")
@GetMapping("/copy") @GetMapping("/copy")
@PreAuthorize("@pms.hasPermission('wxhr:tsettledomain_assign_customerservice')") //@PreAuthorize("@pms.hasPermission('tsettledomain_assign_customerservice')")
public R<String> insertForCopyCutsomerDataPermisson(String[] srcUser, String[] beUser) { public R<String> insertForCopyCutsomerDataPermisson(String[] srcUser, String[] beUser) {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
R result = tCutsomerDataPermissonService.insertForCopyCutsomerDataPermisson(srcUser, beUser, user); R result = tCutsomerDataPermissonService.insertForCopyCutsomerDataPermisson(srcUser, beUser, user);
...@@ -112,7 +111,7 @@ public class TCutsomerDataPermissonController { ...@@ -112,7 +111,7 @@ public class TCutsomerDataPermissonController {
@Operation(description = "新增") @Operation(description = "新增")
@SysLog("新增客户数据权限表") @SysLog("新增客户数据权限表")
@PostMapping @PostMapping
@PreAuthorize("@pms.hasPermission('wxhr:tcutsomerdatapermisson_add')") //@PreAuthorize("@pms.hasPermission('tcutsomerdatapermisson_add')")
public R<Boolean> save(@RequestBody TCutsomerDataPermisson tCutsomerDataPermisson){ public R<Boolean> save(@RequestBody TCutsomerDataPermisson tCutsomerDataPermisson){
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
settleDomainService.removeSettleCache(user, Arrays.asList(tCutsomerDataPermisson.getUserId())); settleDomainService.removeSettleCache(user, Arrays.asList(tCutsomerDataPermisson.getUserId()));
...@@ -127,7 +126,7 @@ public class TCutsomerDataPermissonController { ...@@ -127,7 +126,7 @@ public class TCutsomerDataPermissonController {
@Operation(description = "修改") @Operation(description = "修改")
@SysLog("修改客户数据权限表") @SysLog("修改客户数据权限表")
@PutMapping @PutMapping
@PreAuthorize("@pms.hasPermission('wxhr:tcutsomerdatapermisson_edit')") //@PreAuthorize("@pms.hasPermission('tcutsomerdatapermisson_edit')")
public R<Boolean> update(@RequestBody TCutsomerDataPermisson tCutsomerDataPermisson) { public R<Boolean> update(@RequestBody TCutsomerDataPermisson tCutsomerDataPermisson) {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
settleDomainService.removeSettleCache(user, Arrays.asList(tCutsomerDataPermisson.getUserId())); settleDomainService.removeSettleCache(user, Arrays.asList(tCutsomerDataPermisson.getUserId()));
...@@ -139,10 +138,10 @@ public class TCutsomerDataPermissonController { ...@@ -139,10 +138,10 @@ public class TCutsomerDataPermissonController {
* @param id * @param id
* @return R * @return R
*/ */
@Operation(description = "删除(wxhr:tcutsomerdatapermisson_del)") @Operation(description = "删除(tcutsomerdatapermisson_del)")
@SysLog("删除客户数据权限表") @SysLog("删除客户数据权限表")
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('wxhr:tcutsomerdatapermisson_del')") //@PreAuthorize("@pms.hasPermission('tcutsomerdatapermisson_del')")
public R<Boolean> removeById(@PathVariable String id){ public R<Boolean> removeById(@PathVariable String id){
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
TCutsomerDataPermisson tdp = tCutsomerDataPermissonService.getById(id); TCutsomerDataPermisson tdp = tCutsomerDataPermissonService.getById(id);
......
...@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson; import com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TCutsomerDataPermissonVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
......
...@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson; import com.yifu.cloud.plus.v1.yifu.archives.entity.TCutsomerDataPermisson;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TCutsomerDataPermissonVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
......
...@@ -38,6 +38,12 @@ ...@@ -38,6 +38,12 @@
</sql> </sql>
<sql id="where_getTCutsomerDataPermissonPage"> <sql id="where_getTCutsomerDataPermissonPage">
<if test="tCutsomerDataPermisson != null"> <if test="tCutsomerDataPermisson != null">
<if test="tCutsomerDataPermisson.idList != null">
AND a.id in
<foreach item="idStr" index="index" collection="tCutsomerDataPermisson.idList" open="(" separator="," close=")">
#{idStr}
</foreach>
</if>
<if test="tCutsomerDataPermisson.userNickName != null and tCutsomerDataPermisson.userNickName.trim() != ''"> <if test="tCutsomerDataPermisson.userNickName != null and tCutsomerDataPermisson.userNickName.trim() != ''">
AND a.USER_NICK_NAME like concat('%',#{tCutsomerDataPermisson.userNickName},'%') AND a.USER_NICK_NAME like concat('%',#{tCutsomerDataPermisson.userNickName},'%')
</if> </if>
......
...@@ -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);
public void closeCtx() throws NamingException { ldapPw = Base64.decode(ldapPwd1);
if (ctx != null) break;
ctx.close(); } else {
} return false;
}
public String getUserDN(String uid) {
StringBuilder userDN = new StringBuilder();
try {
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
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());
} }
} }
} catch (Exception e) { MessageDigest md5 = MessageDigest.getInstance("MD5");
e.printStackTrace(); md5.update(pwd.getBytes());
byte[] m = md5.digest();
return MessageDigest.isEqual(m, ldapPw);
} catch (ParseException e) {
log.error(" is not authenticated");
} }
return userDN.toString(); return false;
} }
} }
...@@ -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,35 +204,52 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl ...@@ -206,35 +204,52 @@ 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) {
SysDept insertSysDept = new SysDept(); if (StringUtils.isEmpty(userId)) {
insertSysDept.setName(deptName); SysDept ins = baseMapper.selectCountId(Long.valueOf(entry.getAttributeValue("x-ouid")));
insertSysDept.setParentId(0L); if (Common.isNotNull(ins)) {
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) { ins.setName(deptName);
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid"))); ins.setDeptDn(dn);
baseMapper.updateDeptById(ins);
} else {
SysDept insertSysDept = new SysDept();
insertSysDept.setName(deptName);
insertSysDept.setParentId(0L);
insertSysDept.setDeptDn(dn);
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) {
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid")));
}
baseMapper.insert(insertSysDept);
}
} }
insertSysDept.setDeptDn(dn);
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 insertSysDept = new SysDept(); SysDept ins = baseMapper.selectCountId(Long.valueOf(entry.getAttributeValue("x-ouid")));
insertSysDept.setName(deptName); if (Common.isNotNull(ins)) {
insertSysDept.setParentId(sysDept.getDeptId()); ins.setName(deptName);
insertSysDept.setDeptDn(dn); ins.setDeptDn(dn);
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) { ins.setParentId(sysDept.getDeptId());
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid"))); baseMapper.updateDeptById(ins);
} else {
SysDept insertSysDept = new SysDept();
insertSysDept.setName(deptName);
insertSysDept.setParentId(sysDept.getDeptId());
insertSysDept.setDeptDn(dn);
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) {
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid")));
}
baseMapper.insert(insertSysDept);
} }
this.save(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,38 +454,55 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -455,38 +454,55 @@ 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) {
SysDept insertSysDept = new SysDept(); if (StringUtils.isEmpty(userId)) {
insertSysDept.setName(deptName); SysDept ins = sysDeptMapper.selectCountId(Long.valueOf(entry.getAttributeValue("x-ouid")));
insertSysDept.setParentId(0L); if (Common.isNotNull(ins)) {
insertSysDept.setDeptDn(dn); ins.setName(deptName);
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) { ins.setDeptDn(dn);
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid"))); sysDeptMapper.updateDeptById(ins);
} else {
SysDept insertSysDept = new SysDept();
insertSysDept.setName(deptName);
insertSysDept.setParentId(0L);
insertSysDept.setDeptDn(dn);
if (Common.isNotNull(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 insertSysDept = new SysDept(); SysDept ins = sysDeptMapper.selectCountId(Long.valueOf(entry.getAttributeValue("x-ouid")));
insertSysDept.setName(deptName); if (Common.isNotNull(ins)) {
insertSysDept.setParentId(sysDept.getDeptId()); ins.setName(deptName);
insertSysDept.setDeptDn(dn); ins.setDeptDn(dn);
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) { ins.setParentId(sysDept.getDeptId());
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid"))); sysDeptMapper.updateDeptById(ins);
} else {
SysDept insertSysDept = new SysDept();
insertSysDept.setName(deptName);
insertSysDept.setParentId(sysDept.getDeptId());
insertSysDept.setDeptDn(dn);
if (Common.isNotNull(entry.getAttributeValue("x-ouid"))) {
insertSysDept.setDeptId(Long.valueOf(entry.getAttributeValue("x-ouid")));
}
sysDeptMapper.insert(insertSysDept);
} }
sysDeptMapper.insert(insertSysDept);
} }
} else { } else {
if (!StringUtils.isEmpty(userId)) { if (!StringUtils.isEmpty(userId)) {
...@@ -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