fix(warehouse): reject invalid import files with validation code
This commit is contained in:
+5
-1
@@ -94,7 +94,11 @@ public class PlatformExpressCompanyController {
|
||||
requirePlatform(user);
|
||||
requirePlatformScope(tenantId);
|
||||
try {
|
||||
return ApiResponse.success(importService.importFile(tenantId, file.getOriginalFilename(), file.getBytes()));
|
||||
ExpressCompanyImportResult result = importService.importFile(tenantId, file.getOriginalFilename(), file.getBytes());
|
||||
if (!result.success()) {
|
||||
throw new BizException(ResultCode.VALIDATION_FAILED, "快递公司导入文件校验失败");
|
||||
}
|
||||
return ApiResponse.success(result);
|
||||
} catch (IOException exception) {
|
||||
throw new BizException(ResultCode.BAD_REQUEST, "导入文件读取失败");
|
||||
}
|
||||
|
||||
+5
-1
@@ -75,7 +75,11 @@ public class PlatformPartnerController {
|
||||
requirePlatform(user);
|
||||
requirePlatformScope(tenantId);
|
||||
try {
|
||||
return ApiResponse.success(importService.importFile(0L, file.getOriginalFilename(), file.getBytes()));
|
||||
PartnerImportResult result = importService.importFile(0L, file.getOriginalFilename(), file.getBytes());
|
||||
if (!result.success()) {
|
||||
throw new BizException(ResultCode.VALIDATION_FAILED, "往来单位导入文件校验失败");
|
||||
}
|
||||
return ApiResponse.success(result);
|
||||
} catch (IOException exception) {
|
||||
throw new BizException(ResultCode.BAD_REQUEST, "导入文件读取失败");
|
||||
}
|
||||
|
||||
+5
-1
@@ -163,7 +163,11 @@ public class PlatformWarehouseController {
|
||||
requireImportPermission(user, mode);
|
||||
if (tenantId != null) requireTenant(tenantId);
|
||||
try {
|
||||
return ApiResponse.success(importService.importFile(0L, file.getOriginalFilename(), file.getBytes(), mode, dryRun));
|
||||
WarehouseImportResult result = importService.importFile(0L, file.getOriginalFilename(), file.getBytes(), mode, dryRun);
|
||||
if (!result.success()) {
|
||||
throw new BizException(ResultCode.VALIDATION_FAILED, "仓库导入文件校验失败");
|
||||
}
|
||||
return ApiResponse.success(result);
|
||||
} catch (IOException exception) {
|
||||
throw new BizException(ResultCode.BAD_REQUEST, "导入文件读取失败");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user