diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/api/JobApi.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/api/JobApi.java index 64b38cb3..da3baee2 100644 --- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/api/JobApi.java +++ b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/api/JobApi.java @@ -19,7 +19,10 @@ package top.continew.admin.schedule.api; import com.aizuda.snailjob.common.core.model.Result; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.SpringQueryMap; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; import top.continew.admin.schedule.config.FeignRequestInterceptor; import top.continew.admin.schedule.model.JobPageResult; import top.continew.admin.schedule.model.query.JobQuery; @@ -28,7 +31,6 @@ import top.continew.admin.schedule.model.req.JobTriggerReq; import top.continew.admin.schedule.model.resp.JobResp; import java.util.List; -import java.util.Set; /** * 任务 REST API @@ -67,15 +69,6 @@ public interface JobApi { @PutMapping Result update(@RequestBody JobReq req); - /** - * 删除 - * - * @param ids ID 列表 - * @return 响应信息 - */ - @DeleteMapping("/ids") - Result delete(@RequestBody Set ids); - /** * 执行 * diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/api/JobBatchApi.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/api/JobBatchApi.java index 21a0643d..0582e44f 100644 --- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/api/JobBatchApi.java +++ b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/api/JobBatchApi.java @@ -23,12 +23,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import top.continew.admin.schedule.config.FeignRequestInterceptor; -import top.continew.admin.schedule.model.JobInstanceLogPageResult; import top.continew.admin.schedule.model.JobPageResult; -import top.continew.admin.schedule.model.query.JobInstanceLogQuery; -import top.continew.admin.schedule.model.query.JobInstanceQuery; import top.continew.admin.schedule.model.query.JobLogQuery; -import top.continew.admin.schedule.model.resp.JobInstanceResp; import top.continew.admin.schedule.model.resp.JobLogResp; import java.util.List; @@ -69,22 +65,4 @@ public interface JobBatchApi { */ @PostMapping("/batch/retry/{id}") Result retry(@PathVariable("id") Long id); - - /** - * 分页查询任务实例列表 - * - * @param query 查询条件 - * @return 响应信息 - */ - @GetMapping("/task/list") - JobPageResult> pageTask(@SpringQueryMap JobInstanceQuery query); - - /** - * 分页查询任务实例日志列表 - * - * @param query 查询条件 - * @return 响应信息 - */ - @GetMapping("/log/list") - Result pageLog(@SpringQueryMap JobInstanceLogQuery query); } diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/controller/JobController.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/controller/JobController.java index c8362416..49842935 100644 --- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/controller/JobController.java +++ b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/controller/JobController.java @@ -31,6 +31,7 @@ import top.continew.admin.schedule.model.req.JobStatusReq; import top.continew.admin.schedule.model.req.JobTriggerReq; import top.continew.admin.schedule.model.resp.JobResp; import top.continew.admin.schedule.service.JobService; +import top.continew.starter.core.util.validation.CheckUtils; import top.continew.starter.extension.crud.model.resp.PageResp; import top.continew.starter.extension.crud.validation.CrudValidationGroup; import top.continew.starter.log.annotation.Log; @@ -64,7 +65,7 @@ public class JobController { @PostMapping @Validated(CrudValidationGroup.Create.class) public void create(@RequestBody @Valid JobReq req) { - baseService.create(req); + CheckUtils.throwIf(!baseService.create(req), "任务创建失败"); } @Operation(summary = "修改任务", description = "修改任务") @@ -73,14 +74,14 @@ public class JobController { @PutMapping("/{id}") @Validated(CrudValidationGroup.Update.class) public void update(@RequestBody @Valid JobReq req, @PathVariable Long id) { - baseService.update(req, id); + CheckUtils.throwIf(!baseService.update(req, id), "任务修改失败"); } @Operation(summary = "修改任务状态", description = "修改任务状态") @SaCheckPermission("schedule:job:update") @PatchMapping("/{id}/status") public void updateStatus(@RequestBody @Valid JobStatusReq req, @PathVariable Long id) { - baseService.updateStatus(req, id); + CheckUtils.throwIf(!baseService.updateStatus(req, id), "任务状态修改失败"); } @Operation(summary = "删除任务", description = "删除任务") @@ -88,7 +89,7 @@ public class JobController { @SaCheckPermission("schedule:job:delete") @DeleteMapping("/{id}") public void delete(@PathVariable Long id) { - baseService.delete(id); + CheckUtils.throwIf(!baseService.delete(id), "任务删除失败"); } @Operation(summary = "执行任务", description = "执行任务") @@ -98,7 +99,7 @@ public class JobController { public void trigger(@PathVariable Long id) { JobTriggerReq req = new JobTriggerReq(); req.setJobId(id); - baseService.trigger(req); + CheckUtils.throwIf(!baseService.trigger(req), "任务执行失败"); } @Log(ignore = true) diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/controller/JobLogController.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/controller/JobLogController.java index 5cd7dd29..6a002c76 100644 --- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/controller/JobLogController.java +++ b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/controller/JobLogController.java @@ -24,17 +24,11 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; -import top.continew.admin.schedule.model.JobInstanceLogPageResult; -import top.continew.admin.schedule.model.query.JobInstanceLogQuery; -import top.continew.admin.schedule.model.query.JobInstanceQuery; import top.continew.admin.schedule.model.query.JobLogQuery; -import top.continew.admin.schedule.model.resp.JobInstanceResp; import top.continew.admin.schedule.model.resp.JobLogResp; import top.continew.admin.schedule.service.JobLogService; import top.continew.starter.extension.crud.model.resp.PageResp; -import java.util.List; - /** * 任务日志 API * @@ -72,18 +66,4 @@ public class JobLogController { public void retry(@PathVariable Long id) { baseService.retry(id); } - - @Operation(summary = "查询任务实例列表", description = "查询任务实例列表") - @SaCheckPermission("schedule:log:list") - @GetMapping("/instance") - public List listInstance(@Valid JobInstanceQuery query) { - return baseService.listInstance(query); - } - - @Operation(summary = "分页查询任务实例日志列表", description = "分页查询任务实例日志列表") - @SaCheckPermission("schedule:log:list") - @GetMapping("/instance/log") - public JobInstanceLogPageResult pageInstanceLog(@Valid JobInstanceLogQuery query) { - return baseService.pageInstanceLog(query); - } } diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/query/JobInstanceLogQuery.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/query/JobInstanceLogQuery.java deleted file mode 100644 index 41a6c726..00000000 --- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/query/JobInstanceLogQuery.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.admin.schedule.model.query; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.Min; -import lombok.Data; -import org.hibernate.validator.constraints.Range; - -import java.io.Serial; -import java.io.Serializable; - -/** - * 任务实例日志查询条件 - * - * @author KAI - * @since 2024/6/28 16:58 - */ -@Data -@Schema(description = "任务实例日志查询条件") -public class JobInstanceLogQuery implements Serializable { - - @Serial - private static final long serialVersionUID = 1L; - - /** - * 任务 ID - */ - @Schema(description = "任务ID", example = "1") - private Long jobId; - - /** - * 任务批次 ID - */ - @Schema(description = "任务批次ID", example = "1") - private Long taskBatchId; - - /** - * 任务实例 ID - */ - @Schema(description = "任务实例ID", example = "1") - private Long taskId; - - /** - * 开始 ID - */ - @Schema(description = "开始ID", example = "2850") - private Integer startId; - - /** - * 起始索引 - */ - @Schema(description = "起始索引", example = "0") - @Min(value = 0, message = "起始索引最小值为 {value}") - private Integer fromIndex = 0; - - /** - * 每页条数 - */ - @Schema(description = "每页条数", example = "50") - @Range(min = 1, max = 1000, message = "每页条数(取值范围 {min}-{max})") - private Integer size = 50; -} diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/query/JobInstanceQuery.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/query/JobInstanceQuery.java deleted file mode 100644 index 39768bf0..00000000 --- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/query/JobInstanceQuery.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.admin.schedule.model.query; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.io.Serial; -import java.io.Serializable; - -/** - * 任务实例查询条件 - * - * @author KAI - * @since 2024/6/28 16:58 - */ -@Data -@Schema(description = "任务实例查询条件") -public class JobInstanceQuery implements Serializable { - - @Serial - private static final long serialVersionUID = 1L; - - /** - * 任务 ID - */ - @Schema(description = "任务ID", example = "1") - private Long jobId; - - /** - * 任务批次 ID - */ - @Schema(description = "任务批次ID", example = "1") - private Long taskBatchId; -} diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/resp/JobInstanceResp.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/resp/JobInstanceResp.java deleted file mode 100644 index b6a732d5..00000000 --- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/model/resp/JobInstanceResp.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.admin.schedule.model.resp; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.io.Serial; -import java.io.Serializable; - -/** - * 任务实例响应参数 - * - * @author KAI - * @author Charles7c - * @since 2024/6/28 16:58 - */ -@Data -@Schema(description = "任务实例响应参数") -public class JobInstanceResp implements Serializable { - - @Serial - private static final long serialVersionUID = 1L; - - /** - * ID - */ - @Schema(description = "ID", example = "1") - private Long id; - - /** - * 任务组 - */ - @Schema(description = "任务组", example = "continew-admin") - private String groupName; - - /** - * 任务 ID - */ - @Schema(description = "任务ID", example = "1") - private Long jobId; - - /** - * 任务批次 ID - */ - @Schema(description = "任务批次ID", example = "1") - private Long taskBatchId; - - /** - * 执行状态 - */ - @Schema(description = "执行状态", example = "1") - private Integer taskStatus; - - /** - * 重试次数 - */ - @Schema(description = "重试次数", example = "1") - private Integer retryCount; - - /** - * 执行结果 - */ - @Schema(description = "执行结果", example = "") - private String resultMessage; - - /** - * 客户端信息 - */ - @Schema(description = "客户端信息", example = "1812406095098114048@192.168.138.48:1789") - private String clientInfo; -} diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/JobLogService.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/JobLogService.java index c13bf89d..0c20f270 100644 --- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/JobLogService.java +++ b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/JobLogService.java @@ -16,16 +16,10 @@ package top.continew.admin.schedule.service; -import top.continew.admin.schedule.model.JobInstanceLogPageResult; -import top.continew.admin.schedule.model.query.JobInstanceLogQuery; -import top.continew.admin.schedule.model.query.JobInstanceQuery; import top.continew.admin.schedule.model.query.JobLogQuery; -import top.continew.admin.schedule.model.resp.JobInstanceResp; import top.continew.admin.schedule.model.resp.JobLogResp; import top.continew.starter.extension.crud.model.resp.PageResp; -import java.util.List; - /** * 任务日志业务接口 * @@ -58,20 +52,4 @@ public interface JobLogService { * @return 重试结果 */ boolean retry(Long id); - - /** - * 查询任务实例列表 - * - * @param query 查询条件 - * @return 列表信息 - */ - List listInstance(JobInstanceQuery query); - - /** - * 分页查询任务实例日志列表 - * - * @param query 查询条件 - * @return 分页列表信息 - */ - JobInstanceLogPageResult pageInstanceLog(JobInstanceLogQuery query); } diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/impl/JobLogServiceImpl.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/impl/JobLogServiceImpl.java index 96c918e4..22441b78 100644 --- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/impl/JobLogServiceImpl.java +++ b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/impl/JobLogServiceImpl.java @@ -20,17 +20,11 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import top.continew.admin.schedule.api.JobBatchApi; import top.continew.admin.schedule.api.JobClient; -import top.continew.admin.schedule.model.JobInstanceLogPageResult; -import top.continew.admin.schedule.model.query.JobInstanceLogQuery; -import top.continew.admin.schedule.model.query.JobInstanceQuery; import top.continew.admin.schedule.model.query.JobLogQuery; -import top.continew.admin.schedule.model.resp.JobInstanceResp; import top.continew.admin.schedule.model.resp.JobLogResp; import top.continew.admin.schedule.service.JobLogService; import top.continew.starter.extension.crud.model.resp.PageResp; -import java.util.List; - /** * 任务日志业务实现 * @@ -59,14 +53,4 @@ public class JobLogServiceImpl implements JobLogService { public boolean retry(Long id) { return Boolean.TRUE.equals(jobClient.request(() -> jobBatchApi.retry(id))); } - - @Override - public List listInstance(JobInstanceQuery query) { - return jobClient.requestPage(() -> jobBatchApi.pageTask(query)).getList(); - } - - @Override - public JobInstanceLogPageResult pageInstanceLog(JobInstanceLogQuery query) { - return jobClient.request(() -> jobBatchApi.pageLog(query)); - } } diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/impl/JobServiceImpl.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/impl/JobServiceImpl.java index 5dbfb5b6..d5370034 100644 --- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/impl/JobServiceImpl.java +++ b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/service/impl/JobServiceImpl.java @@ -32,8 +32,8 @@ import top.continew.admin.schedule.model.resp.JobResp; import top.continew.admin.schedule.service.JobService; import top.continew.starter.extension.crud.model.resp.PageResp; -import java.util.Collections; import java.util.List; +import java.util.Set; /** * 任务业务实现 @@ -75,7 +75,7 @@ public class JobServiceImpl implements JobService { @Override public boolean delete(Long id) { - return Boolean.TRUE.equals(jobClient.request(() -> jobApi.delete(Collections.singleton(id)))); + return SnailJobOpenApi.deleteJob(Set.of(id)).execute(); } @Override diff --git a/continew-server/src/main/resources/db/changelog/mysql/plugin/plugin_schedule.sql b/continew-server/src/main/resources/db/changelog/mysql/plugin/plugin_schedule.sql index 55b7e77f..9d2eca11 100644 --- a/continew-server/src/main/resources/db/changelog/mysql/plugin/plugin_schedule.sql +++ b/continew-server/src/main/resources/db/changelog/mysql/plugin/plugin_schedule.sql @@ -17,6 +17,5 @@ VALUES (8020, '任务日志', 8000, 2, '/schedule/log', 'ScheduleLog', 'schedule/log/index', NULL, 'find-replace', b'0', b'0', b'0', NULL, 2, 1, 1, NOW()), (8021, '列表', 8020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:list', 1, 1, 1, NOW()), -(8022, '详情', 8020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:get', 2, 1, 1, NOW()), -(8023, '停止', 8020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:stop', 3, 1, 1, NOW()), -(8024, '重试', 8020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:retry', 4, 1, 1, NOW()); +(8022, '停止', 8020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:stop', 3, 1, 1, NOW()), +(8023, '重试', 8020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:retry', 4, 1, 1, NOW()); diff --git a/continew-server/src/main/resources/db/changelog/postgresql/plugin/plugin_schedule.sql b/continew-server/src/main/resources/db/changelog/postgresql/plugin/plugin_schedule.sql index db23c7f0..34e2e81c 100644 --- a/continew-server/src/main/resources/db/changelog/postgresql/plugin/plugin_schedule.sql +++ b/continew-server/src/main/resources/db/changelog/postgresql/plugin/plugin_schedule.sql @@ -17,6 +17,5 @@ VALUES (8020, '任务日志', 8000, 2, '/schedule/log', 'ScheduleLog', 'schedule/log/index', NULL, 'find-replace', false, false, false, NULL, 2, 1, 1, NOW()), (8021, '列表', 8020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:list', 1, 1, 1, NOW()), -(8022, '详情', 8020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:get', 2, 1, 1, NOW()), -(8023, '停止', 8020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:stop', 3, 1, 1, NOW()), -(8024, '重试', 8020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:retry', 4, 1, 1, NOW()); +(8022, '停止', 8020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:stop', 3, 1, 1, NOW()), +(8023, '重试', 8020, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'schedule:log:retry', 4, 1, 1, NOW());