mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-04-04 17:53:24 +08:00
update 优化 项目中的一些存在null的问题 与一些性能问题 小优化
This commit is contained in:
@@ -73,7 +73,6 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo>, MPJBa
|
||||
default List<SysUserExportVo> selectUserExportList(SysUserBo user, List<Long> deptIds) {
|
||||
MPJLambdaWrapper<SysUser> wrapper = JoinWrappers.lambda("u", SysUser.class)
|
||||
.selectAll(SysUser.class)
|
||||
.selectAs(SysDept::getDeptName, SysUserExportVo::getDeptName)
|
||||
.selectAs("u1", SysUser::getUserName, SysUserExportVo::getLeaderName)
|
||||
.leftJoin(SysDept.class, "d", SysDept::getDeptId, SysUser::getDeptId)
|
||||
.leftJoin(SysUser.class, "u1", SysUser::getUserId, SysDept::getLeader)
|
||||
|
||||
@@ -152,7 +152,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
SysConfig config = MapstructUtils.convert(bo, SysConfig.class);
|
||||
if (config.getConfigId() != null) {
|
||||
SysConfig temp = baseMapper.selectById(config.getConfigId());
|
||||
if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey())) {
|
||||
if (ObjectUtil.isNotNull(temp) && !StringUtils.equals(temp.getConfigKey(), config.getConfigKey())) {
|
||||
CacheUtils.evict(CacheNames.SYS_CONFIG, temp.getConfigKey());
|
||||
}
|
||||
row = baseMapper.updateById(config);
|
||||
|
||||
@@ -216,7 +216,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
@Override
|
||||
public Long selectDeptLeaderById(Long deptId) {
|
||||
SysDeptVo vo = SpringUtils.getAopProxy(this).selectDeptById(deptId);
|
||||
return vo.getLeader();
|
||||
return ObjectUtil.isNull(vo) ? null : vo.getLeader();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,7 +312,10 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
@Override
|
||||
public int insertDept(SysDeptBo bo) {
|
||||
SysDept info = baseMapper.selectById(bo.getParentId());
|
||||
// 如果父节点不为正常状态,则不允许新增子节点
|
||||
// 如果父节点不存在或不为正常状态,则不允许新增子节点
|
||||
if (ObjectUtil.isNull(info)) {
|
||||
throw new ServiceException("父部门不存在");
|
||||
}
|
||||
if (!SystemConstants.NORMAL.equals(info.getStatus())) {
|
||||
throw new ServiceException("部门停用,不允许新增");
|
||||
}
|
||||
@@ -390,7 +393,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
for (SysDept child : children) {
|
||||
SysDept dept = new SysDept();
|
||||
dept.setDeptId(child.getDeptId());
|
||||
dept.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
|
||||
dept.setAncestors(StringUtils.replaceOnce(child.getAncestors(), oldAncestors, newAncestors));
|
||||
list.add(dept);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
@@ -408,7 +411,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
*/
|
||||
@Caching(evict = {
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#deptId"),
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, key = "#deptId")
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, allEntries = true)
|
||||
})
|
||||
@Override
|
||||
public int deleteDeptById(Long deptId) {
|
||||
|
||||
@@ -108,7 +108,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
@Override
|
||||
public List<SysDictDataVo> selectDictDataByType(String dictType) {
|
||||
List<SysDictDataVo> dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||
return CollUtil.isNotEmpty(dictDatas) ? dictDatas : null;
|
||||
return CollUtil.isNotEmpty(dictDatas) ? dictDatas : Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user