Merge remote-tracking branch 'base-version/main' into test
# Conflicts: # pom.xml # zt-dependencies/pom.xml
This commit is contained in:
@@ -67,4 +67,19 @@ public interface BusinessFileApi {
|
||||
CommonResult<Boolean> deleteBusinessFileByBusinessIdAndSource(@RequestParam("businessId") Long businessId,
|
||||
@RequestParam("source") String source);
|
||||
|
||||
@PutMapping(PREFIX + "/enable")
|
||||
@Operation(summary = "启用业务附件关联")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
CommonResult<Boolean> enableBusinessFile(@RequestParam("id") Long id);
|
||||
|
||||
@PutMapping(PREFIX + "/disable")
|
||||
@Operation(summary = "禁用业务附件关联")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
CommonResult<Boolean> disableBusinessFile(@RequestParam("id") Long id);
|
||||
|
||||
@PutMapping(PREFIX + "/update-status")
|
||||
@Operation(summary = "批量更新业务附件状态")
|
||||
CommonResult<Boolean> updateBusinessFileStatus(@RequestParam("ids") List<Long> ids,
|
||||
@RequestParam("status") Integer status);
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,11 @@ public class BusinessFilePageReqDTO extends PageParam implements Serializable {
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 状态(1-正常,0-禁用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
@@ -49,6 +49,11 @@ public class BusinessFileRespDTO implements Serializable {
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 状态(1-正常,0-禁用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
@@ -25,5 +25,7 @@ public class BusinessFileSaveReqDTO implements Serializable {
|
||||
private Long fileId;
|
||||
/** 业务来源 */
|
||||
private String source;
|
||||
/** 状态(1-正常,0-禁用) */
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,18 @@ package com.zt.plat.module.infra.api.file;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileCreateReqDTO;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileRespDTO;
|
||||
import com.zt.plat.module.infra.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 文件")
|
||||
@@ -17,43 +21,19 @@ public interface FileApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/file";
|
||||
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(byte[] content) {
|
||||
return createFile(content, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param content 文件内容
|
||||
* @param name 文件名称,允许空
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(byte[] content, String name) {
|
||||
return createFile(content, name, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param content 文件内容
|
||||
* @param name 文件名称,允许空
|
||||
* @param directory 目录,允许空
|
||||
* @param type 文件的 MIME 类型,允许空
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(@NotEmpty(message = "文件内容不能为空") byte[] content,
|
||||
String name, String directory, String type) {
|
||||
return createFile(new FileCreateReqDTO().setName(name).setDirectory(directory).setType(type).setContent(content)).getCheckedData();
|
||||
}
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
@Operation(summary = "保存文件,并返回文件的访问路径")
|
||||
CommonResult<String> createFile(@Valid @RequestBody FileCreateReqDTO createReqDTO);
|
||||
|
||||
/**
|
||||
* 根据文件编号获取文件信息和二进制内容
|
||||
*
|
||||
* @param fileId 文件编号
|
||||
* @return 文件信息,包含二进制数据
|
||||
*/
|
||||
@GetMapping(PREFIX + "/get")
|
||||
@Operation(summary = "根据文件编号获取文件信息和二进制内容")
|
||||
CommonResult<FileRespDTO> getFile(@Parameter(description = "文件编号", required = true, example = "1024")
|
||||
@RequestParam("fileId") @NotNull(message = "文件编号不能为空") Long fileId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.zt.plat.module.infra.api.file.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "RPC 服务 - 文件信息 Response DTO")
|
||||
@Data
|
||||
public class FileRespDTO {
|
||||
|
||||
@Schema(description = "文件编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "原文件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "xxx.png")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "文件目录", example = "xxx")
|
||||
private String directory;
|
||||
|
||||
@Schema(description = "文件的 MIME 类型", example = "image/png")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "文件大小", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer size;
|
||||
|
||||
@Schema(description = "文件内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private byte[] content;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.zt.plat.module.infra.enums.businessfile;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 业务附件状态枚举
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum BusinessFileStatusEnum {
|
||||
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
NORMAL(1, "正常"),
|
||||
/**
|
||||
* 禁用
|
||||
*/
|
||||
DISABLED(0, "禁用");
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final Integer status;
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user