refactor(quartz): 重构定时任务日志查询接口参数处理

This commit is contained in:
2026-01-12 18:54:31 +08:00
parent 5aa5624350
commit f41f436dd8
8 changed files with 55 additions and 40 deletions
+17 -5
View File
@@ -19,6 +19,8 @@ export default {
url: '', url: '',
// 查询数据的参数 // 查询数据的参数
params: {}, params: {},
// 是否自定义参数
isCustomParams: false,
// 待查询的对象 // 待查询的对象
query: {}, query: {},
// 等待时间 // 等待时间
@@ -76,11 +78,21 @@ export default {
Object.keys(this.params).length !== 0 && Object.keys(this.params).forEach(item => { Object.keys(this.params).length !== 0 && Object.keys(this.params).forEach(item => {
if (this.params[item] === null || this.params[item] === '') this.params[item] = undefined if (this.params[item] === null || this.params[item] === '') this.params[item] = undefined
}) })
return { if (this.isCustomParams) {
page: this.page, return {
size: this.size, page: this.page,
...this.query, size: this.size,
...this.params args: {
...this.params
}
}
} else {
return {
page: this.page,
size: this.size,
...this.query,
...this.params
}
} }
}, },
// 改变页码 // 改变页码
@@ -73,7 +73,7 @@
<el-pagination <el-pagination
:total="total" :total="total"
:current-page="page" :current-page="page"
:page-size="6" :page-size="size"
style="margin-top:8px;" style="margin-top:8px;"
layout="total, prev, pager, next" layout="total, prev, pager, next"
@size-change="sizeChange" @size-change="sizeChange"
@@ -110,7 +110,13 @@ export default {
// 获取数据前设置好接口地址 // 获取数据前设置好接口地址
beforeInit() { beforeInit() {
this.url = 'api/quartzJob/searchQuartzLog' this.url = 'api/quartzJob/searchQuartzLog'
this.size = 6 this.page = 1
this.isCustomParams = true
this.params = {
jobName: this.query.jobName,
createTime: this.query.createTime,
isSuccess: this.query.isSuccess
}
return true return true
}, },
// 异常详情 // 异常详情
@@ -77,9 +77,9 @@ public class SystemQuartzJobController {
@ApiOperation("查询定时任务执行日志") @ApiOperation("查询定时任务执行日志")
@PostMapping(value = "/searchQuartzLog") @PostMapping(value = "/searchQuartzLog")
@PreAuthorize("@el.check('quartzJob:list')") @PreAuthorize("@el.check('quartzJob:list')")
public ResponseEntity<KitPageResult<SystemQuartzLogTb>> queryQuartzJobLog(SystemQueryQuartzJobArgs args) { public ResponseEntity<KitPageResult<SystemQuartzLogTb>> queryQuartzJobLog(@Validated @RequestBody KitPageArgs<SystemQueryQuartzJobArgs> pageArgs) {
Page<SystemQuartzLogTb> page = new Page<>(args.getPage(), args.getSize()); Page<SystemQuartzLogTb> page = new Page<>(pageArgs.getPage(), pageArgs.getSize());
return ResponseEntity.ok(systemQuartzJobService.searchQuartzLogByArgs(args, page)); return ResponseEntity.ok(systemQuartzJobService.searchQuartzLogByArgs(pageArgs.getArgs(), page));
} }
@OperationLog @OperationLog
@@ -29,8 +29,4 @@ public class SystemQueryQuartzJobArgs {
private Boolean isSuccess; private Boolean isSuccess;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private List<Date> createTime; private List<Date> createTime;
@ApiModelProperty(value = "页码", example = "1")
private Integer page = 1;
@ApiModelProperty(value = "每页数据量", example = "10")
private Integer size = 10;
} }
@@ -26,7 +26,6 @@ import cn.odboy.system.dal.model.response.SystemDictDetailVo;
import cn.odboy.system.dal.mysql.SystemDictMapper; import cn.odboy.system.dal.mysql.SystemDictMapper;
import cn.odboy.util.KitBeanUtil; import cn.odboy.util.KitBeanUtil;
import cn.odboy.util.KitPageUtil; import cn.odboy.util.KitPageUtil;
import cn.odboy.util.KitValidUtil;
import cn.odboy.util.xlsx.KitExcelExporter; import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -98,9 +97,10 @@ public class SystemDictService {
} }
private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper<SystemDictTb> wrapper) { private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper<SystemDictTb> wrapper) {
KitValidUtil.notNull(args); if (args != null) {
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or() wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or()
.like(SystemDictTb::getDescription, args.getBlurry())); .like(SystemDictTb::getDescription, args.getBlurry()));
}
} }
public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) { public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) {
@@ -26,7 +26,6 @@ import cn.odboy.system.dal.model.request.SystemQueryJobArgs;
import cn.odboy.system.dal.mysql.SystemJobMapper; import cn.odboy.system.dal.mysql.SystemJobMapper;
import cn.odboy.util.KitBeanUtil; import cn.odboy.util.KitBeanUtil;
import cn.odboy.util.KitPageUtil; import cn.odboy.util.KitPageUtil;
import cn.odboy.util.KitValidUtil;
import cn.odboy.util.xlsx.KitExcelExporter; import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -129,12 +128,13 @@ public class SystemJobService {
} }
public void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper<SystemJobTb> wrapper) { public void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper<SystemJobTb> wrapper) {
KitValidUtil.notNull(args); if (args != null) {
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName()); wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName());
wrapper.eq(args.getEnabled() != null, SystemJobTb::getEnabled, args.getEnabled()); wrapper.eq(args.getEnabled() != null, SystemJobTb::getEnabled, args.getEnabled());
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemJobTb::getCreateTime, args.getCreateTime().get(0), wrapper.between(SystemJobTb::getCreateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1)); args.getCreateTime().get(1));
}
} }
wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId); wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId);
} }
@@ -33,7 +33,6 @@ import cn.odboy.system.dal.mysql.SystemLocalStorageMapper;
import cn.odboy.util.KitBeanUtil; import cn.odboy.util.KitBeanUtil;
import cn.odboy.util.KitFileUtil; import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitPageUtil; import cn.odboy.util.KitPageUtil;
import cn.odboy.util.KitValidUtil;
import cn.odboy.util.xlsx.KitExcelExporter; import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -140,15 +139,16 @@ public class SystemLocalStorageService {
} }
private void injectQueryParams(SystemQueryStorageArgs args, LambdaQueryWrapper<SystemLocalStorageTb> wrapper) { private void injectQueryParams(SystemQueryStorageArgs args, LambdaQueryWrapper<SystemLocalStorageTb> wrapper) {
KitValidUtil.notNull(args); if (args != null) {
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
c -> c.like(SystemLocalStorageTb::getName, args.getBlurry()).or() c -> c.like(SystemLocalStorageTb::getName, args.getBlurry()).or()
.like(SystemLocalStorageTb::getSuffix, args.getBlurry()).or() .like(SystemLocalStorageTb::getSuffix, args.getBlurry()).or()
.like(SystemLocalStorageTb::getType, args.getBlurry()).or() .like(SystemLocalStorageTb::getType, args.getBlurry()).or()
.like(SystemLocalStorageTb::getCreateBy, args.getBlurry())); .like(SystemLocalStorageTb::getCreateBy, args.getBlurry()));
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemLocalStorageTb::getUpdateTime, args.getCreateTime().get(0), wrapper.between(SystemLocalStorageTb::getUpdateTime, args.getCreateTime().get(0),
args.getCreateTime().get(1)); args.getCreateTime().get(1));
}
} }
wrapper.orderByDesc(SystemLocalStorageTb::getId); wrapper.orderByDesc(SystemLocalStorageTb::getId);
} }
@@ -219,11 +219,12 @@ public class SystemQuartzJobService {
} }
private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper<SystemQuartzLogTb> wrapper) { private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper<SystemQuartzLogTb> wrapper) {
KitValidUtil.notNull(args); if (args != null) {
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName()); wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName());
wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess()); wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess());
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
wrapper.between(SystemQuartzLogTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); wrapper.between(SystemQuartzLogTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
}
} }
wrapper.orderByDesc(SystemQuartzLogTb::getId); wrapper.orderByDesc(SystemQuartzLogTb::getId);
} }