mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 22:57:17 +08:00 
			
		
		
		
	refactor(schedule): 使用 Snail Job Open API(SDK API) 替换修改状态接口
目前 Snail Job Open API(SDK API) 的设计偏向于后端代码内直接使用的场景,区别于它的 Web API。 如果你需要创建任务并获取到 ID,可以通过它的 Open API 来直接创建。 Closes #171
This commit is contained in:
		| @@ -24,7 +24,6 @@ import top.continew.admin.schedule.config.FeignRequestInterceptor; | |||||||
| import top.continew.admin.schedule.model.JobPageResult; | import top.continew.admin.schedule.model.JobPageResult; | ||||||
| import top.continew.admin.schedule.model.query.JobQuery; | import top.continew.admin.schedule.model.query.JobQuery; | ||||||
| import top.continew.admin.schedule.model.req.JobReq; | import top.continew.admin.schedule.model.req.JobReq; | ||||||
| import top.continew.admin.schedule.model.req.JobStatusReq; |  | ||||||
| import top.continew.admin.schedule.model.req.JobTriggerReq; | import top.continew.admin.schedule.model.req.JobTriggerReq; | ||||||
| import top.continew.admin.schedule.model.resp.JobResp; | import top.continew.admin.schedule.model.resp.JobResp; | ||||||
|  |  | ||||||
| @@ -68,15 +67,6 @@ public interface JobApi { | |||||||
|     @PutMapping |     @PutMapping | ||||||
|     Result<Boolean> update(@RequestBody JobReq req); |     Result<Boolean> update(@RequestBody JobReq req); | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 修改状态 |  | ||||||
|      * |  | ||||||
|      * @param req 请求参数 |  | ||||||
|      * @return 响应信息 |  | ||||||
|      */ |  | ||||||
|     @PutMapping("/status") |  | ||||||
|     Result<Boolean> updateStatus(@RequestBody JobStatusReq req); |  | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 删除 |      * 删除 | ||||||
|      * |      * | ||||||
|   | |||||||
| @@ -44,10 +44,4 @@ public class JobStatusReq implements Serializable { | |||||||
|     @Schema(description = "任务状态", example = "1") |     @Schema(description = "任务状态", example = "1") | ||||||
|     @NotNull(message = "任务状态无效") |     @NotNull(message = "任务状态无效") | ||||||
|     private JobStatusEnum jobStatus; |     private JobStatusEnum jobStatus; | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * ID |  | ||||||
|      */ |  | ||||||
|     @Schema(hidden = true) |  | ||||||
|     private Long id; |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -16,11 +16,14 @@ | |||||||
|  |  | ||||||
| package top.continew.admin.schedule.service.impl; | package top.continew.admin.schedule.service.impl; | ||||||
|  |  | ||||||
|  | import com.aizuda.snailjob.client.job.core.openapi.SnailJobOpenApi; | ||||||
|  | import com.aizuda.snailjob.common.core.enums.StatusEnum; | ||||||
| import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
| import top.continew.admin.schedule.api.JobApi; | import top.continew.admin.schedule.api.JobApi; | ||||||
| import top.continew.admin.schedule.api.JobClient; | import top.continew.admin.schedule.api.JobClient; | ||||||
| import top.continew.admin.schedule.api.JobGroupApi; | import top.continew.admin.schedule.api.JobGroupApi; | ||||||
|  | import top.continew.admin.schedule.enums.JobStatusEnum; | ||||||
| import top.continew.admin.schedule.model.query.JobQuery; | import top.continew.admin.schedule.model.query.JobQuery; | ||||||
| import top.continew.admin.schedule.model.req.JobReq; | import top.continew.admin.schedule.model.req.JobReq; | ||||||
| import top.continew.admin.schedule.model.req.JobStatusReq; | import top.continew.admin.schedule.model.req.JobStatusReq; | ||||||
| @@ -65,8 +68,9 @@ public class JobServiceImpl implements JobService { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean updateStatus(JobStatusReq req, Long id) { |     public boolean updateStatus(JobStatusReq req, Long id) { | ||||||
|         req.setId(id); |         return SnailJobOpenApi.updateJobStatus(id) | ||||||
|         return Boolean.TRUE.equals(jobClient.request(() -> jobApi.updateStatus(req))); |             .setStatus(JobStatusEnum.DISABLED.equals(req.getJobStatus()) ? StatusEnum.NO : StatusEnum.YES) | ||||||
|  |             .execute(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user