1. 修复非永久地址的改动导致无法正常获取用户头像的 bug
2. 修复代码生成器执行同步时,没有依据导入进行简写匹配转化
This commit is contained in:
@@ -43,6 +43,11 @@ public interface FileApi {
|
||||
CommonResult<FileRespDTO> getFile(@Parameter(description = "文件编号", required = true, example = "1024")
|
||||
@RequestParam("fileId") @NotNull(message = "文件编号不能为空") Long fileId);
|
||||
|
||||
@GetMapping(PREFIX + "/info")
|
||||
@Operation(summary = "根据文件编号获取文件信息")
|
||||
CommonResult<FileRespDTO> getFileInfo(@Parameter(description = "文件编号", required = true, example = "1024")
|
||||
@RequestParam("fileId") @NotNull(message = "文件编号不能为空") Long fileId);
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
|
||||
@@ -16,6 +16,15 @@ public class FileRespDTO {
|
||||
@Schema(description = "文件目录", example = "xxx")
|
||||
private String directory;
|
||||
|
||||
@Schema(description = "文件访问地址", example = "https://www.iocoder.cn/xxx.png")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "文件预览地址", example = "https://www.iocoder.cn/preview/xxx")
|
||||
private String previewUrl;
|
||||
|
||||
@Schema(description = "是否加密", example = "false")
|
||||
private Boolean encrypted;
|
||||
|
||||
@Schema(description = "文件的 MIME 类型", example = "image/png")
|
||||
private String type;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zt.plat.module.infra.api.file;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
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.controller.admin.file.vo.file.FileRespVO;
|
||||
@@ -76,6 +77,20 @@ public class FileApiImpl implements FileApi {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<FileRespDTO> getFileInfo(Long fileId) {
|
||||
try {
|
||||
FileDO fileDO = fileService.getActiveFileById(fileId);
|
||||
if (fileDO == null) {
|
||||
return CommonResult.error(404, "文件不存在");
|
||||
}
|
||||
FileRespDTO respDTO = convertToRespDTO(fileDO);
|
||||
return success(respDTO);
|
||||
} catch (Exception e) {
|
||||
return CommonResult.error(500, "获取文件信息失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteFile(Long fileId) {
|
||||
try {
|
||||
@@ -97,19 +112,23 @@ public class FileApiImpl implements FileApi {
|
||||
* 将 FileDO 转换为 FileRespDTO
|
||||
*/
|
||||
private FileRespDTO convertToRespDTO(FileDO fileDO) {
|
||||
FileRespVO fileRespVO = BeanUtils.toBean(fileDO, FileRespVO.class);
|
||||
FileRespDTO respDTO = new FileRespDTO();
|
||||
respDTO.setId(fileDO.getId());
|
||||
respDTO.setName(fileDO.getName());
|
||||
respDTO.setType(fileDO.getType());
|
||||
respDTO.setSize(fileDO.getSize());
|
||||
|
||||
respDTO.setUrl(fileRespVO.getUrl());
|
||||
respDTO.setPreviewUrl(fileRespVO.getPreviewUrl());
|
||||
respDTO.setEncrypted(Boolean.TRUE.equals(fileRespVO.getIsEncrypted()));
|
||||
|
||||
// 从文件路径中提取目录信息
|
||||
String path = fileDO.getPath();
|
||||
if (path != null && path.contains("/")) {
|
||||
String directory = path.substring(0, path.lastIndexOf("/"));
|
||||
respDTO.setDirectory(directory);
|
||||
}
|
||||
|
||||
|
||||
return respDTO;
|
||||
}
|
||||
|
||||
@@ -122,6 +141,9 @@ public class FileApiImpl implements FileApi {
|
||||
respDTO.setName(fileRespVO.getName());
|
||||
respDTO.setType(fileRespVO.getType());
|
||||
respDTO.setSize(fileRespVO.getSize());
|
||||
respDTO.setUrl(fileRespVO.getUrl());
|
||||
respDTO.setPreviewUrl(fileRespVO.getPreviewUrl());
|
||||
respDTO.setEncrypted(Boolean.TRUE.equals(fileRespVO.getIsEncrypted()));
|
||||
|
||||
// 从文件路径中提取目录信息
|
||||
String path = fileRespVO.getPath();
|
||||
|
||||
@@ -106,10 +106,15 @@ public class CodegenController {
|
||||
|
||||
@Operation(summary = "基于数据库的表结构,同步数据库的表和字段定义")
|
||||
@PutMapping("/sync-from-db")
|
||||
@Parameter(name = "tableId", description = "表编号", required = true, example = "1024")
|
||||
@Parameters({
|
||||
@Parameter(name = "tableId", description = "表编号", required = true, example = "1024"),
|
||||
@Parameter(name = "isStandardized", description = "是否标准化缩写字段名", example = "false")
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('infra:codegen:update')")
|
||||
public CommonResult<Boolean> syncCodegenFromDB(@RequestParam("tableId") Long tableId) {
|
||||
codegenService.syncCodegenFromDB(tableId);
|
||||
public CommonResult<Boolean> syncCodegenFromDB(
|
||||
@RequestParam("tableId") Long tableId,
|
||||
@RequestParam(value = "isStandardized", required = false, defaultValue = "false") Boolean isStandardized) {
|
||||
codegenService.syncCodegenFromDB(tableId, isStandardized);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public interface CodegenService {
|
||||
*
|
||||
* @param tableId 表编号
|
||||
*/
|
||||
void syncCodegenFromDB(Long tableId);
|
||||
void syncCodegenFromDB(Long tableId, Boolean isStandardized);
|
||||
|
||||
/**
|
||||
* 删除数据库的表和字段定义
|
||||
|
||||
@@ -148,14 +148,14 @@ public class CodegenServiceImpl implements CodegenService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncCodegenFromDB(Long tableId) {
|
||||
public void syncCodegenFromDB(Long tableId, Boolean isStandardized) {
|
||||
// 校验是否已经存在
|
||||
CodegenTableDO table = codegenTableMapper.selectById(tableId);
|
||||
if (table == null) {
|
||||
throw exception(CODEGEN_TABLE_NOT_EXISTS);
|
||||
}
|
||||
// 从数据库中,获得数据库表结构
|
||||
TableInfo tableInfo = databaseTableService.getTable(table.getDataSourceConfigId(), table.getTableName(),false);
|
||||
TableInfo tableInfo = databaseTableService.getTable(table.getDataSourceConfigId(), table.getTableName(), Boolean.TRUE.equals(isStandardized));
|
||||
// 执行同步
|
||||
syncCodegen0(tableId, tableInfo);
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
||||
}))).thenReturn(newColumns);
|
||||
|
||||
// 调用
|
||||
codegenService.syncCodegenFromDB(tableId);
|
||||
codegenService.syncCodegenFromDB(tableId, false);
|
||||
// 断言
|
||||
List<CodegenColumnDO> dbColumns = codegenColumnMapper.selectList();
|
||||
assertEquals(newColumns.size(), dbColumns.size());
|
||||
|
||||
Reference in New Issue
Block a user