|
|
@@ -1,7 +1,6 @@
|
|
|
package org.dromara.system.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.lang.tree.Tree;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
@@ -19,7 +18,6 @@ import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.core.utils.TreeBuildUtils;
|
|
|
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
|
|
import org.dromara.common.redis.utils.CacheUtils;
|
|
|
-import org.dromara.common.redis.utils.RedisUtils;
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
import org.dromara.system.domain.SysDept;
|
|
|
import org.dromara.system.domain.SysRole;
|
|
|
@@ -106,10 +104,10 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
return CollUtil.newArrayList();
|
|
|
}
|
|
|
return TreeBuildUtils.build(depts, (dept, tree) ->
|
|
|
- tree.setId(dept.getDeptId())
|
|
|
- .setParentId(dept.getParentId())
|
|
|
- .setName(dept.getDeptName())
|
|
|
- .setWeight(dept.getOrderNum()));
|
|
|
+ tree.setId(dept.getDeptId())
|
|
|
+ .setParentId(dept.getParentId())
|
|
|
+ .setName(dept.getDeptName())
|
|
|
+ .setWeight(dept.getOrderNum()));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -138,7 +136,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
return null;
|
|
|
}
|
|
|
SysDeptVo parentDept = baseMapper.selectVoOne(new LambdaQueryWrapper<SysDept>()
|
|
|
- .select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId()));
|
|
|
+ .select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId()));
|
|
|
dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null);
|
|
|
return dept;
|
|
|
}
|
|
|
@@ -152,9 +150,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
@Override
|
|
|
public List<SysDeptVo> selectDeptByIds(List<Long> deptIds) {
|
|
|
return baseMapper.selectDeptList(new LambdaQueryWrapper<SysDept>()
|
|
|
- .select(SysDept::getDeptId, SysDept::getDeptName)
|
|
|
- .eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
|
|
|
- .in(CollUtil.isNotEmpty(deptIds), SysDept::getDeptId, deptIds));
|
|
|
+ .select(SysDept::getDeptId, SysDept::getDeptName)
|
|
|
+ .eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
|
|
|
+ .in(CollUtil.isNotEmpty(deptIds), SysDept::getDeptId, deptIds));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -184,8 +182,8 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
@Override
|
|
|
public long selectNormalChildrenDeptById(Long deptId) {
|
|
|
return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>()
|
|
|
- .eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
|
|
|
- .apply(DataBaseHelper.findInSet(deptId, "ancestors")));
|
|
|
+ .eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
|
|
|
+ .apply(DataBaseHelper.findInSet(deptId, "ancestors")));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -197,7 +195,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
@Override
|
|
|
public boolean hasChildByDeptId(Long deptId) {
|
|
|
return baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
|
|
- .eq(SysDept::getParentId, deptId));
|
|
|
+ .eq(SysDept::getParentId, deptId));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -209,7 +207,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
@Override
|
|
|
public boolean checkDeptExistUser(Long deptId) {
|
|
|
return userMapper.exists(new LambdaQueryWrapper<SysUser>()
|
|
|
- .eq(SysUser::getDeptId, deptId));
|
|
|
+ .eq(SysUser::getDeptId, deptId));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -221,9 +219,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
@Override
|
|
|
public boolean checkDeptNameUnique(SysDeptBo dept) {
|
|
|
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
|
|
- .eq(SysDept::getDeptName, dept.getDeptName())
|
|
|
- .eq(SysDept::getParentId, dept.getParentId())
|
|
|
- .ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId()));
|
|
|
+ .eq(SysDept::getDeptName, dept.getDeptName())
|
|
|
+ .eq(SysDept::getParentId, dept.getParentId())
|
|
|
+ .ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId()));
|
|
|
return !exist;
|
|
|
}
|
|
|
|
|
|
@@ -312,7 +310,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
}
|
|
|
int result = baseMapper.updateById(dept);
|
|
|
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
|
|
- && !StringUtils.equals(UserConstants.DEPT_NORMAL, dept.getAncestors())) {
|
|
|
+ && !StringUtils.equals(UserConstants.DEPT_NORMAL, dept.getAncestors())) {
|
|
|
// 如果该部门是启用状态,则启用该部门的所有上级部门
|
|
|
updateParentDeptStatusNormal(dept);
|
|
|
}
|
|
|
@@ -328,8 +326,8 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
String ancestors = dept.getAncestors();
|
|
|
Long[] deptIds = Convert.toLongArray(ancestors);
|
|
|
baseMapper.update(null, new LambdaUpdateWrapper<SysDept>()
|
|
|
- .set(SysDept::getStatus, UserConstants.DEPT_NORMAL)
|
|
|
- .in(SysDept::getDeptId, Arrays.asList(deptIds)));
|
|
|
+ .set(SysDept::getStatus, UserConstants.DEPT_NORMAL)
|
|
|
+ .in(SysDept::getDeptId, Arrays.asList(deptIds)));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -341,7 +339,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
*/
|
|
|
private void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
|
|
|
List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>()
|
|
|
- .apply(DataBaseHelper.findInSet(deptId, "ancestors")));
|
|
|
+ .apply(DataBaseHelper.findInSet(deptId, "ancestors")));
|
|
|
List<SysDept> list = new ArrayList<>();
|
|
|
for (SysDept child : children) {
|
|
|
SysDept dept = new SysDept();
|
|
|
@@ -375,9 +373,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
return CollUtil.newArrayList(deptId);
|
|
|
}
|
|
|
return baseMapper.selectList(Wrappers.lambdaQuery(SysDept.class)
|
|
|
- .select(SysDept::getDeptId)
|
|
|
- .eq(SysDept::getParentId, deptId).or().eq(SysDept::getDeptId, deptId).or().likeRight(SysDept::getAncestors,
|
|
|
- sysDeptVo.getAncestors() + "," + deptId)
|
|
|
+ .select(SysDept::getDeptId)
|
|
|
+ .eq(SysDept::getParentId, deptId).or().eq(SysDept::getDeptId, deptId).or().likeRight(SysDept::getAncestors,
|
|
|
+ sysDeptVo.getAncestors() + "," + deptId)
|
|
|
).stream().map(SysDept::getDeptId).toList();
|
|
|
}
|
|
|
|
|
|
@@ -394,8 +392,8 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
@Override
|
|
|
public SysDeptVo selectDeptByParentIdAndName(Long parentId, String deptName) {
|
|
|
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysDept>()
|
|
|
- .eq(SysDept::getParentId, parentId)
|
|
|
- .eq(SysDept::getDeptName, deptName));
|
|
|
+ .eq(SysDept::getParentId, parentId)
|
|
|
+ .eq(SysDept::getDeptName, deptName));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -418,20 +416,25 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|
|
|
|
|
/**
|
|
|
* 查询指定时间的进行中的班级
|
|
|
+ *
|
|
|
* @param doingDate 指定时间
|
|
|
* @return 班级列表
|
|
|
*/
|
|
|
@Override
|
|
|
public List<SysDeptVo> selectDoingClass(Date doingDate) {
|
|
|
- List<SysDeptVo> redisList = RedisUtils.getCacheList(CacheNames.DOING_CLASS);
|
|
|
- if(CollectionUtil.isNotEmpty(redisList)){
|
|
|
- return redisList;
|
|
|
- }
|
|
|
- List<SysDeptVo> list = baseMapper.selectVoList(new LambdaQueryWrapper<SysDept>().ge(SysDept::getCheckDate, doingDate).le(SysDept::getEndDate, doingDate));
|
|
|
- if(CollectionUtil.isNotEmpty(redisList)){
|
|
|
- RedisUtils.setCacheList(CacheNames.DOING_CLASS, list);
|
|
|
- return list;
|
|
|
- }
|
|
|
- return null;
|
|
|
+ //List<SysDeptVo> redisList = RedisUtils.getCacheList(CacheNames.DOING_CLASS);
|
|
|
+ //if(CollectionUtil.isNotEmpty(redisList)){
|
|
|
+ // return redisList;
|
|
|
+ //}
|
|
|
+ //List<SysDeptVo> list = baseMapper.selectVoList(new LambdaQueryWrapper<SysDept>()
|
|
|
+ // .le(SysDept::getCheckDate, doingDate).ge(SysDept::getEndDate, doingDate));
|
|
|
+ //if(CollectionUtil.isNotEmpty(list)){
|
|
|
+ // RedisUtils.setCacheList(CacheNames.DOING_CLASS, list);
|
|
|
+ // return list;
|
|
|
+ //}
|
|
|
+ //return null;
|
|
|
+
|
|
|
+ return baseMapper.selectVoList(new LambdaQueryWrapper<SysDept>()
|
|
|
+ .le(SysDept::getCheckDate, doingDate).ge(SysDept::getEndDate, doingDate));
|
|
|
}
|
|
|
}
|