refactor(system): 重构系统模块的分页参数处理和代码优化
This commit is contained in:
+3
-3
@@ -77,9 +77,9 @@ public class SystemQuartzJobController {
|
||||
@ApiOperation("查询定时任务执行日志")
|
||||
@PostMapping(value = "/searchQuartzLog")
|
||||
@PreAuthorize("@el.check('quartzJob:list')")
|
||||
public ResponseEntity<KitPageResult<SystemQuartzLogTb>> queryQuartzJobLog(SystemQueryQuartzJobArgs args) {
|
||||
Page<SystemQuartzLogTb> page = new Page<>(args.getPage(), args.getSize());
|
||||
return ResponseEntity.ok(systemQuartzJobService.searchQuartzLogByArgs(args, page));
|
||||
public ResponseEntity<KitPageResult<SystemQuartzLogTb>> queryQuartzJobLog(@Validated @RequestBody KitPageArgs<SystemQueryQuartzJobArgs> pageArgs) {
|
||||
Page<SystemQuartzLogTb> page = new Page<>(pageArgs.getPage(), pageArgs.getSize());
|
||||
return ResponseEntity.ok(systemQuartzJobService.searchQuartzLogByArgs(pageArgs.getArgs(), page));
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
|
||||
-4
@@ -29,8 +29,4 @@ public class SystemQueryQuartzJobArgs {
|
||||
private Boolean isSuccess;
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private List<Date> createTime;
|
||||
@ApiModelProperty(value = "页码", example = "1")
|
||||
private Integer page = 1;
|
||||
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||
private Integer size = 10;
|
||||
}
|
||||
|
||||
+2
-2
@@ -288,7 +288,7 @@ public class SystemDeptService {
|
||||
}
|
||||
}
|
||||
// 编辑部门时不显示自己以及自己下级的数据, 避免出现PID数据环形问题
|
||||
depts = depts.stream().filter(i -> !ids.contains(i.getId())).toList();
|
||||
depts = depts.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toList());
|
||||
}
|
||||
deptSet1.addAll(depts);
|
||||
}
|
||||
@@ -296,7 +296,7 @@ public class SystemDeptService {
|
||||
// 构建部门树
|
||||
Set<SystemDeptVo> trees = new LinkedHashSet<>();
|
||||
Set<SystemDeptVo> deptSet = new LinkedHashSet<>();
|
||||
List<String> deptNames = deptList.stream().map(SystemDeptVo::getName).toList();
|
||||
List<String> deptNames = deptList.stream().map(SystemDeptVo::getName).collect(Collectors.toList());
|
||||
boolean isChild;
|
||||
for (SystemDeptVo dept : deptList) {
|
||||
isChild = false;
|
||||
|
||||
+4
-4
@@ -26,7 +26,6 @@ import cn.odboy.system.dal.model.response.SystemDictDetailVo;
|
||||
import cn.odboy.system.dal.mysql.SystemDictMapper;
|
||||
import cn.odboy.util.KitBeanUtil;
|
||||
import cn.odboy.util.KitPageUtil;
|
||||
import cn.odboy.util.KitValidUtil;
|
||||
import cn.odboy.util.xlsx.KitExcelExporter;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -98,9 +97,10 @@ public class SystemDictService {
|
||||
}
|
||||
|
||||
private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper<SystemDictTb> wrapper) {
|
||||
KitValidUtil.notNull(args);
|
||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or()
|
||||
.like(SystemDictTb::getDescription, args.getBlurry()));
|
||||
if (args != null) {
|
||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or()
|
||||
.like(SystemDictTb::getDescription, args.getBlurry()));
|
||||
}
|
||||
}
|
||||
|
||||
public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) {
|
||||
|
||||
+7
-7
@@ -26,7 +26,6 @@ import cn.odboy.system.dal.model.request.SystemQueryJobArgs;
|
||||
import cn.odboy.system.dal.mysql.SystemJobMapper;
|
||||
import cn.odboy.util.KitBeanUtil;
|
||||
import cn.odboy.util.KitPageUtil;
|
||||
import cn.odboy.util.KitValidUtil;
|
||||
import cn.odboy.util.xlsx.KitExcelExporter;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -129,12 +128,13 @@ public class SystemJobService {
|
||||
}
|
||||
|
||||
public void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper<SystemJobTb> wrapper) {
|
||||
KitValidUtil.notNull(args);
|
||||
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName());
|
||||
wrapper.eq(args.getEnabled() != null, SystemJobTb::getEnabled, args.getEnabled());
|
||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||
wrapper.between(SystemJobTb::getCreateTime, args.getCreateTime().get(0),
|
||||
args.getCreateTime().get(1));
|
||||
if (args != null) {
|
||||
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName());
|
||||
wrapper.eq(args.getEnabled() != null, SystemJobTb::getEnabled, args.getEnabled());
|
||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||
wrapper.between(SystemJobTb::getCreateTime, args.getCreateTime().get(0),
|
||||
args.getCreateTime().get(1));
|
||||
}
|
||||
}
|
||||
wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId);
|
||||
}
|
||||
|
||||
+10
-10
@@ -33,7 +33,6 @@ import cn.odboy.system.dal.mysql.SystemLocalStorageMapper;
|
||||
import cn.odboy.util.KitBeanUtil;
|
||||
import cn.odboy.util.KitFileUtil;
|
||||
import cn.odboy.util.KitPageUtil;
|
||||
import cn.odboy.util.KitValidUtil;
|
||||
import cn.odboy.util.xlsx.KitExcelExporter;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -140,15 +139,16 @@ public class SystemLocalStorageService {
|
||||
}
|
||||
|
||||
private void injectQueryParams(SystemQueryStorageArgs args, LambdaQueryWrapper<SystemLocalStorageTb> wrapper) {
|
||||
KitValidUtil.notNull(args);
|
||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
|
||||
c -> c.like(SystemLocalStorageTb::getName, args.getBlurry()).or()
|
||||
.like(SystemLocalStorageTb::getSuffix, args.getBlurry()).or()
|
||||
.like(SystemLocalStorageTb::getType, args.getBlurry()).or()
|
||||
.like(SystemLocalStorageTb::getCreateBy, args.getBlurry()));
|
||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||
wrapper.between(SystemLocalStorageTb::getUpdateTime, args.getCreateTime().get(0),
|
||||
args.getCreateTime().get(1));
|
||||
if (args != null) {
|
||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
|
||||
c -> c.like(SystemLocalStorageTb::getName, args.getBlurry()).or()
|
||||
.like(SystemLocalStorageTb::getSuffix, args.getBlurry()).or()
|
||||
.like(SystemLocalStorageTb::getType, args.getBlurry()).or()
|
||||
.like(SystemLocalStorageTb::getCreateBy, args.getBlurry()));
|
||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||
wrapper.between(SystemLocalStorageTb::getUpdateTime, args.getCreateTime().get(0),
|
||||
args.getCreateTime().get(1));
|
||||
}
|
||||
}
|
||||
wrapper.orderByDesc(SystemLocalStorageTb::getId);
|
||||
}
|
||||
|
||||
-1
@@ -20,7 +20,6 @@ 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;
|
||||
|
||||
+6
-5
@@ -219,11 +219,12 @@ public class SystemQuartzJobService {
|
||||
}
|
||||
|
||||
private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper<SystemQuartzLogTb> wrapper) {
|
||||
KitValidUtil.notNull(args);
|
||||
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName());
|
||||
wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess());
|
||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||
wrapper.between(SystemQuartzLogTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
||||
if (args != null) {
|
||||
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName());
|
||||
wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess());
|
||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||
wrapper.between(SystemQuartzLogTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
||||
}
|
||||
}
|
||||
wrapper.orderByDesc(SystemQuartzLogTb::getId);
|
||||
}
|
||||
|
||||
+2
-2
@@ -147,7 +147,7 @@ public class SystemRoleService {
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteRoleByIds(Set<Long> ids) {
|
||||
List<Integer> roleLevels = systemRoleMapper.selectByIds(ids).stream().map(SystemRoleTb::getLevel).distinct().toList();
|
||||
List<Integer> roleLevels = systemRoleMapper.selectByIds(ids).stream().map(SystemRoleTb::getLevel).distinct().collect(Collectors.toList());
|
||||
for (Integer roleLevel : roleLevels) {
|
||||
checkRoleLevels(roleLevel);
|
||||
}
|
||||
@@ -274,7 +274,7 @@ public class SystemRoleService {
|
||||
*/
|
||||
private int checkRoleLevels(Integer level) {
|
||||
List<Integer> levels = systemUserRoleService.queryRoleByUsersId(KitSecurityHelper.getCurrentUserId()).stream()
|
||||
.map(SystemRoleVo::getLevel).toList();
|
||||
.map(SystemRoleVo::getLevel).collect(Collectors.toList());
|
||||
int min = Collections.min(levels);
|
||||
if (level != null) {
|
||||
if (level < min) {
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ public class SystemUserService {
|
||||
}
|
||||
}
|
||||
// 清理缓存
|
||||
List<String> usernameList = systemUserMapper.selectByIds(ids).stream().map(SystemUserTb::getUsername).distinct().toList();
|
||||
List<String> usernameList = systemUserMapper.selectByIds(ids).stream().map(SystemUserTb::getUsername).distinct().collect(Collectors.toList());
|
||||
for (String username : usernameList) {
|
||||
systemUserInfoDAO.deleteUserLoginInfoByUserName(username);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user