Merge remote-tracking branch 'base-version/main' into dev
This commit is contained in:
@@ -10,10 +10,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
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;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 文件")
|
||||
@@ -25,6 +22,16 @@ public interface FileApi {
|
||||
@Operation(summary = "保存文件,并返回文件的访问路径")
|
||||
CommonResult<String> createFile(@Valid @RequestBody FileCreateReqDTO createReqDTO);
|
||||
|
||||
/**
|
||||
* 创建文件并返回完整文件信息
|
||||
*
|
||||
* @param createReqDTO 文件创建请求
|
||||
* @return 文件完整信息
|
||||
*/
|
||||
@PostMapping(PREFIX + "/create-with-return")
|
||||
@Operation(summary = "创建文件并返回完整文件信息")
|
||||
CommonResult<FileRespDTO> createFileWithReturn(@Valid @RequestBody FileCreateReqDTO createReqDTO);
|
||||
|
||||
/**
|
||||
* 根据文件编号获取文件信息和二进制内容
|
||||
*
|
||||
@@ -36,4 +43,15 @@ public interface FileApi {
|
||||
CommonResult<FileRespDTO> getFile(@Parameter(description = "文件编号", required = true, example = "1024")
|
||||
@RequestParam("fileId") @NotNull(message = "文件编号不能为空") Long fileId);
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param fileId 文件编号
|
||||
* @return 删除结果
|
||||
*/
|
||||
@DeleteMapping(PREFIX + "/delete")
|
||||
@Operation(summary = "删除文件")
|
||||
CommonResult<Boolean> deleteFile(@Parameter(description = "文件编号", required = true, example = "1024")
|
||||
@RequestParam("fileId") @NotNull(message = "文件编号不能为空") Long fileId);
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.infra.controller.admin.file.vo.file.FileCreateReqVO;
|
||||
@@ -18,7 +19,6 @@ import com.zt.plat.module.infra.framework.file.core.client.FileClient;
|
||||
import com.zt.plat.module.infra.framework.file.core.client.s3.FilePresignedUrlRespDTO;
|
||||
import com.zt.plat.module.infra.framework.file.core.utils.FileTypeUtils;
|
||||
import com.zt.plat.module.infra.util.VerificationCodeUtil;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -122,7 +122,8 @@ public class FileServiceImpl implements FileService {
|
||||
@SneakyThrows
|
||||
public String createFile(byte[] content, String name, String directory, String type, Boolean encrypt) {
|
||||
FileDO entity = uploadFile(content, name, directory, type, encrypt);
|
||||
return entity.getUrl();
|
||||
FileRespVO fileRespVO = BeanUtils.toBean(entity, FileRespVO.class);
|
||||
return fileRespVO.getUrl();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
|
||||
Reference in New Issue
Block a user