当前位置:网站首页>[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
边栏推荐
- [in simple terms, play with FPGA learning 3 ----- basic grammar]
- Verilog and VHDL signed and unsigned number correlation operations
- MySQL比较运算符IN问题求解
- TIPC protocol
- ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
- [quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
- How does the whole network display IP ownership?
- Order by注入
- Complement (Mathematical Simulation
- Use Huawei performance management service to configure the sampling rate on demand
猜你喜欢

Flink two Open, implement Batch Lookup join (attached source)

Win11 arm system configuration Net core environment variable

How to use ide to automatically sign and debug Hongmeng application

二.Stm32f407芯片GPIO编程,寄存器操作,库函数操作和位段操作

2022 love analysis · panoramic report of digital manufacturers of state-owned enterprises

ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘

Eight sorting summaries

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

Verilog 和VHDL有符号数和无符号数相关运算

从攻击面视角,看信创零信任方案实践
随机推荐
Verilog 和VHDL有符号数和无符号数相关运算
金山云——2023届暑期实习
Logu p3398 hamster looks for sugar (double LCA on the tree to judge whether the two paths in the tree intersect)
Jinshanyun - 2023 Summer Internship
mysql 基本语句
SSRF
TIPC 寻址2
Multi line display and single line display of tqdm
[ark UI] implementation of the startup page of harmonios ETS
TIPC introduction 1
Gaode draws lines according to the track
TIPC Service and Topology Tracking4
spritejs
Xiao Sha's pain (double pointer
Jenkins安装
ros缺少catkin_pkg
enumrate的start属性的坑
TIPC protocol
Order by注入
【IDEA】使用插件一键逆向生成代码