IDEA插件EasyCode及MyBatis最优配置步骤详解
作者:混〔IT〕的小学生 时间:2023-11-09 03:19:19
具体安装步骤,不再赘述,仅附上个人工作、学习中的对 EasyCode 的详细配置。
插件链接地址:https://gitee.com/makejava/EasyCode
Type Mapper
varchar(\(\d+\))?java.lang.String
char(\(\d+\))?java.lang.String
textjava.lang.String
decimal(\(\d+\))?java.lang.Double
decimal(\(\d+,\d+\))?java.lang.Double
integerjava.lang.Integer
int(\(\d+\))?java.lang.Integer
int4java.lang.Integer
int8java.lang.Long
bigint(\(\d+\))?java.lang.Long
datetime(\(\d+\))?java.time.LocalDateTime
timestampjava.time.LocalDateTime
booleanjava.lang.Boolean
tinyint(\(\d+\))?java.lang.Integer
smallint(\(\d+\))?java.lang.Integer
double(\(\d+\))?java.lang.Double
double(\(\d+,\d+\))?java.lang.Double
Template Setting
entity.java
##初始化定义
$!init
##引入宏定义
$!define
##使用宏定义设置回调(保存位置与文件后缀)
#save("/entity", ".java")
##使用宏定义设置包后缀
#setPackageSuffix("entity")
##使用全局变量实现默认包导入
$!autoImport
import java.io.Serializable;
##使用宏定义实现类注释信息
#tableComment("实体类")
public class $!{tableInfo.name} implements Serializable {
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
public $!{tableInfo.name}() {
}
public $!{tableInfo.name}(#foreach($column in $tableInfo.fullColumn)$!{tool.getClsNameByFullName($column.type)} $!column.name #if($velocityCount != $tableInfo.fullColumn.size()), #end#end) {
#foreach($column in $tableInfo.fullColumn) this.$!column.name = $!column.name;#end
}
#foreach($column in $tableInfo.fullColumn)
##使用宏定义实现get,set方法
#getSetMethod($column)
#end
@Override
public String toString() {
StringBuilder str = new StringBuilder();
str.append("$!{tableInfo.name}{");
#foreach( $column in $tableInfo.fullColumn )
str.append("$!column.name=").append(this.$!column.name)#if( $foreach.hasNext ).append(", ")#end;
#end
str.append('}');
return str.toString();
}
}
DTO.java
##导入宏定义
$!define
##保存文件(宏定义)
#save("/dto", "DTO.java")
##包路径(宏定义)
#setPackageSuffix("dto")
##自动导入包(全局变量)
$!autoImport
##import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import lombok.Data;
##import com.baomidou.mybatisplus.annotation.IdType;
##import com.baomidou.mybatisplus.annotation.TableId;
##表注释(宏定义)
#tableComment("DTO")
@Data
public class $!{tableInfo.name}DTO implements Serializable {
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
}
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 $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
#set($time=$!time.currTime())
#set($time=$time.substring(0,11))
#set($time=$time.replace("-","/"))
/**
* <p>
* $!{tableInfo.comment}($!{tableInfo.name})表数据库访问层
* </p>
*
* @author:$!author
* @date:$!time
*/
@Mapper
public interface $!{tableName} {
/**
* 通过ID查询单条数据
*
* @param $!pk.name 主键
* @return 实例对象
*/
$!{tableInfo.name} queryById($!pk.shortType $!pk.name);
/**
* 通过实体作为筛选条件查询
*
* @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
* @return 对象列表
*/
List<$!{tableInfo.name}> queryAll($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
/**
* 通过实体作为筛选条件查询条数
*
* @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
* @return 条数
*/
int queryAllCount($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
/**
* 新增数据
*
* @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
* @return 影响行数
*/
int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
/**
* 新增选择列
*
* @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
* @return 影响行数
*/
int insertSelective($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
/**
* 修改数据
*
* @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
* @return 影响行数
*/
int update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
/**
* 通过主键删除数据
*
* @param $!pk.name 主键
* @return 影响行数
*/
int deleteById($!pk.shortType $!pk.name);
/**
* 批量新增
* @param recordList
* @return 影响行数
*/
int batchInsert(@Param("recordList") List<$!{tableInfo.name}> recordList);
/**
* 批量修改
* @param recordList
* @return 影响行数
*/
int batchUpdate(@Param("recordList") List<$!{tableInfo.name}> recordList);
/**
* 根据主键批量删除
* @param ids 主键s
* @return 影响行数
*/
int batchDelete(@Param("ids") String[] ids);
}
serviceImpl.java
##初始化定义
$!init
##定义初始变量
#set($tableName = $tool.append($tableInfo.name, "ServiceImpl"))
##设置回调
$!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 $!{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;
#set($time=$!time.currTime())
#set($time=$time.substring(0,11))
#set($time=$time.replace("-","/"))
/**
* <p>
* $!{tableInfo.comment}($!{tableInfo.name})表服务实现类
* </p>
*
* @author:$!author
* @date:$!time
*/
@Service("/$!tool.firstLowerCase($!{tableInfo.name})Service")
public class $!{tableName} implements $!{tableInfo.name}Service {
@Autowired
private $!{tableInfo.name}Mapper $!tool.firstLowerCase($!{tableInfo.name})Mapper;
}
service.java
##定义初始变量
#set($tableName = $tool.append($tableInfo.name, "Service"))
##设置回调
$!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;
#set($time=$!time.currTime())
#set($time=$time.substring(0,11))
#set($time=$time.replace("-","/"))
/**
* <p>
* $!{tableInfo.comment}($!{tableInfo.name})表服务接口
* </p>
*
* @author:$!author
* @date:$!time
*/
public interface $!{tableName} {
}
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}.service.$!{tableInfo.name}Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
#set($time=$!time.currTime())
#set($time=$time.substring(0,11))
#set($time=$time.replace("-","/"))
/**
* <p>
* $!{tableInfo.comment}($!{tableInfo.name})表控制层
* </p>
*
* @author:$!author
* @date:$!time
*/
@RestController
@RequestMapping("/$!tool.firstLowerCase($tableInfo.name)")
public class $!{tableName} {
@Autowired
private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;
}
mysql-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}.entity.$!{tableInfo.name}" id="$!{tableInfo.name}Map">
#foreach($column in $tableInfo.fullColumn)
<result property="$!column.name" column="$!column.name" jdbcType="$!column.ext.jdbcType"/>
#end
</resultMap>
<!-- 伪列 -->
<sql id="columns">
#foreach($column in $tableInfo.fullColumn)
a.$!column.obj.name AS $!column.name #if($velocityCount != $tableInfo.fullColumn.size()),#end
#end
</sql>
<!-- 查询条件 -->
<sql id="whereSql">
<where>
#foreach($column in $tableInfo.fullColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
and a.$!column.obj.name = #{$!column.name}
</if>
#end
</where>
</sql>
<!-- 通过ID查询单条数据 -->
<select id="queryById" resultType="$!{tableInfo.savePackageName}.entity.$!{tableInfo.name}">
select
<include refid="columns"/>
from $!{tableInfo.obj.parent.name}.$!tableInfo.obj.name a
where a.$!pk.obj.name = #{$!pk.name}
</select>
<!-- 通过实体作为筛选条件查询 -->
<select id="queryAll" resultType="$!{tableInfo.savePackageName}.entity.$!{tableInfo.name}">
select
<include refid="columns"/>
from $!{tableInfo.obj.parent.name}.$!tableInfo.obj.name a
<include refid="whereSql" />
</select>
<!-- 通过实体作为筛选条件查询条数 -->
<select id="queryAllCount" resultType="java.lang.Integer">
select
count(1)
from $!{tableInfo.obj.parent.name}.$!tableInfo.obj.name a
<include refid="whereSql" />
</select>
<!-- 新增数据 -->
<insert id="insert" keyProperty="$!pk.name" useGeneratedKeys="true">
insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.fullColumn)$!column.obj.name#if($velocityHasNext), #end#end)
values (#foreach($column in $tableInfo.fullColumn)#{$!{column.name}}#if($velocityHasNext), #end#end)
</insert>
<!-- 新增选择列 -->
<insert id="insertSelective" keyProperty="$!pk.name" useGeneratedKeys="true">
insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}
<trim prefix="(" suffix=")" suffixOverrides="," >
#foreach($column in $tableInfo.fullColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
$!column.obj.name,
</if>
#end
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
#foreach($column in $tableInfo.fullColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
#{$!column.name,jdbcType=$!column.ext.jdbcType},
</if>
#end
</trim>
</insert>
<!-- 修改数据 -->
<update id="update">
update $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}
<set>
#foreach($column in $tableInfo.otherColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
$!column.obj.name = #{$!column.name},
</if>
#end
</set>
where $!pk.obj.name = #{$!pk.name}
</update>
<!-- 通过主键删除数据 -->
<delete id="deleteById">
delete from $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name}
</delete>
<!-- 批量新增 -->
<insert id="batchInsert" parameterType="java.util.List">
insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} (
#foreach($column in $tableInfo.fullColumn)$!column.obj.name#if($velocityHasNext), #end#end
)
values
<foreach collection="recordList" index="index" item="item" separator=",">
(
#foreach($column in $tableInfo.fullColumn)#{item.$!{column.name}}#if($velocityHasNext), #end#end
)
</foreach>
</insert>
<!-- 批量修改 -->
<update id="batchUpdate" parameterType="java.util.List">
update $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}
<trim prefix="set" suffixOverrides=",">
#foreach($column in $tableInfo.otherColumn)
<trim prefix="$!column.obj.name =case $!pk.obj.name" suffix="end,">
<foreach collection="recordList" index="index" item="item">
<if test="item.$!column.name !=null ">
when #{item.$!pk.name} then #{item.$!column.name}
</if>
<if test="item.$!column.name ==null ">
when #{item.$!pk.name} then $!{tableInfo.obj.name}.$!column.obj.name
</if>
</foreach>
</trim>
#end
</trim>
where $!pk.obj.name in(
<foreach collection="recordList" index="index" item="item" separator=",">
#{item.$!pk.name}
</foreach>
)
</update>
<!-- 根据主键批量删除 -->
<delete id="batchDelete" parameterType="java.lang.String">
delete from $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} where $!pk.obj.name in (
<foreach collection="ids" index="index" item="item" separator=",">
#{item}
</foreach>
)
</delete>
</mapper>
oracle-mapper.xml
##引入mybatis支持
$!mybatisSupport
##设置保存名称与保存位置
$!callback.setFileName($tool.append($!{tableInfo.name}, "Mapper.xml"))
$!callback.setSavePath($tool.append($tableInfo.savePath, "/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}" id="$!{tableInfo.name}Map">
#foreach($column in $tableInfo.fullColumn)
<result property="$!column.name" column="$!column.name" jdbcType="$!column.ext.jdbcType"/>
#end
</resultMap>
<!-- 伪列 -->
<sql id="columns">
#foreach($column in $tableInfo.fullColumn)
a.$!column.obj.name AS $!column.name #if($velocityCount != $tableInfo.fullColumn.size()),#end
#end
</sql>
<!-- 查询条件 -->
<sql id="whereSql">
<where>
#foreach($column in $tableInfo.fullColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
and a.$!column.obj.name = #{$!column.name}
</if>
#end
</where>
</sql>
<!-- 通过ID查询单条数据 -->
<select id="queryById" resultType="$!{tableInfo.savePackageName}.entity.$!{tableInfo.name}">
select
<include refid="columns"/>
from $!{tableInfo.obj.parent.name}.$!tableInfo.obj.name a
where a.$!pk.obj.name = #{$!pk.name}
</select>
<!-- 通过实体作为筛选条件查询 -->
<select id="queryAll" resultType="$!{tableInfo.savePackageName}.entity.$!{tableInfo.name}">
select
<include refid="columns"/>
from $!{tableInfo.obj.parent.name}.$!tableInfo.obj.name a
<include refid="whereSql" />
</select>
<!-- 通过实体作为筛选条件查询条数 -->
<select id="queryAllCount" resultType="java.lang.Integer">
select
count(1)
from $!{tableInfo.obj.parent.name}.$!tableInfo.obj.name a
<include refid="whereSql" />
</select>
<!-- 新增数据 -->
<insert id="insert" keyProperty="$!pk.name" useGeneratedKeys="true">
insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}(#foreach($column in $tableInfo.fullColumn)$!column.obj.name#if($velocityHasNext), #end#end)
values (#foreach($column in $tableInfo.fullColumn)#{$!{column.name}}#if($velocityHasNext), #end#end)
</insert>
<!-- 新增选择列 -->
<insert id="insertSelective" keyProperty="$!pk.name" useGeneratedKeys="true">
insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}
<trim prefix="(" suffix=")" suffixOverrides="," >
#foreach($column in $tableInfo.fullColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
$!column.obj.name,
</if>
#end
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
#foreach($column in $tableInfo.fullColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
#{$!column.name,jdbcType=$!column.ext.jdbcType},
</if>
#end
</trim>
</insert>
<!-- 修改数据 -->
<update id="update">
update $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}
<set>
#foreach($column in $tableInfo.otherColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
$!column.obj.name = #{$!column.name},
</if>
#end
</set>
where $!pk.obj.name = #{$!pk.name}
</update>
<!-- 通过主键删除数据 -->
<delete id="deleteById">
delete from $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name}
</delete>
<!-- 批量新增 -->
<insert id="batchInsert" parameterType="java.util.List">
insert into $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} (
#foreach($column in $tableInfo.fullColumn)$!column.obj.name#if($velocityHasNext), #end#end
)
(
<foreach collection="recordList" index="index" item="item" separator=",">
(
select
#foreach($column in $tableInfo.fullColumn)#{item.$!{column.name}}#if($velocityHasNext), #end#end
from dual
)
</foreach>
)
</insert>
<!-- 批量修改 -->
<update id="batchUpdate" parameterType="java.util.List">
begin
<foreach collection="recordList" index="index" item="item" separator=";">
update $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}
<set>
#foreach($column in $tableInfo.otherColumn)
$!column.obj.name = #{item.$!column.name}
#end
</set>
where ID = #{item.$!pk.obj.name}
</foreach>
;end;
</update>
<!-- 根据主键批量删除 -->
<delete id="batchDelete" parameterType="java.lang.String">
delete from $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name} where $!pk.obj.name in (
<foreach collection="ids" index="index" item="item" separator=",">
#{item}
</foreach>
)
</delete>
</mapper>
Global Config
init
##初始化区域
##去掉表的t_前缀
#if($tableInfo.obj.name.startsWith("t_"))
$!tableInfo.setName($tool.getClassName($tableInfo.obj.name.substring(2)))
#end
##参考阿里巴巴开发手册,POJO 类中布尔类型的变量,都不要加 is 前缀,否则部分框架解析会引起序列化错误
#foreach($column in $tableInfo.fullColumn)
#if($column.name.startsWith("is") && $column.type.equals("java.lang.Boolean"))
$!column.setName($tool.firstLowerCase($column.name.substring(2)))
#end
#end
##实现动态排除列
#set($temp = $tool.newHashSet("testCreateTime", "otherColumn"))
#foreach($item in $temp)
#set($newList = $tool.newArrayList())
#foreach($column in $tableInfo.fullColumn)
#if($column.name!=$item)
##带有反回值的方法调用时使用$tool.call来消除返回值
$tool.call($newList.add($column))
#end
#end
##重新保存
$tableInfo.setFullColumn($newList)
#end
##对importList进行篡改
#set($temp = $tool.newHashSet())
#foreach($column in $tableInfo.fullColumn)
#if(!$column.type.startsWith("java.lang."))
##带有反回值的方法调用时使用$tool.call来消除返回值
$tool.call($temp.add($column.type))
#end
#end
##覆盖
#set($importList = $temp)
define
##(Velocity宏定义)
##定义设置表名后缀的宏定义,调用方式:#setTableSuffix("Test")
#macro(setTableSuffix $suffix)
#set($tableName = $!tool.append($tableInfo.name, $suffix))
#end
##定义设置包名后缀的宏定义,调用方式:#setPackageSuffix("Test")
#macro(setPackageSuffix $suffix)
#if($suffix!="")package #end#if($tableInfo.savePackageName!="")$!{tableInfo.savePackageName}.#{end}$!suffix;
#end
##定义直接保存路径与文件名简化的宏定义,调用方式:#save("/entity", ".java")
#macro(save $path $fileName)
$!callback.setSavePath($tool.append($tableInfo.savePath, $path))
$!callback.setFileName($tool.append($tableInfo.name, $fileName))
#end
##定义表注释的宏定义,调用方式:#tableComment("注释信息")
#macro(tableComment $desc)
#set($time=$!time.currTime())
#set($time=$time.substring(0,11))
#set($time=$time.replace("-","/"))
/**
* <p>
* $!{tableInfo.comment}($!{tableInfo.name})$desc
* </p>
*
* @author:$!author
* @date:$!time
*/
#end
##定义GET,SET方法的宏定义,调用方式:#getSetMethod($column)
#macro(getSetMethod $column)
public $!{tool.getClsNameByFullName($column.type)} get$!{tool.firstUpperCase($column.name)}() {
return $!{column.name};
}
public void set$!{tool.firstUpperCase($column.name)}($!{tool.getClsNameByFullName($column.type)} $!{column.name}) {
#if(${column.type.equals("java.lang.String")})this.$!{column.name} = $!{column.name}== null ? null : $!{column.name}.trim();
#else this.$!{column.name} = $!{column.name};#end}
#end
mybatisSupport
##针对Mybatis 进行支持,主要用于生成xml文件
#foreach($column in $tableInfo.fullColumn)
##储存列类型
$tool.call($column.ext.put("sqlType", $tool.getField($column.obj.dataType, "typeName")))
#if($tool.newHashSet("java.lang.String").contains($column.type))
#set($jdbcType="VARCHAR")
#elseif($tool.newHashSet("java.lang.Boolean", "boolean").contains($column.type))
#set($jdbcType="BOOLEAN")
#elseif($tool.newHashSet("java.lang.Byte", "byte").contains($column.type))
#set($jdbcType="BYTE")
#elseif($tool.newHashSet("java.lang.Integer", "int", "java.lang.Short", "short").contains($column.type))
#set($jdbcType="INTEGER")
#elseif($tool.newHashSet("java.lang.Long", "long").contains($column.type))
#set($jdbcType="INTEGER")
#elseif($tool.newHashSet("java.lang.Float", "float", "java.lang.Double", "double").contains($column.type))
#set($jdbcType="NUMERIC")
#elseif($tool.newHashSet("java.util.Date", "java.sql.Timestamp", "java.time.Instant", "java.time.LocalDateTime", "java.time.OffsetDateTime", "java.time.ZonedDateTime").contains($column.type))
#set($jdbcType="TIMESTAMP")
#elseif($tool.newHashSet("java.sql.Date", "java.time.LocalDate").contains($column.type))
#set($jdbcType="TIMESTAMP")
#else
##其他类型
#set($jdbcType="OTHER")
#end
$tool.call($column.ext.put("jdbcType", $jdbcType))
#end
##定义宏,查询所有列
#macro(allSqlColumn)#foreach($column in $tableInfo.fullColumn)$column.obj.name#if($velocityHasNext), #end#end#end
来源:https://blog.csdn.net/BUG_call110/article/details/103503730
标签:idea,插件,EasyCode,MyBatis,配置
0
投稿
猜你喜欢
揭秘双十一手机淘宝图标如何被动态更换
2022-06-05 20:14:04
maven继承父工程统一版本号的实现
2023-01-27 09:19:49
IntelliJ IDEA像Eclipse一样打开多个项目的图文教程
2022-03-14 05:31:40
java实现倒序读取文件功能示例分享
2023-07-12 09:23:54
Android(2.2/2.3系统)Gallery解决默认和横竖屏切换选中状态问题
2022-09-30 19:06:18
C#中实现任意List的全组合算法代码
2022-09-23 01:06:48
Java并发编程之Exchanger方法详解
2022-08-22 02:44:41
Android实战教程第八篇之短信备份
2021-07-17 23:31:43
Mybatis-Plus自动填充更新操作相关字段的实现
2022-01-14 20:43:01
Swift编程中的泛型解析
2022-04-19 05:37:24
Spring5路径匹配器PathPattern解析
2021-07-09 00:12:28
Android实现页面短信验证功能
2022-02-13 01:36:56
Java While循环 do-while循环用法
2021-06-12 17:46:54
Java基础之练习打印三角形
2023-08-25 05:39:33
如何用java实现分页查询
2023-09-23 06:50:24
Android开发中Toast显示消息的方法小结
2023-07-31 20:29:14
Android 图片缩放与旋转的实现详解
2023-03-10 10:57:41
Flutter之Timer实现短信验证码获取60s倒计时功能的代码
2023-07-20 20:00:30
Android Studio 通过登录功能介绍SQLite数据库的使用流程
2023-09-22 00:37:29
Jmeter生成UUID作为唯一标识符过程图解
2022-09-17 03:35:36