1. 修复非永久地址的改动导致无法正常获取用户头像的 bug

2. 修复代码生成器执行同步时,没有依据导入进行简写匹配转化
This commit is contained in:
chenbowen
2025-10-27 09:55:15 +08:00
parent 6e4cc4d55e
commit 4346299a03
15 changed files with 109 additions and 24 deletions

View File

@@ -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();

View File

@@ -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);
}

View File

@@ -39,7 +39,7 @@ public interface CodegenService {
*
* @param tableId 表编号
*/
void syncCodegenFromDB(Long tableId);
void syncCodegenFromDB(Long tableId, Boolean isStandardized);
/**
* 删除数据库的表和字段定义

View File

@@ -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);
}

View File

@@ -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());