解决现有 vo、do、mapper 的问题
parent
13f37ce0cc
commit
fade9bce32
|
@ -10,8 +10,10 @@ import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX;
|
|||
import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenColumnDO;
|
||||
import cn.iocoder.dashboard.modules.tool.dal.mysql.dataobject.codegen.ToolCodegenTableDO;
|
||||
import cn.iocoder.dashboard.util.date.DateUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -49,9 +51,10 @@ public class ToolCodegenEngine {
|
|||
// 全局配置
|
||||
globalBindingMap.put("basePackage", "cn.iocoder.dashboard.modules"); // TODO 基础包
|
||||
// 全局 Java Bean
|
||||
globalBindingMap.put("pageResultClassName", PageResult.class.getName());
|
||||
globalBindingMap.put("PageResultClassName", PageResult.class.getName());
|
||||
globalBindingMap.put("DateUtilsClassName", DateUtils.class.getName());
|
||||
// VO 类,独有字段
|
||||
globalBindingMap.put("pageParamClassName", PageParam.class.getName());
|
||||
globalBindingMap.put("PageParamClassName", PageParam.class.getName());
|
||||
// DO 类,独有字段
|
||||
globalBindingMap.put("baseDOFields", ToolCodegenBuilder.BASE_DO_FIELDS);
|
||||
globalBindingMap.put("baseDOClassName", BaseDO.class.getName());
|
||||
|
@ -64,6 +67,8 @@ public class ToolCodegenEngine {
|
|||
Map<String, Object> bindingMap = new HashMap<>();
|
||||
bindingMap.put("table", table);
|
||||
bindingMap.put("columns", columns);
|
||||
bindingMap.put("hasDateColumn", columns.stream().anyMatch(codegenColumnDO ->
|
||||
codegenColumnDO.getJavaType().equals(Date.class.getSimpleName())));
|
||||
bindingMap.putAll(globalBindingMap);
|
||||
// 执行生成
|
||||
// String result = templateEngine.getTemplate("codegen/dal/do.vm").render(bindingMap);
|
||||
|
|
|
@ -2,9 +2,13 @@ package ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo;
|
|||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import io.swagger.annotations.*;
|
||||
import ${pageParamClassName};
|
||||
import ${PageParamClassName};
|
||||
#if (${hasDateColumn})
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
#end
|
||||
|
||||
@ApiModel("${table.classComment}分页 Request VO")
|
||||
@Data
|
||||
|
@ -18,7 +22,7 @@ public class ${table.className}PageReqVO extends PageParam {
|
|||
#foreach ($column in $columns)
|
||||
#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写
|
||||
#if (${column.listOperation})##查询操作
|
||||
#if (${column.listOperationCondition} == "BETWEEN")## Between 的时候
|
||||
#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候
|
||||
@ApiModelProperty(value = "开始${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
#if (${column.javaType} == "Date")## 时间类型
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
|
@ -30,7 +34,7 @@ public class ${table.className}PageReqVO extends PageParam {
|
|||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
#end
|
||||
private ${column.javaType} end${JavaField};
|
||||
#else
|
||||
#else##情况二,非 Between 的时间
|
||||
#if (${column.javaType} == "Date")## 时间类型
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
#end
|
||||
|
|
|
@ -3,7 +3,7 @@ package ${basePackage}.${table.moduleName}.dal.mysql.dataobject.${table.business
|
|||
import lombok.*;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import ${baseDOClassName};
|
||||
import ${BaseDOClassName};
|
||||
|
||||
/**
|
||||
* ${table.classComment} DO
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ${basePackage}.${table.moduleName}.dal.mysql.dao.${table.businessName};
|
||||
|
||||
import ${pageResultClassName};
|
||||
import ${PageResultClassName};
|
||||
import ${QueryWrapperClassName};
|
||||
import ${BaseMapperClassName};
|
||||
import ${basePackage}.${table.moduleName}.dal.mysql.dataobject.${table.businessName}.${table.className}DO;
|
||||
|
|
Loading…
Reference in New Issue