easycode使用
一.Type Mapper
varchar(\(\d+\))? java.lang.String char(\(\d+\))? java.lang.String text java.lang.String decimal(\(\d+\))? java.lang.Double decimal(\(\d+,\d+\))? java.lang.Double integer java.lang.Integer int(\(\d+\))? java.lang.Integer int4 java.lang.Integer int8 java.lang.Long bigint(\(\d+\))? java.lang.Long datetime java.util.LocalDateTime timestamp java.util.LocalDateTime boolean java.lang.Boolean smallint(\(\d+\))? java.lang.Integer tinyint java.lang.Integer double(\(\d+,\d+\))? java.math.BigDecimal date java.lang.LocalDate tinyint(\(\d+\))? java.lang.Integer longtext java.lang.String
二.Template Setting
1.controller.java
##定义初始变量 #set($tableName = $tool.append($tableInfo.name, "Controller")) ##设置回调 $!callback.setFileName($tool.append($tableName, ".java")) $!callback.setSavePath($tool.append($tableInfo.savePath, "/controller")) ##拿到主键 #if(!$tableInfo.pkColumn.isEmpty()) #set($pk = $tableInfo.pkColumn.get(0)) #end #if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}controller; import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name}; import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; /** * $!{tableInfo.comment}($!{tableInfo.name})表控制层 * * @author $!author * @since $!time.currTime() */ @RestController @RequestMapping("/api/[]/$!tool.firstLowerCase($tableInfo.name)") @Slf4j @Api(description = "$!{tableInfo.comment}($!{tableInfo.name})表控制层",value="$tableName") public class $!{tableName} { @Autowired private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service; }
2.service.java
##定义初始变量 #set($tableName = $tool.append($tableInfo.name, "Service")) ##定义初始变量 #set($tablePoName = $tool.append($tableInfo.name, "Po")) ##设置回调 $!callback.setFileName($tool.append($tableName, ".java")) $!callback.setSavePath($tool.append($tableInfo.savePath, "/service")) ##拿到主键 #if(!$tableInfo.pkColumn.isEmpty()) #set($pk = $tableInfo.pkColumn.get(0)) #end #if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service; import com.baomidou.mybatisplus.extension.service.IService; /** * $!{tableInfo.comment}($!{tableInfo.name})表服务接口 * * @author $!author * @since $!time.currTime() */ public interface $!{tableName} extends IService<$tablePoName> { }
3.serviceImpl.java
##定义初始变量 #set($tableName = $tool.append($tableInfo.name, "ServiceImpl")) ##定义初始变量 #set($tableMapperName = $tool.append($tableInfo.name, "Mapper")) ##定义初始变量 #set($tablePoName = $tool.append($tableInfo.name, "Po")) ##设置回调 $!callback.setFileName($tool.append($tableName, ".java")) $!callback.setSavePath($tool.append($tableInfo.savePath, "/service/impl")) ##拿到主键 #if(!$tableInfo.pkColumn.isEmpty()) #set($pk = $tableInfo.pkColumn.get(0)) #end #if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import $!{tableInfo.savePackageName}.mapper.$!{tableInfo.name}Mapper; import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; import java.util.List; /** * $!{tableInfo.comment}($!{tableInfo.name})表服务实现类 * * @author $!author * @since $!time.currTime() */ @Service("$!tool.firstLowerCase($!{tableInfo.name})Service") public class $!{tableName} extends ServiceImpl<$tableMapperName, $tablePoName> implements $!{tableInfo.name}Service { @Autowired private $!{tableInfo.name}Mapper $!tool.firstLowerCase($!{tableInfo.name})Mapper; }
4.mapper.java
##定义初始变量 #set($tableName = $tool.append($tableInfo.name, "Mapper")) ##设置回调 $!callback.setFileName($tool.append($tableName, ".java")) $!callback.setSavePath($tool.append($tableInfo.savePath, "/mapper")) ##拿到主键 #if(!$tableInfo.pkColumn.isEmpty()) #set($pk = $tableInfo.pkColumn.get(0)) #end #if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; /** * $!{tableInfo.comment}($!{tableInfo.name})表数据库访问层 * * @author $!author * @since $!time.currTime() */ @Mapper @Repository public interface $!{tableName} extends BaseMapper<$!{tableInfo.name}Po>{ }
5.mapper.xml
##引入mybatis支持 $!mybatisSupport ##设置保存名称与保存位置 $!callback.setFileName($tool.append($!{tableInfo.name}, "Mapper.xml")) $!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper")) ##拿到主键 #if(!$tableInfo.pkColumn.isEmpty()) #set($pk = $tableInfo.pkColumn.get(0)) #end <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="$!{tableInfo.savePackageName}.mapper.$!{tableInfo.name}Mapper"> <resultMap type="$!{tableInfo.savePackageName}.pojo.po.$!{tableInfo.name}Po" id="$!{tableInfo.name}Map"> #foreach($column in $tableInfo.fullColumn) <result property="$!column.name" column="$!column.obj.name" jdbcType="$!column.ext.jdbcType"/> #end </resultMap> </mapper>
6.po.java
##引入宏定义 $!define $!init ##定义初始变量 #set($tableName = $tool.append($tableInfo.name, "Po")) ##使用宏定义设置回调(保存位置与文件后缀) #save("/pojo/po", "Po.java") ##使用宏定义设置包后缀 #setPackageSuffix("pojo.po") ##使用全局变量实现默认包导入 import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import com.ruoyi.common.core.domain.BasePo; import java.io.Serializable; import lombok.Data; import java.time.LocalDateTime; import lombok.EqualsAndHashCode; ##使用宏定义实现类注释信息 #tableComment("PO实体类") @EqualsAndHashCode(callSuper = true) @TableName("$!{tableInfo.obj.getName()}") @Data public class $!{tableInfo.name}Po extends BasePo implements Serializable { #if(!$tableInfo.pkColumn.isEmpty()) #set($pk = $tableInfo.pkColumn.get(0)) #end private static final long serialVersionUID = $!tool.serial(); #foreach($column in $tableInfo.fullColumn) #if(${column.comment})/** * ${column.comment} */#end private $!{tool.getClsNameByFullName($column.type)} $!{column.name}; #end }
7.dto.java
##引入宏定义 $!define $!init ##使用宏定义设置回调(保存位置与文件后缀) #save("/pojo/dto", "Dto.java") ##使用宏定义设置包后缀 #setPackageSuffix("pojo.dto") import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDateTime; import java.io.Serializable; ##使用宏定义实现类注释信息 #tableComment("提交Dto") @Data @ApiModel("$tableInfo.comment传输对象") public class $!{tableInfo.name}Dto implements Serializable { private static final long serialVersionUID = $!tool.serial(); #foreach($column in $tableInfo.fullColumn) @ApiModelProperty(value = "${column.comment}") private $!{tool.getClsNameByFullName($column.type)} $!{column.name}; #end }
8.vo.java
##引入宏定义 $!define $!init ##使用宏定义设置回调(保存位置与文件后缀) #save("/pojo/vo", "Vo.java") ##使用宏定义设置包后缀 #setPackageSuffix("pojo.vo") import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDateTime; import java.io.Serializable; ##使用宏定义实现类注释信息 #tableComment("VO实体类") @Data @ApiModel("$tableInfo.comment返回视图") public class $!{tableInfo.name}Vo implements Serializable { private static final long serialVersionUID = $!tool.serial(); #foreach($column in $tableInfo.fullColumn) @ApiModelProperty(value = "${column.comment}") private $!{tool.getClsNameByFullName($column.type)} $!{column.name}; #end }
9.debug.json
$tool.debug($tableInfo)