当前位置:网站首页>[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
边栏推荐
- [paid promotion] collection of frequently asked questions, recommended list FAQ
- [play with FPGA learning 2 in simple terms ----- design skills (basic grammar)]
- Compilation errors and printout garbled problems caused by Chinese content in vs2019 code
- Native method merge word
- Astparser parsing class files with enum enumeration methods
- ASTParser 解析含有emum 枚举方法的类文件的踩坑记
- TIPC Service and Topology Tracking4
- Creation and use of unified links in Huawei applinking
- STM32单片机编程学习
- TIPC 寻址2
猜你喜欢

Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?

三.芯片启动和时钟系统

Verilog and VHDL signed and unsigned number correlation operations

金山云——2023届暑期实习

The first white paper on agile practice in Chinese enterprises was released | complete download is attached

Summary of data export methods in powerbi

How to implement tabbar title bar with list component

Tick Data and Resampling
![[AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?](/img/66/674a06d8e45a31ae879b81554ef373.png)
[AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?

ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
随机推荐
Importerror: impossible d'importer le nom « graph» de « graphviz»
spritejs
SSRF
Compilation errors and printout garbled problems caused by Chinese content in vs2019 code
Flick two open, realized a batch lookup join (with source code)
PKG package manager usage instance in FreeBSD
Regular and common formulas
Multi line display and single line display of tqdm
One trick to quickly realize custom application titlebar
ros gazebo相关包的安装
webauthn——官方开发文档
Eight sorting summaries
启牛商学院给的股票账户安全吗?能开户吗?
STM32 single chip microcomputer programming learning
What are the methods of adding elements to arrays in JS
ros缺少catkin_pkg
Tick Data and Resampling
【深入浅出玩转FPGA学习3-----基本语法】
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
TIPC messaging3