当前位置:网站首页>[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
边栏推荐
- 从ros1到ros2配置的一些东西
- Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?
- 函数式接口和方法引用
- What are the methods of adding elements to arrays in JS
- Flink two Open, implement Batch Lookup join (attached source)
- Xiao Sha's pain (double pointer
- Logu p3398 hamster looks for sugar (double LCA on the tree to judge whether the two paths in the tree intersect)
- Resources reads 2D texture and converts it to PNG format
- 三.芯片启动和时钟系统
- C file and folder operation
猜你喜欢
Thanos Receiver
Luogu p5536 [xr-3] core city (greed + tree DP looking for the center of the tree)
【IDEA】使用插件一键逆向生成代码
Win11 arm system configuration Net core environment variable
TIPC addressing 2
III Chip startup and clock system
Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?
Compilation errors and printout garbled problems caused by Chinese content in vs2019 code
PowerBI中导出数据方法汇总
How to transfer event objects and user-defined parameters simultaneously in Huawei express applications
随机推荐
通过券商经理的开户二维码开股票账户安全吗?还是去证券公司开户安全?
Tick Data and Resampling
TIPC messaging3
Luogu p5536 [xr-3] core city (greed + tree DP looking for the center of the tree)
二.Stm32f407芯片GPIO编程,寄存器操作,库函数操作和位段操作
php中self和static在方法中的区别
TIPC protocol
Resources读取2d纹理 转换为png格式
[play with FPGA learning 5 in simple terms ----- reset design]
STM32单片机编程学习
Mongodb learning and sorting (condition operator, $type operator, limit() method, skip() method and sort() method)
CentOS8之mysql基本用法
Gaode draws lines according to the track
Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)
TIPC 寻址2
LVM操作
【深入浅出玩转FPGA学习4----漫谈状态机设计】
The first white paper on agile practice in Chinese enterprises was released | complete download is attached
webauthn——官方开发文档
[ark UI] implementation of the startup page of harmonios ETS