fix(lsfx): 修复流水分析对接模块的代码质量问题
1. 修复配置问题 - 替换app-secret占位符为正确的密钥dXj6eHRmPv 2. 添加异常处理 - HttpUtil所有方法添加完整的异常处理 - 统一使用LsfxApiException包装异常 - 检查HTTP状态码和响应体 3. 添加日志记录 - Client所有方法添加详细的日志记录 - 记录请求参数、响应结果、耗时 - 异常情况记录错误日志 4. 完善参数校验 - 接口1:添加6个必填字段校验 - 接口2:添加groupId和文件校验,限制文件大小10MB - 接口3:添加7个参数校验和日期范围校验 - 接口4:添加groupId和inprogressList校验 5. 性能优化 - RestTemplate使用Apache HttpClient连接池 - 最大连接数100,每个路由最大20个连接 - 支持连接复用,提升性能 6. 代码审查文档 - 添加详细的代码审查报告 - 记录发现的问题和改进建议 修改的文件: - ccdi-lsfx/pom.xml - ccdi-lsfx/src/main/java/com/ruoyi/lsfx/client/LsfxAnalysisClient.java - ccdi-lsfx/src/main/java/com/ruoyi/lsfx/config/RestTemplateConfig.java - ccdi-lsfx/src/main/java/com/ruoyi/lsfx/controller/LsfxTestController.java - ccdi-lsfx/src/main/java/com/ruoyi/lsfx/util/HttpUtil.java - ruoyi-admin/src/main/resources/application-dev.yml - doc/implementation/lsfx-code-review-20260302.md
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.lsfx.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.lsfx.client.LsfxAnalysisClient;
|
||||
import com.ruoyi.lsfx.domain.request.*;
|
||||
import com.ruoyi.lsfx.domain.response.*;
|
||||
@@ -26,6 +27,26 @@ public class LsfxTestController {
|
||||
@Operation(summary = "获取Token", description = "创建项目并获取访问Token")
|
||||
@PostMapping("/getToken")
|
||||
public AjaxResult getToken(@RequestBody GetTokenRequest request) {
|
||||
// 参数校验
|
||||
if (StringUtils.isBlank(request.getProjectNo())) {
|
||||
return AjaxResult.error("参数不完整:projectNo为必填");
|
||||
}
|
||||
if (StringUtils.isBlank(request.getEntityName())) {
|
||||
return AjaxResult.error("参数不完整:entityName为必填");
|
||||
}
|
||||
if (StringUtils.isBlank(request.getUserId())) {
|
||||
return AjaxResult.error("参数不完整:userId为必填");
|
||||
}
|
||||
if (StringUtils.isBlank(request.getUserName())) {
|
||||
return AjaxResult.error("参数不完整:userName为必填");
|
||||
}
|
||||
if (StringUtils.isBlank(request.getOrgCode())) {
|
||||
return AjaxResult.error("参数不完整:orgCode为必填");
|
||||
}
|
||||
if (StringUtils.isBlank(request.getDepartmentCode())) {
|
||||
return AjaxResult.error("参数不完整:departmentCode为必填");
|
||||
}
|
||||
|
||||
GetTokenResponse response = lsfxAnalysisClient.getToken(request);
|
||||
return AjaxResult.success(response);
|
||||
}
|
||||
@@ -36,6 +57,17 @@ public class LsfxTestController {
|
||||
@Parameter(description = "项目ID") @RequestParam Integer groupId,
|
||||
@Parameter(description = "流水文件") @RequestParam("file") MultipartFile file
|
||||
) {
|
||||
// 参数校验
|
||||
if (groupId == null || groupId <= 0) {
|
||||
return AjaxResult.error("参数不完整:groupId为必填且大于0");
|
||||
}
|
||||
if (file == null || file.isEmpty()) {
|
||||
return AjaxResult.error("参数不完整:文件不能为空");
|
||||
}
|
||||
if (file.getSize() > 10 * 1024 * 1024) { // 10MB限制
|
||||
return AjaxResult.error("文件大小超过限制:最大10MB");
|
||||
}
|
||||
|
||||
org.springframework.core.io.Resource fileResource = file.getResource();
|
||||
UploadFileResponse response = lsfxAnalysisClient.uploadFile(groupId, fileResource);
|
||||
return AjaxResult.success(response);
|
||||
@@ -44,6 +76,26 @@ public class LsfxTestController {
|
||||
@Operation(summary = "拉取行内流水", description = "从数仓拉取行内流水数据")
|
||||
@PostMapping("/fetchInnerFlow")
|
||||
public AjaxResult fetchInnerFlow(@RequestBody FetchInnerFlowRequest request) {
|
||||
// 参数校验
|
||||
if (request.getGroupId() == null || request.getGroupId() <= 0) {
|
||||
return AjaxResult.error("参数不完整:groupId为必填且大于0");
|
||||
}
|
||||
if (StringUtils.isEmpty(request.getCustomerNo())) {
|
||||
return AjaxResult.error("参数不完整:customerNo为必填");
|
||||
}
|
||||
if (request.getRequestDateId() == null) {
|
||||
return AjaxResult.error("参数不完整:requestDateId为必填");
|
||||
}
|
||||
if (request.getDataStartDateId() == null) {
|
||||
return AjaxResult.error("参数不完整:dataStartDateId为必填");
|
||||
}
|
||||
if (request.getDataEndDateId() == null) {
|
||||
return AjaxResult.error("参数不完整:dataEndDateId为必填");
|
||||
}
|
||||
if (request.getDataStartDateId() > request.getDataEndDateId()) {
|
||||
return AjaxResult.error("参数错误:开始日期不能大于结束日期");
|
||||
}
|
||||
|
||||
FetchInnerFlowResponse response = lsfxAnalysisClient.fetchInnerFlow(request);
|
||||
return AjaxResult.success(response);
|
||||
}
|
||||
@@ -54,6 +106,14 @@ public class LsfxTestController {
|
||||
@Parameter(description = "项目ID") @RequestParam Integer groupId,
|
||||
@Parameter(description = "文件ID列表") @RequestParam String inprogressList
|
||||
) {
|
||||
// 参数校验
|
||||
if (groupId == null || groupId <= 0) {
|
||||
return AjaxResult.error("参数不完整:groupId为必填且大于0");
|
||||
}
|
||||
if (StringUtils.isEmpty(inprogressList)) {
|
||||
return AjaxResult.error("参数不完整:inprogressList为必填");
|
||||
}
|
||||
|
||||
CheckParseStatusResponse response = lsfxAnalysisClient.checkParseStatus(groupId, inprogressList);
|
||||
return AjaxResult.success(response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user