mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-09 08:57:16 +08:00
fix: 修复任务调度 API 使用错误(由1.1.0-beta => 1.1.0引发)
This commit is contained in:
@@ -29,6 +29,7 @@ import top.continew.admin.job.model.req.JobStatusReq;
|
||||
import top.continew.admin.job.model.resp.JobResp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 任务 REST API
|
||||
@@ -87,11 +88,11 @@ public interface JobApi {
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id ID
|
||||
* @param ids ID 列表
|
||||
* @return 响应信息
|
||||
*/
|
||||
@DeleteExchange("/job/{id}")
|
||||
ResponseEntity<Result<Boolean>> delete(@PathVariable("id") Long id);
|
||||
@DeleteExchange("/job/ids")
|
||||
ResponseEntity<Result<Boolean>> delete(@RequestBody Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 执行
|
||||
|
@@ -75,18 +75,13 @@ public class JobClient {
|
||||
* @return 响应信息
|
||||
*/
|
||||
public <T> T request(Supplier<ResponseEntity<Result<T>>> apiSupplier) {
|
||||
try {
|
||||
ResponseEntity<Result<T>> responseEntity = apiSupplier.get();
|
||||
this.checkResponse(responseEntity);
|
||||
Result<T> result = responseEntity.getBody();
|
||||
if (!STATUS_SUCCESS.equals(result.getStatus())) {
|
||||
throw new IllegalStateException(result.getMessage());
|
||||
}
|
||||
return result.getData();
|
||||
} catch (Exception e) {
|
||||
log.error("Request job server failed, error msg: {}", e.getMessage(), e);
|
||||
throw new IllegalStateException("连接任务调度中心异常");
|
||||
ResponseEntity<Result<T>> responseEntity = apiSupplier.get();
|
||||
this.checkResponse(responseEntity);
|
||||
Result<T> result = responseEntity.getBody();
|
||||
if (!STATUS_SUCCESS.equals(result.getStatus())) {
|
||||
throw new IllegalStateException(result.getMessage());
|
||||
}
|
||||
return result.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,21 +92,16 @@ public class JobClient {
|
||||
* @return 分页列表信息
|
||||
*/
|
||||
public <T> PageResp<T> requestPage(Supplier<ResponseEntity<JobPageResult<List<T>>>> apiSupplier) {
|
||||
try {
|
||||
ResponseEntity<JobPageResult<List<T>>> responseEntity = apiSupplier.get();
|
||||
this.checkResponse(responseEntity);
|
||||
JobPageResult<List<T>> result = responseEntity.getBody();
|
||||
if (!STATUS_SUCCESS.equals(result.getStatus())) {
|
||||
throw new IllegalStateException(result.getMessage());
|
||||
}
|
||||
PageResp<T> page = new PageResp<>();
|
||||
page.setList(result.getData());
|
||||
page.setTotal(result.getTotal());
|
||||
return page;
|
||||
} catch (Exception e) {
|
||||
log.error("Request job server failed, error msg: {}", e.getMessage(), e);
|
||||
throw new IllegalStateException("连接任务调度中心异常");
|
||||
ResponseEntity<JobPageResult<List<T>>> responseEntity = apiSupplier.get();
|
||||
this.checkResponse(responseEntity);
|
||||
JobPageResult<List<T>> result = responseEntity.getBody();
|
||||
if (!STATUS_SUCCESS.equals(result.getStatus())) {
|
||||
throw new IllegalStateException(result.getMessage());
|
||||
}
|
||||
PageResp<T> page = new PageResp<>();
|
||||
page.setList(result.getData());
|
||||
page.setTotal(result.getTotal());
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,8 +137,9 @@ public class JobClient {
|
||||
}
|
||||
Result<?> result = JSONUtil.toBean(response.body(), Result.class);
|
||||
if (!STATUS_SUCCESS.equals(result.getStatus())) {
|
||||
throw new IllegalStateException("Password Authentication failed, expected a successful response. error msg: %s"
|
||||
.formatted(result.getMessage()));
|
||||
log.warn("Password Authentication failed, expected a successful response. error msg: {}", result
|
||||
.getMessage());
|
||||
throw new IllegalStateException(result.getMessage());
|
||||
}
|
||||
return JSONUtil.parseObj(result.getData()).getStr("token");
|
||||
}
|
||||
|
@@ -30,15 +30,15 @@ import top.continew.starter.core.enums.BaseEnum;
|
||||
@RequiredArgsConstructor
|
||||
public enum JobTriggerTypeEnum implements BaseEnum<Integer> {
|
||||
|
||||
/**
|
||||
* CRON
|
||||
*/
|
||||
CRON(1, "CRON"),
|
||||
|
||||
/**
|
||||
* 固定时间
|
||||
*/
|
||||
FIXED_TIME(2, "固定时间"),;
|
||||
FIXED_TIME(2, "固定时间"),
|
||||
|
||||
/**
|
||||
* CRON
|
||||
*/
|
||||
CRON(3, "CRON");
|
||||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
|
@@ -27,6 +27,7 @@ import top.continew.admin.job.model.resp.JobResp;
|
||||
import top.continew.admin.job.service.JobService;
|
||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -68,7 +69,7 @@ public class JobServiceImpl implements JobService {
|
||||
|
||||
@Override
|
||||
public boolean delete(Long id) {
|
||||
return Boolean.TRUE.equals(jobClient.request(() -> jobApi.delete(id)));
|
||||
return Boolean.TRUE.equals(jobClient.request(() -> jobApi.delete(Collections.singleton(id))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user