1. 实现集中式的附件统一管理,统一上传统一预览(代码生成器,公共组件,公共附件元数据定义)

2. 实现统一的 DB 字段数据库定义(代码生成器,共用规范检查)
This commit is contained in:
chenbowen
2025-08-01 08:47:13 +08:00
parent 4479c3c0b7
commit c2195ee3cf
63 changed files with 1674 additions and 351 deletions

View File

@@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.infra.api.businessfile;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.infra.api.businessfile.dto.BusinessFileSaveReqDTO;
import cn.iocoder.yudao.module.infra.controller.admin.businessfile.vo.BusinessFileSaveReqVO;
import cn.iocoder.yudao.module.infra.service.businessfile.BusinessFileService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* 业务附件关联 API 实现
* @author chenbowen
*/
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
public class BusinessFileApiImpl implements BusinessFileApi {
@Resource
private BusinessFileService businessFileService;
@Override
public CommonResult<List<Long>> batchCreateBusinessFile(List<BusinessFileSaveReqDTO> createReqDTOList) {
List<BusinessFileSaveReqVO> createReqVOList = BeanUtils.toBean(createReqDTOList, BusinessFileSaveReqVO.class);
List<Long> ids = businessFileService.batchCreateBusinessFile(createReqVOList);
return success(ids);
}
}

View File

@@ -0,0 +1,59 @@
package cn.iocoder.yudao.module.infra.api.stdnms;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.infra.api.stdnms.dto.StdNmsRespDTO;
import cn.iocoder.yudao.module.infra.dal.dataobject.stdnms.stdnms.StdNmsDO;
import cn.iocoder.yudao.module.infra.stdnms.StdNmsService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* 数据命名与简写标准 API 实现
*
* @author 后台管理
*/
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
public class StdNmsApiImpl implements StdNmsApi {
@Resource
private StdNmsService stdNmsService;
@Override
public CommonResult<Boolean> deleteStdNms(Long id) {
stdNmsService.deleteStdNms(id);
return success(true);
}
@Override
public CommonResult<Boolean> deleteStdNmsList(List<Long> ids) {
stdNmsService.deleteStdNmsListByIds(ids);
return success(true);
}
@Override
public CommonResult<StdNmsRespDTO> getStdNms(Long id) {
StdNmsDO stdNms = stdNmsService.getStdNms(id);
return success(BeanUtils.toBean(stdNms, StdNmsRespDTO.class));
}
@Override
public CommonResult<StdNmsRespDTO> getStdNmsByAbbr(String abbr) {
StdNmsDO stdNms = stdNmsService.getStdNmsByAbbr(abbr);
return success(BeanUtils.toBean(stdNms, StdNmsRespDTO.class));
}
@Override
public CommonResult<List<StdNmsRespDTO>> getStdNmsListByAbbrs(Collection<String> abbrs) {
List<StdNmsDO> stdNmsList = stdNmsService.getStdNmsListByAbbrs(abbrs);
return success(BeanUtils.toBean(stdNmsList, StdNmsRespDTO.class));
}
}

View File

@@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.infra.controller.admin.businessfile.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 业务附件关联分页 Request VO")
@Data
public class BusinessFilePageReqVO extends PageParam {
@Schema(description = "业务Id", example = "24322")
private Long businessId;
@Schema(description = "业务编码")
private String businessCode;
@Schema(description = "附件fileId", example = "10125")
private Long fileId;
@Schema(description = "附件名称", example = "李四")
private String fileName;
@Schema(description = "附件来源")
private String source;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.infra.controller.admin.businessfile.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 业务附件关联 Response VO")
@Data
@ExcelIgnoreUnannotated
public class BusinessFileRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29216")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "业务Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "24322")
@ExcelProperty("业务Id")
private Long businessId;
@Schema(description = "业务编码")
@ExcelProperty("业务编码")
private String businessCode;
@Schema(description = "附件fileId", requiredMode = Schema.RequiredMode.REQUIRED, example = "10125")
@ExcelProperty("附件fileId")
private Long fileId;
@Schema(description = "附件名称", example = "李四")
@ExcelProperty("附件名称")
private String fileName;
@Schema(description = "附件来源")
@ExcelProperty("附件来源")
private String source;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,25 @@
package cn.iocoder.yudao.module.infra.controller.admin.businessfile.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 业务附件关联新增/修改 Request VO")
@Data
public class BusinessFileSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29216")
private Long id;
@Schema(description = "附件Id", example = "李四")
private Long fileId;
@Schema(description = "业务Id", example = "李四")
private Long businessId;
@Schema(description = "附件名称", example = "李四")
private String fileName;
@Schema(description = "附件来源")
private String source;
}

View File

@@ -126,12 +126,17 @@ public class CodegenController {
@GetMapping("/preview")
@Parameters({
@Parameter(name = "tableId", description = "表编号", required = true, example = "1024"),
@Parameter(name = "isBusiness", description = "是否业务基类", example = "false")
@Parameter(name = "isBusiness", description = "是否业务基类", example = "false"),
@Parameter(name = "isStandardized", description = "是否标准化", example = "false"),
@Parameter(name = "isFileUpload", description = "是否包含附件上传能力", example = "false")
})
@PreAuthorize("@ss.hasPermission('infra:codegen:preview')")
public CommonResult<List<CodegenPreviewRespVO>> previewCodegen(@RequestParam("tableId") Long tableId,
@RequestParam(value = "isBusiness", required = false, defaultValue = "false") Boolean isBusiness) {
Map<String, String> codes = codegenService.generationCodes(tableId, isBusiness);
public CommonResult<List<CodegenPreviewRespVO>> previewCodegen(
@RequestParam("tableId") Long tableId,
@RequestParam(value = "isBusiness", required = false, defaultValue = "false") Boolean isBusiness,
@RequestParam(value = "isStandardized", required = false, defaultValue = "false") Boolean isStandardized,
@RequestParam(value = "isFileUpload", required = false, defaultValue = "false") Boolean isFileUpload) {
Map<String, String> codes = codegenService.generationCodes(tableId, isBusiness, isStandardized, isFileUpload);
return success(CodegenConvert.INSTANCE.convert(codes));
}
@@ -139,14 +144,19 @@ public class CodegenController {
@GetMapping("/download")
@Parameters({
@Parameter(name = "tableId", description = "表编号", required = true, example = "1024"),
@Parameter(name = "isBusiness", description = "是否业务基类", example = "false")
@Parameter(name = "isBusiness", description = "是否业务基类", example = "false"),
@Parameter(name = "isStandardized", description = "是否标准化", example = "false"),
@Parameter(name = "isFileUpload", description = "是否包含附件上传能力", example = "false")
})
@PreAuthorize("@ss.hasPermission('infra:codegen:download')")
public void downloadCodegen(@RequestParam("tableId") Long tableId,
@RequestParam(value = "isBusiness", required = false, defaultValue = "false") Boolean isBusiness,
HttpServletResponse response) throws IOException {
// 生成代码,传递 isBusiness
Map<String, String> codes = codegenService.generationCodes(tableId, isBusiness);
public void downloadCodegen(
@RequestParam("tableId") Long tableId,
@RequestParam(value = "isBusiness", required = false, defaultValue = "false") Boolean isBusiness,
@RequestParam(value = "isStandardized", required = false, defaultValue = "false") Boolean isStandardized,
@RequestParam(value = "isFileUpload", required = false, defaultValue = "false") Boolean isFileUpload,
HttpServletResponse response) throws IOException {
// 生成代码,传递 isBusiness、isStandardized、isFileUpload
Map<String, String> codes = codegenService.generationCodes(tableId, isBusiness, isStandardized, isFileUpload);
// 构建 zip 包
String[] paths = codes.keySet().toArray(new String[0]);
ByteArrayInputStream[] ins = codes.values().stream().map(IoUtil::toUtf8Stream).toArray(ByteArrayInputStream[]::new);

View File

@@ -76,7 +76,7 @@ public class FileRespVO {
if (presignedUrl == null || presignedUrl.isEmpty()) {
return null;
}
String base64PresignedUrl = Base64.getUrlEncoder().encodeToString(presignedUrl.getBytes(StandardCharsets.UTF_8));
String base64PresignedUrl = Base64.getEncoder().encodeToString(presignedUrl.getBytes(StandardCharsets.UTF_8));
String timestamp = String.valueOf(System.currentTimeMillis());
String watermark = SpringUtils.getProperty("aj.captcha.water-mark", "中国铜业");
return onlinePreview + base64PresignedUrl + "&t=" + timestamp + "&watermarkTxt=" + watermark;

View File

@@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.infra.controller.admin.stdnms.stdnms.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 数据命名与简写标准分页 Request VO")
@Data
public class StdNmsPageReqVO extends PageParam {
@Schema(description = "英文")
private String word;
@Schema(description = "简写")
private String abbr;
@Schema(description = "中文意思")
private String info;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

Some files were not shown because too many files have changed in this diff Show More