1. 修复非永久地址的改动导致无法正常获取用户头像的 bug
2. 修复代码生成器执行同步时,没有依据导入进行简写匹配转化
This commit is contained in:
@@ -43,6 +43,11 @@ public interface FileApi {
|
|||||||
CommonResult<FileRespDTO> getFile(@Parameter(description = "文件编号", required = true, example = "1024")
|
CommonResult<FileRespDTO> getFile(@Parameter(description = "文件编号", required = true, example = "1024")
|
||||||
@RequestParam("fileId") @NotNull(message = "文件编号不能为空") Long fileId);
|
@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")
|
@Schema(description = "文件目录", example = "xxx")
|
||||||
private String directory;
|
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")
|
@Schema(description = "文件的 MIME 类型", example = "image/png")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.zt.plat.module.infra.api.file;
|
package com.zt.plat.module.infra.api.file;
|
||||||
|
|
||||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
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.FileCreateReqDTO;
|
||||||
import com.zt.plat.module.infra.api.file.dto.FileRespDTO;
|
import com.zt.plat.module.infra.api.file.dto.FileRespDTO;
|
||||||
import com.zt.plat.module.infra.controller.admin.file.vo.file.FileRespVO;
|
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
|
@Override
|
||||||
public CommonResult<Boolean> deleteFile(Long fileId) {
|
public CommonResult<Boolean> deleteFile(Long fileId) {
|
||||||
try {
|
try {
|
||||||
@@ -97,19 +112,23 @@ public class FileApiImpl implements FileApi {
|
|||||||
* 将 FileDO 转换为 FileRespDTO
|
* 将 FileDO 转换为 FileRespDTO
|
||||||
*/
|
*/
|
||||||
private FileRespDTO convertToRespDTO(FileDO fileDO) {
|
private FileRespDTO convertToRespDTO(FileDO fileDO) {
|
||||||
|
FileRespVO fileRespVO = BeanUtils.toBean(fileDO, FileRespVO.class);
|
||||||
FileRespDTO respDTO = new FileRespDTO();
|
FileRespDTO respDTO = new FileRespDTO();
|
||||||
respDTO.setId(fileDO.getId());
|
respDTO.setId(fileDO.getId());
|
||||||
respDTO.setName(fileDO.getName());
|
respDTO.setName(fileDO.getName());
|
||||||
respDTO.setType(fileDO.getType());
|
respDTO.setType(fileDO.getType());
|
||||||
respDTO.setSize(fileDO.getSize());
|
respDTO.setSize(fileDO.getSize());
|
||||||
|
respDTO.setUrl(fileRespVO.getUrl());
|
||||||
|
respDTO.setPreviewUrl(fileRespVO.getPreviewUrl());
|
||||||
|
respDTO.setEncrypted(Boolean.TRUE.equals(fileRespVO.getIsEncrypted()));
|
||||||
|
|
||||||
// 从文件路径中提取目录信息
|
// 从文件路径中提取目录信息
|
||||||
String path = fileDO.getPath();
|
String path = fileDO.getPath();
|
||||||
if (path != null && path.contains("/")) {
|
if (path != null && path.contains("/")) {
|
||||||
String directory = path.substring(0, path.lastIndexOf("/"));
|
String directory = path.substring(0, path.lastIndexOf("/"));
|
||||||
respDTO.setDirectory(directory);
|
respDTO.setDirectory(directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
return respDTO;
|
return respDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,6 +141,9 @@ public class FileApiImpl implements FileApi {
|
|||||||
respDTO.setName(fileRespVO.getName());
|
respDTO.setName(fileRespVO.getName());
|
||||||
respDTO.setType(fileRespVO.getType());
|
respDTO.setType(fileRespVO.getType());
|
||||||
respDTO.setSize(fileRespVO.getSize());
|
respDTO.setSize(fileRespVO.getSize());
|
||||||
|
respDTO.setUrl(fileRespVO.getUrl());
|
||||||
|
respDTO.setPreviewUrl(fileRespVO.getPreviewUrl());
|
||||||
|
respDTO.setEncrypted(Boolean.TRUE.equals(fileRespVO.getIsEncrypted()));
|
||||||
|
|
||||||
// 从文件路径中提取目录信息
|
// 从文件路径中提取目录信息
|
||||||
String path = fileRespVO.getPath();
|
String path = fileRespVO.getPath();
|
||||||
|
|||||||
@@ -106,10 +106,15 @@ public class CodegenController {
|
|||||||
|
|
||||||
@Operation(summary = "基于数据库的表结构,同步数据库的表和字段定义")
|
@Operation(summary = "基于数据库的表结构,同步数据库的表和字段定义")
|
||||||
@PutMapping("/sync-from-db")
|
@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')")
|
@PreAuthorize("@ss.hasPermission('infra:codegen:update')")
|
||||||
public CommonResult<Boolean> syncCodegenFromDB(@RequestParam("tableId") Long tableId) {
|
public CommonResult<Boolean> syncCodegenFromDB(
|
||||||
codegenService.syncCodegenFromDB(tableId);
|
@RequestParam("tableId") Long tableId,
|
||||||
|
@RequestParam(value = "isStandardized", required = false, defaultValue = "false") Boolean isStandardized) {
|
||||||
|
codegenService.syncCodegenFromDB(tableId, isStandardized);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public interface CodegenService {
|
|||||||
*
|
*
|
||||||
* @param tableId 表编号
|
* @param tableId 表编号
|
||||||
*/
|
*/
|
||||||
void syncCodegenFromDB(Long tableId);
|
void syncCodegenFromDB(Long tableId, Boolean isStandardized);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除数据库的表和字段定义
|
* 删除数据库的表和字段定义
|
||||||
|
|||||||
@@ -148,14 +148,14 @@ public class CodegenServiceImpl implements CodegenService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void syncCodegenFromDB(Long tableId) {
|
public void syncCodegenFromDB(Long tableId, Boolean isStandardized) {
|
||||||
// 校验是否已经存在
|
// 校验是否已经存在
|
||||||
CodegenTableDO table = codegenTableMapper.selectById(tableId);
|
CodegenTableDO table = codegenTableMapper.selectById(tableId);
|
||||||
if (table == null) {
|
if (table == null) {
|
||||||
throw exception(CODEGEN_TABLE_NOT_EXISTS);
|
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);
|
syncCodegen0(tableId, tableInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
|||||||
}))).thenReturn(newColumns);
|
}))).thenReturn(newColumns);
|
||||||
|
|
||||||
// 调用
|
// 调用
|
||||||
codegenService.syncCodegenFromDB(tableId);
|
codegenService.syncCodegenFromDB(tableId, false);
|
||||||
// 断言
|
// 断言
|
||||||
List<CodegenColumnDO> dbColumns = codegenColumnMapper.selectList();
|
List<CodegenColumnDO> dbColumns = codegenColumnMapper.selectList();
|
||||||
assertEquals(newColumns.size(), dbColumns.size());
|
assertEquals(newColumns.size(), dbColumns.size());
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class AuthPermissionInfoRespVO {
|
|||||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
|
||||||
@Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.jpg")
|
@Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
@Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
@Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class UserProfileRespVO {
|
|||||||
@Schema(description = "用户性别,参见 SexEnum 枚举类", example = "1")
|
@Schema(description = "用户性别,参见 SexEnum 枚举类", example = "1")
|
||||||
private Integer sex;
|
private Integer sex;
|
||||||
|
|
||||||
@Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png")
|
@Schema(description = "用户头像", example = "123456" )
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
@Schema(description = "最后登录 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "192.168.1.1")
|
@Schema(description = "最后登录 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "192.168.1.1")
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package com.zt.plat.module.system.controller.admin.user.vo.profile;
|
package com.zt.plat.module.system.controller.admin.user.vo.profile;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import jakarta.validation.constraints.Email;
|
import jakarta.validation.constraints.Email;
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import org.hibernate.validator.constraints.URL;
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 用户个人信息更新 Request VO")
|
@Schema(description = "管理后台 - 用户个人信息更新 Request VO")
|
||||||
@@ -29,8 +30,16 @@ public class UserProfileUpdateReqVO {
|
|||||||
@Schema(description = "用户性别,参见 SexEnum 枚举类", example = "1")
|
@Schema(description = "用户性别,参见 SexEnum 枚举类", example = "1")
|
||||||
private Integer sex;
|
private Integer sex;
|
||||||
|
|
||||||
@Schema(description = "角色头像", example = "https://www.iocoder.cn/1.png")
|
@Schema(description = "用户头像", example = "123456" )
|
||||||
@URL(message = "头像地址格式不正确")
|
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
private boolean avatarPresent;
|
||||||
|
|
||||||
|
@JsonSetter("avatar")
|
||||||
|
public void setAvatarValue(String avatar) {
|
||||||
|
this.avatar = avatar;
|
||||||
|
this.avatarPresent = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user