|
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.constant.CacheConstant;
|
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
@@ -23,6 +24,8 @@ import org.jeecg.modules.geke.teams.service.ITeamsService;
|
|
|
import org.jeecg.modules.system.entity.*;
|
|
|
import org.jeecg.modules.system.mapper.*;
|
|
|
import org.jeecg.modules.system.model.SysUserSysDepartModel;
|
|
|
+import org.jeecg.modules.system.service.ISysDepartService;
|
|
|
+import org.jeecg.modules.system.service.ISysUserRoleService;
|
|
|
import org.jeecg.modules.system.service.ISysUserService;
|
|
|
import org.jeecg.modules.system.util.UrlData;
|
|
|
import org.jeecg.modules.system.vo.DepartTreeVo;
|
|
@@ -48,7 +51,9 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ISysDepartService sysDepartService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private SysUserMapper userMapper;
|
|
|
@Autowired
|
|
@@ -70,6 +75,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
@Resource
|
|
|
private BaseCommonService baseCommonService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysUserRoleService sysUserRoleService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ITeamsService teamsService;
|
|
|
|
|
@@ -508,11 +516,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
|
|
|
//企业微信接口拉取数据增加用户方法
|
|
|
@Override
|
|
|
- public Boolean add(SysUser sysUser) {
|
|
|
+ public Boolean add(SysUser sysUser,SysUserRole sysUserRole) {
|
|
|
SysUser byId = this.getOnes(sysUser.getId());
|
|
|
if (byId!=null &&!byId.equals("")){
|
|
|
return super.updateById(sysUser);
|
|
|
}else {
|
|
|
+ sysUserRoleService.saveUserRole(sysUserRole);
|
|
|
sysUser.setStatus(1);
|
|
|
sysUser.setDelFlag(0);
|
|
|
if (StringUtils.isBlank(sysUser.getPassword())) {
|
|
@@ -522,10 +531,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
// 密码加密加盐
|
|
|
String salt = oConvertUtils.randomGen(8);
|
|
|
sysUser.setSalt(salt);
|
|
|
- sysUser.setUsername(UrlData.getPingYin(sysUser.getRealname()));
|
|
|
String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(), sysUser.getPassword(), salt);
|
|
|
sysUser.setPassword(passwordEncode);
|
|
|
- sysUser.setCode(UrlData.getPingYin(sysUser.getRealname()));
|
|
|
return this.save(sysUser);
|
|
|
}
|
|
|
|
|
@@ -576,6 +583,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
return page.setRecords(sysUsers);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<SysUser> deptUser(Page<SysUser> page, String username, List<String> deptids, Integer sex, String realname, String ipone, Integer state) {
|
|
|
+ return page.setRecords(userMapper.deptUser(page,username,deptids,sex,realname,ipone,state));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 循环获取字典数据 树
|
|
@@ -588,25 +600,51 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
// 转化为vo
|
|
|
List<String>id=new ArrayList<>();
|
|
|
List<DepartTreeVo> dictVos=new ArrayList<>();
|
|
|
+ String deptids="";
|
|
|
+ String state="0";
|
|
|
+ List<String> mySubDepIdsByDepId=null;
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ List<SysUserRole> userRole = sysUserRoleService.list(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, sysUser.getId()));
|
|
|
+ if (userRole!=null&&userRole.size()>0){
|
|
|
+ for (SysUserRole role:userRole){
|
|
|
+ if (role.getRoleId().equals("1462659329857978370")){
|
|
|
+ List<SysDepart> list = this.sysDepartService.queryUserDeparts(sysUser.getId());
|
|
|
+ for (SysDepart depart:list){
|
|
|
+ deptids+=depart.getId()+",";
|
|
|
+ if (depart.getId().equals("1")){
|
|
|
+ state="1";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (state.equals("0")){
|
|
|
+ mySubDepIdsByDepId = sysDepartService.getMySubDepIdsByDepId(deptids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (name!=null&&!name.equals("")){
|
|
|
- dictVos = userMapper.Deptlist(null, name);
|
|
|
- if (dictVos!=null&&dictVos.size()>0){
|
|
|
- id.add(dictVos.get(0).getId());
|
|
|
- while (id!=null&&id.size()>0){
|
|
|
- List<DepartTreeVo> deptlist1 = userMapper.Deptlist(id, "");
|
|
|
- if (deptlist1!=null&&deptlist1.size()>0){
|
|
|
- dictVos.addAll(deptlist1);
|
|
|
- id.clear();
|
|
|
- for (DepartTreeVo is:deptlist1){
|
|
|
- id.add(is.getId());
|
|
|
+ if (mySubDepIdsByDepId!=null){
|
|
|
+ dictVos = userMapper.Deptlist(null, name,mySubDepIdsByDepId);
|
|
|
+ }else {
|
|
|
+ dictVos = userMapper.Deptlist(null, name, null);
|
|
|
+ if (dictVos != null && dictVos.size() > 0) {
|
|
|
+ id.add(dictVos.get(0).getId());
|
|
|
+ while (id != null && id.size() > 0) {
|
|
|
+ List<DepartTreeVo> deptlist1 = userMapper.Deptlist(id, "", null);
|
|
|
+ if (deptlist1 != null && deptlist1.size() > 0) {
|
|
|
+ dictVos.addAll(deptlist1);
|
|
|
+ id.clear();
|
|
|
+ for (DepartTreeVo is : deptlist1) {
|
|
|
+ id.add(is.getId());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ id.clear();
|
|
|
}
|
|
|
- }else {
|
|
|
- id.clear();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
- dictVos = userMapper.DeptTree();
|
|
|
+ dictVos = userMapper.DeptTree(mySubDepIdsByDepId);
|
|
|
}
|
|
|
// 最终输出的树
|
|
|
List<DepartTreeVo> vos = new ArrayList<>();
|