refactor(core): 替换 CollectionUtil 为 CollUtil 并优化代码结构
This commit is contained in:
+3
-3
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package cn.odboy.framework.mybatisplus.core;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.base.KitBaseUserTimeTb;
|
||||
@@ -131,7 +131,7 @@ public class KitMpQUtil {
|
||||
private static <R> void handleInOrNotQuery(boolean b, QueryWrapper<R> queryWrapper, String attributeName,
|
||||
Object fieldVal) {
|
||||
Collection<?> wrapNotInVal = (Collection<?>) fieldVal;
|
||||
if (CollectionUtil.isNotEmpty(wrapNotInVal)) {
|
||||
if (CollUtil.isNotEmpty(wrapNotInVal)) {
|
||||
Optional<?> anyValOptional = wrapNotInVal.stream().findAny();
|
||||
if (anyValOptional.isPresent()) {
|
||||
Object o = anyValOptional.get();
|
||||
@@ -159,7 +159,7 @@ public class KitMpQUtil {
|
||||
if (fieldVal instanceof List) {
|
||||
List<Object> between = new ArrayList<>((List<?>) fieldVal);
|
||||
int minLength = 2;
|
||||
if (CollectionUtil.isNotEmpty(between) && between.size() >= minLength) {
|
||||
if (CollUtil.isNotEmpty(between) && between.size() >= minLength) {
|
||||
queryWrapper.between(finalAttributeName, between.get(0), between.get(1));
|
||||
} else {
|
||||
throw new BadRequestException("BETWEEN类型的对象列表长度必须 >= 2");
|
||||
|
||||
+8
-5
@@ -16,7 +16,6 @@
|
||||
package cn.odboy.system.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.base.KitPageResult;
|
||||
@@ -84,7 +83,7 @@ public class SystemDeptService {
|
||||
public void updateDeptById(SystemDeptTb args) {
|
||||
KitValidUtil.notNull(args);
|
||||
// 旧的父部门
|
||||
Long oldPid = this.getDeptVoById(args.getId()).getPid();
|
||||
Long oldPid = this.getDeptById(args.getId()).getPid();
|
||||
// 新的父部门
|
||||
Long newPid = args.getPid();
|
||||
if (args.getPid() != null && args.getId().equals(args.getPid())) {
|
||||
@@ -97,6 +96,10 @@ public class SystemDeptService {
|
||||
this.updateDeptSubCnt(newPid);
|
||||
}
|
||||
|
||||
private SystemDeptTb getDeptById(Long id) {
|
||||
return systemDeptMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
@@ -322,11 +325,11 @@ public class SystemDeptService {
|
||||
deptSet.add(dept);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isEmpty(trees)) {
|
||||
if (CollUtil.isEmpty(trees)) {
|
||||
trees = deptSet;
|
||||
}
|
||||
KitPageResult<SystemDeptVo> baseResult = new KitPageResult<>();
|
||||
baseResult.setContent(CollectionUtil.isEmpty(trees) ? new ArrayList<>(deptSet) : new ArrayList<>(trees));
|
||||
baseResult.setContent(CollUtil.isEmpty(trees) ? new ArrayList<>(deptSet) : new ArrayList<>(trees));
|
||||
baseResult.setTotalElements(deptSet.size());
|
||||
return baseResult;
|
||||
}
|
||||
@@ -364,7 +367,7 @@ public class SystemDeptService {
|
||||
depts.add(this.getDeptVoById(id));
|
||||
// 子部门
|
||||
List<SystemDeptVo> deptList = this.listDeptVoByPid(id);
|
||||
if (CollectionUtil.isNotEmpty(deptList)) {
|
||||
if (CollUtil.isNotEmpty(deptList)) {
|
||||
queryRelationDeptByArgs(deptList, depts);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -16,11 +16,9 @@
|
||||
package cn.odboy.system.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.framework.exception.BadRequestException;
|
||||
import cn.odboy.framework.logging.ExecutionTimeStatisticsFace;
|
||||
import cn.odboy.system.constant.SystemTransferProtocolConst;
|
||||
import cn.odboy.system.constant.SystemYesOrNoChConst;
|
||||
import cn.odboy.system.dal.dataobject.SystemMenuTb;
|
||||
@@ -337,7 +335,7 @@ public class SystemMenuService {
|
||||
}
|
||||
}
|
||||
menuVo.setMeta(new SystemMenuMetaVo(menu.getTitle(), menu.getIcon(), !menu.getCache()));
|
||||
if (CollectionUtil.isNotEmpty(menuList)) {
|
||||
if (CollUtil.isNotEmpty(menuList)) {
|
||||
menuVo.setAlwaysShow(true);
|
||||
menuVo.setRedirect("noredirect");
|
||||
menuVo.setChildren(buildMenuVo(menuList));
|
||||
@@ -441,7 +439,7 @@ public class SystemMenuService {
|
||||
public List<SystemMenuVo> listMenuSuperior(List<Long> ids) {
|
||||
Set<SystemMenuVo> menus;
|
||||
List<SystemMenuVo> systemMenuTbs;
|
||||
if (CollectionUtil.isNotEmpty(ids)) {
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
menus = new LinkedHashSet<>(this.listMenuByIds(ids));
|
||||
for (SystemMenuVo menu : menus) {
|
||||
List<SystemMenuVo> menuList = this.querySuperiorMenuByArgs(menu, new ArrayList<>());
|
||||
|
||||
+2
-3
@@ -16,7 +16,6 @@
|
||||
package cn.odboy.system.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.base.KitPageResult;
|
||||
@@ -74,7 +73,7 @@ public class SystemRoleService {
|
||||
SystemRoleTb roleTb = KitBeanUtil.copyToClass(args, SystemRoleTb.class);
|
||||
systemRoleMapper.insert(roleTb);
|
||||
// 判断是否有部门数据, 若有, 则需创建关联
|
||||
if (CollectionUtil.isNotEmpty(args.getDepts())) {
|
||||
if (CollUtil.isNotEmpty(args.getDepts())) {
|
||||
systemRoleDeptService.batchInsertRoleDept(args.getDepts(), roleTb.getId());
|
||||
}
|
||||
}
|
||||
@@ -113,7 +112,7 @@ public class SystemRoleService {
|
||||
// 删除关联部门数据
|
||||
systemRoleDeptService.batchDeleteRoleDept(Collections.singleton(args.getId()));
|
||||
// 判断是否有部门数据, 若有, 则需更新关联
|
||||
if (CollectionUtil.isNotEmpty(args.getDepts())) {
|
||||
if (CollUtil.isNotEmpty(args.getDepts())) {
|
||||
systemRoleDeptService.batchInsertRoleDept(args.getDepts(), args.getId());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-8
@@ -16,7 +16,6 @@
|
||||
package cn.odboy.system.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.base.KitPageArgs;
|
||||
import cn.odboy.base.KitPageResult;
|
||||
@@ -62,7 +61,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -72,10 +70,6 @@ public class SystemUserService {
|
||||
@Autowired
|
||||
private SystemUserMapper systemUserMapper;
|
||||
@Autowired
|
||||
private SystemJobService systemJobService;
|
||||
@Autowired
|
||||
private SystemRoleService systemRoleService;
|
||||
@Autowired
|
||||
private SystemDeptService systemDeptService;
|
||||
@Autowired
|
||||
private SystemUserJobService systemUserJobService;
|
||||
@@ -479,10 +473,10 @@ public class SystemUserService {
|
||||
// 数据权限
|
||||
List<Long> dataScopes = systemDataService.queryDeptIdByArgs(this.getUserVoByUsername(currentUsername));
|
||||
// args.getDeptIds() 不为空并且数据权限不为空则取交集
|
||||
if (!CollectionUtils.isEmpty(args.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) {
|
||||
if (!CollUtil.isEmpty(args.getDeptIds()) && !CollUtil.isEmpty(dataScopes)) {
|
||||
// 取交集
|
||||
args.getDeptIds().retainAll(dataScopes);
|
||||
if (!CollectionUtil.isEmpty(args.getDeptIds())) {
|
||||
if (!CollUtil.isEmpty(args.getDeptIds())) {
|
||||
return this.searchUserByArgs(args, page);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user