feat:【INFRA 基础设施】代码生成时,支持配置 VO/DO 模式
This commit is contained in:
@@ -12,6 +12,18 @@ import java.time.LocalDateTime;
|
||||
#end
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import ${BaseDOClassName};
|
||||
## 处理 Excel 导出 + Schema 注解(仅 DO 模式)
|
||||
#if ($voType == 20)
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
#foreach ($column in $columns)
|
||||
#if ("$!column.dictType" != "")## 有设置数据字典
|
||||
import ${DictFormatClassName};
|
||||
import ${DictConvertClassName};
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${table.classComment} DO
|
||||
@@ -26,6 +38,11 @@ import ${BaseDOClassName};
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
## 处理 Excel 导出 + Schema 注解(仅 DO 模式)
|
||||
#if ($voType == 20)
|
||||
@Schema(description = "${sceneEnum.name} - ${table.classComment} Response VO")
|
||||
@ExcelIgnoreUnannotated
|
||||
#end
|
||||
public class ${table.className}DO extends BaseDO {
|
||||
|
||||
## 特殊:树表专属逻辑
|
||||
@@ -45,6 +62,18 @@ public class ${table.className}DO extends BaseDO {
|
||||
#if (${column.primaryKey})##处理主键
|
||||
@TableId#if (${column.javaType} == 'String')(type = IdType.INPUT)#end
|
||||
#end
|
||||
#if ($voType == 20)
|
||||
## 1. 处理 Swagger 注解
|
||||
@Schema(description = "${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
## 2. 处理 Excel 导出
|
||||
#if ("$!column.dictType" != "")##处理枚举值
|
||||
@ExcelProperty(value = "${column.columnComment}", converter = DictConvert.class)
|
||||
@DictFormat("${column.dictType}") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
#else
|
||||
@ExcelProperty("${column.columnComment}")
|
||||
#end
|
||||
#end
|
||||
## 3. 处理字段定义
|
||||
private ${column.javaType} ${column.javaField};
|
||||
#end
|
||||
#end
|
||||
|
Reference in New Issue
Block a user