Commit b4adaeac authored by fangxinjiang's avatar fangxinjiang

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

parents 08ad960b 3f796936
......@@ -207,9 +207,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
userId = dn.substring(4, dn.indexOf(",", 1));
dn = dn.substring(dn.indexOf(",", 1) + 1);
}
List<String> list = Arrays.asList(dn.split(",")).stream().filter(e -> (e.contains("ou=") && !e.equals("ou=wanxin"))).collect(Collectors.toList());
String deptName = list.get(0).replace("ou=", "");
int size = list.size();
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=", "");
int size = saveDnList.size();
if (size == 1) {
SysDept sysDept = this.getOne(Wrappers.<SysDept>query().lambda().eq(SysDept::getDeptDn, dn));
if (null == sysDept) {
......
......@@ -20,10 +20,12 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.unboundid.ldap.sdk.SearchResultEntry;
import com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserDTO;
import com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserInfo;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.*;
......@@ -31,6 +33,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.util.ParamResolver;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserExcelVO;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserVO;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.*;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysMenuService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysUserService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
......@@ -83,6 +86,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
private final SysUserMapper sysUserMapper;
private final SysDeptService sysDeptService;
/**
* 保存用户信息
* @param userDto DTO 对象
......@@ -405,26 +410,32 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
*/
@Override
public R<Boolean> updateByLdap() {
List<PersonVo> list = ldapUtil.getAllPersons();
if (null != list) {
List<SysUser> listUser = this.list(Wrappers.<SysUser>query().lambda().eq(SysUser::getDelFlag, CommonConstants.STATUS_NORMAL));
List<String> list1 = listUser.stream().map(SysUser::getUsername).collect(Collectors.toList());
Map<String, String> map = listUser.stream().collect(HashMap::new, (m, v) -> m.put(v.getUsername(), v.getUserId()), HashMap::putAll);
List<PersonVo> updateList = new ArrayList<>();
List<PersonVo> insertList = new ArrayList<>();
for (PersonVo personVo : list) {
if (list1.stream().anyMatch(e -> e.equals(personVo.getUid()))) {
updateList.add(personVo);
} else {
insertList.add(personVo);
try {
List<PersonVo> list = ldapUtil.getAllPersons();
if (null != list) {
List<SysUser> listUser = this.list(Wrappers.<SysUser>query().lambda().eq(SysUser::getDelFlag, CommonConstants.STATUS_NORMAL));
List<String> list1 = listUser.stream().map(SysUser::getUsername).collect(Collectors.toList());
Map<String, String> map = listUser.stream().collect(HashMap::new, (m, v) -> m.put(v.getUsername(), v.getUserId()), HashMap::putAll);
List<PersonVo> updateList = new ArrayList<>();
List<PersonVo> insertList = new ArrayList<>();
for (PersonVo personVo : list) {
if (list1.stream().anyMatch(e -> e.equals(personVo.getUid()))) {
updateList.add(personVo);
} else {
insertList.add(personVo);
}
}
if (updateList.size() > 0) {
sysUserMapper.batchUpdateUser(updateList);
}
if (insertList.size() > 0) {
sysUserMapper.batchInsertUser(insertList);
}
}
if (updateList.size()>0) {
sysUserMapper.batchUpdateUser(updateList);
}
if (insertList.size()>0) {
sysUserMapper.batchInsertUser(insertList);
}
sysDeptService.updateDeptByLdap();
}catch (Exception e) {
log.info("用户部门信息同步异常:" + e.getMessage());
return R.failed("用户部门信息同步异常!");
}
return R.ok();
}
......
......@@ -76,5 +76,6 @@
1=1
<include refid="sysDataAuthMap_where"/>
</where>
order by a.create_time desc
</select>
</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