You've already forked FrameTour-BE
refactor(device): 重构默认配置接口返回类型
- 将 DefaultConfigClient 中的 listDefaultConfigs 方法返回类型由 PageResponse 改为 CommonResponse<PageResponse> - 更新 DefaultConfigIntegrationService 中的调用方式 - 移除 handlePageResponse 方法,改为使用 handleResponse 方法处理响应
This commit is contained in:
@@ -18,7 +18,7 @@ public interface DefaultConfigClient {
|
|||||||
* 获取默认配置列表
|
* 获取默认配置列表
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
PageResponse<DefaultConfigResponse> listDefaultConfigs(@RequestParam(value = "page", defaultValue = "1") int page,
|
CommonResponse<PageResponse<DefaultConfigResponse>> listDefaultConfigs(@RequestParam(value = "page", defaultValue = "1") int page,
|
||||||
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize);
|
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -35,8 +35,8 @@ public class DefaultConfigIntegrationService {
|
|||||||
SERVICE_NAME,
|
SERVICE_NAME,
|
||||||
"defaults:list:" + page + ":" + pageSize,
|
"defaults:list:" + page + ":" + pageSize,
|
||||||
() -> {
|
() -> {
|
||||||
PageResponse<DefaultConfigResponse> response = defaultConfigClient.listDefaultConfigs(page, pageSize);
|
CommonResponse<PageResponse<DefaultConfigResponse>> response = defaultConfigClient.listDefaultConfigs(page, pageSize);
|
||||||
return handlePageResponse(response, "获取默认配置列表失败");
|
return handleResponse(response, "获取默认配置列表失败");
|
||||||
},
|
},
|
||||||
PageResponse.class
|
PageResponse.class
|
||||||
);
|
);
|
||||||
@@ -216,15 +216,4 @@ public class DefaultConfigIntegrationService {
|
|||||||
}
|
}
|
||||||
return response.getData();
|
return response.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> PageResponse<T> handlePageResponse(PageResponse<T> response, String errorMessage) {
|
|
||||||
if (response == null || !response.isSuccess()) {
|
|
||||||
String msg = response != null && response.getMessage() != null
|
|
||||||
? response.getMessage()
|
|
||||||
: errorMessage;
|
|
||||||
Integer code = response != null ? response.getCode() : 5000;
|
|
||||||
throw new IntegrationException(code, msg, SERVICE_NAME);
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user