客户照片上传功能

This commit is contained in:
2026-05-02 21:01:07 +08:00
parent b2547dce1e
commit 9b791fabd1
5 changed files with 328 additions and 44 deletions

View File

@@ -0,0 +1,40 @@
package com.rj.dto;
import lombok.Getter;
import java.io.InputStream;
/**
* 客户照片预览:从 MinIO 打开流的结果。
*/
@Getter
public class CustomerPhotoPreviewResult {
public enum Status {
OK,
NOT_FOUND,
BAD_REQUEST
}
private final Status status;
private final InputStream inputStream;
private final String contentType;
private CustomerPhotoPreviewResult(Status status, InputStream inputStream, String contentType) {
this.status = status;
this.inputStream = inputStream;
this.contentType = contentType;
}
public static CustomerPhotoPreviewResult ok(InputStream inputStream, String contentType) {
return new CustomerPhotoPreviewResult(Status.OK, inputStream, contentType);
}
public static CustomerPhotoPreviewResult notFound() {
return new CustomerPhotoPreviewResult(Status.NOT_FOUND, null, null);
}
public static CustomerPhotoPreviewResult badRequest() {
return new CustomerPhotoPreviewResult(Status.BAD_REQUEST, null, null);
}
}

View File

@@ -0,0 +1,34 @@
package com.rj.dto;
import lombok.Getter;
/**
* 客户照片上传至 MinIO 的结果,供控制器映射 HTTP 状态与 JSON。
*/
@Getter
public class CustomerPhotoUploadResult {
private final int httpStatus;
private final boolean success;
private final String message;
private final String url;
private CustomerPhotoUploadResult(int httpStatus, boolean success, String message, String url) {
this.httpStatus = httpStatus;
this.success = success;
this.message = message;
this.url = url;
}
public static CustomerPhotoUploadResult ok(String url) {
return new CustomerPhotoUploadResult(200, true, "上传成功", url);
}
public static CustomerPhotoUploadResult badRequest(String message) {
return new CustomerPhotoUploadResult(400, false, message, null);
}
public static CustomerPhotoUploadResult serverError(String message) {
return new CustomerPhotoUploadResult(500, false, message, null);
}
}