当前位置:网站首页>[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
边栏推荐
- Complement (Mathematical Simulation
- Multi line display and single line display of tqdm
- The working day of the month is calculated from the 1st day of each month
- TIPC messaging3
- Jenkins安装
- mysql 基本语句
- Skills of PLC recorder in quickly monitoring multiple PLC bits
- Tick Data and Resampling
- ASTParser 解析含有emum 枚举方法的类文件的踩坑记
- STM32单片机编程学习
猜你喜欢

CentOS8之mysql基本用法

How to use ide to automatically sign and debug Hongmeng application

V2x SIM dataset (Shanghai Jiaotong University & New York University)
![[applinking practical case] share in app pictures through applinking](/img/12/5616f1fa55387b81e25e55a98022b9.png)
[applinking practical case] share in app pictures through applinking

enumrate的start属性的坑

从攻击面视角,看信创零信任方案实践

I STM32 development environment, keil5/mdk5.14 installation tutorial (with download link)

TIPC Service and Topology Tracking4

The most detailed MySQL installation tutorial

Verilog 和VHDL有符号数和无符号数相关运算
随机推荐
Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)
TIPC introduction 1
[AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?
Array splitting (regular thinking
Implement custom drawer component in quick application
ros缺少catkin_pkg
String (Analog
C# 文件与文件夹操作
二.Stm32f407芯片GPIO编程,寄存器操作,库函数操作和位段操作
Xiao Sha's pain (double pointer
[applinking practical case] share in app pictures through applinking
金山云——2023届暑期实习
一.STM32的开发环境,keil5/MDK5.14安装教程(附下载链接)
Iii. Système de démarrage et d'horloge à puce
[ark UI] implementation of the startup page of harmonios ETS
Astparser parsing class files with enum enumeration methods
The first white paper on agile practice in Chinese enterprises was released | complete download is attached
ctf 记录
From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
Importerror: impossible d'importer le nom « graph» de « graphviz»