mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
完成 do 模板的生成
This commit is contained in:
parent
6c5c32c845
commit
528d2a9bca
@ -1,27 +0,0 @@
|
||||
package cn.iocoder.dashboard.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 通用状态枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum OldCommonStatusEnum {
|
||||
|
||||
ENABLE("0", "开启"),
|
||||
DISABLE("1", "关闭");
|
||||
|
||||
/**
|
||||
* 状态值
|
||||
*/
|
||||
private final String status;
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
}
|
@ -50,6 +50,10 @@ public class ToolCodegenBuilder {
|
||||
.put("content", ToolCodegenColumnHtmlTypeEnum.EDITOR)
|
||||
.build();
|
||||
|
||||
/**
|
||||
* {@link BaseDO} 的字段
|
||||
*/
|
||||
public static final Set<String> BASE_DO_FIELDS = new HashSet<>();
|
||||
/**
|
||||
* 新增操作,不需要传递的字段
|
||||
*/
|
||||
@ -82,14 +86,13 @@ public class ToolCodegenBuilder {
|
||||
.build();
|
||||
|
||||
static {
|
||||
Arrays.stream(BaseDO.class.getDeclaredFields()).forEach(field -> BASE_DO_FIELDS.add(field.getName()));
|
||||
// 处理 OPERATION 相关的字段
|
||||
Arrays.stream(BaseDO.class.getDeclaredFields()).forEach(field -> {
|
||||
CREATE_OPERATION_EXCLUDE_COLUMN.add(field.getName());
|
||||
UPDATE_OPERATION_EXCLUDE_COLUMN.add(field.getName());
|
||||
LIST_OPERATION_EXCLUDE_COLUMN.add(field.getName());
|
||||
LIST_OPERATION_RESULT_EXCLUDE_COLUMN.add(field.getName());
|
||||
});
|
||||
CREATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS);
|
||||
UPDATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS);
|
||||
LIST_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS);
|
||||
LIST_OPERATION_EXCLUDE_COLUMN.remove("create_time"); // 创建时间,还是可能需要传递的
|
||||
LIST_OPERATION_RESULT_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS);
|
||||
LIST_OPERATION_RESULT_EXCLUDE_COLUMN.remove("create_time"); // 创建时间,还是需要返回的
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package cn.iocoder.dashboard.modules.tool.service.codegen.impl;
|
||||
import cn.hutool.extra.template.TemplateConfig;
|
||||
import cn.hutool.extra.template.TemplateEngine;
|
||||
import cn.hutool.extra.template.TemplateUtil;
|
||||
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenColumnDO;
|
||||
import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenTableDO;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -37,6 +38,10 @@ public class ToolCodegenEngine {
|
||||
Map<String, Object> bindingMap = new HashMap<>();
|
||||
bindingMap.put("table", table);
|
||||
bindingMap.put("columns", columns);
|
||||
bindingMap.put("basePackage", "cn.iocoder.dashboard.modules"); // TODO 基础包
|
||||
// DO 类,独有字段
|
||||
bindingMap.put("baseDOFields", ToolCodegenBuilder.BASE_DO_FIELDS);
|
||||
bindingMap.put("baseDOClassName", BaseDO.class.getName());
|
||||
String result = templateEngine.getTemplate("codegen/dal/do.vm").render(bindingMap);
|
||||
System.out.println(result);
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ spring:
|
||||
write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳
|
||||
fail-on-empty-beans: false # 允许序列化无属性的 Bean
|
||||
|
||||
main:
|
||||
lazy-initialization: true # TODO 芋艿:本地开发环境,可以配置下 lazy 延迟加载
|
||||
|
||||
# 芋道配置项,设置当前项目所有自定义的配置
|
||||
yudao:
|
||||
version: 1.0.0
|
||||
@ -79,7 +82,7 @@ apollo:
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印日志
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印日志
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: auto # 自增 ID
|
||||
|
@ -1,9 +1,14 @@
|
||||
package ${basePackage}.${table.moduleName}.dal.mysql.dataobject.${table.businessName};
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import ${baseDOClassName};
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* ${table.description}
|
||||
* ${table.classComment} DO
|
||||
*
|
||||
* @author ${table.author}
|
||||
*/
|
||||
@TableName("${table.tableName}")
|
||||
@Data
|
||||
@ -12,19 +17,24 @@ import java.util.*;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ${table.tableName}DO extends BaseDO {
|
||||
public class ${table.className}DO extends BaseDO {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段
|
||||
/**
|
||||
* ${column.columnComment}
|
||||
*/
|
||||
#if(${column.primaryKey} && ${column.javaType} != 'String')
|
||||
#if ($column.dictType != "")##处理枚举值
|
||||
// TODO 枚举 ${column.dictType}
|
||||
#end
|
||||
#if (${column.primaryKey} && ${column.javaType} != 'String')##处理主键 + 非 String 的情况
|
||||
@TableId
|
||||
#end
|
||||
#if(${column.primaryKey} && ${column.javaType} == 'String')
|
||||
#if (${column.primaryKey} && ${column.javaType} == 'String')##处理主键 + String 的情况
|
||||
@TableId(type = IdType.INPUT)
|
||||
#end
|
||||
private ${column.javaType} ${column.javaField};
|
||||
#end
|
||||
#end
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user