1 MybatisX 与 EasyCode 一键自动生成代码
2 Lombok Lombok能通过注解的方式,在编译时自动为属性生成构造器、getter/setter、equals、hashcode、toString方法
3 Alibaba_Java_Coding_Guidelines 自动核实代码规范
4 Commit_Template git提交模板
5 ke_ Promoter_X 快捷键提示工具
6 Power Mode ii 装逼神器
EasyCode 模板
entity
##引入宏定义
$!define
##使用宏定义设置回调(保存位置与文件后缀)
#save("/entity", ".java")
##使用宏定义设置包后缀
#setPackageSuffix("entity")
##使用全局变量实现默认包导入
$!autoImport
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
/**
* $!{tableInfo.comment}($!{tableInfo.name})
*
* @author $!author
* @since $!time.currTime()
*/
@Data
@TableName("${tableInfo.obj.name}")
public class $!{tableInfo.name} implements Serializable {
private static final long serialVersionUID = $!tool.serial();
##拿到主键
#if(!$tableInfo.pkColumn.isEmpty())
#set($pk = $tableInfo.pkColumn.get(0))
#end
@TableId(value = "${pk.obj.name}", type = IdType.AUTO)
private ${pk.shortType} ${pk.name};
#foreach($column in $tableInfo.otherColumn)
#if(${column.comment})
/**
* ${column.comment}
*/#end
@TableField(value = "$!{column.obj.name}")
private $!{tool.getClsNameByFullName($column.type)} $!{column.name};
#end
}
dao
##定义初始变量
#set($tableName = $tool.append($tableInfo.name, "Mapper"))
##设置回调
$!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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
/**
* $!{tableInfo.comment}($!{tableInfo.name})
*
* @author $!author
* @since $!time.currTime()
*/
@Mapper
public interface $!{tableName} extends BaseMapper<$!{tableInfo.name}>{
public Page<$!{tableInfo.name}> findPageList($!{tableInfo.name} page ,@Param("req") $!{tableInfo.name} req);
}
service
##定义初始变量
#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 com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* $!{tableInfo.comment}($!{tableInfo.name})
*
* @author $!author
* @since $!time.currTime()
*/
public interface $!{tableName} extends IService<$!{tableInfo.name}>{
public IPage<$!{tableInfo.name}> findPageList(Page<$!{tableInfo.name}> page ,$!{tableInfo.name} $!tool.firstLowerCase($tableInfo.name));
}
ServiceImpl
##定义初始变量
#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}Mapper;
import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import javax.annotation.Resource;
/**
* $!{tableInfo.comment}($!{tableInfo.name})
*
* @author $!author
* @since $!time.currTime()
*/
@Service
public class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Mapper,$!{tableInfo.name}> implements $!{tableInfo.name}Service{
/**
* 服务对象
*/
@Resource
private $!{tableInfo.name}Mapper $!tool.firstLowerCase($tableInfo.name)Mapper;
@Override
public IPage<$!{tableInfo.name}> findPageList(Page<$!{tableInfo.name}> page ,$!{tableInfo.name} $!tool.firstLowerCase($tableInfo.name)){
return getBaseMapper().findPageList(page,$!tool.firstLowerCase($tableInfo.name));
}
}
mapper
##引入mybatis支持
$!mybatisSupport
##设置保存名称与保存位置
$!callback.setFileName($tool.append($!{tableInfo.name}, "Mapper.xml"))
$!callback.setSavePath($tool.append($modulePath, "/src/main/resources/config/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}Mapper">
<resultMap type="$!{tableInfo.savePackageName}.entity.$!{tableInfo.name}" id="BaseResultMap">
#foreach($column in $tableInfo.fullColumn)
<result property="$!column.name" column="$!column.obj.name" jdbcType="$!column.ext.jdbcType"/>
#end
</resultMap>
<!-- 基本字段 -->
<sql id="Base_Column_List">
#allSqlColumn()
</sql>
<!--通过实体作为筛选条件查询-->
<select id="findPageList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from $!tableInfo.obj.name
<where>
#foreach($column in $tableInfo.fullColumn)
<if test="req.$!column.name != null#if($column.type.equals("java.lang.String")) and req.$!column.name != ''#end">
and $!column.obj.name = #{$!column.name}
</if>
#end
</where>
</select>
</mapper>
controller
##定义初始变量
#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 org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* $!{tableInfo.comment}($!{tableInfo.name})
*
* @author $!author
* @since $!time.currTime()
*/
@RestController
@RequestMapping("$!tool.firstLowerCase($tableInfo.name)")
public class $!{tableName}{
/**
* 服务对象
*/
@Resource
private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;
@RequestMapping("/$!tool.firstLowerCase($tableInfo.name)Page")
public ResultVO<Object> $!tool.firstLowerCase($tableInfo.name)page($!{tableInfo.name} $!tool.firstLowerCase($tableInfo.name)) {
Page<$!{tableInfo.name}> page = new Page<>(1,10);
$!tool.firstLowerCase($tableInfo.name)Service. findPageList(page,$!tool.firstLowerCase($tableInfo.name));
}
}