当前位置:网站首页>EASYCODE one click plug-in custom template
EASYCODE one click plug-in custom template
2022-06-12 19:28:00 【A rookie is a great God】
Easycode yes idea A plug-in for , You can directly generate the data table entity,controller,service,dao,mapper, No coding required , Simple and powerful .
The template function of the official website is lacking , A customized template .
Be careful :
1. increase , Batch increase , Delete , Change , Just check , Filter query
2.lombok Realization , without lombok Change files or install by yourself lombok
One 、dao.java Templates
## Define the initial variable
#set($tableName = $tool.append($tableInfo.name, "Dao"))
## Set callback
$!callback.setFileName($tool.append($tableName, ".java"))
$!callback.setSavePath($tool.append($tableInfo.savePath, "/dao"))
## Get the primary key
#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.Param;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* $!{tableInfo.comment}($!{tableInfo.name}) Table database access layer
* @author shenning
* @description
* @since $!time.currTime()
*/
@Mapper
public interface $!{tableName} {
/**
* adopt ID Query single data
*
* @param $!pk.name Primary key
* @return Instance object
*/
$!{tableInfo.name} queryById($!pk.shortType $!pk.name);
/**
* Query by entity as filter criteria
*
* @param $!tool.firstLowerCase($!{tableInfo.name}) Instance object
* @return The object list
*/
List<$!{tableInfo.name}> queryAll($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
/**
* The new data
*
* @param $!tool.firstLowerCase($!{tableInfo.name}) Instance object
* @return Number of rows affected
*/
int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
/**
* Batch add
*
* @param $!tool.firstLowerCase($!{tableInfo.name}) A collection of instances of objects
* @return Number of rows affected
*/
int batchInsert(List<$!{tableInfo.name}> $!tool.firstLowerCase($!{tableInfo.name}));
/**
* Modifying data
*
* @param $!tool.firstLowerCase($!{tableInfo.name}) Instance object
* @return Number of rows affected
*/
int updateById($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
/**
* Delete data through primary key
*
* @param $!pk.name Primary key
* @return Number of rows affected
*/
int deleteById($!pk.shortType $!pk.name);
}
Two 、mapper.xml Templates
## introduce mybatis Support
$!mybatisSupport
## Set save name and save location
$!callback.setFileName($tool.append($!{tableInfo.name}, "Dao.xml"))
$!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper"))
## Get the primary key
#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">
<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>
<!-- Basic fields -->
<sql id="Base_Column_List">
#allSqlColumn()
</sql>
<!-- Query individual -->
<select id="queryById" resultMap="$!{tableInfo.name}Map">
select
<include refid="Base_Column_List" />
from $!tableInfo.obj.name
where $!pk.obj.name = #{$!pk.name}
</select>
<!-- Query by entity as filter criteria -->
<select id="queryAll" resultMap="$!{tableInfo.name}Map">
select
<include refid="Base_Column_List" />
from $!tableInfo.obj.name
<where>
#foreach($column in $tableInfo.fullColumn)
<if test="$!column.name != null#if($column.type.equals("java.lang.String")) and $!column.name != ''#end">
and $!column.obj.name = #{$!column.name}
</if>
#end
</where>
</select>
<!-- Add all columns -->
<insert id="insert" keyProperty="$!pk.name" useGeneratedKeys="true">
insert into $!{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>
<!-- Batch add -->
<insert id="batchInsert">
insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.fullColumn)$!column.obj.name#if($velocityHasNext), #end#end)
values
<foreach collection="list" item="stu" separator=",">
(
#foreach($column in $tableInfo.fullColumn)
#{stu.$!{column.name}}#if($velocityHasNext), #end#end
)
</foreach>
</insert>
<!-- Modify data through primary key -->
<update id="updateById">
update $!{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... By primary key -->
<delete id="deleteById">
delete from $!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name}
</delete>
</mapper>
3、 ... and :entity.java Templates
## Introduce macro definition
$!define
## Use macro definition to set callback ( Save location and file suffix )
#save("/entity", ".java")
## Use macro definition to set package suffix
#setPackageSuffix("entity")
## Use global variables to implement the default package import
$!autoImport
import java.io.Serializable;
import lombok.*;
##
## Use macro definition to implement class annotation information
/**
* $!{tableInfo.comment}($!{tableInfo.name}) Entity class
* @author shenning
* @description
* @since $!time.currTime()
*/
@Getter
@Setter
@ToString
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};
## private $!{tool.getClsNameByFullName($column.type)} $!{tool.firstUpperCase($column.name)};
#end
## If not used lombok plug-in unit , Do not comment on this paragraph , Follow the default template
###foreach($column in $tableInfo.fullColumn)
#### Use macro definitions to implement get,set Method
###getSetMethod($column)
###end
}
Four :service.java Templates
## Define the initial variable
#set($tableName = $tool.append($tableInfo.name, "Service"))
## Set callback
$!callback.setFileName($tool.append($tableName, ".java"))
$!callback.setSavePath($tool.append($tableInfo.savePath, "/service"))
## Get the primary key
#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;
import com.github.pagehelper.PageInfo;
/**
* $!{tableInfo.comment}($!{tableInfo.name}) Table service interface
* @author shenning
* @description
* @since $!time.currTime()
*/
public interface $!{tableName} {
// adopt ID Inquire about
$!{tableInfo.name} queryById($!pk.shortType $!pk.name);
// Query by entity as filter criteria
List<$!{tableInfo.name}> queryAll($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
// The new data
int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
// Modifying data
int updateById($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));
// Through primary key id Delete data
int deleteById($!pk.shortType $!pk.name);
}
5、 ... and :serivceImpl.java
## Define the initial variable
#set($tableName = $tool.append($tableInfo.name, "ServiceImpl"))
## Set callback
$!callback.setFileName($tool.append($tableName, ".java"))
$!callback.setSavePath($tool.append($tableInfo.savePath, "/service/impl"))
## Get the primary key
#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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import javax.annotation.Resource;
import java.util.List;
/**
* $!{tableInfo.comment}($!{tableInfo.name}) Table service implementation class
* @author shenning
* @description
* @since $!time.currTime()
*/
@Service
@Transactional
public class $!{tableName} implements $!{tableInfo.name}Service {
@Autowired
private $!{tableInfo.name}Dao $!tool.firstLowerCase($!{tableInfo.name})Dao;
/**
* adopt ID Query single data
* @param $!pk.name Primary key
* @return Instance object
*/
@Override
public $!{tableInfo.name} queryById($!pk.shortType $!pk.name) {
return $!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryById($!pk.name);
}
/**
* Query multiple data
* @param $!tool.firstLowerCase($!{tableInfo.name}) Instance object
* @return The object list
*/
@Override
public List<$!{tableInfo.name}> queryAll($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {
//PageHelper.startPage(pageNum,pageSize);
List<$!{tableInfo.name}> dataList = $!{tool.firstLowerCase($!{tableInfo.name})}Dao.queryAll($!tool.firstLowerCase($!{tableInfo.name}));
//PageInfo<$!{tableInfo.name}> page = new PageInfo<$!{tableInfo.name}>(dataList);
return dataList;
}
/**
* The new data
* @param $!tool.firstLowerCase($!{tableInfo.name}) Instance object
* @return Instance object
*/
@Override
public int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {
return $!{tool.firstLowerCase($!{tableInfo.name})}Dao.insert($!tool.firstLowerCase($!{tableInfo.name}));
}
/**
* Modifying data
* @param $!tool.firstLowerCase($!{tableInfo.name}) Instance object
* @return Instance object
*/
@Override
public int updateById($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {
return $!{tool.firstLowerCase($!{tableInfo.name})}Dao.updateById($!tool.firstLowerCase($!{tableInfo.name}));
}
/**
* Through primary key id Delete data
* @param $!pk.name Primary key
*/
@Override
public int deleteById($!pk.shortType $!pk.name) {
return $!{tool.firstLowerCase($!{tableInfo.name})}Dao.deleteById($!pk.name);
}
}
6、 ... and :controller.java Templates
## Define the initial variable
#set($tableName = $tool.append($tableInfo.name, "Controller"))
## Set callback
$!callback.setFileName($tool.append($tableName, ".java"))
$!callback.setSavePath($tool.append($tableInfo.savePath, "/controller"))
## Get the primary key
#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 $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import javax.annotation.Resource;
/**
* $!{tableInfo.comment}($!{tableInfo.name}) Table control layer
* @author shenning
* @description
* @since $!time.currTime()
*/
@RestController
@RequestMapping("$!tool.firstLowerCase($tableInfo.name)")
public class $!{tableName} {
/**
* $!{tableInfo.comment} service object
*/
@Autowired
private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;
/**
* Query single data through primary key
*/
@GetMapping("get$!tool.firstUpperCase($tableInfo.name)One")
public $!{tableInfo.name} get$!tool.firstUpperCase($tableInfo.name)One($!pk.shortType id) {
return $!{tool.firstLowerCase($tableInfo.name)}Service.queryById(id);
}
/**
* Filter data by query criteria
*/
@GetMapping("get$!tool.firstUpperCase($tableInfo.name)List")
public List<$!{tableInfo.name}> get$!tool.firstUpperCase($tableInfo.name)List($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {
List<$!{tableInfo.name}> getList=$!{tool.firstLowerCase($tableInfo.name)}Service.queryAll($!tool.firstLowerCase($!{tableInfo.name}));
return getList;
}
/**
* The new data $!{tableInfo.comment}
*/
@PostMapping("add$!tool.firstUpperCase($tableInfo.name)")
public int add$!tool.firstUpperCase($!{tableInfo.name})(@RequestBody $!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {
int addState=$!{tool.firstLowerCase($tableInfo.name)}Service.insert($!tool.firstLowerCase($!{tableInfo.name}));
return addState;
}
/**
* Modifying data $!{tableInfo.comment}
*/
@GetMapping("update$!tool.firstUpperCase($tableInfo.name)")
public int update$!tool.firstUpperCase($!{tableInfo.name})(@RequestBody $!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {
int updateState=$!{tool.firstLowerCase($tableInfo.name)}Service.updateById($!tool.firstLowerCase($!{tableInfo.name}));
return updateState;
}
/**
* Delete data $!{tableInfo.comment}
*/
@GetMapping("delete$!tool.firstUpperCase($tableInfo.name)")
public int delete$!tool.firstUpperCase($!{tableInfo.name})($!pk.shortType id) {
int deleteState=$!{tool.firstLowerCase($tableInfo.name)}Service.deleteById(id);
return deleteState;
}
}
边栏推荐
- Mode of most elements (map, sort, random, Boyer Moore voting method)
- leetcodeSQL:578. Questions with the highest response rate
- Méthode de sauvegarde programmée basée sur la base de données distribuée elle - même
- [image denoising] image denoising based on regularization with matlab code
- China's asset management market demand and future competitive trends outlook report 2022-2028
- What did 3GPP ran do in the first F2F meeting?
- Wireshark basic commands
- Exploration of a flexible injection scheme for istio sidecar
- Six stone cognition: the apparent and potential speed of the brain
- Details of thansmitablethreadlocal
猜你喜欢

选电子工程被劝退,真的没前景了?

Redis中的事务

数据库全量SQL分析与审计系统性能优化之旅

7:00 tonight | application of PhD debate self supervised learning in Recommendation System

Add, delete, modify and query mysql, common MySQL commands
![[SQL] MySQL query statement execution sequence analysis](/img/e0/6c55b798b5debfc780fb51498455ab.jpg)
[SQL] MySQL query statement execution sequence analysis

Liunx deploy Seata (Nacos version)

Wincc7.5 SP1 method for adjusting picture size to display resolution

In 2021, the global revenue of chlorinated polyvinyl chloride (CPVC) was about $1809.9 million, and it is expected to reach $3691.5 million in 2028

I was badly hurt by the eight part essay...
随机推荐
超级重磅!Apache Hudi多模索引对查询优化高达30倍
Report on market demand trends and future strategic planning recommendations of the global and Chinese smart financial solutions industry 2022-2028
Meituan won the first place in fewclue in the small sample learning list! Prompt learning+ self training practice
Chrome browser solves cross domain problems
uniapp使用阿里图标
模块八作业
In 2021, the global fire pump drive power revenue is about $381million, and it is expected to reach $489.3 million in 2028
What did 3GPP ran do in the first F2F meeting?
asp. Net using JSON to interact with API data
软件确认测试知识分享,上海第三方软件测试机构有哪些?
Hardware test - why not use grounding clip for ripple test
leetcode:6095. Strong password verifier II [simple simulation + direct false]
leetcode:5259. Calculate the total tax payable [simple simulation + see which range]
[digital ic/fpga] data accumulation output
【图像去噪】基于正则化实现图像去噪附matlab代码
基于微信电子书阅读小程序毕业设计毕设作品(4)开题报告
王学岗room+paging3
硬件测试之—纹波测试为什么不要使用接地夹子
A fruitful afternoon
[blockbuster release] ant dynamic card, enabling the app home page to realize agile update