客户照片上传功能
This commit is contained in:
40
src/main/java/com/rj/dto/CustomerPhotoPreviewResult.java
Normal file
40
src/main/java/com/rj/dto/CustomerPhotoPreviewResult.java
Normal 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);
|
||||
}
|
||||
}
|
||||
34
src/main/java/com/rj/dto/CustomerPhotoUploadResult.java
Normal file
34
src/main/java/com/rj/dto/CustomerPhotoUploadResult.java
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user