update 优化 项目中的一些存在null的问题 与一些性能问题 小优化
This commit is contained in:
+2
-1
@@ -2,6 +2,7 @@ package org.dromara.system.dubbo;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
@@ -53,7 +54,7 @@ public class RemoteDeptServiceImpl implements RemoteDeptService {
|
||||
@Override
|
||||
public Long selectDeptLeaderById(Long deptId) {
|
||||
SysDeptVo vo = deptService.selectDeptById(deptId);
|
||||
return vo.getLeader();
|
||||
return ObjectUtil.isNull(vo) ? null : vo.getLeader();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -142,7 +142,7 @@ public class SysConfigServiceImpl implements ISysConfigService {
|
||||
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);
|
||||
|
||||
+6
-3
@@ -281,7 +281,10 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
@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("部门停用,不允许新增");
|
||||
}
|
||||
@@ -356,7 +359,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
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)) {
|
||||
@@ -374,7 +377,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||
*/
|
||||
@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) {
|
||||
|
||||
+2
-1
@@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -100,7 +101,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
||||
@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