refactor(util): 移除多余BeanUtil导入并添加参数验证工具类

This commit is contained in:
2026-01-07 18:09:04 +08:00
parent 54cae0855b
commit e88d535153
23 changed files with 134 additions and 148 deletions
@@ -49,4 +49,16 @@ public final class KitValidUtil {
violations.stream().map(ConstraintViolation::getMessage).collect(Collectors.joining(",")));
}
}
public static void notNull(Object value) {
if (value == null) {
throw new BadRequestException("参数必填");
}
}
public static void isNull(Object value) {
if (value != null) {
throw new BadRequestException("参数非必填");
}
}
}
@@ -15,7 +15,6 @@
*/
package cn.odboy.framework.mybatisplus.core.interfaces;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.odboy.base.KitPageResult;
@@ -49,4 +49,16 @@ public final class KitValidUtil {
violations.stream().map(ConstraintViolation::getMessage).collect(Collectors.joining(",")));
}
}
public static void notNull(Object value) {
if (value == null) {
throw new BadRequestException("参数必填");
}
}
public static void isNull(Object value) {
if (value != null) {
throw new BadRequestException("参数非必填");
}
}
}
@@ -3,7 +3,6 @@ package cn.odboy.system.controller;
import cn.odboy.base.KitPageArgs;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemOperationLogTb;
import cn.odboy.system.dal.model.SystemQueryDeptArgs;
import cn.odboy.system.dal.model.SystemQueryOperationLogArgs;
import cn.odboy.system.service.SystemOperationLogService;
import cn.odboy.util.KitPageUtil;
@@ -14,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -21,7 +21,6 @@ import cn.odboy.base.KitSelectOptionVo;
import cn.odboy.system.dal.dataobject.SystemUserTb;
import cn.odboy.system.dal.model.SystemQueryUserArgs;
import cn.odboy.system.dal.model.SystemUpdateUserPasswordArgs;
import cn.odboy.system.dal.model.SystemUserInfoVo;
import cn.odboy.system.dal.model.SystemUserJwtVo;
import cn.odboy.system.dal.model.SystemUserVo;
import cn.odboy.system.framework.operalog.OperationLog;
@@ -15,8 +15,6 @@
*/
package cn.odboy.system.dal.dataobject;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.odboy.base.KitBaseUserTimeTb;
import cn.odboy.util.KitBeanUtil;
import com.baomidou.mybatisplus.annotation.IdType;
@@ -4,7 +4,6 @@ import cn.odboy.system.dal.dataobject.SystemDeptTb;
import cn.odboy.system.dal.dataobject.SystemJobTb;
import cn.odboy.system.dal.dataobject.SystemRoleTb;
import cn.odboy.system.dal.dataobject.SystemUserTb;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import java.util.Set;
import lombok.Getter;
@@ -13,6 +12,7 @@ import lombok.Setter;
@Getter
@Setter
public class SystemUserVo extends SystemUserTb {
@ApiModelProperty(value = "用户部门")
private SystemDeptTb dept;
@ApiModelProperty(value = "用户角色")
@@ -15,7 +15,6 @@
*/
package cn.odboy.system.dal.mysql;
import cn.hutool.core.bean.BeanUtil;
import cn.odboy.system.dal.dataobject.SystemQuartzJobTb;
import cn.odboy.system.dal.model.SystemQuartzJobVo;
import cn.odboy.util.KitBeanUtil;
@@ -1,28 +1,24 @@
package cn.odboy.system.dal.redis;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import cn.odboy.base.KitPageResult;
import cn.odboy.framework.properties.AppProperties;
import cn.odboy.framework.redis.KitRedisHelper;
import cn.odboy.system.dal.model.SystemUserJwtVo;
import cn.odboy.system.dal.model.SystemUserOnlineExportRowVo;
import cn.odboy.system.dal.model.SystemUserOnlineVo;
import cn.odboy.system.framework.permission.core.handler.TokenProvider;
import cn.odboy.util.KitBeanUtil;
import cn.odboy.util.KitBrowserUtil;
import cn.odboy.util.KitDesEncryptUtil;
import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitIPUtil;
import cn.odboy.util.KitPageUtil;
import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
@@ -174,7 +170,7 @@ public class SystemUserOnlineInfoDAO {
List<SystemUserOnlineVo> userOnlineVos = this.queryUserOnlineModelListByUsername(username);
// KitXlsxExportUtil.exportFile(response, "在线用户数据", userOnlineVos, SystemUserOnlineExportRowVo.class,
// (dataObject) -> CollUtil.newArrayList(KitBeanUtil.copyProperties(dataObject, SystemUserOnlineExportRowVo.class)));
List<SystemUserOnlineVo> rowVos = KitBeanUtil.copyToList(userOnlineVos, SystemUserOnlineVo.class);
KitExcelExporter.exportSimple(response, "在线用户数据", SystemUserOnlineVo.class, rowVos);
List<SystemUserOnlineExportRowVo> rowVos = KitBeanUtil.copyToList(userOnlineVos, SystemUserOnlineExportRowVo.class);
KitExcelExporter.exportSimple(response, "在线用户数据", SystemUserOnlineExportRowVo.class, rowVos);
}
}
@@ -19,7 +19,6 @@ import cn.hutool.core.collection.CollUtil;
import cn.odboy.system.constant.SystemDataScopeEnum;
import cn.odboy.system.dal.dataobject.SystemDeptTb;
import cn.odboy.system.dal.dataobject.SystemRoleTb;
import cn.odboy.system.dal.dataobject.SystemUserTb;
import cn.odboy.system.dal.model.SystemRoleVo;
import cn.odboy.system.dal.model.SystemUserVo;
import java.util.ArrayList;
@@ -15,7 +15,6 @@
*/
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -35,6 +34,7 @@ import cn.odboy.system.dal.mysql.SystemDeptMapper;
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
import cn.odboy.util.KitBeanUtil;
import cn.odboy.util.KitClassUtil;
import cn.odboy.util.KitValidUtil;
import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import java.lang.reflect.Field;
@@ -147,17 +147,16 @@ public class SystemDeptService {
}
private List<SystemDeptTb> queryDeptByArgs(SystemQueryDeptArgs args) {
KitValidUtil.notNull(args);
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
if (args != null) {
wrapper.in(CollUtil.isNotEmpty(args.getIds()), SystemDeptTb::getId, args.getIds());
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemDeptTb::getName, args.getName());
wrapper.eq(args.getEnabled() != null, SystemDeptTb::getEnabled, args.getEnabled());
wrapper.eq(args.getPid() != null, SystemDeptTb::getPid, args.getPid());
wrapper.isNull(args.getPidIsNull() != null, SystemDeptTb::getPid);
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemDeptTb::getCreateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1));
}
wrapper.in(CollUtil.isNotEmpty(args.getIds()), SystemDeptTb::getId, args.getIds());
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemDeptTb::getName, args.getName());
wrapper.eq(args.getEnabled() != null, SystemDeptTb::getEnabled, args.getEnabled());
wrapper.eq(args.getPid() != null, SystemDeptTb::getPid, args.getPid());
wrapper.isNull(args.getPidIsNull() != null, SystemDeptTb::getPid);
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemDeptTb::getCreateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1));
}
wrapper.orderByAsc(SystemDeptTb::getDeptSort);
return systemDeptMapper.selectList(wrapper);
@@ -15,7 +15,6 @@
*/
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.odboy.base.KitPageResult;
@@ -15,7 +15,6 @@
*/
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.odboy.base.KitPageResult;
@@ -27,6 +26,7 @@ import cn.odboy.system.dal.model.SystemQueryDictArgs;
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;
@@ -97,10 +97,9 @@ public class SystemDictService {
}
private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper<SystemDictTb> wrapper) {
if (args != null) {
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or()
.like(SystemDictTb::getDescription, args.getBlurry()));
}
KitValidUtil.notNull(args);
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) {
@@ -15,7 +15,6 @@
*/
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.odboy.base.KitPageResult;
@@ -27,6 +26,7 @@ import cn.odboy.system.dal.model.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;
@@ -128,13 +128,12 @@ public class SystemJobService {
}
public void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper<SystemJobTb> wrapper) {
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));
}
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));
}
wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId);
}
@@ -15,7 +15,6 @@
*/
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
@@ -34,6 +33,7 @@ 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,16 +140,15 @@ public class SystemLocalStorageService {
}
private void injectQueryParams(SystemQueryStorageArgs args, LambdaQueryWrapper<SystemLocalStorageTb> wrapper) {
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));
}
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));
}
wrapper.orderByDesc(SystemLocalStorageTb::getId);
}
@@ -15,7 +15,6 @@
*/
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -35,6 +34,7 @@ import cn.odboy.system.dal.mysql.SystemMenuMapper;
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
import cn.odboy.util.KitBeanUtil;
import cn.odboy.util.KitClassUtil;
import cn.odboy.util.KitValidUtil;
import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -397,18 +397,17 @@ public class SystemMenuService {
}
private List<SystemMenuTb> queryMenuByArgs(SystemQueryMenuArgs args) {
KitValidUtil.notNull(args);
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
if (args != null) {
wrapper.isNull(args.getPidIsNull() != null, SystemMenuTb::getPid);
wrapper.eq(args.getPid() != null, SystemMenuTb::getPid, args.getPid());
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
c -> c.like(SystemMenuTb::getTitle, args.getBlurry()).or()
.like(SystemMenuTb::getComponentName, args.getBlurry()).or()
.like(SystemMenuTb::getPermission, args.getBlurry()));
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemMenuTb::getCreateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1));
}
wrapper.isNull(args.getPidIsNull() != null, SystemMenuTb::getPid);
wrapper.eq(args.getPid() != null, SystemMenuTb::getPid, args.getPid());
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
c -> c.like(SystemMenuTb::getTitle, args.getBlurry()).or()
.like(SystemMenuTb::getComponentName, args.getBlurry()).or()
.like(SystemMenuTb::getPermission, args.getBlurry()));
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemMenuTb::getCreateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1));
}
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
return systemMenuMapper.selectList(wrapper);
@@ -15,7 +15,6 @@
*/
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
@@ -35,6 +34,7 @@ import cn.odboy.system.dal.mysql.SystemQuartzLogMapper;
import cn.odboy.system.framework.quartz.QuartzManage;
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;
@@ -200,36 +200,27 @@ public class SystemQuartzJobService {
* @param page 分页参数
* @return /
*/
public KitPageResult<SystemQuartzJobTb> searchQuartzJobByArgs(SystemQueryQuartzJobArgs args,
Page<SystemQuartzJobTb> page) {
public KitPageResult<SystemQuartzJobTb> searchQuartzJobByArgs(SystemQueryQuartzJobArgs args, Page<SystemQuartzJobTb> page) {
LambdaQueryWrapper<SystemQuartzJobTb> wrapper = new LambdaQueryWrapper<>();
this.injectQuartzJobQueryParams(args, wrapper);
return KitPageUtil.toPage(systemQuartzJobMapper.selectPage(page, wrapper));
}
private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args,
LambdaQueryWrapper<SystemQuartzJobTb> wrapper) {
if (args != null) {
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName,
args.getJobName());
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1));
}
private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper<SystemQuartzJobTb> wrapper) {
KitValidUtil.notNull(args);
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName());
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
}
wrapper.orderByDesc(SystemQuartzJobTb::getId);
}
private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args,
LambdaQueryWrapper<SystemQuartzLogTb> wrapper) {
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));
}
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));
}
wrapper.orderByDesc(SystemQuartzLogTb::getId);
}
@@ -15,7 +15,6 @@
*/
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Dict;
@@ -34,6 +33,7 @@ import cn.odboy.system.dal.mysql.SystemRoleMapper;
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
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;
@@ -164,19 +164,18 @@ public class SystemRoleService {
* @return /
*/
public List<SystemRoleVo> queryRoleByArgs(SystemQueryRoleArgs args) {
KitValidUtil.notNull(args);
// 查询角色基本信息
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
if (args != null) {
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
c -> c.like(SystemRoleTb::getName, args.getBlurry()).or()
.like(SystemRoleTb::getDescription, args.getBlurry()));
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1));
}
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
c -> c.like(SystemRoleTb::getName, args.getBlurry()).or()
.like(SystemRoleTb::getDescription, args.getBlurry()));
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1));
}
wrapper.orderByAsc(SystemRoleTb::getLevel);
if (args != null && args.getSize() != null) {
if (args.getSize() != null) {
Page<SystemRoleTb> rolePage = new Page<>(args.getPage(), args.getSize());
Page<SystemRoleTb> page = systemRoleMapper.selectPage(rolePage, wrapper);
List<SystemRoleTb> roles = page.getRecords();
@@ -233,15 +232,14 @@ public class SystemRoleService {
}
public Long countRoleByArgs(SystemQueryRoleArgs args) {
KitValidUtil.notNull(args);
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
if (args != null) {
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
c -> c.like(SystemRoleTb::getName, args.getBlurry()).or()
.like(SystemRoleTb::getDescription, args.getBlurry()));
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1));
}
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
c -> c.like(SystemRoleTb::getName, args.getBlurry()).or()
.like(SystemRoleTb::getDescription, args.getBlurry()));
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1));
}
return systemRoleMapper.selectCount(wrapper);
}
@@ -15,7 +15,6 @@
*/
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.odboy.framework.exception.BadRequestException;
import cn.odboy.system.dal.dataobject.SystemDeptTb;
@@ -15,7 +15,6 @@
*/
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
@@ -45,6 +44,7 @@ import cn.odboy.util.KitBeanUtil;
import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitPageUtil;
import cn.odboy.util.KitRsaEncryptUtil;
import cn.odboy.util.KitValidUtil;
import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -401,26 +401,25 @@ public class SystemUserService {
* @return /
*/
private LambdaQueryWrapper<SystemUserTb> buildUserQueryWrapper(SystemQueryUserArgs args) {
KitValidUtil.notNull(args);
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
if (args != null) {
if (args.getId() != null) {
wrapper.eq(SystemUserTb::getId, args.getId());
}
if (args.getEnabled() != null) {
wrapper.eq(SystemUserTb::getEnabled, args.getEnabled());
}
if (CollUtil.isNotEmpty(args.getDeptIds())) {
wrapper.in(SystemUserTb::getDeptId, args.getDeptIds());
}
if (StrUtil.isNotBlank(args.getBlurry())) {
wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry())
.or().like(SystemUserTb::getNickName, args.getBlurry())
.or().like(SystemUserTb::getEmail, args.getBlurry()));
}
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1));
}
if (args.getId() != null) {
wrapper.eq(SystemUserTb::getId, args.getId());
}
if (args.getEnabled() != null) {
wrapper.eq(SystemUserTb::getEnabled, args.getEnabled());
}
if (CollUtil.isNotEmpty(args.getDeptIds())) {
wrapper.in(SystemUserTb::getDeptId, args.getDeptIds());
}
if (StrUtil.isNotBlank(args.getBlurry())) {
wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry())
.or().like(SystemUserTb::getNickName, args.getBlurry())
.or().like(SystemUserTb::getEmail, args.getBlurry()));
}
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1));
}
wrapper.orderByDesc(SystemUserTb::getCreateTime);
return wrapper;
@@ -33,6 +33,7 @@ import cn.odboy.util.KitBeanUtil;
import cn.odboy.util.KitDateUtil;
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.core.metadata.IPage;
@@ -68,33 +69,27 @@ public class SystemMinioStorageServiceImpl extends ServiceImpl<SystemOssStorageM
private SystemOssStorageMapper systemOssStorageMapper;
@Override
public KitPageResult<SystemOssStorageVo> searchOssStorage(SystemQueryStorageArgs args,
Page<SystemOssStorageTb> page) {
IPage<SystemOssStorageTb> ossStorageTbs = this.selectOssStorageByArgs(args, page);
IPage<SystemOssStorageVo> convert = ossStorageTbs.convert(c -> {
SystemOssStorageVo storageVo = KitBeanUtil.copyToClass(c, SystemOssStorageVo.class);
public KitPageResult<SystemOssStorageVo> searchOssStorage(SystemQueryStorageArgs args, Page<SystemOssStorageTb> page) {
IPage<SystemOssStorageVo> ossStorageTbs = this.selectOssStorageByArgs(args, page);
for (SystemOssStorageVo storageVo : ossStorageTbs.getRecords()) {
storageVo.setFileSizeDesc(KitFileUtil.getSize(storageVo.getFileSize()));
return storageVo;
});
return KitPageUtil.toPage(convert);
}
return KitPageUtil.toPage(ossStorageTbs);
}
private IPage<SystemOssStorageTb> selectOssStorageByArgs(SystemQueryStorageArgs args,
Page<SystemOssStorageTb> page) {
private IPage<SystemOssStorageVo> selectOssStorageByArgs(SystemQueryStorageArgs args, Page<SystemOssStorageTb> page) {
KitValidUtil.notNull(args);
LambdaQueryWrapper<SystemOssStorageTb> wrapper = new LambdaQueryWrapper<>();
if (args != null) {
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
c -> c.like(SystemOssStorageTb::getFileName, args.getBlurry()).or()
.like(SystemOssStorageTb::getFilePrefix, args.getBlurry()).or()
.like(SystemOssStorageTb::getFileMime, args.getBlurry()).or()
.like(SystemOssStorageTb::getFileMd5, args.getBlurry()));
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemOssStorageTb::getUpdateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1));
}
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
c -> c.like(SystemOssStorageTb::getFileName, args.getBlurry()).or()
.like(SystemOssStorageTb::getFilePrefix, args.getBlurry()).or()
.like(SystemOssStorageTb::getFileMime, args.getBlurry()).or()
.like(SystemOssStorageTb::getFileMd5, args.getBlurry()));
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemOssStorageTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
}
wrapper.orderByAsc(SystemOssStorageTb::getId);
return systemOssStorageMapper.selectPage(page, wrapper);
return systemOssStorageMapper.selectPage(page, wrapper).convert(i -> KitBeanUtil.copyToClass(i, SystemOssStorageVo.class));
}
@Override
@@ -15,7 +15,6 @@
*/
package cn.odboy.task.core;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import cn.odboy.framework.context.KitSpringBeanHolder;
import cn.odboy.framework.exception.BadRequestException;
@@ -15,7 +15,6 @@
*/
package cn.odboy.task.core;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import cn.odboy.framework.context.KitSpringBeanHolder;
import cn.odboy.framework.exception.BadRequestException;