parent
18b6dfa068
commit
13f37ce0cc
|
@ -22,11 +22,11 @@ public class InfConfigExportReqVO {
|
|||
@ApiModelProperty(value = "参数类型", example = "1", notes = "参见 SysConfigTypeEnum 枚举")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "开始时间", example = "2020-10-24")
|
||||
@ApiModelProperty(value = "开始时间", example = "2020-10-24 00:00:00")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date beginTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间", example = "2020-10-24")
|
||||
@ApiModelProperty(value = "结束时间", example = "2020-10-24 23:59:59")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date endTime;
|
||||
|
||||
|
|
|
@ -25,11 +25,11 @@ public class InfConfigPageReqVO extends PageParam {
|
|||
@ApiModelProperty(value = "参数类型", example = "1", notes = "参见 SysConfigTypeEnum 枚举")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "开始时间", example = "2020-10-24")
|
||||
@ApiModelProperty(value = "开始时间", example = "2020-10-24 00:00:00")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date beginTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间", example = "2020-10-24")
|
||||
@ApiModelProperty(value = "结束时间", example = "2020-10-24 23:59:59")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date endTime;
|
||||
|
||||
|
|
|
@ -83,6 +83,10 @@ public class ToolCodegenColumnDO extends BaseDO {
|
|||
* 关联 {@link SysDictTypeDO#getType()}
|
||||
*/
|
||||
private String dictType;
|
||||
/**
|
||||
* 数据示例,主要用于生成 Swagger 注解的 example 字段
|
||||
*/
|
||||
private String example;
|
||||
|
||||
// ========== CRUD 相关字段 ==========
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ public class ToolCodegenBuilder {
|
|||
.put("image", ToolCodegenColumnHtmlTypeEnum.UPLOAD_IMAGE)
|
||||
.put("file", ToolCodegenColumnHtmlTypeEnum.UPLOAD_FILE)
|
||||
.put("content", ToolCodegenColumnHtmlTypeEnum.EDITOR)
|
||||
.put("time", ToolCodegenColumnHtmlTypeEnum.DATETIME)
|
||||
.put("date", ToolCodegenColumnHtmlTypeEnum.DATETIME)
|
||||
.build();
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,12 +3,13 @@ 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.common.pojo.PageParam;
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
||||
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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -49,11 +50,13 @@ public class ToolCodegenEngine {
|
|||
globalBindingMap.put("basePackage", "cn.iocoder.dashboard.modules"); // TODO 基础包
|
||||
// 全局 Java Bean
|
||||
globalBindingMap.put("pageResultClassName", PageResult.class.getName());
|
||||
// VO 类,独有字段
|
||||
globalBindingMap.put("pageParamClassName", PageParam.class.getName());
|
||||
// DO 类,独有字段
|
||||
globalBindingMap.put("baseDOFields", ToolCodegenBuilder.BASE_DO_FIELDS);
|
||||
globalBindingMap.put("baseDOClassName", BaseDO.class.getName());
|
||||
globalBindingMap.put("QueryWrapperClassName", QueryWrapperX.class.getName());
|
||||
globalBindingMap.put("BaseMapperClassName", BaseMapper.class.getName());
|
||||
globalBindingMap.put("BaseMapperClassName", BaseMapperX.class.getName());
|
||||
}
|
||||
|
||||
public void execute(ToolCodegenTableDO table, List<ToolCodegenColumnDO> columns) {
|
||||
|
@ -64,7 +67,8 @@ public class ToolCodegenEngine {
|
|||
bindingMap.putAll(globalBindingMap);
|
||||
// 执行生成
|
||||
// String result = templateEngine.getTemplate("codegen/dal/do.vm").render(bindingMap);
|
||||
String result = templateEngine.getTemplate("codegen/dal/mapper.vm").render(bindingMap);
|
||||
// String result = templateEngine.getTemplate("codegen/dal/mapper.vm").render(bindingMap);
|
||||
String result = templateEngine.getTemplate("codegen/controller/vo/pageReqVO.vm").render(bindingMap);
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import java.util.*;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* ${class.description} Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/${class.classNameLowerUnderscore}")
|
||||
@Api(tags = "${class.description}")
|
||||
@Validated
|
||||
public class ${class.className}Controller {
|
||||
|
||||
@Autowired
|
||||
private ${class.className}Service ${class.classNameVar}Service;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建${class.description}")
|
||||
public CommonResult<Integer> create${class.className}(@Valid ${class.className}CreateReqVO createVO) {
|
||||
return success(${class.classNameVar}Service.create${class.className}(createVO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新${class.description}")
|
||||
public CommonResult<Boolean> update${class.className}(@Valid ${class.className}UpdateReqVO updateVO) {
|
||||
${class.classNameVar}Service.update${class.className}(updateVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除${class.description}")
|
||||
@ApiImplicitParam(name = "${class.classNameVar}Id", value = "${class.description}编号", required = true)
|
||||
public CommonResult<Boolean> delete${class.className}(@RequestParam("${class.classNameVar}Id") Integer ${class.classNameVar}Id) {
|
||||
${class.classNameVar}Service.delete${class.className}(${class.classNameVar}Id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得${class.description}")
|
||||
@ApiImplicitParam(name = "${class.classNameVar}Id", value = "${class.description}编号", required = true)
|
||||
public CommonResult<${class.className}RespVO> get${class.className}(@RequestParam("${class.classNameVar}Id") Integer ${class.classNameVar}Id) {
|
||||
return success(${class.classNameVar}Service.get${class.className}(${class.classNameVar}Id));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得${class.description}列表")
|
||||
@ApiImplicitParam(name = "${class.classNameVar}Ids", value = "${class.description}编号列表", required = true)
|
||||
public CommonResult<List<${class.className}RespVO>> list${class.className}s(@RequestParam("${class.classNameVar}Ids") List<Integer> ${class.classNameVar}Ids) {
|
||||
return success(${class.classNameVar}Service.list${class.className}s(${class.classNameVar}Ids));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得${class.description}分页")
|
||||
public CommonResult<PageResult<${class.className}RespVO>> page${class.className}(${class.className}PageReqVO pageVO) {
|
||||
return success(${class.classNameVar}Service.page${class.className}(pageVO));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import io.swagger.annotations.*;
|
||||
import ${pageParamClassName};
|
||||
|
||||
@ApiModel("${table.classComment}分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
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 的时候
|
||||
@ApiModelProperty(value = "开始${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
#if (${column.javaType} == "Date")## 时间类型
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
#end
|
||||
private ${column.javaType} begin${JavaField};
|
||||
|
||||
@ApiModelProperty(value = "结束${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
#if (${column.javaType} == "Date")## 时间类型
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
#end
|
||||
private ${column.javaType} end${JavaField};
|
||||
#else
|
||||
#if (${column.javaType} == "Date")## 时间类型
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
#end
|
||||
@ApiModelProperty(value = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
private ${column.javaType} ${column.javaField};
|
||||
#end
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package ${basePackage}.${table.moduleName}.dal.mysql.dataobject.${table.businessName};
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import ${baseDOClassName};
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import ${baseDOClassName};
|
||||
|
||||
/**
|
||||
* ${table.classComment} DO
|
||||
|
@ -24,7 +24,7 @@ public class ${table.className}DO extends BaseDO {
|
|||
/**
|
||||
* ${column.columnComment}
|
||||
*/
|
||||
#if ($column.dictType != "")##处理枚举值
|
||||
#if ("$!column.dictType" != "")##处理枚举值
|
||||
// TODO 枚举 ${column.dictType}
|
||||
#end
|
||||
#if (${column.primaryKey} && ${column.javaType} != 'String')##处理主键 + 非 String 的情况
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package ${basePackage}.${table.moduleName}.dal.mysql.dao.${table.businessName};
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import ${pageResultClassName};
|
||||
import ${QueryWrapperClassName};
|
||||
import ${BaseMapperClassName};
|
||||
import ${basePackage}.${table.moduleName}.dal.mysql.dataobject.${table.businessName}DO;
|
||||
import ${basePackage}.${table.moduleName}.dal.mysql.dataobject.${table.businessName}.${table.className}DO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
|
@ -17,22 +15,25 @@ public interface ${table.className}Mapper extends BaseMapperX<${table.className}
|
|||
#if (${column.listOperation})
|
||||
#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写
|
||||
#if (${column.listOperationCondition} == "=")##情况一,= 的时候
|
||||
.eqIfPresent("${column.column_name}", reqVO.get${JavaField}())
|
||||
.eqIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == "!=")##情况二,!= 的时候
|
||||
.neIfPresent("${column.column_name}", reqVO.get${JavaField}())
|
||||
.neIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == ">")##情况三,> 的时候
|
||||
.gtIfPresent("${column.column_name}", reqVO.get${JavaField}())
|
||||
.gtIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == ">=")##情况四,>= 的时候
|
||||
.geIfPresent("${column.column_name}", reqVO.get${JavaField}())
|
||||
.geIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == "<")##情况五,< 的时候
|
||||
.gtIfPresent("${column.column_name}", reqVO.get${JavaField}())
|
||||
.gtIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == "<=")##情况六,<= 的时候
|
||||
.geIfPresent("${column.column_name}", reqVO.get${JavaField}())
|
||||
#if (${column.listOperationCondition} == "LIKE")##情况七,Like 的时候
|
||||
.likeIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == "BETWEEN")##情况八,Between 的时候
|
||||
.betweenIfPresent("${column.columnName}", reqVO.getBegin${JavaField}(), reqVO.getEnd${JavaField}())
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
|
Loading…
Reference in New Issue