当前位置:网站首页>[idea] use the plug-in to reverse generate code with one click
[idea] use the plug-in to reverse generate code with one click
2022-07-02 11:18:00 【winrh】
Purpose
According to the table I built , Reverse generation xml file 、service、mapper、domain Wait for the documents . And you can customize the template .
plug-in unit
IDEA plug-in unit :Easy Code
edit author name

Custom template

1. mapper.xml.vm
## introduce mybatis Support
$!{mybatisSupport.vm}
## Set save name and save location
$!callback.setFileName($tool.append($!{tableInfo.name}, "Mapper.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}.mapper.$!{tableInfo.name}Mapper">
<resultMap type="$!{tableInfo.savePackageName}.domain.$!{tableInfo.name}Domain" id="$!{tableInfo.name}Map">
#foreach($column in $tableInfo.fullColumn)
<result property="$!column.name" column="$!column.obj.name" jdbcType="$!column.ext.jdbcType"/>
#end
</resultMap>
</mapper>
2. controller.java.vm
## 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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* $!{tableInfo.comment}($!{tableInfo.name}) Table control layer
*
* @author $!author
* @since $!time.currTime()
*/
@RestController
@RequestMapping("$!tool.firstLowerCase($tableInfo.name)")
public class $!{tableName} {
/**
* service object
*/
@Autowired
private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)Service;
}
3. service.java.vm
## 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}.domain.$!{tableInfo.name}Domain;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* $!{tableInfo.comment}($!{tableInfo.name}) Table service interface
*
* @author $!author
* @since $!time.currTime()
*/
public interface $!{tableName} extends IService<$!{tableInfo.name}Domain> {
}4. serviceImpl.java.vm
## 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}.domain.$!{tableInfo.name}Domain;
import $!{tableInfo.savePackageName}.mapper.$!{tableInfo.name}Mapper;
import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* $!{tableInfo.comment}($!{tableInfo.name}) Table service implementation class
*
* @author $!author
* @since $!time.currTime()
*/
@Service("$!tool.firstLowerCase($!{tableInfo.name})Service")
public class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Mapper, $!{tableInfo.name}Domain> implements $!{tableInfo.name}Service {
}5. mapper.java.vm
## Define the initial variable
#set($tableName = $tool.append($tableInfo.name, "Mapper"))
## Set callback
$!callback.setFileName($tool.append($tableName, ".java"))
$!callback.setSavePath($tool.append($tableInfo.savePath, "/mapper"))
#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}mapper;
import $!{tableInfo.savePackageName}.domain.$!{tableInfo.name}Domain;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* $!{tableInfo.comment}($!{tableInfo.name}) Table database access layer
*
* @author $!author
* @since $!time.currTime()
*/
@Mapper
public interface $!{tableName} extends BaseMapper<$!{tableInfo.name}Domain> {
/**
* Batch new data (MyBatis Native foreach Method )
*
* @param domains List<$!{tableInfo.name}Domain> Instance object list
* @return Number of rows affected
*/
int insertBatch(@Param("domains") List<$!{tableInfo.name}Domain> domains);
}
6. domain.java.vm
## Introduce macro definition
$!{define.vm}
## Define the initial variable
#set($tableName = $tool.append($tableInfo.name, "Domain"))
## Set callback
$!callback.setFileName($tool.append($tableName, ".java"))
$!callback.setSavePath($tool.append($tableInfo.savePath, "/domain"))
## Use macro definition to set package suffix
#setPackageSuffix("domain")
## Use global variables to implement the default package import
$!{autoImport.vm}
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
#if(${hasBigDecimal})
import java.math.BigDecimal;
#end
import java.util.Date;
/**
* @Description $!{tableInfo.comment}
* @author ${author}
* @date $!time.currTime()
*/
@Data
@TableName(value = "$!{tableInfo.obj.name}")
public class $!{tableInfo.name}Domain implements Serializable {
#foreach($column in $tableInfo.fullColumn)
#if(${column.comment})
/**
* ${column.comment}
*/#end
@TableField("${column.obj.name}")
private $!{tool.getClsNameByFullName($column.type)} $!{column.name};
#end
}Connect to database
Right click table , choice Easy Code
Select the template to use , Then export it
result
边栏推荐
- Some suggestions for young people who are about to enter the workplace in the graduation season
- The difference between self and static in PHP in methods
- [applinking practical case] share in app pictures through applinking
- Xiao Sha's pain (double pointer
- VS2019代码中包含中文内容导致的编译错误和打印输出乱码问题
- TIPC介绍1
- [play with FPGA learning 5 in simple terms ----- reset design]
- Some things configured from ros1 to ros2
- Rest (XOR) position and thinking
- Special topic of binary tree -- acwing 3540 Binary search tree building (use the board to build a binary search tree and output the pre -, middle -, and post sequence traversal)
猜你喜欢

【IDEA】使用插件一键逆向生成代码

How to use ide to automatically sign and debug Hongmeng application

Multi line display and single line display of tqdm

Solve the problem of data blank in the quick sliding page of the uniapp list

TIPC Service and Topology Tracking4

Skills of PLC recorder in quickly monitoring multiple PLC bits

Pit of the start attribute of enumrate

Special topic of binary tree -- acwing 1589 Building binary search tree

Flink two Open, implement Batch Lookup join (attached source)
![[AGC] build service 3 - authentication service example](/img/89/63f367270e806e89c4ff92360dc3c5.png)
[AGC] build service 3 - authentication service example
随机推荐
flink二開,實現了個 batch lookup join(附源碼)
MySQL比较运算符IN问题求解
Special topic of binary tree -- Logu p1229 traversal problem (the number of traversals in the middle order is calculated when the pre and post order traversals of the multiplication principle are know
PKG package manager usage instance in FreeBSD
TIPC Getting Started6
【深入浅出玩转FPGA学习5-----复位设计】
原生方法合并word
[paid promotion] collection of frequently asked questions, recommended list FAQ
ctf 记录
liftOver进行基因组坐标转换
STM32单片机编程学习
Approximate sum count (approximate
What are the software product management systems? Inventory of 12 best product management tools
Multi line display and single line display of tqdm
SQLite modify column type
Webauthn - official development document
[play with FPGA learning 4 in simple terms ----- talk about state machine design]
Eight sorting summaries
VS2019代码中包含中文内容导致的编译错误和打印输出乱码问题
One trick to quickly realize custom application titlebar