摸鱼神器IntelliJ IDEA插件EasyCode的使用

简介: 摸鱼神器IntelliJ IDEA插件EasyCode的使用

EasyCode是一个什么东西?

EasyCode是基于IntelliJ IDEA开发的代码生成插件,支持自定义任意模板(Java,html,js,xml)。只要是与数据库相关的代码都可以通过自定义模板来生成。支持数据库类型与java类型映射关系配置。支持同时生成生成多张表的代码。每张表有独立的配置信息。完全的个性化定义,规则由你设置。

创建一个SpringBoot项目

下载Easy Code

配置数据源

使用Easy Code一定要使用IDEA自带的数据库工具来配置数据源。

打开侧边的Database,查看效果

准备数据表

我这里使用Navcat工具创建了一个user表

自定义生成模板

第一次安装EasyCode的时候默认的模板(服务于MyBatis)可以生成下面类型的代码

  • entity.java
  • dao.java
  • service.java
  • serviceImpl.java
  • controller.java
  • mapper.xml
  • debug.json
    查看分组,也可以看到还可以支持生成MyBatisPlus

以user表为例,根据你定义的模板生成代码,文章的最后贴出我自定义的模板

选择模板

点击OK之后,就可以看到生成了这些代码

实体类层:User.java

package com.moti.springbooteasycode.entity;
import java.io.Serializable;
/**
 * (User)实体类
 *
 * @author 莫提
 * @since 2020-02-14 12:37:22
 */
public class User implements Serializable {
    private static final long serialVersionUID = 360314844000215122L;
    
    private Integer userId;
    
    private String userName;
    
    private String password;
    public Integer getUserId() {
        return userId;
    }
    public void setUserId(Integer userId) {
        this.userId = userId;
    }
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    @Override
    public String toString() {
        return "User{" +
                "userId=" + userId +
                "userName=" + userName +
                "password=" + password +
                 '}';      
    }
}

Dao层:UserDao.java

package com.moti.springbooteasycode.dao;
import com.moti.springbooteasycode.entity.User;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
 /**
 * @InterfaceName UserDao
 * @Description (User)表数据库访问层
 * @author 莫提
 * @date 2020-02-14 11:54:45
 * @Version 1.0
 **/
@Mapper
public interface UserDao {
    /**
     * @Description 添加User
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param user 实例对象
     * @return 影响行数
     */
    int insert(User user);
    
    /**
     * @Description 删除User
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param userId 主键
     * @return 影响行数
     */
    int deleteById(Integer userId);
    /**
     * @Description 查询单条数据
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param userId 主键
     * @return 实例对象
     */
    User queryById(Integer userId);
    /**
     * @Description 查询全部数据
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * 分页使用MyBatis的插件实现
     * @return 对象列表
     */
    List<User> queryAll();
    /**
     * @Description 实体作为筛选条件查询数据
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param user 实例对象
     * @return 对象列表
     */
    List<User> queryAll(User user);
    /**
     * @Description 修改User
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param 根据user的主键修改数据
     * @return 影响行数
     */
    int update(User user);
}

Service接口层:UserService.java

package com.moti.springbooteasycode.service;
import com.moti.springbooteasycode.entity.User;
import java.util.List;
/**
 * @InterfaceName UserService
 * @Description (User)表服务接口
 * @author 莫提
 * @date 2020-02-14 11:54:45
 * @Version 1.0
 **/
public interface UserService {
    /**
     * @Description 添加User
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param user 实例对象
     * @return 是否成功
     */
    boolean insert(User user);
    /**
     * @Description 删除User
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param userId 主键
     * @return 是否成功
     */
    boolean deleteById(Integer userId);
    /**
     * @Description 查询单条数据
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param userId 主键
     * @return 实例对象
     */
    User queryById(Integer userId);
    /**
     * @Description 查询全部数据
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * 分页使用MyBatis的插件实现
     * @return 对象列表
     */
    List<User> queryAll();
    /**
     * @Description 实体作为筛选条件查询数据
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param user 实例对象
     * @return 对象列表
     */
    List<User> queryAll(User user);
    /**
     * @Description 修改数据,哪个属性不为空就修改哪个属性
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param user 实例对象
     * @return 是否成功
     */
    boolean update(User user);
}

ServiceImpl服务接口实现层:UserServiceImpl.java

package com.moti.springbooteasycode.service.impl;
import com.moti.springbooteasycode.dao.UserDao;
import com.moti.springbooteasycode.entity.User;
import com.moti.springbooteasycode.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
 /**
 * @ClassName UserServiceImpl
 * @Description (User)表服务实现类
 * @author 莫提
 * @date 2020-02-14 11:54:45
 * @Version 1.0
 **/
@Service("userService")
public class UserServiceImpl extends BaseService implements UserService {
     @Autowired
     protected UserDao userDao;
    /**
     * @Description 添加User
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param user 实例对象
     * @return 是否成功
     */
    @Override
    public boolean insert(User user) {
        if(userDao.insert(user) == 1){
            return true;
        }
        return false;
    }
    /**
     * @Description 删除User
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param userId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer userId) {
        if(userDao.deleteById(userId) == 1){
            return true;
        }
        return false;
    }
    /**
     * @Description 查询单条数据
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param userId 主键
     * @return 实例对象
     */
    @Override
    public User queryById(Integer userId) {
        return userDao.queryById(userId);
    }
    /**
     * @Description 查询全部数据
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * 分页使用MyBatis的插件实现
     * @return 对象列表
     */
    @Override
    public List<User> queryAll() {
        return userDao.queryAll();
    }
    /**
     * @Description 实体作为筛选条件查询数据
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param user 实例对象
     * @return 对象列表
     */
    @Override
    public List<User> queryAll(User user) {
        return userDao.queryAll(user);
    }
    /**
     * @Description 修改数据,哪个属性不为空就修改哪个属性
     * @author 莫提
     * @date 2020-02-14 11:54:45
     * @param user 实例对象
     * @return 是否成功
     */
    @Override
    public boolean update(User user) {
        if(userDao.update(user) == 1){
            return true;
        }
        return false;
    }
}

Mapper映射文件:UserMapper.xml

<?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="com.moti.springbooteasycode.dao.UserDao">
    <!--user的映射结果集-->
    <resultMap type="com.moti.springbooteasycode.entity.User" id="UserMap">
        <result property="userId" column="user_id" jdbcType="INTEGER"/>
        <result property="userName" column="user_name" jdbcType="VARCHAR"/>
        <result property="password" column="password" jdbcType="VARCHAR"/>
    </resultMap>
    
    <!--全部字段-->
    <sql id="allColumn"> user_id, user_name, password </sql>
    
    <!--添加语句的字段列表-->
    <sql id="insertColumn">
        <if test="userName != null and userName != ''">
                user_name,
        </if>
        <if test="password != null and password != ''">
                password,
        </if>
    </sql>
    
    <!--添加语句的值列表-->
        <sql id="insertValue">
        <if test="userName != null and userName != ''">
                #{userName},
        </if>
        <if test="password != null and password != ''">
                #{password},
        </if>
    </sql>
    
    <!--通用对User各个属性的值的非空判断-->
    <sql id="commonsValue">
        <if test="userName != null and userName != ''">
                user_name = #{userName},
        </if>
        <if test="password != null and password != ''">
                password = #{password},
        </if>
    </sql>
    
    <!--新增user:哪个字段不为空就添加哪列数据,返回自增主键-->
    <insert id="insert" keyProperty="userId" useGeneratedKeys="true">
        insert into user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="insertColumn"/>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <include refid="insertValue"/>
        </trim>
    </insert>
   
    <!--删除user:通过主键-->
    <delete id="deleteById">
        delete from user
        <where>
            user_id = #{userId}
        </where>
    </delete>
    
    <!--查询单个user-->
    <select id="queryById" resultMap="UserMap">
        select
        <include refid="allColumn"></include>
        from user
        <where>
            user_id = #{userId}
        </where>
    </select>
    <!--查询所有user-->
    <select id="queryAllByLimit" resultMap="UserMap">
        select
        <include refid="allColumn"></include>
        from user
    </select>
    <!--通过实体作为筛选条件查询-->
    <select id="queryAll" resultMap="UserMap">
        select
          <include refid="allColumn"></include>
        from user
        <trim prefix="where" prefixOverrides="and" suffixOverrides=",">
            <include refid="commonsValue"></include>
        </trim>
    </select>
    <!--通过主键修改数据-->
    <update id="update">
        update user
        <set>
            <include refid="commonsValue"></include>
        </set>
        <where>
            user_id = #{userId}
        </where>
    </update>
</mapper>

以上代码完全是生成出来了,从头到尾只需要点几下鼠标,是不是很神奇!

BaseService是我根据需求自己后加的

package com.moti.springbooteasycode.service.impl;
import com.moti.springbooteasycode.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * @ClassName: BaseService
 * @Description: TODO
 * @author: xw
 * @date 2020/2/14 1:49
 * @Version: 1.0
 **/
public class BaseService {
    @Autowired
    protected UserDao userDao;
}

我的默认模板

注意使用我的模板的时候,需要将我上面的BaseService类添加到service.impl包下

entity.java

##引入宏定义
$!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
#foreach($column in $tableInfo.fullColumn)
##使用宏定义实现get,set方法
#getSetMethod($column)
#end
    @Override
    public String toString() {
        return "$!{tableInfo.name}{" +
    #foreach($column in $tableInfo.fullColumn)
            "$!{column.name}=" + $!{column.name} +
    #end
             '}';      
    }
}

dao.java

##定义初始变量
#set($tableName = $tool.append($tableInfo.name, "Dao"))
##设置回调
$!callback.setFileName($tool.append($tableName, ".java"))
$!callback.setSavePath($tool.append($tableInfo.savePath, "/dao"))
##拿到主键
#if(!$tableInfo.pkColumn.isEmpty())
    #set($pk = $tableInfo.pkColumn.get(0))
#end
#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}dao;
import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
 /**
 * @InterfaceName $!{tableName}
 * @Description $!{tableInfo.comment}($!{tableInfo.name})表数据库访问层
 * @author $!author
 * @date $!time.currTime()
 * @Version 1.0
 **/
@Mapper
public interface $!{tableName} {
    /**
     * @Description 添加$!{tableInfo.name}
     * @author $!author
     * @date $!time.currTime()
     * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
     * @return 影响行数
     */
    int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
    
    /**
     * @Description 删除$!{tableInfo.name}
     * @author $!author
     * @date $!time.currTime()
     * @param $!pk.name 主键
     * @return 影响行数
     */
    int deleteById($!pk.shortType $!pk.name);
    /**
     * @Description 查询单条数据
     * @author $!author
     * @date $!time.currTime()
     * @param $!pk.name 主键
     * @return 实例对象
     */
    $!{tableInfo.name} queryById($!pk.shortType $!pk.name);
    /**
     * @Description 查询全部数据
     * @author $!author
     * @date $!time.currTime()
     * 分页使用MyBatis的插件实现
     * @return 对象列表
     */
    List<$!{tableInfo.name}> queryAll();
    /**
     * @Description 实体作为筛选条件查询数据
     * @author $!author
     * @date $!time.currTime()
     * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
     * @return 对象列表
     */
    List<$!{tableInfo.name}> queryAll($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
    /**
     * @Description 修改$!{tableInfo.name}
     * @author $!author
     * @date $!time.currTime()
     * @param 根据$!tool.firstLowerCase($!{tableInfo.name})的主键修改数据
     * @return 影响行数
     */
    int update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
}

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;
import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};
import java.util.List;
/**
 * @InterfaceName $!{tableName}
 * @Description $!{tableInfo.comment}($!{tableInfo.name})表服务接口
 * @author $!author
 * @date $!time.currTime()
 * @Version 1.0
 **/
public interface $!{tableName} {
    /**
     * @Description 添加$!{tableInfo.name}
     * @author $!author
     * @date $!time.currTime()
     * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
     * @return 是否成功
     */
    boolean insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
    /**
     * @Description 删除$!{tableInfo.name}
     * @author $!author
     * @date $!time.currTime()
     * @param $!pk.name 主键
     * @return 是否成功
     */
    boolean deleteById($!pk.shortType $!pk.name);
    /**
     * @Description 查询单条数据
     * @author $!author
     * @date $!time.currTime()
     * @param $!pk.name 主键
     * @return 实例对象
     */
    $!{tableInfo.name} queryById($!pk.shortType $!pk.name);
    /**
     * @Description 查询全部数据
     * @author $!author
     * @date $!time.currTime()
     * 分页使用MyBatis的插件实现
     * @return 对象列表
     */
    List<$!{tableInfo.name}> queryAll();
    /**
     * @Description 实体作为筛选条件查询数据
     * @author $!author
     * @date $!time.currTime()
     * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
     * @return 对象列表
     */
    List<$!{tableInfo.name}> queryAll($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
    /**
     * @Description 修改数据,哪个属性不为空就修改哪个属性
     * @author $!author
     * @date $!time.currTime()
     * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
     * @return 是否成功
     */
    boolean update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
}

serviceImpl.java

##定义初始变量
#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}.entity.$!{tableInfo.name};
import $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;
import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
 /**
 * @ClassName $!{tableName}
 * @Description $!{tableInfo.comment}($!{tableInfo.name})表服务实现类
 * @author $!author
 * @date $!time.currTime()
 * @Version 1.0
 **/
@Service("$!tool.firstLowerCase($!{tableInfo.name})Service")
public class $!{tableName} extends BaseService implements $!{tableInfo.name}Service {
    @Autowired
    protected $!{tableInfo.name}Dao $!tool.firstLowerCase($!{tableInfo.name})Dao;
    /**
     * @Description 添加$!{tableInfo.name}
     * @author $!author
     * @date $!time.currTime()
     * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
     * @return 是否成功
     */
    @Override
    public boolean insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {
        if($!{tool.firstLowerCase($!{tableInfo.name})}Dao.insert($!tool.firstLowerCase($!{tableInfo.name})) == 1){
            return true;
        }
        return false;
    }
    /**
     * @Description 删除$!{tableInfo.name}
     * @author $!author
     * @date $!time.currTime()
     * @param $!pk.name 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById($!pk.shortType $!pk.name) {
        if($!{tool.firstLowerCase($!{tableInfo.name})}Dao.deleteById($!pk.name) == 1){
            return true;
        }
        return false;
    }
    /**
     * @Description 查询单条数据
     * @author $!author
     * @date $!time.currTime()
     * @param $!pk.name 主键
     * @return 实例对象
     */
    @Override
    public $!{tableInfo.name} queryById($!pk.shortType $!pk.name) {
        return $!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryById($!pk.name);
    }
    /**
     * @Description 查询全部数据
     * @author $!author
     * @date $!time.currTime()
     * 分页使用MyBatis的插件实现
     * @return 对象列表
     */
    @Override
    public List<$!{tableInfo.name}> queryAll() {
        return $!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryAll();
    }
    /**
     * @Description 实体作为筛选条件查询数据
     * @author $!author
     * @date $!time.currTime()
     * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
     * @return 对象列表
     */
    @Override
    public List<$!{tableInfo.name}> queryAll($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {
        return $!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryAll($!tool.firstLowerCase($!{tableInfo.name}));
    }
    /**
     * @Description 修改数据,哪个属性不为空就修改哪个属性
     * @author $!author
     * @date $!time.currTime()
     * @param $!tool.firstLowerCase($!{tableInfo.name}) 实例对象
     * @return 是否成功
     */
    @Override
    public boolean update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {
        if($!{tool.firstLowerCase($!{tableInfo.name})}Dao.update($!tool.firstLowerCase($!{tableInfo.name})) == 1){
            return true;
        }
        return false;
    }
}

mapper.xml

##引入mybatis支持
$!mybatisSupport
##设置保存名称与保存位置
$!callback.setFileName($tool.append($!{tableInfo.name}, "Dao.xml"))
$!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mybatis/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}.dao.$!{tableInfo.name}Dao">
    <!--$!{tableInfo.obj.name}的映射结果集-->
    <resultMap type="$!{tableInfo.savePackageName}.entity.$!{tableInfo.name}" id="$!{tableInfo.name}Map">
#foreach($column in $tableInfo.fullColumn)
        <result property="$!column.name" column="$!column.obj.name" jdbcType="$!column.ext.jdbcType"/>
#end
    </resultMap>
    
    <!--全部字段-->
    <sql id="allColumn"> #allSqlColumn() </sql>
    
    <!--添加语句的字段列表-->
    <sql id="insertColumn">
#foreach($column in $tableInfo.otherColumn)
        <if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
                $!column.obj.name,
        </if>
#end
    </sql>
    
    <!--添加语句的值列表-->
        <sql id="insertValue">
#foreach($column in $tableInfo.otherColumn)
        <if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
                #{$!column.name},
        </if>
#end
    </sql>
    
    <!--通用对$!{tableInfo.name}各个属性的值的非空判断-->
    <sql id="commonsValue">
#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
    </sql>
    
    <!--新增$!{tableInfo.obj.name}:哪个字段不为空就添加哪列数据,返回自增主键-->
    <insert id="insert" keyProperty="$!pk.name" useGeneratedKeys="true">
        insert into $!{tableInfo.obj.name}
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <include refid="insertColumn"/>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <include refid="insertValue"/>
        </trim>
    </insert>
   
    <!--删除$!{tableInfo.obj.name}:通过主键-->
    <delete id="deleteById">
        delete from $!{tableInfo.obj.name}
        <where>
            $!pk.obj.name = #{$!pk.name}
        </where>
    </delete>
    
    <!--查询单个$!{tableInfo.obj.name}-->
    <select id="queryById" resultMap="$!{tableInfo.name}Map">
        select
        <include refid="allColumn"></include>
        from $!tableInfo.obj.name
        <where>
            $!pk.obj.name = #{$!pk.name}
        </where>
    </select>
    <!--查询所有$!{tableInfo.obj.name}-->
    <select id="queryAllByLimit" resultMap="$!{tableInfo.name}Map">
        select
        <include refid="allColumn"></include>
        from $!tableInfo.obj.name
    </select>
    <!--通过实体作为筛选条件查询-->
    <select id="queryAll" resultMap="$!{tableInfo.name}Map">
        select
          <include refid="allColumn"></include>
        from $!tableInfo.obj.name
        <trim prefix="where" prefixOverrides="and" suffixOverrides=",">
            <include refid="commonsValue"></include>
        </trim>
    </select>
    <!--通过主键修改数据-->
    <update id="update">
        update $!{tableInfo.obj.name}
        <set>
            <include refid="commonsValue"></include>
        </set>
        <where>
            $!pk.obj.name = #{$!pk.name}
        </where>
    </update>
</mapper>
Lombok实体类层:entity.java
##引入宏定义
$!define
##使用宏定义设置回调(保存位置与文件后缀)
#save("/entity", ".java")
##使用宏定义设置包后缀
#setPackageSuffix("entity")
##使用全局变量实现默认包导入
$!autoImport
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
##使用宏定义实现类注释信息
#tableComment("实体类")
@AllArgsConstructor
@Data
@Builder
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
}

多个分组的切换

选择好分组后,点击OK,之后在Datebase视图的数据表右键选择EasyCode生成的时候会让你选择当前分组的模板


相关文章
|
网络协议 Windows
两步带你解决IDEA 插件下载安装慢、超时、不成功问题
这篇文章提供了解决IDEA插件下载慢或超时问题的方案,通过查找国内插件节点IP地址并修改本地hosts文件来加速下载。
两步带你解决IDEA 插件下载安装慢、超时、不成功问题
|
7月前
|
Java 应用服务中间件 Maven
在IntelliJ IDEA中如何配置使用Maven以创建Tomcat环境
所以,别担心这些工具看起来有些吓人,实际上这些都是为了帮助你更好的完成工作的工具,就像超市里的各种烹饪工具一样,尽管它们看起来可能很复杂,但只要你学会用,它们会为你烹饪出一道道美妙的食物。这就是学习新技能的乐趣,让我们一起享受这个过程,攀登知识的高峰!
465 27
|
6月前
|
JSON Java 数据库连接
IDEA的插件大总汇 (让你的工作效率大大提高!)
我是小假 期待与你的下一次相遇 ~
1183 5
|
Java
轻松上手Java字节码编辑:IDEA插件VisualClassBytes全方位解析
本插件VisualClassBytes可修改class字节码,包括class信息、字段信息、内部类,常量池和方法等。
662 6
|
9月前
|
IDE 程序员 开发工具
只用正版!教你5个方法,白嫖JetBrains家族的所有产品,包含:IntelliJ IDEA、PyCharm、WebStorm、CLion、Rider
程序员晚枫分享了5种官方认证的免费使用JetBrains家族产品的方法,包括内容创作者计划、开源项目支持、教育许可证、用户组支持和开发者认可计划。这些方法帮助个人开发者与小型团队合法获取强大开发工具,如IntelliJ IDEA、PyCharm等,降低开发成本,提升效率。同时提醒大家遵守使用规范,尊重知识产权。
1619 13
|
10月前
|
人工智能 IDE 编译器
idea如何使用AI编程提升效率-在IntelliJ IDEA 中安装 GitHub Copilot 插件的步骤-卓伊凡
idea如何使用AI编程提升效率-在IntelliJ IDEA 中安装 GitHub Copilot 插件的步骤-卓伊凡
2033 15
idea如何使用AI编程提升效率-在IntelliJ IDEA 中安装 GitHub Copilot 插件的步骤-卓伊凡
|
11月前
|
开发工具 开发者 git
IntelliJ IDEA 插件推荐:提升开发效率的神器
本文介绍了 IntelliJ IDEA 的多个实用插件,涵盖从提高开发效率到美化界面的各个方面。
1376 1
|
12月前
|
前端开发 Java 开发者
这款免费 IDEA 插件让你开发 Spring 程序更简单
Feign-Helper 是一款支持 Spring 框架的 IDEA 免费插件,提供 URL 快速搜索、Spring Web Controller 路径一键复制及 Feign 与 Controller 接口互相导航等功能,极大提升了开发效率。
1498 1
|
Windows
IDEA如何查看已经安装的插件并删除
【10月更文挑战第1天】这段内容主要介绍了如何在IntelliJ IDEA中查看和删除已安装的插件。可以通过软件内的插件市场查看插件列表,包括插件名称、版本号和供应商等信息;也可以通过访问插件目录查看。删除插件则建议在插件市场中进行,包括禁用和卸载步骤,手动删除插件文件夹的方法不推荐,因为可能存在配置残留等问题。
3466 12
|
人工智能 Java 数据库连接
IDEA开发 常用代码规范插件 常用辅助类插件
IDEA开发 常用代码规范插件 常用辅助类插件
1688 1