贴标申请,仓储转运
This commit is contained in:
@@ -31,6 +31,7 @@ enum BusinessFileCategory {
|
||||
CONTAINER_DELIVERY_ORDER(false, FormatPolicy.STANDARD, Limits.STANDARD, BusinessIdPolicy.POSITIVE_LONG),
|
||||
CONTAINER_PICKUP_ORDER(false, FormatPolicy.STANDARD, Limits.STANDARD, BusinessIdPolicy.POSITIVE_LONG),
|
||||
OVERSEAS_UNLOAD_PHOTO(false, FormatPolicy.STANDARD, Limits.STANDARD, BusinessIdPolicy.POSITIVE_LONG),
|
||||
OVERSEAS_CARGO_DISCARD_PHOTO(true, FormatPolicy.IMAGE, Limits.STANDARD, BusinessIdPolicy.POSITIVE_LONG),
|
||||
OVERSEAS_RELABEL_PHOTO(true, FormatPolicy.STANDARD, Limits.STANDARD, BusinessIdPolicy.POSITIVE_LONG),
|
||||
OVERSEAS_TRANSFER_MEASUREMENT_PHOTO(true, FormatPolicy.STANDARD, Limits.STANDARD, BusinessIdPolicy.POSITIVE_LONG),
|
||||
OVERSEAS_RELABEL_TOTAL_DOCUMENT(true, FormatPolicy.PDF, Limits.STANDARD, BusinessIdPolicy.POSITIVE_LONG),
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: Cargo discard photo storage ownership contract
|
||||
version: 1.0.0
|
||||
description: >-
|
||||
Uses the existing internal business-file upload, metadata and content endpoints, protected
|
||||
by X-Internal-Service-Token. businessType is OVERSEAS_CARGO_DISCARD_PHOTO; tenantId is a
|
||||
positive customer ID and businessId is the positive cargo discard application ID.
|
||||
File enforces composite ownership and non-empty JPG/PNG bytes with image signature and
|
||||
10 MiB limit. Lastleg owns the pallet binding, submitted visibility and immutable confirmation.
|
||||
No anonymous or public file endpoint is introduced.
|
||||
paths: {}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.baiyue.file.service;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import java.nio.file.Path;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
class CargoDiscardPhotoStorageTest {
|
||||
@TempDir Path root;
|
||||
@Test void discardEvidenceIsCustomerOwnedAndRequiresRealImageSignature() throws Exception {
|
||||
var category = BusinessFileCategory.require("OVERSEAS_CARGO_DISCARD_PHOTO");
|
||||
category.validateOwner(7);
|
||||
assertThatThrownBy(() -> category.validateOwner(0)).isInstanceOf(com.baiyue.common.core.exception.BizException.class);
|
||||
assertThatThrownBy(() -> category.storageBusinessId("0")).isInstanceOf(com.baiyue.common.core.exception.BizException.class);
|
||||
var storage = new BusinessFileStorage(); ReflectionTestUtils.setField(storage, "configuredRoot", root); storage.initializeRoot();
|
||||
byte[] bytes = {(byte)0x89, 0x50, 0x4e, 0x47, 13, 10, 26, 10};
|
||||
var result = storage.store(7, "11", new MockMultipartFile("file", "discard.png", "image/png", bytes), category);
|
||||
assertThat(storage.read(result.objectKey())).isEqualTo(bytes);
|
||||
assertThatThrownBy(() -> storage.store(7, "11", new MockMultipartFile("file", "fake.png", "image/png", "fake".getBytes()), category)).hasMessageContaining("不是有效图片");
|
||||
assertThatThrownBy(() -> storage.store(7, "11", new MockMultipartFile("file", "doc.pdf", "application/pdf", "%PDF-test".getBytes()), category)).hasMessageContaining("仅支持JPG");
|
||||
assertThatThrownBy(() -> storage.store(7, "11", new MockMultipartFile("file", "large.png", "image/png", new byte[10*1024*1024+1]), category)).isInstanceOf(com.baiyue.common.core.exception.BizException.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user