Commit e541fe63246e140b9e3c1e309ec7f7d6540f191b
1 parent
35d171b1
🔧 简化 job 模块的 VO
Showing
22 changed files
with
151 additions
and
591 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/JobController.java
| 1 | package cn.iocoder.yudao.module.infra.controller.admin.job; | 1 | package cn.iocoder.yudao.module.infra.controller.admin.job; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 7 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 6 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 8 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 7 | import cn.iocoder.yudao.framework.quartz.core.util.CronUtils; | 9 | import cn.iocoder.yudao.framework.quartz.core.util.CronUtils; |
| 8 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.*; | ||
| 9 | -import cn.iocoder.yudao.module.infra.convert.job.JobConvert; | 10 | +import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO; |
| 11 | +import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobRespVO; | ||
| 12 | +import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobSaveReqVO; | ||
| 10 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO; | 13 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO; |
| 11 | import cn.iocoder.yudao.module.infra.service.job.JobService; | 14 | import cn.iocoder.yudao.module.infra.service.job.JobService; |
| 12 | -import io.swagger.v3.oas.annotations.tags.Tag; | 15 | +import io.swagger.v3.oas.annotations.Operation; |
| 13 | import io.swagger.v3.oas.annotations.Parameter; | 16 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | import io.swagger.v3.oas.annotations.Parameters; | 17 | import io.swagger.v3.oas.annotations.Parameters; |
| 15 | -import io.swagger.v3.oas.annotations.Operation; | 18 | +import io.swagger.v3.oas.annotations.tags.Tag; |
| 16 | import org.quartz.SchedulerException; | 19 | import org.quartz.SchedulerException; |
| 17 | import org.springframework.security.access.prepost.PreAuthorize; | 20 | import org.springframework.security.access.prepost.PreAuthorize; |
| 18 | import org.springframework.validation.annotation.Validated; | 21 | import org.springframework.validation.annotation.Validated; |
| @@ -23,7 +26,6 @@ import javax.servlet.http.HttpServletResponse; | @@ -23,7 +26,6 @@ import javax.servlet.http.HttpServletResponse; | ||
| 23 | import javax.validation.Valid; | 26 | import javax.validation.Valid; |
| 24 | import java.io.IOException; | 27 | import java.io.IOException; |
| 25 | import java.time.LocalDateTime; | 28 | import java.time.LocalDateTime; |
| 26 | -import java.util.Collection; | ||
| 27 | import java.util.Collections; | 29 | import java.util.Collections; |
| 28 | import java.util.List; | 30 | import java.util.List; |
| 29 | 31 | ||
| @@ -42,7 +44,7 @@ public class JobController { | @@ -42,7 +44,7 @@ public class JobController { | ||
| 42 | @PostMapping("/create") | 44 | @PostMapping("/create") |
| 43 | @Operation(summary = "创建定时任务") | 45 | @Operation(summary = "创建定时任务") |
| 44 | @PreAuthorize("@ss.hasPermission('infra:job:create')") | 46 | @PreAuthorize("@ss.hasPermission('infra:job:create')") |
| 45 | - public CommonResult<Long> createJob(@Valid @RequestBody JobCreateReqVO createReqVO) | 47 | + public CommonResult<Long> createJob(@Valid @RequestBody JobSaveReqVO createReqVO) |
| 46 | throws SchedulerException { | 48 | throws SchedulerException { |
| 47 | return success(jobService.createJob(createReqVO)); | 49 | return success(jobService.createJob(createReqVO)); |
| 48 | } | 50 | } |
| @@ -50,7 +52,7 @@ public class JobController { | @@ -50,7 +52,7 @@ public class JobController { | ||
| 50 | @PutMapping("/update") | 52 | @PutMapping("/update") |
| 51 | @Operation(summary = "更新定时任务") | 53 | @Operation(summary = "更新定时任务") |
| 52 | @PreAuthorize("@ss.hasPermission('infra:job:update')") | 54 | @PreAuthorize("@ss.hasPermission('infra:job:update')") |
| 53 | - public CommonResult<Boolean> updateJob(@Valid @RequestBody JobUpdateReqVO updateReqVO) | 55 | + public CommonResult<Boolean> updateJob(@Valid @RequestBody JobSaveReqVO updateReqVO) |
| 54 | throws SchedulerException { | 56 | throws SchedulerException { |
| 55 | jobService.updateJob(updateReqVO); | 57 | jobService.updateJob(updateReqVO); |
| 56 | return success(true); | 58 | return success(true); |
| @@ -94,16 +96,7 @@ public class JobController { | @@ -94,16 +96,7 @@ public class JobController { | ||
| 94 | @PreAuthorize("@ss.hasPermission('infra:job:query')") | 96 | @PreAuthorize("@ss.hasPermission('infra:job:query')") |
| 95 | public CommonResult<JobRespVO> getJob(@RequestParam("id") Long id) { | 97 | public CommonResult<JobRespVO> getJob(@RequestParam("id") Long id) { |
| 96 | JobDO job = jobService.getJob(id); | 98 | JobDO job = jobService.getJob(id); |
| 97 | - return success(JobConvert.INSTANCE.convert(job)); | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - @GetMapping("/list") | ||
| 101 | - @Operation(summary = "获得定时任务列表") | ||
| 102 | - @Parameter(name = "ids", description = "编号列表", required = true) | ||
| 103 | - @PreAuthorize("@ss.hasPermission('infra:job:query')") | ||
| 104 | - public CommonResult<List<JobRespVO>> getJobList(@RequestParam("ids") Collection<Long> ids) { | ||
| 105 | - List<JobDO> list = jobService.getJobList(ids); | ||
| 106 | - return success(JobConvert.INSTANCE.convertList(list)); | 99 | + return success(BeanUtils.toBean(job, JobRespVO.class)); |
| 107 | } | 100 | } |
| 108 | 101 | ||
| 109 | @GetMapping("/page") | 102 | @GetMapping("/page") |
| @@ -111,19 +104,20 @@ public class JobController { | @@ -111,19 +104,20 @@ public class JobController { | ||
| 111 | @PreAuthorize("@ss.hasPermission('infra:job:query')") | 104 | @PreAuthorize("@ss.hasPermission('infra:job:query')") |
| 112 | public CommonResult<PageResult<JobRespVO>> getJobPage(@Valid JobPageReqVO pageVO) { | 105 | public CommonResult<PageResult<JobRespVO>> getJobPage(@Valid JobPageReqVO pageVO) { |
| 113 | PageResult<JobDO> pageResult = jobService.getJobPage(pageVO); | 106 | PageResult<JobDO> pageResult = jobService.getJobPage(pageVO); |
| 114 | - return success(JobConvert.INSTANCE.convertPage(pageResult)); | 107 | + return success(BeanUtils.toBean(pageResult, JobRespVO.class)); |
| 115 | } | 108 | } |
| 116 | 109 | ||
| 117 | @GetMapping("/export-excel") | 110 | @GetMapping("/export-excel") |
| 118 | @Operation(summary = "导出定时任务 Excel") | 111 | @Operation(summary = "导出定时任务 Excel") |
| 119 | @PreAuthorize("@ss.hasPermission('infra:job:export')") | 112 | @PreAuthorize("@ss.hasPermission('infra:job:export')") |
| 120 | @OperateLog(type = EXPORT) | 113 | @OperateLog(type = EXPORT) |
| 121 | - public void exportJobExcel(@Valid JobExportReqVO exportReqVO, | 114 | + public void exportJobExcel(@Valid JobPageReqVO exportReqVO, |
| 122 | HttpServletResponse response) throws IOException { | 115 | HttpServletResponse response) throws IOException { |
| 123 | - List<JobDO> list = jobService.getJobList(exportReqVO); | 116 | + exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| 117 | + List<JobDO> list = jobService.getJobPage(exportReqVO).getList(); | ||
| 124 | // 导出 Excel | 118 | // 导出 Excel |
| 125 | - List<JobExcelVO> datas = JobConvert.INSTANCE.convertList02(list); | ||
| 126 | - ExcelUtils.write(response, "定时任务.xls", "数据", JobExcelVO.class, datas); | 119 | + ExcelUtils.write(response, "定时任务.xls", "数据", JobRespVO.class, |
| 120 | + BeanUtils.toBean(list, JobRespVO.class)); | ||
| 127 | } | 121 | } |
| 128 | 122 | ||
| 129 | @GetMapping("/get_next_times") | 123 | @GetMapping("/get_next_times") |
| @@ -133,8 +127,9 @@ public class JobController { | @@ -133,8 +127,9 @@ public class JobController { | ||
| 133 | @Parameter(name = "count", description = "数量", example = "5") | 127 | @Parameter(name = "count", description = "数量", example = "5") |
| 134 | }) | 128 | }) |
| 135 | @PreAuthorize("@ss.hasPermission('infra:job:query')") | 129 | @PreAuthorize("@ss.hasPermission('infra:job:query')") |
| 136 | - public CommonResult<List<LocalDateTime>> getJobNextTimes(@RequestParam("id") Long id, | ||
| 137 | - @RequestParam(value = "count", required = false, defaultValue = "5") Integer count) { | 130 | + public CommonResult<List<LocalDateTime>> getJobNextTimes( |
| 131 | + @RequestParam("id") Long id, | ||
| 132 | + @RequestParam(value = "count", required = false, defaultValue = "5") Integer count) { | ||
| 138 | JobDO job = jobService.getJob(id); | 133 | JobDO job = jobService.getJob(id); |
| 139 | if (job == null) { | 134 | if (job == null) { |
| 140 | return success(Collections.emptyList()); | 135 | return success(Collections.emptyList()); |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/JobLogController.java
| 1 | package cn.iocoder.yudao.module.infra.controller.admin.job; | 1 | package cn.iocoder.yudao.module.infra.controller.admin.job; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 7 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 6 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 8 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 7 | -import cn.iocoder.yudao.framework.operatelog.core.util.OperateLogUtils; | ||
| 8 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExcelVO; | ||
| 9 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO; | ||
| 10 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; | 9 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; |
| 11 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogRespVO; | 10 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogRespVO; |
| 12 | -import cn.iocoder.yudao.module.infra.convert.job.JobLogConvert; | ||
| 13 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; | 11 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; |
| 14 | import cn.iocoder.yudao.module.infra.service.job.JobLogService; | 12 | import cn.iocoder.yudao.module.infra.service.job.JobLogService; |
| 15 | -import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 16 | -import io.swagger.v3.oas.annotations.Parameter; | ||
| 17 | import io.swagger.v3.oas.annotations.Operation; | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 14 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 15 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 18 | import org.springframework.security.access.prepost.PreAuthorize; | 16 | import org.springframework.security.access.prepost.PreAuthorize; |
| 19 | import org.springframework.validation.annotation.Validated; | 17 | import org.springframework.validation.annotation.Validated; |
| 20 | import org.springframework.web.bind.annotation.GetMapping; | 18 | import org.springframework.web.bind.annotation.GetMapping; |
| @@ -26,7 +24,6 @@ import javax.annotation.Resource; | @@ -26,7 +24,6 @@ import javax.annotation.Resource; | ||
| 26 | import javax.servlet.http.HttpServletResponse; | 24 | import javax.servlet.http.HttpServletResponse; |
| 27 | import javax.validation.Valid; | 25 | import javax.validation.Valid; |
| 28 | import java.io.IOException; | 26 | import java.io.IOException; |
| 29 | -import java.util.Collection; | ||
| 30 | import java.util.List; | 27 | import java.util.List; |
| 31 | 28 | ||
| 32 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 29 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| @@ -47,16 +44,7 @@ public class JobLogController { | @@ -47,16 +44,7 @@ public class JobLogController { | ||
| 47 | @PreAuthorize("@ss.hasPermission('infra:job:query')") | 44 | @PreAuthorize("@ss.hasPermission('infra:job:query')") |
| 48 | public CommonResult<JobLogRespVO> getJobLog(@RequestParam("id") Long id) { | 45 | public CommonResult<JobLogRespVO> getJobLog(@RequestParam("id") Long id) { |
| 49 | JobLogDO jobLog = jobLogService.getJobLog(id); | 46 | JobLogDO jobLog = jobLogService.getJobLog(id); |
| 50 | - return success(JobLogConvert.INSTANCE.convert(jobLog)); | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - @GetMapping("/list") | ||
| 54 | - @Operation(summary = "获得定时任务日志列表") | ||
| 55 | - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | ||
| 56 | - @PreAuthorize("@ss.hasPermission('infra:job:query')") | ||
| 57 | - public CommonResult<List<JobLogRespVO>> getJobLogList(@RequestParam("ids") Collection<Long> ids) { | ||
| 58 | - List<JobLogDO> list = jobLogService.getJobLogList(ids); | ||
| 59 | - return success(JobLogConvert.INSTANCE.convertList(list)); | 47 | + return success(BeanUtils.toBean(jobLog, JobLogRespVO.class)); |
| 60 | } | 48 | } |
| 61 | 49 | ||
| 62 | @GetMapping("/page") | 50 | @GetMapping("/page") |
| @@ -64,19 +52,20 @@ public class JobLogController { | @@ -64,19 +52,20 @@ public class JobLogController { | ||
| 64 | @PreAuthorize("@ss.hasPermission('infra:job:query')") | 52 | @PreAuthorize("@ss.hasPermission('infra:job:query')") |
| 65 | public CommonResult<PageResult<JobLogRespVO>> getJobLogPage(@Valid JobLogPageReqVO pageVO) { | 53 | public CommonResult<PageResult<JobLogRespVO>> getJobLogPage(@Valid JobLogPageReqVO pageVO) { |
| 66 | PageResult<JobLogDO> pageResult = jobLogService.getJobLogPage(pageVO); | 54 | PageResult<JobLogDO> pageResult = jobLogService.getJobLogPage(pageVO); |
| 67 | - return success(JobLogConvert.INSTANCE.convertPage(pageResult)); | 55 | + return success(BeanUtils.toBean(pageResult, JobLogRespVO.class)); |
| 68 | } | 56 | } |
| 69 | 57 | ||
| 70 | @GetMapping("/export-excel") | 58 | @GetMapping("/export-excel") |
| 71 | @Operation(summary = "导出定时任务日志 Excel") | 59 | @Operation(summary = "导出定时任务日志 Excel") |
| 72 | @PreAuthorize("@ss.hasPermission('infra:job:export')") | 60 | @PreAuthorize("@ss.hasPermission('infra:job:export')") |
| 73 | @OperateLog(type = EXPORT) | 61 | @OperateLog(type = EXPORT) |
| 74 | - public void exportJobLogExcel(@Valid JobLogExportReqVO exportReqVO, | 62 | + public void exportJobLogExcel(@Valid JobLogPageReqVO exportReqVO, |
| 75 | HttpServletResponse response) throws IOException { | 63 | HttpServletResponse response) throws IOException { |
| 76 | - List<JobLogDO> list = jobLogService.getJobLogList(exportReqVO); | 64 | + exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| 65 | + List<JobLogDO> list = jobLogService.getJobLogPage(exportReqVO).getList(); | ||
| 77 | // 导出 Excel | 66 | // 导出 Excel |
| 78 | - List<JobLogExcelVO> datas = JobLogConvert.INSTANCE.convertList02(list); | ||
| 79 | - ExcelUtils.write(response, "任务日志.xls", "数据", JobLogExcelVO.class, datas); | 67 | + ExcelUtils.write(response, "任务日志.xls", "数据", JobLogRespVO.class, |
| 68 | + BeanUtils.toBean(list, JobLogRespVO.class)); | ||
| 80 | } | 69 | } |
| 81 | 70 | ||
| 82 | -} | 71 | -} |
| 72 | +} | ||
| 83 | \ No newline at end of file | 73 | \ No newline at end of file |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/job/JobCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | -import lombok.ToString; | ||
| 7 | - | ||
| 8 | -import javax.validation.constraints.NotNull; | ||
| 9 | - | ||
| 10 | -@Schema(description = "管理后台 - 定时任务创建 Request VO") | ||
| 11 | -@Data | ||
| 12 | -@EqualsAndHashCode(callSuper = true) | ||
| 13 | -@ToString(callSuper = true) | ||
| 14 | -public class JobCreateReqVO extends JobBaseVO { | ||
| 15 | - | ||
| 16 | - @Schema(description = "处理器的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "sysUserSessionTimeoutJob") | ||
| 17 | - @NotNull(message = "处理器的名字不能为空") | ||
| 18 | - private String handlerName; | ||
| 19 | - | ||
| 20 | -} |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/job/JobExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||
| 4 | -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||
| 5 | -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; | ||
| 6 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 7 | -import lombok.Data; | ||
| 8 | - | ||
| 9 | -import java.time.LocalDateTime; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * 定时任务 Excel VO | ||
| 13 | - * | ||
| 14 | - * @author 芋道源码 | ||
| 15 | - */ | ||
| 16 | -@Data | ||
| 17 | -public class JobExcelVO { | ||
| 18 | - | ||
| 19 | - @ExcelProperty("任务编号") | ||
| 20 | - private Long id; | ||
| 21 | - | ||
| 22 | - @ExcelProperty("任务名称") | ||
| 23 | - private String name; | ||
| 24 | - | ||
| 25 | - @ExcelProperty(value = "任务状态", converter = DictConvert.class) | ||
| 26 | - @DictFormat(DictTypeConstants.JOB_STATUS) | ||
| 27 | - private Integer status; | ||
| 28 | - | ||
| 29 | - @ExcelProperty("处理器的名字") | ||
| 30 | - private String handlerName; | ||
| 31 | - | ||
| 32 | - @ExcelProperty("处理器的参数") | ||
| 33 | - private String handlerParam; | ||
| 34 | - | ||
| 35 | - @ExcelProperty("CRON 表达式") | ||
| 36 | - private String cronExpression; | ||
| 37 | - | ||
| 38 | - @ExcelProperty("最后一次执行的开始时间") | ||
| 39 | - private LocalDateTime executeBeginTime; | ||
| 40 | - | ||
| 41 | - @ExcelProperty("最后一次执行的结束时间") | ||
| 42 | - private LocalDateTime executeEndTime; | ||
| 43 | - | ||
| 44 | - @ExcelProperty("上一次触发时间") | ||
| 45 | - private LocalDateTime firePrevTime; | ||
| 46 | - | ||
| 47 | - @ExcelProperty("下一次触发时间") | ||
| 48 | - private LocalDateTime fireNextTime; | ||
| 49 | - | ||
| 50 | - @ExcelProperty("监控超时时间") | ||
| 51 | - private Integer monitorTimeout; | ||
| 52 | - | ||
| 53 | - @ExcelProperty("创建时间") | ||
| 54 | - private LocalDateTime createTime; | ||
| 55 | - | ||
| 56 | -} |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/job/JobExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | - | ||
| 6 | -@Schema(description = "管理后台 - 定时任务 Excel 导出 Request VO-参数和 JobPageReqVO 是一致的") | ||
| 7 | -@Data | ||
| 8 | -public class JobExportReqVO { | ||
| 9 | - | ||
| 10 | - @Schema(description = "任务名称-模糊匹配", example = "测试任务") | ||
| 11 | - private String name; | ||
| 12 | - | ||
| 13 | - @Schema(description = "任务状态-参见 JobStatusEnum 枚举", example = "1") | ||
| 14 | - private Integer status; | ||
| 15 | - | ||
| 16 | - @Schema(description = "处理器的名字-模糊匹配", example = "UserSessionTimeoutJob") | ||
| 17 | - private String handlerName; | ||
| 18 | - | ||
| 19 | -} |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/job/JobRespVO.java
| 1 | package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job; | 1 | package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||
| 4 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||
| 5 | +import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; | ||
| 6 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||
| 7 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 8 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 9 | import lombok.Data; |
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | -import lombok.ToString; | ||
| 7 | 10 | ||
| 8 | import javax.validation.constraints.NotNull; | 11 | import javax.validation.constraints.NotNull; |
| 9 | import java.time.LocalDateTime; | 12 | import java.time.LocalDateTime; |
| 10 | 13 | ||
| 11 | @Schema(description = "管理后台 - 定时任务 Response VO") | 14 | @Schema(description = "管理后台 - 定时任务 Response VO") |
| 12 | @Data | 15 | @Data |
| 13 | -@EqualsAndHashCode(callSuper = true) | ||
| 14 | -@ToString(callSuper = true) | ||
| 15 | -public class JobRespVO extends JobBaseVO { | 16 | +@ExcelIgnoreUnannotated |
| 17 | +public class JobRespVO { | ||
| 16 | 18 | ||
| 17 | @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 19 | @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 20 | + @ExcelProperty("任务编号") | ||
| 18 | private Long id; | 21 | private Long id; |
| 19 | 22 | ||
| 23 | + @Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试任务") | ||
| 24 | + @ExcelProperty("任务名称") | ||
| 25 | + private String name; | ||
| 26 | + | ||
| 20 | @Schema(description = "任务状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | 27 | @Schema(description = "任务状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 28 | + @ExcelProperty(value = "任务状态", converter = DictConvert.class) | ||
| 29 | + @DictFormat(DictTypeConstants.JOB_STATUS) | ||
| 21 | private Integer status; | 30 | private Integer status; |
| 22 | 31 | ||
| 23 | @Schema(description = "处理器的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "sysUserSessionTimeoutJob") | 32 | @Schema(description = "处理器的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "sysUserSessionTimeoutJob") |
| 24 | - @NotNull(message = "处理器的名字不能为空") | 33 | + @ExcelProperty("处理器的名字") |
| 25 | private String handlerName; | 34 | private String handlerName; |
| 26 | 35 | ||
| 36 | + @Schema(description = "处理器的参数", example = "yudao") | ||
| 37 | + @ExcelProperty("处理器的参数") | ||
| 38 | + private String handlerParam; | ||
| 39 | + | ||
| 40 | + @Schema(description = "CRON 表达式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0/10 * * * * ? *") | ||
| 41 | + @ExcelProperty("CRON 表达式") | ||
| 42 | + private String cronExpression; | ||
| 43 | + | ||
| 44 | + @Schema(description = "重试次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") | ||
| 45 | + @NotNull(message = "重试次数不能为空") | ||
| 46 | + private Integer retryCount; | ||
| 47 | + | ||
| 48 | + @Schema(description = "重试间隔", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") | ||
| 49 | + private Integer retryInterval; | ||
| 50 | + | ||
| 51 | + @Schema(description = "监控超时时间", example = "1000") | ||
| 52 | + @ExcelProperty("监控超时时间") | ||
| 53 | + private Integer monitorTimeout; | ||
| 54 | + | ||
| 27 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 55 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 56 | + @ExcelProperty("创建时间") | ||
| 28 | private LocalDateTime createTime; | 57 | private LocalDateTime createTime; |
| 29 | 58 | ||
| 30 | } | 59 | } |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/job/JobBaseVO.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/job/JobSaveReqVO.java
| @@ -3,24 +3,29 @@ package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job; | @@ -3,24 +3,29 @@ package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job; | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | 5 | ||
| 6 | +import javax.validation.constraints.NotEmpty; | ||
| 6 | import javax.validation.constraints.NotNull; | 7 | import javax.validation.constraints.NotNull; |
| 7 | 8 | ||
| 8 | -/** | ||
| 9 | -* 定时任务 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 10 | -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 11 | -*/ | 9 | +@Schema(description = "管理后台 - 定时任务创建/修改 Request VO") |
| 12 | @Data | 10 | @Data |
| 13 | -public class JobBaseVO { | 11 | +public class JobSaveReqVO { |
| 12 | + | ||
| 13 | + @Schema(description = "任务编号", example = "1024") | ||
| 14 | + private Long id; | ||
| 14 | 15 | ||
| 15 | @Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试任务") | 16 | @Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试任务") |
| 16 | - @NotNull(message = "任务名称不能为空") | 17 | + @NotEmpty(message = "任务名称不能为空") |
| 17 | private String name; | 18 | private String name; |
| 18 | 19 | ||
| 20 | + @Schema(description = "处理器的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "sysUserSessionTimeoutJob") | ||
| 21 | + @NotEmpty(message = "处理器的名字不能为空") | ||
| 22 | + private String handlerName; | ||
| 23 | + | ||
| 19 | @Schema(description = "处理器的参数", example = "yudao") | 24 | @Schema(description = "处理器的参数", example = "yudao") |
| 20 | private String handlerParam; | 25 | private String handlerParam; |
| 21 | 26 | ||
| 22 | @Schema(description = "CRON 表达式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0/10 * * * * ? *") | 27 | @Schema(description = "CRON 表达式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0/10 * * * * ? *") |
| 23 | - @NotNull(message = "CRON 表达式不能为空") | 28 | + @NotEmpty(message = "CRON 表达式不能为空") |
| 24 | private String cronExpression; | 29 | private String cronExpression; |
| 25 | 30 | ||
| 26 | @Schema(description = "重试次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") | 31 | @Schema(description = "重试次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "3") |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/job/JobUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | -import lombok.ToString; | ||
| 7 | - | ||
| 8 | -import javax.validation.constraints.NotNull; | ||
| 9 | - | ||
| 10 | -@Schema(description = "管理后台 - 定时任务更新 Request VO") | ||
| 11 | -@Data | ||
| 12 | -@EqualsAndHashCode(callSuper = true) | ||
| 13 | -@ToString(callSuper = true) | ||
| 14 | -public class JobUpdateReqVO extends JobBaseVO { | ||
| 15 | - | ||
| 16 | - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 17 | - @NotNull(message = "任务编号不能为空") | ||
| 18 | - private Long id; | ||
| 19 | - | ||
| 20 | -} |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/log/JobLogBaseVO.java deleted
| 1 | -package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 6 | - | ||
| 7 | -import javax.validation.constraints.NotNull; | ||
| 8 | -import java.time.LocalDateTime; | ||
| 9 | - | ||
| 10 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | -* 定时任务日志 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 14 | -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 15 | -*/ | ||
| 16 | -@Data | ||
| 17 | -public class JobLogBaseVO { | ||
| 18 | - | ||
| 19 | - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 20 | - @NotNull(message = "任务编号不能为空") | ||
| 21 | - private Long jobId; | ||
| 22 | - | ||
| 23 | - @Schema(description = "处理器的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "sysUserSessionTimeoutJob") | ||
| 24 | - @NotNull(message = "处理器的名字不能为空") | ||
| 25 | - private String handlerName; | ||
| 26 | - | ||
| 27 | - @Schema(description = "处理器的参数", example = "yudao") | ||
| 28 | - private String handlerParam; | ||
| 29 | - | ||
| 30 | - @Schema(description = "第几次执行", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 31 | - @NotNull(message = "第几次执行不能为空") | ||
| 32 | - private Integer executeIndex; | ||
| 33 | - | ||
| 34 | - @Schema(description = "开始执行时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 35 | - @NotNull(message = "开始执行时间不能为空") | ||
| 36 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 37 | - private LocalDateTime beginTime; | ||
| 38 | - | ||
| 39 | - @Schema(description = "结束执行时间") | ||
| 40 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 41 | - private LocalDateTime endTime; | ||
| 42 | - | ||
| 43 | - @Schema(description = "执行时长", example = "123") | ||
| 44 | - private Integer duration; | ||
| 45 | - | ||
| 46 | - @Schema(description = "任务状态,参见 JobLogStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 47 | - @NotNull(message = "任务状态不能为空") | ||
| 48 | - private Integer status; | ||
| 49 | - | ||
| 50 | - @Schema(description = "结果数据", example = "执行成功") | ||
| 51 | - private String result; | ||
| 52 | - | ||
| 53 | -} |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/log/JobLogExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||
| 4 | -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||
| 5 | -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; | ||
| 6 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 7 | -import lombok.Data; | ||
| 8 | - | ||
| 9 | -import java.time.LocalDateTime; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * 定时任务 Excel VO | ||
| 13 | - * | ||
| 14 | - * @author 芋艿 | ||
| 15 | - */ | ||
| 16 | -@Data | ||
| 17 | -public class JobLogExcelVO { | ||
| 18 | - | ||
| 19 | - @ExcelProperty("日志编号") | ||
| 20 | - private Long id; | ||
| 21 | - | ||
| 22 | - @ExcelProperty("任务编号") | ||
| 23 | - private Long jobId; | ||
| 24 | - | ||
| 25 | - @ExcelProperty("处理器的名字") | ||
| 26 | - private String handlerName; | ||
| 27 | - | ||
| 28 | - @ExcelProperty("处理器的参数") | ||
| 29 | - private String handlerParam; | ||
| 30 | - | ||
| 31 | - @ExcelProperty("第几次执行") | ||
| 32 | - private Integer executeIndex; | ||
| 33 | - | ||
| 34 | - @ExcelProperty("开始执行时间") | ||
| 35 | - private LocalDateTime beginTime; | ||
| 36 | - | ||
| 37 | - @ExcelProperty("结束执行时间") | ||
| 38 | - private LocalDateTime endTime; | ||
| 39 | - | ||
| 40 | - @ExcelProperty("执行时长") | ||
| 41 | - private Integer duration; | ||
| 42 | - | ||
| 43 | - @ExcelProperty(value = "任务状态", converter = DictConvert.class) | ||
| 44 | - @DictFormat(DictTypeConstants.JOB_STATUS) | ||
| 45 | - private Integer status; | ||
| 46 | - | ||
| 47 | - @ExcelProperty("结果数据") | ||
| 48 | - private String result; | ||
| 49 | - | ||
| 50 | - @ExcelProperty("创建时间") | ||
| 51 | - private LocalDateTime createTime; | ||
| 52 | - | ||
| 53 | -} |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/log/JobLogExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 6 | - | ||
| 7 | -import java.time.LocalDateTime; | ||
| 8 | - | ||
| 9 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 10 | - | ||
| 11 | -@Schema(description = "管理后台 - 定时任务 Excel 导出 Request VO,参数和 JobLogPageReqVO 是一致的") | ||
| 12 | -@Data | ||
| 13 | -public class JobLogExportReqVO { | ||
| 14 | - | ||
| 15 | - @Schema(description = "任务编号", example = "10") | ||
| 16 | - private Long jobId; | ||
| 17 | - | ||
| 18 | - @Schema(description = "处理器的名字,模糊匹配") | ||
| 19 | - private String handlerName; | ||
| 20 | - | ||
| 21 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 22 | - @Schema(description = "开始执行时间") | ||
| 23 | - private LocalDateTime beginTime; | ||
| 24 | - | ||
| 25 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 26 | - @Schema(description = "结束执行时间") | ||
| 27 | - private LocalDateTime endTime; | ||
| 28 | - | ||
| 29 | - @Schema(description = "任务状态,参见 JobLogStatusEnum 枚举") | ||
| 30 | - private Integer status; | ||
| 31 | - | ||
| 32 | -} |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/log/JobLogRespVO.java
| 1 | package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log; | 1 | package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||
| 4 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||
| 5 | +import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; | ||
| 6 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||
| 7 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 8 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 9 | import lombok.Data; |
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | -import lombok.ToString; | ||
| 7 | 10 | ||
| 8 | import java.time.LocalDateTime; | 11 | import java.time.LocalDateTime; |
| 9 | 12 | ||
| 10 | @Schema(description = "管理后台 - 定时任务日志 Response VO") | 13 | @Schema(description = "管理后台 - 定时任务日志 Response VO") |
| 11 | @Data | 14 | @Data |
| 12 | -@EqualsAndHashCode(callSuper = true) | ||
| 13 | -@ToString(callSuper = true) | ||
| 14 | -public class JobLogRespVO extends JobLogBaseVO { | 15 | +@ExcelIgnoreUnannotated |
| 16 | +public class JobLogRespVO { | ||
| 15 | 17 | ||
| 16 | @Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 18 | @Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 19 | + @ExcelProperty("日志编号") | ||
| 17 | private Long id; | 20 | private Long id; |
| 18 | 21 | ||
| 22 | + @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 23 | + @ExcelProperty("任务编号") | ||
| 24 | + private Long jobId; | ||
| 25 | + | ||
| 26 | + @Schema(description = "处理器的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "sysUserSessionTimeoutJob") | ||
| 27 | + @ExcelProperty("处理器的名字") | ||
| 28 | + private String handlerName; | ||
| 29 | + | ||
| 30 | + @Schema(description = "处理器的参数", example = "yudao") | ||
| 31 | + @ExcelProperty("处理器的参数") | ||
| 32 | + private String handlerParam; | ||
| 33 | + | ||
| 34 | + @Schema(description = "第几次执行", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 35 | + @ExcelProperty("第几次执行") | ||
| 36 | + private Integer executeIndex; | ||
| 37 | + | ||
| 38 | + @Schema(description = "开始执行时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 39 | + @ExcelProperty("开始执行时间") | ||
| 40 | + private LocalDateTime beginTime; | ||
| 41 | + | ||
| 42 | + @Schema(description = "结束执行时间") | ||
| 43 | + @ExcelProperty("结束执行时间") | ||
| 44 | + private LocalDateTime endTime; | ||
| 45 | + | ||
| 46 | + @Schema(description = "执行时长", example = "123") | ||
| 47 | + @ExcelProperty("执行时长") | ||
| 48 | + private Integer duration; | ||
| 49 | + | ||
| 50 | + @Schema(description = "任务状态,参见 JobLogStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 51 | + @ExcelProperty(value = "任务状态", converter = DictConvert.class) | ||
| 52 | + @DictFormat(DictTypeConstants.JOB_STATUS) | ||
| 53 | + private Integer status; | ||
| 54 | + | ||
| 55 | + @Schema(description = "结果数据", example = "执行成功") | ||
| 56 | + @ExcelProperty("结果数据") | ||
| 57 | + private String result; | ||
| 58 | + | ||
| 19 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 59 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 60 | + @ExcelProperty("创建时间") | ||
| 20 | private LocalDateTime createTime; | 61 | private LocalDateTime createTime; |
| 21 | 62 | ||
| 22 | } | 63 | } |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/job/JobConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.infra.convert.job; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobCreateReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobExcelVO; | ||
| 6 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobRespVO; | ||
| 7 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobUpdateReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO; | ||
| 9 | -import org.mapstruct.Mapper; | ||
| 10 | -import org.mapstruct.factory.Mappers; | ||
| 11 | - | ||
| 12 | -import java.util.List; | ||
| 13 | - | ||
| 14 | -/** | ||
| 15 | - * 定时任务 Convert | ||
| 16 | - * | ||
| 17 | - * @author 芋道源码 | ||
| 18 | - */ | ||
| 19 | -@Mapper | ||
| 20 | -public interface JobConvert { | ||
| 21 | - | ||
| 22 | - JobConvert INSTANCE = Mappers.getMapper(JobConvert.class); | ||
| 23 | - | ||
| 24 | - JobDO convert(JobCreateReqVO bean); | ||
| 25 | - | ||
| 26 | - JobDO convert(JobUpdateReqVO bean); | ||
| 27 | - | ||
| 28 | - JobRespVO convert(JobDO bean); | ||
| 29 | - | ||
| 30 | - List<JobRespVO> convertList(List<JobDO> list); | ||
| 31 | - | ||
| 32 | - PageResult<JobRespVO> convertPage(PageResult<JobDO> page); | ||
| 33 | - | ||
| 34 | - List<JobExcelVO> convertList02(List<JobDO> list); | ||
| 35 | - | ||
| 36 | -} |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/job/JobLogConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.infra.convert.job; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExcelVO; | ||
| 5 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogRespVO; | ||
| 6 | -import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; | ||
| 7 | -import org.mapstruct.Mapper; | ||
| 8 | -import org.mapstruct.factory.Mappers; | ||
| 9 | - | ||
| 10 | -import java.util.List; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * 定时任务日志 Convert | ||
| 14 | - * | ||
| 15 | - * @author 芋艿 | ||
| 16 | - */ | ||
| 17 | -@Mapper | ||
| 18 | -public interface JobLogConvert { | ||
| 19 | - | ||
| 20 | - JobLogConvert INSTANCE = Mappers.getMapper(JobLogConvert.class); | ||
| 21 | - | ||
| 22 | - JobLogRespVO convert(JobLogDO bean); | ||
| 23 | - | ||
| 24 | - List<JobLogRespVO> convertList(List<JobLogDO> list); | ||
| 25 | - | ||
| 26 | - PageResult<JobLogRespVO> convertPage(PageResult<JobLogDO> page); | ||
| 27 | - | ||
| 28 | - List<JobLogExcelVO> convertList02(List<JobLogDO> list); | ||
| 29 | - | ||
| 30 | -} |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/job/JobLogMapper.java
| @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.infra.dal.mysql.job; | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.infra.dal.mysql.job; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO; | ||
| 7 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; | 6 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; |
| 8 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; | 7 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; |
| 9 | import org.apache.ibatis.annotations.Delete; | 8 | import org.apache.ibatis.annotations.Delete; |
| @@ -11,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper; | @@ -11,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 11 | import org.apache.ibatis.annotations.Param; | 10 | import org.apache.ibatis.annotations.Param; |
| 12 | 11 | ||
| 13 | import java.time.LocalDateTime; | 12 | import java.time.LocalDateTime; |
| 14 | -import java.util.List; | ||
| 15 | 13 | ||
| 16 | /** | 14 | /** |
| 17 | * 任务日志 Mapper | 15 | * 任务日志 Mapper |
| @@ -32,17 +30,6 @@ public interface JobLogMapper extends BaseMapperX<JobLogDO> { | @@ -32,17 +30,6 @@ public interface JobLogMapper extends BaseMapperX<JobLogDO> { | ||
| 32 | ); | 30 | ); |
| 33 | } | 31 | } |
| 34 | 32 | ||
| 35 | - default List<JobLogDO> selectList(JobLogExportReqVO reqVO) { | ||
| 36 | - return selectList(new LambdaQueryWrapperX<JobLogDO>() | ||
| 37 | - .eqIfPresent(JobLogDO::getJobId, reqVO.getJobId()) | ||
| 38 | - .likeIfPresent(JobLogDO::getHandlerName, reqVO.getHandlerName()) | ||
| 39 | - .geIfPresent(JobLogDO::getBeginTime, reqVO.getBeginTime()) | ||
| 40 | - .leIfPresent(JobLogDO::getEndTime, reqVO.getEndTime()) | ||
| 41 | - .eqIfPresent(JobLogDO::getStatus, reqVO.getStatus()) | ||
| 42 | - .orderByDesc(JobLogDO::getId) // ID 倒序 | ||
| 43 | - ); | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | /** | 33 | /** |
| 47 | * 物理删除指定时间之前的日志 | 34 | * 物理删除指定时间之前的日志 |
| 48 | * | 35 | * |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/job/JobMapper.java
| 1 | package cn.iocoder.yudao.module.infra.dal.mysql.job; | 1 | package cn.iocoder.yudao.module.infra.dal.mysql.job; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobExportReqVO; | ||
| 4 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO; | ||
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 8 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | +import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO; | ||
| 9 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 9 | ||
| 11 | -import java.util.List; | ||
| 12 | - | ||
| 13 | /** | 10 | /** |
| 14 | * 定时任务 Mapper | 11 | * 定时任务 Mapper |
| 15 | * | 12 | * |
| @@ -30,12 +27,4 @@ public interface JobMapper extends BaseMapperX<JobDO> { | @@ -30,12 +27,4 @@ public interface JobMapper extends BaseMapperX<JobDO> { | ||
| 30 | ); | 27 | ); |
| 31 | } | 28 | } |
| 32 | 29 | ||
| 33 | - default List<JobDO> selectList(JobExportReqVO reqVO) { | ||
| 34 | - return selectList(new LambdaQueryWrapperX<JobDO>() | ||
| 35 | - .likeIfPresent(JobDO::getName, reqVO.getName()) | ||
| 36 | - .eqIfPresent(JobDO::getStatus, reqVO.getStatus()) | ||
| 37 | - .likeIfPresent(JobDO::getHandlerName, reqVO.getHandlerName()) | ||
| 38 | - ); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | } | 30 | } |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobLogService.java
| @@ -2,13 +2,9 @@ package cn.iocoder.yudao.module.infra.service.job; | @@ -2,13 +2,9 @@ package cn.iocoder.yudao.module.infra.service.job; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.quartz.core.service.JobLogFrameworkService; | 4 | import cn.iocoder.yudao.framework.quartz.core.service.JobLogFrameworkService; |
| 5 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO; | ||
| 6 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; | 5 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; |
| 7 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; | 6 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; |
| 8 | 7 | ||
| 9 | -import java.util.Collection; | ||
| 10 | -import java.util.List; | ||
| 11 | - | ||
| 12 | /** | 8 | /** |
| 13 | * Job 日志 Service 接口 | 9 | * Job 日志 Service 接口 |
| 14 | * | 10 | * |
| @@ -25,14 +21,6 @@ public interface JobLogService extends JobLogFrameworkService { | @@ -25,14 +21,6 @@ public interface JobLogService extends JobLogFrameworkService { | ||
| 25 | JobLogDO getJobLog(Long id); | 21 | JobLogDO getJobLog(Long id); |
| 26 | 22 | ||
| 27 | /** | 23 | /** |
| 28 | - * 获得定时任务列表 | ||
| 29 | - * | ||
| 30 | - * @param ids 编号 | ||
| 31 | - * @return 定时任务列表 | ||
| 32 | - */ | ||
| 33 | - List<JobLogDO> getJobLogList(Collection<Long> ids); | ||
| 34 | - | ||
| 35 | - /** | ||
| 36 | * 获得定时任务分页 | 24 | * 获得定时任务分页 |
| 37 | * | 25 | * |
| 38 | * @param pageReqVO 分页查询 | 26 | * @param pageReqVO 分页查询 |
| @@ -41,14 +29,6 @@ public interface JobLogService extends JobLogFrameworkService { | @@ -41,14 +29,6 @@ public interface JobLogService extends JobLogFrameworkService { | ||
| 41 | PageResult<JobLogDO> getJobLogPage(JobLogPageReqVO pageReqVO); | 29 | PageResult<JobLogDO> getJobLogPage(JobLogPageReqVO pageReqVO); |
| 42 | 30 | ||
| 43 | /** | 31 | /** |
| 44 | - * 获得定时任务列表, 用于 Excel 导出 | ||
| 45 | - * | ||
| 46 | - * @param exportReqVO 查询条件 | ||
| 47 | - * @return 定时任务分页 | ||
| 48 | - */ | ||
| 49 | - List<JobLogDO> getJobLogList(JobLogExportReqVO exportReqVO); | ||
| 50 | - | ||
| 51 | - /** | ||
| 52 | * 清理 exceedDay 天前的任务日志 | 32 | * 清理 exceedDay 天前的任务日志 |
| 53 | * | 33 | * |
| 54 | * @param exceedDay 超过多少天就进行清理 | 34 | * @param exceedDay 超过多少天就进行清理 |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImpl.java
| 1 | package cn.iocoder.yudao.module.infra.service.job; | 1 | package cn.iocoder.yudao.module.infra.service.job; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO; | ||
| 5 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; | 4 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; |
| 6 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; | 5 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; |
| 7 | import cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper; | 6 | import cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper; |
| @@ -13,8 +12,6 @@ import org.springframework.validation.annotation.Validated; | @@ -13,8 +12,6 @@ import org.springframework.validation.annotation.Validated; | ||
| 13 | 12 | ||
| 14 | import javax.annotation.Resource; | 13 | import javax.annotation.Resource; |
| 15 | import java.time.LocalDateTime; | 14 | import java.time.LocalDateTime; |
| 16 | -import java.util.Collection; | ||
| 17 | -import java.util.List; | ||
| 18 | 15 | ||
| 19 | /** | 16 | /** |
| 20 | * Job 日志 Service 实现类 | 17 | * Job 日志 Service 实现类 |
| @@ -30,8 +27,10 @@ public class JobLogServiceImpl implements JobLogService { | @@ -30,8 +27,10 @@ public class JobLogServiceImpl implements JobLogService { | ||
| 30 | private JobLogMapper jobLogMapper; | 27 | private JobLogMapper jobLogMapper; |
| 31 | 28 | ||
| 32 | @Override | 29 | @Override |
| 33 | - public Long createJobLog(Long jobId, LocalDateTime beginTime, String jobHandlerName, String jobHandlerParam, Integer executeIndex) { | ||
| 34 | - JobLogDO log = JobLogDO.builder().jobId(jobId).handlerName(jobHandlerName).handlerParam(jobHandlerParam).executeIndex(executeIndex) | 30 | + public Long createJobLog(Long jobId, LocalDateTime beginTime, |
| 31 | + String jobHandlerName, String jobHandlerParam, Integer executeIndex) { | ||
| 32 | + JobLogDO log = JobLogDO.builder().jobId(jobId).handlerName(jobHandlerName) | ||
| 33 | + .handlerParam(jobHandlerParam).executeIndex(executeIndex) | ||
| 35 | .beginTime(beginTime).status(JobLogStatusEnum.RUNNING.getStatus()).build(); | 34 | .beginTime(beginTime).status(JobLogStatusEnum.RUNNING.getStatus()).build(); |
| 36 | jobLogMapper.insert(log); | 35 | jobLogMapper.insert(log); |
| 37 | return log.getId(); | 36 | return log.getId(); |
| @@ -42,7 +41,8 @@ public class JobLogServiceImpl implements JobLogService { | @@ -42,7 +41,8 @@ public class JobLogServiceImpl implements JobLogService { | ||
| 42 | public void updateJobLogResultAsync(Long logId, LocalDateTime endTime, Integer duration, boolean success, String result) { | 41 | public void updateJobLogResultAsync(Long logId, LocalDateTime endTime, Integer duration, boolean success, String result) { |
| 43 | try { | 42 | try { |
| 44 | JobLogDO updateObj = JobLogDO.builder().id(logId).endTime(endTime).duration(duration) | 43 | JobLogDO updateObj = JobLogDO.builder().id(logId).endTime(endTime).duration(duration) |
| 45 | - .status(success ? JobLogStatusEnum.SUCCESS.getStatus() : JobLogStatusEnum.FAILURE.getStatus()).result(result).build(); | 44 | + .status(success ? JobLogStatusEnum.SUCCESS.getStatus() : JobLogStatusEnum.FAILURE.getStatus()) |
| 45 | + .result(result).build(); | ||
| 46 | jobLogMapper.updateById(updateObj); | 46 | jobLogMapper.updateById(updateObj); |
| 47 | } catch (Exception ex) { | 47 | } catch (Exception ex) { |
| 48 | log.error("[updateJobLogResultAsync][logId({}) endTime({}) duration({}) success({}) result({})]", | 48 | log.error("[updateJobLogResultAsync][logId({}) endTime({}) duration({}) success({}) result({})]", |
| @@ -73,18 +73,8 @@ public class JobLogServiceImpl implements JobLogService { | @@ -73,18 +73,8 @@ public class JobLogServiceImpl implements JobLogService { | ||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | @Override | 75 | @Override |
| 76 | - public List<JobLogDO> getJobLogList(Collection<Long> ids) { | ||
| 77 | - return jobLogMapper.selectBatchIds(ids); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - @Override | ||
| 81 | public PageResult<JobLogDO> getJobLogPage(JobLogPageReqVO pageReqVO) { | 76 | public PageResult<JobLogDO> getJobLogPage(JobLogPageReqVO pageReqVO) { |
| 82 | return jobLogMapper.selectPage(pageReqVO); | 77 | return jobLogMapper.selectPage(pageReqVO); |
| 83 | } | 78 | } |
| 84 | 79 | ||
| 85 | - @Override | ||
| 86 | - public List<JobLogDO> getJobLogList(JobLogExportReqVO exportReqVO) { | ||
| 87 | - return jobLogMapper.selectList(exportReqVO); | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | } | 80 | } |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobService.java
| 1 | package cn.iocoder.yudao.module.infra.service.job; | 1 | package cn.iocoder.yudao.module.infra.service.job; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobCreateReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobExportReqVO; | ||
| 6 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO; | 4 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO; |
| 7 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobUpdateReqVO; | 5 | +import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobSaveReqVO; |
| 8 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO; | 6 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO; |
| 9 | import org.quartz.SchedulerException; | 7 | import org.quartz.SchedulerException; |
| 10 | 8 | ||
| @@ -25,14 +23,14 @@ public interface JobService { | @@ -25,14 +23,14 @@ public interface JobService { | ||
| 25 | * @param createReqVO 创建信息 | 23 | * @param createReqVO 创建信息 |
| 26 | * @return 编号 | 24 | * @return 编号 |
| 27 | */ | 25 | */ |
| 28 | - Long createJob(@Valid JobCreateReqVO createReqVO) throws SchedulerException; | 26 | + Long createJob(@Valid JobSaveReqVO createReqVO) throws SchedulerException; |
| 29 | 27 | ||
| 30 | /** | 28 | /** |
| 31 | * 更新定时任务 | 29 | * 更新定时任务 |
| 32 | * | 30 | * |
| 33 | * @param updateReqVO 更新信息 | 31 | * @param updateReqVO 更新信息 |
| 34 | */ | 32 | */ |
| 35 | - void updateJob(@Valid JobUpdateReqVO updateReqVO) throws SchedulerException; | 33 | + void updateJob(@Valid JobSaveReqVO updateReqVO) throws SchedulerException; |
| 36 | 34 | ||
| 37 | /** | 35 | /** |
| 38 | * 更新定时任务的状态 | 36 | * 更新定时任务的状态 |
| @@ -80,12 +78,4 @@ public interface JobService { | @@ -80,12 +78,4 @@ public interface JobService { | ||
| 80 | */ | 78 | */ |
| 81 | PageResult<JobDO> getJobPage(JobPageReqVO pageReqVO); | 79 | PageResult<JobDO> getJobPage(JobPageReqVO pageReqVO); |
| 82 | 80 | ||
| 83 | - /** | ||
| 84 | - * 获得定时任务列表, 用于 Excel 导出 | ||
| 85 | - * | ||
| 86 | - * @param exportReqVO 查询条件 | ||
| 87 | - * @return 定时任务分页 | ||
| 88 | - */ | ||
| 89 | - List<JobDO> getJobList(JobExportReqVO exportReqVO); | ||
| 90 | - | ||
| 91 | } | 81 | } |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobServiceImpl.java
| 1 | package cn.iocoder.yudao.module.infra.service.job; | 1 | package cn.iocoder.yudao.module.infra.service.job; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 4 | import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; | 5 | import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; |
| 5 | import cn.iocoder.yudao.framework.quartz.core.util.CronUtils; | 6 | import cn.iocoder.yudao.framework.quartz.core.util.CronUtils; |
| 6 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobCreateReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobExportReqVO; | ||
| 8 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO; | 7 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO; |
| 9 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobUpdateReqVO; | ||
| 10 | -import cn.iocoder.yudao.module.infra.convert.job.JobConvert; | 8 | +import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobSaveReqVO; |
| 11 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO; | 9 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO; |
| 12 | import cn.iocoder.yudao.module.infra.dal.mysql.job.JobMapper; | 10 | import cn.iocoder.yudao.module.infra.dal.mysql.job.JobMapper; |
| 13 | import cn.iocoder.yudao.module.infra.enums.job.JobStatusEnum; | 11 | import cn.iocoder.yudao.module.infra.enums.job.JobStatusEnum; |
| @@ -21,8 +19,8 @@ import java.util.Collection; | @@ -21,8 +19,8 @@ import java.util.Collection; | ||
| 21 | import java.util.List; | 19 | import java.util.List; |
| 22 | 20 | ||
| 23 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 21 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 24 | -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; | ||
| 25 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.containsAny; | 22 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.containsAny; |
| 23 | +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; | ||
| 26 | 24 | ||
| 27 | /** | 25 | /** |
| 28 | * 定时任务 Service 实现类 | 26 | * 定时任务 Service 实现类 |
| @@ -41,14 +39,14 @@ public class JobServiceImpl implements JobService { | @@ -41,14 +39,14 @@ public class JobServiceImpl implements JobService { | ||
| 41 | 39 | ||
| 42 | @Override | 40 | @Override |
| 43 | @Transactional(rollbackFor = Exception.class) | 41 | @Transactional(rollbackFor = Exception.class) |
| 44 | - public Long createJob(JobCreateReqVO createReqVO) throws SchedulerException { | 42 | + public Long createJob(JobSaveReqVO createReqVO) throws SchedulerException { |
| 45 | validateCronExpression(createReqVO.getCronExpression()); | 43 | validateCronExpression(createReqVO.getCronExpression()); |
| 46 | // 校验唯一性 | 44 | // 校验唯一性 |
| 47 | if (jobMapper.selectByHandlerName(createReqVO.getHandlerName()) != null) { | 45 | if (jobMapper.selectByHandlerName(createReqVO.getHandlerName()) != null) { |
| 48 | throw exception(JOB_HANDLER_EXISTS); | 46 | throw exception(JOB_HANDLER_EXISTS); |
| 49 | } | 47 | } |
| 50 | // 插入 | 48 | // 插入 |
| 51 | - JobDO job = JobConvert.INSTANCE.convert(createReqVO); | 49 | + JobDO job = BeanUtils.toBean(createReqVO, JobDO.class); |
| 52 | job.setStatus(JobStatusEnum.INIT.getStatus()); | 50 | job.setStatus(JobStatusEnum.INIT.getStatus()); |
| 53 | fillJobMonitorTimeoutEmpty(job); | 51 | fillJobMonitorTimeoutEmpty(job); |
| 54 | jobMapper.insert(job); | 52 | jobMapper.insert(job); |
| @@ -66,7 +64,7 @@ public class JobServiceImpl implements JobService { | @@ -66,7 +64,7 @@ public class JobServiceImpl implements JobService { | ||
| 66 | 64 | ||
| 67 | @Override | 65 | @Override |
| 68 | @Transactional(rollbackFor = Exception.class) | 66 | @Transactional(rollbackFor = Exception.class) |
| 69 | - public void updateJob(JobUpdateReqVO updateReqVO) throws SchedulerException { | 67 | + public void updateJob(JobSaveReqVO updateReqVO) throws SchedulerException { |
| 70 | validateCronExpression(updateReqVO.getCronExpression()); | 68 | validateCronExpression(updateReqVO.getCronExpression()); |
| 71 | // 校验存在 | 69 | // 校验存在 |
| 72 | JobDO job = validateJobExists(updateReqVO.getId()); | 70 | JobDO job = validateJobExists(updateReqVO.getId()); |
| @@ -75,7 +73,7 @@ public class JobServiceImpl implements JobService { | @@ -75,7 +73,7 @@ public class JobServiceImpl implements JobService { | ||
| 75 | throw exception(JOB_UPDATE_ONLY_NORMAL_STATUS); | 73 | throw exception(JOB_UPDATE_ONLY_NORMAL_STATUS); |
| 76 | } | 74 | } |
| 77 | // 更新 | 75 | // 更新 |
| 78 | - JobDO updateObj = JobConvert.INSTANCE.convert(updateReqVO); | 76 | + JobDO updateObj = BeanUtils.toBean(updateReqVO, JobDO.class); |
| 79 | fillJobMonitorTimeoutEmpty(updateObj); | 77 | fillJobMonitorTimeoutEmpty(updateObj); |
| 80 | jobMapper.updateById(updateObj); | 78 | jobMapper.updateById(updateObj); |
| 81 | 79 | ||
| @@ -159,11 +157,6 @@ public class JobServiceImpl implements JobService { | @@ -159,11 +157,6 @@ public class JobServiceImpl implements JobService { | ||
| 159 | return jobMapper.selectPage(pageReqVO); | 157 | return jobMapper.selectPage(pageReqVO); |
| 160 | } | 158 | } |
| 161 | 159 | ||
| 162 | - @Override | ||
| 163 | - public List<JobDO> getJobList(JobExportReqVO exportReqVO) { | ||
| 164 | - return jobMapper.selectList(exportReqVO); | ||
| 165 | - } | ||
| 166 | - | ||
| 167 | private static void fillJobMonitorTimeoutEmpty(JobDO job) { | 160 | private static void fillJobMonitorTimeoutEmpty(JobDO job) { |
| 168 | if (job.getMonitorTimeout() == null) { | 161 | if (job.getMonitorTimeout() == null) { |
| 169 | job.setMonitorTimeout(0); | 162 | job.setMonitorTimeout(0); |
yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImplTest.java
| @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.infra.service.job; | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.infra.service.job; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 5 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO; | ||
| 6 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; | 5 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO; |
| 7 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; | 6 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO; |
| 8 | import cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper; | 7 | import cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper; |
| @@ -12,14 +11,11 @@ import org.springframework.context.annotation.Import; | @@ -12,14 +11,11 @@ import org.springframework.context.annotation.Import; | ||
| 12 | 11 | ||
| 13 | import javax.annotation.Resource; | 12 | import javax.annotation.Resource; |
| 14 | import java.time.LocalDateTime; | 13 | import java.time.LocalDateTime; |
| 15 | -import java.util.Collection; | ||
| 16 | -import java.util.List; | ||
| 17 | 14 | ||
| 18 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; | 15 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; |
| 19 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | 16 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; |
| 20 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | 17 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 21 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | 18 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; |
| 22 | -import static java.util.Collections.singleton; | ||
| 23 | import static org.junit.jupiter.api.Assertions.assertEquals; | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 24 | import static org.junit.jupiter.api.Assertions.assertNotNull; | 20 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 25 | 21 | ||
| @@ -111,23 +107,6 @@ public class JobLogServiceImplTest extends BaseDbUnitTest { | @@ -111,23 +107,6 @@ public class JobLogServiceImplTest extends BaseDbUnitTest { | ||
| 111 | } | 107 | } |
| 112 | 108 | ||
| 113 | @Test | 109 | @Test |
| 114 | - public void testGetJobLogList() { | ||
| 115 | - // mock 数据 | ||
| 116 | - JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> o.setExecuteIndex(1)); | ||
| 117 | - jobLogMapper.insert(dbJobLog); | ||
| 118 | - // 测试 handlerName 不匹配 | ||
| 119 | - jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> {})); | ||
| 120 | - // 准备参数 | ||
| 121 | - Collection<Long> ids = singleton(dbJobLog.getId()); | ||
| 122 | - | ||
| 123 | - // 调用 | ||
| 124 | - List<JobLogDO> list = jobLogService.getJobLogList(ids); | ||
| 125 | - // 断言 | ||
| 126 | - assertEquals(1, list.size()); | ||
| 127 | - assertPojoEquals(dbJobLog, list.get(0)); | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | - @Test | ||
| 131 | public void testGetJobPage() { | 110 | public void testGetJobPage() { |
| 132 | // mock 数据 | 111 | // mock 数据 |
| 133 | JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> { | 112 | JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> { |
| @@ -164,40 +143,4 @@ public class JobLogServiceImplTest extends BaseDbUnitTest { | @@ -164,40 +143,4 @@ public class JobLogServiceImplTest extends BaseDbUnitTest { | ||
| 164 | assertPojoEquals(dbJobLog, pageResult.getList().get(0)); | 143 | assertPojoEquals(dbJobLog, pageResult.getList().get(0)); |
| 165 | } | 144 | } |
| 166 | 145 | ||
| 167 | - @Test | ||
| 168 | - public void testGetJobList_export() { | ||
| 169 | - // mock 数据 | ||
| 170 | - JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> { | ||
| 171 | - o.setExecuteIndex(1); | ||
| 172 | - o.setHandlerName("handlerName 单元测试"); | ||
| 173 | - o.setStatus(JobLogStatusEnum.SUCCESS.getStatus()); | ||
| 174 | - o.setBeginTime(buildTime(2021, 1, 8)); | ||
| 175 | - o.setEndTime(buildTime(2021, 1, 8)); | ||
| 176 | - }); | ||
| 177 | - jobLogMapper.insert(dbJobLog); | ||
| 178 | - // 测试 jobId 不匹配 | ||
| 179 | - jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setJobId(randomLongId()))); | ||
| 180 | - // 测试 handlerName 不匹配 | ||
| 181 | - jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setHandlerName(randomString()))); | ||
| 182 | - // 测试 beginTime 不匹配 | ||
| 183 | - jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setBeginTime(buildTime(2021, 1, 7)))); | ||
| 184 | - // 测试 endTime 不匹配 | ||
| 185 | - jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setEndTime(buildTime(2021, 1, 9)))); | ||
| 186 | - // 测试 status 不匹配 | ||
| 187 | - jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setStatus(JobLogStatusEnum.FAILURE.getStatus()))); | ||
| 188 | - // 准备参数 | ||
| 189 | - JobLogExportReqVO reqVo = new JobLogExportReqVO(); | ||
| 190 | - reqVo.setJobId(dbJobLog.getJobId()); | ||
| 191 | - reqVo.setHandlerName("单元"); | ||
| 192 | - reqVo.setBeginTime(dbJobLog.getBeginTime()); | ||
| 193 | - reqVo.setEndTime(dbJobLog.getEndTime()); | ||
| 194 | - reqVo.setStatus(JobLogStatusEnum.SUCCESS.getStatus()); | ||
| 195 | - | ||
| 196 | - // 调用 | ||
| 197 | - List<JobLogDO> list = jobLogService.getJobLogList(reqVo); | ||
| 198 | - // 断言 | ||
| 199 | - assertEquals(1, list.size()); | ||
| 200 | - assertPojoEquals(dbJobLog, list.get(0)); | ||
| 201 | - } | ||
| 202 | - | ||
| 203 | } | 146 | } |
yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobServiceImplTest.java
| @@ -3,10 +3,8 @@ package cn.iocoder.yudao.module.infra.service.job; | @@ -3,10 +3,8 @@ package cn.iocoder.yudao.module.infra.service.job; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; | 4 | import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; |
| 5 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | 5 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 6 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobCreateReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobExportReqVO; | ||
| 8 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO; | 6 | import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO; |
| 9 | -import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobUpdateReqVO; | 7 | +import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobSaveReqVO; |
| 10 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO; | 8 | import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO; |
| 11 | import cn.iocoder.yudao.module.infra.dal.mysql.job.JobMapper; | 9 | import cn.iocoder.yudao.module.infra.dal.mysql.job.JobMapper; |
| 12 | import cn.iocoder.yudao.module.infra.enums.job.JobStatusEnum; | 10 | import cn.iocoder.yudao.module.infra.enums.job.JobStatusEnum; |
| @@ -16,17 +14,13 @@ import org.springframework.boot.test.mock.mockito.MockBean; | @@ -16,17 +14,13 @@ import org.springframework.boot.test.mock.mockito.MockBean; | ||
| 16 | import org.springframework.context.annotation.Import; | 14 | import org.springframework.context.annotation.Import; |
| 17 | 15 | ||
| 18 | import javax.annotation.Resource; | 16 | import javax.annotation.Resource; |
| 19 | -import java.util.Collection; | ||
| 20 | -import java.util.List; | ||
| 21 | 17 | ||
| 22 | -import static cn.hutool.core.util.RandomUtil.randomEle; | ||
| 23 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | 18 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; |
| 24 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | 19 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 25 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | 20 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; |
| 26 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | 21 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; |
| 27 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; | 22 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; |
| 28 | import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; | 23 | import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; |
| 29 | -import static java.util.Collections.singletonList; | ||
| 30 | import static org.junit.jupiter.api.Assertions.*; | 24 | import static org.junit.jupiter.api.Assertions.*; |
| 31 | import static org.mockito.ArgumentMatchers.eq; | 25 | import static org.mockito.ArgumentMatchers.eq; |
| 32 | import static org.mockito.Mockito.verify; | 26 | import static org.mockito.Mockito.verify; |
| @@ -44,7 +38,7 @@ public class JobServiceImplTest extends BaseDbUnitTest { | @@ -44,7 +38,7 @@ public class JobServiceImplTest extends BaseDbUnitTest { | ||
| 44 | @Test | 38 | @Test |
| 45 | public void testCreateJob_cronExpressionValid() { | 39 | public void testCreateJob_cronExpressionValid() { |
| 46 | // 准备参数。Cron 表达式为 String 类型,默认随机字符串。 | 40 | // 准备参数。Cron 表达式为 String 类型,默认随机字符串。 |
| 47 | - JobCreateReqVO reqVO = randomPojo(JobCreateReqVO.class); | 41 | + JobSaveReqVO reqVO = randomPojo(JobSaveReqVO.class); |
| 48 | 42 | ||
| 49 | // 调用,并断言异常 | 43 | // 调用,并断言异常 |
| 50 | assertServiceException(() -> jobService.createJob(reqVO), JOB_CRON_EXPRESSION_VALID); | 44 | assertServiceException(() -> jobService.createJob(reqVO), JOB_CRON_EXPRESSION_VALID); |
| @@ -53,7 +47,7 @@ public class JobServiceImplTest extends BaseDbUnitTest { | @@ -53,7 +47,7 @@ public class JobServiceImplTest extends BaseDbUnitTest { | ||
| 53 | @Test | 47 | @Test |
| 54 | public void testCreateJob_jobHandlerExists() throws SchedulerException { | 48 | public void testCreateJob_jobHandlerExists() throws SchedulerException { |
| 55 | // 准备参数 指定 Cron 表达式 | 49 | // 准备参数 指定 Cron 表达式 |
| 56 | - JobCreateReqVO reqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *")); | 50 | + JobSaveReqVO reqVO = randomPojo(JobSaveReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *")); |
| 57 | 51 | ||
| 58 | // 调用 | 52 | // 调用 |
| 59 | jobService.createJob(reqVO); | 53 | jobService.createJob(reqVO); |
| @@ -64,7 +58,8 @@ public class JobServiceImplTest extends BaseDbUnitTest { | @@ -64,7 +58,8 @@ public class JobServiceImplTest extends BaseDbUnitTest { | ||
| 64 | @Test | 58 | @Test |
| 65 | public void testCreateJob_success() throws SchedulerException { | 59 | public void testCreateJob_success() throws SchedulerException { |
| 66 | // 准备参数 指定 Cron 表达式 | 60 | // 准备参数 指定 Cron 表达式 |
| 67 | - JobCreateReqVO reqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *")); | 61 | + JobSaveReqVO reqVO = randomPojo(JobSaveReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *")) |
| 62 | + .setId(null); | ||
| 68 | 63 | ||
| 69 | // 调用 | 64 | // 调用 |
| 70 | Long jobId = jobService.createJob(reqVO); | 65 | Long jobId = jobService.createJob(reqVO); |
| @@ -72,7 +67,7 @@ public class JobServiceImplTest extends BaseDbUnitTest { | @@ -72,7 +67,7 @@ public class JobServiceImplTest extends BaseDbUnitTest { | ||
| 72 | assertNotNull(jobId); | 67 | assertNotNull(jobId); |
| 73 | // 校验记录的属性是否正确 | 68 | // 校验记录的属性是否正确 |
| 74 | JobDO job = jobMapper.selectById(jobId); | 69 | JobDO job = jobMapper.selectById(jobId); |
| 75 | - assertPojoEquals(reqVO, job); | 70 | + assertPojoEquals(reqVO, job, "id"); |
| 76 | assertEquals(JobStatusEnum.NORMAL.getStatus(), job.getStatus()); | 71 | assertEquals(JobStatusEnum.NORMAL.getStatus(), job.getStatus()); |
| 77 | // 校验调用 | 72 | // 校验调用 |
| 78 | verify(schedulerManager).addJob(eq(job.getId()), eq(job.getHandlerName()), eq(job.getHandlerParam()), | 73 | verify(schedulerManager).addJob(eq(job.getId()), eq(job.getHandlerName()), eq(job.getHandlerParam()), |
| @@ -82,7 +77,7 @@ public class JobServiceImplTest extends BaseDbUnitTest { | @@ -82,7 +77,7 @@ public class JobServiceImplTest extends BaseDbUnitTest { | ||
| 82 | @Test | 77 | @Test |
| 83 | public void testUpdateJob_jobNotExists(){ | 78 | public void testUpdateJob_jobNotExists(){ |
| 84 | // 准备参数 | 79 | // 准备参数 |
| 85 | - JobUpdateReqVO reqVO = randomPojo(JobUpdateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *")); | 80 | + JobSaveReqVO reqVO = randomPojo(JobSaveReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *")); |
| 86 | 81 | ||
| 87 | // 调用,并断言异常 | 82 | // 调用,并断言异常 |
| 88 | assertServiceException(() -> jobService.updateJob(reqVO), JOB_NOT_EXISTS); | 83 | assertServiceException(() -> jobService.updateJob(reqVO), JOB_NOT_EXISTS); |
| @@ -94,7 +89,7 @@ public class JobServiceImplTest extends BaseDbUnitTest { | @@ -94,7 +89,7 @@ public class JobServiceImplTest extends BaseDbUnitTest { | ||
| 94 | JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.INIT.getStatus())); | 89 | JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.INIT.getStatus())); |
| 95 | jobMapper.insert(job); | 90 | jobMapper.insert(job); |
| 96 | // 准备参数 | 91 | // 准备参数 |
| 97 | - JobUpdateReqVO updateReqVO = randomPojo(JobUpdateReqVO.class, o -> { | 92 | + JobSaveReqVO updateReqVO = randomPojo(JobSaveReqVO.class, o -> { |
| 98 | o.setId(job.getId()); | 93 | o.setId(job.getId()); |
| 99 | o.setCronExpression("0 0/1 * * * ? *"); | 94 | o.setCronExpression("0 0/1 * * * ? *"); |
| 100 | }); | 95 | }); |
| @@ -110,7 +105,7 @@ public class JobServiceImplTest extends BaseDbUnitTest { | @@ -110,7 +105,7 @@ public class JobServiceImplTest extends BaseDbUnitTest { | ||
| 110 | JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus())); | 105 | JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus())); |
| 111 | jobMapper.insert(job); | 106 | jobMapper.insert(job); |
| 112 | // 准备参数 | 107 | // 准备参数 |
| 113 | - JobUpdateReqVO updateReqVO = randomPojo(JobUpdateReqVO.class, o -> { | 108 | + JobSaveReqVO updateReqVO = randomPojo(JobSaveReqVO.class, o -> { |
| 114 | o.setId(job.getId()); | 109 | o.setId(job.getId()); |
| 115 | o.setCronExpression("0 0/1 * * * ? *"); | 110 | o.setCronExpression("0 0/1 * * * ? *"); |
| 116 | }); | 111 | }); |
| @@ -201,25 +196,6 @@ public class JobServiceImplTest extends BaseDbUnitTest { | @@ -201,25 +196,6 @@ public class JobServiceImplTest extends BaseDbUnitTest { | ||
| 201 | } | 196 | } |
| 202 | 197 | ||
| 203 | @Test | 198 | @Test |
| 204 | - public void testGetJobList() { | ||
| 205 | - // mock 数据 | ||
| 206 | - JobDO dbJob = randomPojo(JobDO.class, o -> { | ||
| 207 | - o.setStatus(randomEle(JobStatusEnum.values()).getStatus()); // 保证 status 的范围 | ||
| 208 | - }); | ||
| 209 | - jobMapper.insert(dbJob); | ||
| 210 | - // 测试 id 不匹配 | ||
| 211 | - jobMapper.insert(cloneIgnoreId(dbJob, o -> {})); | ||
| 212 | - | ||
| 213 | - // 准备参数 | ||
| 214 | - Collection<Long> ids = singletonList(dbJob.getId()); | ||
| 215 | - // 调用 | ||
| 216 | - List<JobDO> list = jobService.getJobList(ids); | ||
| 217 | - // 断言 | ||
| 218 | - assertEquals(1, list.size()); | ||
| 219 | - assertPojoEquals(dbJob, list.get(0)); | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | - @Test | ||
| 223 | public void testGetJobPage() { | 199 | public void testGetJobPage() { |
| 224 | // mock 数据 | 200 | // mock 数据 |
| 225 | JobDO dbJob = randomPojo(JobDO.class, o -> { | 201 | JobDO dbJob = randomPojo(JobDO.class, o -> { |
| @@ -249,34 +225,6 @@ public class JobServiceImplTest extends BaseDbUnitTest { | @@ -249,34 +225,6 @@ public class JobServiceImplTest extends BaseDbUnitTest { | ||
| 249 | } | 225 | } |
| 250 | 226 | ||
| 251 | @Test | 227 | @Test |
| 252 | - public void testGetJobList_export() { | ||
| 253 | - // mock 数据 | ||
| 254 | - JobDO dbJob = randomPojo(JobDO.class, o -> { | ||
| 255 | - o.setName("定时任务测试"); | ||
| 256 | - o.setHandlerName("handlerName 单元测试"); | ||
| 257 | - o.setStatus(JobStatusEnum.INIT.getStatus()); | ||
| 258 | - }); | ||
| 259 | - jobMapper.insert(dbJob); | ||
| 260 | - // 测试 name 不匹配 | ||
| 261 | - jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setName("土豆"))); | ||
| 262 | - // 测试 status 不匹配 | ||
| 263 | - jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus()))); | ||
| 264 | - // 测试 handlerName 不匹配 | ||
| 265 | - jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setHandlerName(randomString()))); | ||
| 266 | - // 准备参数 | ||
| 267 | - JobExportReqVO reqVo = new JobExportReqVO(); | ||
| 268 | - reqVo.setName("定时"); | ||
| 269 | - reqVo.setStatus(JobStatusEnum.INIT.getStatus()); | ||
| 270 | - reqVo.setHandlerName("单元"); | ||
| 271 | - | ||
| 272 | - // 调用 | ||
| 273 | - List<JobDO> list = jobService.getJobList(reqVo); | ||
| 274 | - // 断言 | ||
| 275 | - assertEquals(1, list.size()); | ||
| 276 | - assertPojoEquals(dbJob, list.get(0)); | ||
| 277 | - } | ||
| 278 | - | ||
| 279 | - @Test | ||
| 280 | public void testGetJob() { | 228 | public void testGetJob() { |
| 281 | // mock 数据 | 229 | // mock 数据 |
| 282 | JobDO dbJob = randomPojo(JobDO.class); | 230 | JobDO dbJob = randomPojo(JobDO.class); |