安装必要插件:Easy Code、Database
配置想要格式的模板:
常用实体类模板:
##引入宏定义
$!define
##使用宏定义设置回调(保存位置与文件后缀)
#save("/entity", "DO.java")
##使用宏定义设置包后缀
#setPackageSuffix("entity")
##使用全局变量实现默认包导入
$!autoImport
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
##使用宏定义实现类注释信息
/**
* $!{tableInfo.comment}($!{tableInfo.name})实体类
*
* @author liuhuashan
* @since $!time.currTime()
*/
@Data
@ApiModel(description = "$!{tableInfo.comment}($!{tableInfo.name})实体类")
public class $!{tableInfo.name}DO implements Serializable {
private static final long serialVersionUID = $!tool.serial();
#foreach($column in $tableInfo.fullColumn)
#if(${column.comment})@ApiModelProperty(value = "${column.comment}")
#end
private $!{tool.getClsNameByFullName($column.type)} $!{column.name};
#end
}
mapper中resultMap:
##引入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}.entity.$!{tableInfo.name}DO" id="result$!{tableInfo.name}Map">
#foreach($column in $tableInfo.fullColumn)
<result property="$!column.name" column="$!column.obj.name" />
#end
</resultMap>
</mapper>
使用Database连接数据库:
easyexcel实体类模板:
##引入宏定义
$!define
##使用宏定义设置回调(保存位置与文件后缀)
#save("/entity", "DO.java")
##使用宏定义设置包后缀
#setPackageSuffix("entity")
##使用全局变量实现默认包导入
$!autoImport
import com.alibaba.excel.annotation.ExcelProperty;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
##使用宏定义实现类注释信息
/**
* $!{tableInfo.comment}($!{tableInfo.name})实体类
*
* @author liuhuashan
* @since $!time.currTime()
*/
@Data
@ApiModel(description = "$!{tableInfo.comment}($!{tableInfo.name})实体类")
public class $!{tableInfo.name}DO implements Serializable {
private static final long serialVersionUID = $!tool.serial();
#foreach($column in $tableInfo.fullColumn)
#if(${column.comment})@ApiModelProperty(value = "${column.comment}")
@ExcelProperty("${column.comment}")
#end
private $!{tool.getClsNameByFullName($column.type)} $!{column.name};
#end
}
视图实体类:
##引入宏定义
$!define
##使用宏定义设置回调(保存位置与文件后缀)
#save("/entity", "VO.java")
##使用宏定义设置包后缀
#setPackageSuffix("entity")
##使用全局变量实现默认包导入
$!autoImport
import com.rate.common.core.annotation.Excel;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
##使用宏定义实现类注释信息
/**
* $!{tableInfo.comment}($!{tableInfo.name})实体类
*
* @author liuhuashan
* @since $!time.currTime()
*/
@Data
@ApiModel(description = "$!{tableInfo.comment}($!{tableInfo.name})实体类")
public class $!{tableInfo.name}VO implements Serializable {
private static final long serialVersionUID = $!tool.serial();
#foreach($column in $tableInfo.fullColumn)
#if(${column.comment})@ApiModelProperty(value = "${column.comment}")
@Excel(name = "${column.comment}")
#end
private $!{tool.getClsNameByFullName($column.type)} $!{column.name};
#end
}