优化
This commit is contained in:
+4
-4
@@ -64,8 +64,8 @@ public class InternalMeasurementImageController {
|
||||
@PathVariable long receiptId,
|
||||
@RequestPart("file") MultipartFile file) {
|
||||
requireToken(token);
|
||||
if (tenantId <= 0 || receiptId <= 0 || operatorId <= 0) {
|
||||
throw new BizException(ResultCode.BAD_REQUEST, "客户、收件记录和操作主体ID必须大于0");
|
||||
if (tenantId < 0 || receiptId <= 0 || operatorId <= 0) {
|
||||
throw new BizException(ResultCode.BAD_REQUEST, "收件作用域不能为负,收件记录和操作主体ID必须大于0");
|
||||
}
|
||||
return ApiResponse.success(images.uploadMojiaReceiptEvidence(
|
||||
tenantId, receiptId, operatorId, file));
|
||||
@@ -94,8 +94,8 @@ public class InternalMeasurementImageController {
|
||||
@PathVariable long receiptId,
|
||||
@PathVariable long fileId) {
|
||||
requireToken(token);
|
||||
if (tenantId <= 0 || receiptId <= 0 || fileId <= 0 || operatorId <= 0) {
|
||||
throw new BizException(ResultCode.BAD_REQUEST, "客户、收件记录、文件和操作主体ID必须大于0");
|
||||
if (tenantId < 0 || receiptId <= 0 || fileId <= 0 || operatorId <= 0) {
|
||||
throw new BizException(ResultCode.BAD_REQUEST, "收件作用域不能为负,收件记录、文件和操作主体ID必须大于0");
|
||||
}
|
||||
images.deleteMojiaReceiptEvidence(tenantId, receiptId, fileId, operatorId);
|
||||
return ApiResponse.success(null);
|
||||
|
||||
+16
@@ -73,4 +73,20 @@ class InternalMeasurementImageControllerTest {
|
||||
assertThat(response.data().fileId()).isEqualTo(41L);
|
||||
verify(images).uploadMojiaReceiptEvidence(11L, 51L, 31L, file);
|
||||
}
|
||||
|
||||
@Test
|
||||
void storesAndDeletesPlatformScopedUnmatchedMojiaReceiptImage() {
|
||||
var file = new MockMultipartFile("file", "mojia.jpg", MediaType.IMAGE_JPEG_VALUE,
|
||||
new byte[]{1, 2, 3});
|
||||
when(images.uploadMojiaReceiptEvidence(0L, 51L, 31L, file)).thenReturn(
|
||||
new MeasurementImageService.UploadResult(41L, "mojia.jpg",
|
||||
MediaType.IMAGE_JPEG_VALUE, 3L, "NOT_REQUIRED", null, null, null, null, null));
|
||||
|
||||
assertThat(controller.uploadReceipt("internal-token", 31L, 0L, 51L, file).data().fileId())
|
||||
.isEqualTo(41L);
|
||||
controller.deleteReceipt("internal-token", 31L, 0L, 51L, 41L);
|
||||
|
||||
verify(images).uploadMojiaReceiptEvidence(0L, 51L, 31L, file);
|
||||
verify(images).deleteMojiaReceiptEvidence(0L, 51L, 41L, 31L);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user