[UPDATE]:新增代码生成器
This commit is contained in:
parent
2e5a704abd
commit
1975a0a8a3
|
@ -97,8 +97,7 @@ token:
|
||||||
# 令牌有效期(默认30分钟)
|
# 令牌有效期(默认30分钟)
|
||||||
expireTime: 30
|
expireTime: 30
|
||||||
|
|
||||||
# MyBatis配置
|
mybatis-plus:
|
||||||
mybatis:
|
|
||||||
# 搜索指定包别名
|
# 搜索指定包别名
|
||||||
typeAliasesPackage: com.tcctlo.**.domain
|
typeAliasesPackage: com.tcctlo.**.domain
|
||||||
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||||
|
|
|
@ -140,6 +140,12 @@
|
||||||
<version>1.18.24</version>
|
<version>1.18.24</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mybatis-plus 增强CRUD -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>3.5.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -55,6 +55,9 @@ public class SysUser extends BaseEntity
|
||||||
/** 密码 */
|
/** 密码 */
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
/** 职工在职状态(0正常,1离职) */
|
||||||
|
private Integer employedStatus;
|
||||||
|
|
||||||
/** 帐号状态(0正常 1停用) */
|
/** 帐号状态(0正常 1停用) */
|
||||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||||
private String status;
|
private String status;
|
||||||
|
@ -62,6 +65,14 @@ public class SysUser extends BaseEntity
|
||||||
/** 删除标志(0代表存在 2代表删除) */
|
/** 删除标志(0代表存在 2代表删除) */
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
|
public Integer getEmployedStatus() {
|
||||||
|
return employedStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmployedStatus(Integer employedStatus) {
|
||||||
|
this.employedStatus = employedStatus;
|
||||||
|
}
|
||||||
|
|
||||||
/** 最后登录IP */
|
/** 最后登录IP */
|
||||||
@Excel(name = "最后登录IP", type = Type.EXPORT)
|
@Excel(name = "最后登录IP", type = Type.EXPORT)
|
||||||
private String loginIp;
|
private String loginIp;
|
||||||
|
|
|
@ -1,132 +0,0 @@
|
||||||
package com.tcctlo.framework.config;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
import org.apache.ibatis.io.VFS;
|
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
|
||||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
|
||||||
import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
import org.springframework.core.io.DefaultResourceLoader;
|
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
|
||||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
|
||||||
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
|
||||||
import org.springframework.core.type.classreading.MetadataReader;
|
|
||||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
|
||||||
import org.springframework.util.ClassUtils;
|
|
||||||
import com.tcctlo.common.utils.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mybatis支持*匹配扫描包
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class MyBatisConfig
|
|
||||||
{
|
|
||||||
@Autowired
|
|
||||||
private Environment env;
|
|
||||||
|
|
||||||
static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
|
|
||||||
|
|
||||||
public static String setTypeAliasesPackage(String typeAliasesPackage)
|
|
||||||
{
|
|
||||||
ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver();
|
|
||||||
MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
|
|
||||||
List<String> allResult = new ArrayList<String>();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
for (String aliasesPackage : typeAliasesPackage.split(","))
|
|
||||||
{
|
|
||||||
List<String> result = new ArrayList<String>();
|
|
||||||
aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
|
|
||||||
+ ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN;
|
|
||||||
Resource[] resources = resolver.getResources(aliasesPackage);
|
|
||||||
if (resources != null && resources.length > 0)
|
|
||||||
{
|
|
||||||
MetadataReader metadataReader = null;
|
|
||||||
for (Resource resource : resources)
|
|
||||||
{
|
|
||||||
if (resource.isReadable())
|
|
||||||
{
|
|
||||||
metadataReader = metadataReaderFactory.getMetadataReader(resource);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName());
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (result.size() > 0)
|
|
||||||
{
|
|
||||||
HashSet<String> hashResult = new HashSet<String>(result);
|
|
||||||
allResult.addAll(hashResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (allResult.size() > 0)
|
|
||||||
{
|
|
||||||
typeAliasesPackage = String.join(",", (String[]) allResult.toArray(new String[0]));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return typeAliasesPackage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Resource[] resolveMapperLocations(String[] mapperLocations)
|
|
||||||
{
|
|
||||||
ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
|
|
||||||
List<Resource> resources = new ArrayList<Resource>();
|
|
||||||
if (mapperLocations != null)
|
|
||||||
{
|
|
||||||
for (String mapperLocation : mapperLocations)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Resource[] mappers = resourceResolver.getResources(mapperLocation);
|
|
||||||
resources.addAll(Arrays.asList(mappers));
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resources.toArray(new Resource[resources.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
|
|
||||||
{
|
|
||||||
String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
|
|
||||||
String mapperLocations = env.getProperty("mybatis.mapperLocations");
|
|
||||||
String configLocation = env.getProperty("mybatis.configLocation");
|
|
||||||
typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
|
|
||||||
VFS.addImplClass(SpringBootVFS.class);
|
|
||||||
|
|
||||||
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
|
||||||
sessionFactory.setDataSource(dataSource);
|
|
||||||
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
|
|
||||||
sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
|
|
||||||
sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
|
|
||||||
return sessionFactory.getObject();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.tcctlo.framework.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mybatis Plus 配置
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@EnableTransactionManagement(proxyTargetClass = true)
|
||||||
|
@Configuration
|
||||||
|
public class MybatisPlusConfig
|
||||||
|
{
|
||||||
|
@Bean
|
||||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor()
|
||||||
|
{
|
||||||
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
|
// 分页插件
|
||||||
|
interceptor.addInnerInterceptor(paginationInnerInterceptor());
|
||||||
|
// 乐观锁插件
|
||||||
|
interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
|
||||||
|
// 阻断插件
|
||||||
|
interceptor.addInnerInterceptor(blockAttackInnerInterceptor());
|
||||||
|
return interceptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页插件,自动识别数据库类型 https://baomidou.com/guide/interceptor-pagination.html
|
||||||
|
*/
|
||||||
|
public PaginationInnerInterceptor paginationInnerInterceptor()
|
||||||
|
{
|
||||||
|
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
|
||||||
|
// 设置数据库类型为mysql
|
||||||
|
paginationInnerInterceptor.setDbType(DbType.MYSQL);
|
||||||
|
// 设置最大单页限制数量,默认 500 条,-1 不受限制
|
||||||
|
paginationInnerInterceptor.setMaxLimit(-1L);
|
||||||
|
return paginationInnerInterceptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 乐观锁插件 https://baomidou.com/guide/interceptor-optimistic-locker.html
|
||||||
|
*/
|
||||||
|
public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor()
|
||||||
|
{
|
||||||
|
return new OptimisticLockerInnerInterceptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果是对全表的删除或更新操作,就会终止该操作 https://baomidou.com/guide/interceptor-block-attack.html
|
||||||
|
*/
|
||||||
|
public BlockAttackInnerInterceptor blockAttackInnerInterceptor()
|
||||||
|
{
|
||||||
|
return new BlockAttackInnerInterceptor();
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,6 +35,20 @@
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.davidfantasy</groupId>
|
||||||
|
<artifactId>mybatis-plus-generator-ui</artifactId>
|
||||||
|
<version>1.4.5</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>8.0.33</version> <!-- 根据需要选择版本 -->
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,45 @@
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.github.davidfantasy.mybatisplus.generatorui.GeneratorConfig;
|
||||||
|
import com.github.davidfantasy.mybatisplus.generatorui.MybatisPlusToolsApplication;
|
||||||
|
import com.github.davidfantasy.mybatisplus.generatorui.mbp.NameConverter;
|
||||||
|
|
||||||
|
public class GeneratorUIServer {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
GeneratorConfig config = GeneratorConfig.builder().jdbcUrl("jdbc:mysql://localhost:3306/low-office-oa?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8")
|
||||||
|
.userName("root")
|
||||||
|
.password("root")
|
||||||
|
.driverClassName("com.mysql.cj.jdbc.Driver")
|
||||||
|
//数据库schema,MSSQL,PGSQL,ORACLE,DB2类型的数据库需要指定
|
||||||
|
.schemaName("low-office-oa")
|
||||||
|
//数据库表前缀,生成entity名称时会去掉(v2.0.3新增)
|
||||||
|
// .tablePrefix("t_")
|
||||||
|
//如果需要修改entity及其属性的命名规则,以及自定义各类生成文件的命名规则,可自定义一个NameConverter实例,覆盖相应的名称转换方法,详细可查看该接口的说明:
|
||||||
|
.nameConverter(new NameConverter() {
|
||||||
|
/**
|
||||||
|
* 自定义Service类文件的名称规则,entityName是NameConverter.entityNameConvert处理表名后的返回结果,如有特别的需求可以自定义实现
|
||||||
|
*/
|
||||||
|
/*@Override
|
||||||
|
public String serviceNameConvert(String entityName) {
|
||||||
|
return entityName + "Service";
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义Controller类文件的名称规则
|
||||||
|
*/
|
||||||
|
/*@Override
|
||||||
|
public String controllerNameConvert(String entityName) {
|
||||||
|
return entityName + "Action";
|
||||||
|
}*/
|
||||||
|
@Override
|
||||||
|
public String entityNameConvert(String tableName) {
|
||||||
|
String camelCase = StrUtil.toCamelCase(tableName);
|
||||||
|
return StrUtil.upperFirst(camelCase);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
//所有生成的java文件的父包名,后续也可单独在界面上设置
|
||||||
|
.basePackage("com.tcctyn.forestfire")
|
||||||
|
.port(8068)
|
||||||
|
.build();
|
||||||
|
MybatisPlusToolsApplication.run(config);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
package ${package.Controller};
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
<% if(!restControllerStyle){ %>
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
<% } %>
|
||||||
|
<% if(isNotEmpty(superControllerClassPackage)){ %>
|
||||||
|
import ${superControllerClassPackage};
|
||||||
|
<% } %>
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.list)){ %>
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
<% } %>
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.hasMethod)){ %>
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import ${package.Service}.${table.serviceName};
|
||||||
|
import ${package.Entity}.${table.entityName};
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* ${table.comment!} 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("<% if(isNotEmpty(package.ModuleName)){ %>/${package.ModuleName}<% } %>/<% if(isNotEmpty(controllerMappingHyphenStyle)){ %>${controllerMappingHyphen}<% }else{ %>${table.entityPath}<% } %>")
|
||||||
|
<% if(kotlin){ %>
|
||||||
|
class ${table.controllerName}<% if(isNotEmpty(superControllerClass)){ %> : ${superControllerClass}()<% } %>
|
||||||
|
<% }else{ %>
|
||||||
|
<% if(isNotEmpty(superControllerClass)){ %>
|
||||||
|
public class ${table.controllerName} extends ${superControllerClass} {
|
||||||
|
<% }else{ %>
|
||||||
|
public class ${table.controllerName} {
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<%
|
||||||
|
var serviceInstanceName = @cn.hutool.core.util.StrUtil.lowerFirst(table.serviceName);
|
||||||
|
%>
|
||||||
|
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.hasMethod)){ %>
|
||||||
|
@Autowired
|
||||||
|
private ${table.serviceName} ${serviceInstanceName};
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.list)){ %>
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public AjaxResult list(@RequestParam(required = false) Integer current, @RequestParam(required = false) Integer size) {
|
||||||
|
if (current == null) {
|
||||||
|
current = 1;
|
||||||
|
}
|
||||||
|
if (size == null) {
|
||||||
|
size = 10;
|
||||||
|
}
|
||||||
|
Page<${table.entityName}> pageList = ${serviceInstanceName}.list(current,size);
|
||||||
|
return AjaxResult.success(pageList);
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.getById)){ %>
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getById(@PathVariable("id") Long id) {
|
||||||
|
${table.entityName} ${@cn.hutool.core.util.StrUtil.lowerFirst(table.entityName)} = ${serviceInstanceName}.getById(id);
|
||||||
|
return AjaxResult.success(${@cn.hutool.core.util.StrUtil.lowerFirst(table.entityName)});
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.create)){ %>
|
||||||
|
@PostMapping(value = "/create")
|
||||||
|
public AjaxResult create(@RequestBody ${table.entityName} params) {
|
||||||
|
Integer result = ${serviceInstanceName}.create(params);
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.delete)){ %>
|
||||||
|
@PostMapping(value = "/delete/{id}")
|
||||||
|
public AjaxResult delete(@PathVariable("id") Long id) {
|
||||||
|
Integer result = ${serviceInstanceName}.delete(id);
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.update)){ %>
|
||||||
|
@PostMapping(value = "/update")
|
||||||
|
public AjaxResult update(@RequestBody ${table.entityName} params) {
|
||||||
|
Integer result = ${serviceInstanceName}.update(params);
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
}
|
||||||
|
<% } %>
|
|
@ -0,0 +1,99 @@
|
||||||
|
package ${package.Controller};
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
<% if(!restControllerStyle){ %>
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
<% } %>
|
||||||
|
<% if(isNotEmpty(superControllerClassPackage)){ %>
|
||||||
|
import ${superControllerClassPackage};
|
||||||
|
<% } %>
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.list)){ %>
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
<% } %>
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.hasMethod)){ %>
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import ${package.Service}.${table.serviceName};
|
||||||
|
import ${package.Entity}.${table.entityName};
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import com.tcctyn.common.core.controller.BaseController;
|
||||||
|
import com.tcctyn.common.core.domain.AjaxResult;
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* ${table.comment!} 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("<% if(isNotEmpty(package.ModuleName)){ %>/${package.ModuleName}<% } %>/<% if(isNotEmpty(controllerMappingHyphenStyle)){ %>${controllerMappingHyphen}<% }else{ %>${table.entityPath}<% } %>")
|
||||||
|
<% if(kotlin){ %>
|
||||||
|
class ${table.controllerName}<% if(isNotEmpty(superControllerClass)){ %> : ${superControllerClass}()<% } %>
|
||||||
|
<% }else{ %>
|
||||||
|
<% if(isNotEmpty(superControllerClass)){ %>
|
||||||
|
public class ${table.controllerName} extends ${superControllerClass} {
|
||||||
|
<% }else{ %>
|
||||||
|
public class ${table.controllerName} {
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<%
|
||||||
|
var serviceInstanceName = @cn.hutool.core.util.StrUtil.lowerFirst(table.serviceName);
|
||||||
|
%>
|
||||||
|
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.hasMethod)){ %>
|
||||||
|
@Autowired
|
||||||
|
private ${table.serviceName} ${serviceInstanceName};
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.list)){ %>
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public AjaxResult list(@RequestParam(required = false) Integer current, @RequestParam(required = false) Integer size) {
|
||||||
|
if (current == null) {
|
||||||
|
current = 1;
|
||||||
|
}
|
||||||
|
if (size == null) {
|
||||||
|
size = 10;
|
||||||
|
}
|
||||||
|
Page<${table.entityName}> pageList = ${serviceInstanceName}.list(current,size);
|
||||||
|
return AjaxResult.success(pageList);
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.getById)){ %>
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getById(@PathVariable("id") Long id) {
|
||||||
|
${table.entityName} ${@cn.hutool.core.util.StrUtil.lowerFirst(table.entityName)} = ${serviceInstanceName}.getById(id);
|
||||||
|
return AjaxResult.success(${@cn.hutool.core.util.StrUtil.lowerFirst(table.entityName)});
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.create)){ %>
|
||||||
|
@PostMapping(value = "/create")
|
||||||
|
public AjaxResult create(@RequestBody ${table.entityName} params) {
|
||||||
|
Integer result = ${serviceInstanceName}.create(params);
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.delete)){ %>
|
||||||
|
@PostMapping(value = "/delete/{id}")
|
||||||
|
public AjaxResult delete(@PathVariable("id") Long id) {
|
||||||
|
Integer result = ${serviceInstanceName}.delete(id);
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% if(isNotEmpty(cfg.controllerMethods.update)){ %>
|
||||||
|
@PostMapping(value = "/update")
|
||||||
|
public AjaxResult update(@RequestBody ${table.entityName} params) {
|
||||||
|
Integer result = ${serviceInstanceName}.update(params);
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
}
|
||||||
|
<% } %>
|
|
@ -0,0 +1,78 @@
|
||||||
|
package ${package.Service};
|
||||||
|
|
||||||
|
import ${package.Entity}.${entity};
|
||||||
|
import ${superServiceClassPackage};
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* ${table.comment!} 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
public interface ${table.serviceName} {
|
||||||
|
<%
|
||||||
|
var paramsName = @cn.hutool.core.util.StrUtil.lowerFirst(table.entityName);
|
||||||
|
%>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 分页列表查询
|
||||||
|
* </p>
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
Page<${table.entityName}> list(Integer pageNo, Integer pageSize);
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 详情接口
|
||||||
|
* </p>
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
${table.entityName} getById(Long id);
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 新增接口
|
||||||
|
* </p>
|
||||||
|
* @param ${paramsName}
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
Integer create(${table.entityName} ${paramsName});
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 删除接口
|
||||||
|
* </p>
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
Integer delete(Long id);
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 更新接口
|
||||||
|
* </p>
|
||||||
|
* @param ${paramsName}
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
Integer update(${table.entityName} ${paramsName});
|
||||||
|
<% } %>
|
||||||
|
}
|
||||||
|
<% } %>
|
|
@ -0,0 +1,64 @@
|
||||||
|
package ${package.Service}.impl;
|
||||||
|
|
||||||
|
import ${package.Entity}.${entity};
|
||||||
|
import ${superServiceClassPackage};
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* ${table.comment!} 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
@Service
|
||||||
|
public class ${table.serviceImplName} extends ServiceImpl<${table.entityName}Mapper,${table.entityName}> implements ${table.serviceName} {
|
||||||
|
|
||||||
|
<%
|
||||||
|
var paramsName = @cn.hutool.core.util.StrUtil.lowerFirst(table.entityName);
|
||||||
|
%>
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ${table.entityName}Mapper ${paramsName}Mapper;
|
||||||
|
|
||||||
|
<% { %>
|
||||||
|
@Override
|
||||||
|
public Page<${table.entityName}> list(Integer pageNo, Integer pageSize) {
|
||||||
|
return ${paramsName}Mapper.selectPage(new Page<>(pageNo, pageSize), new QueryWrapper<>());
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% { %>
|
||||||
|
@Override
|
||||||
|
public ${table.entityName} getById(Long id) {
|
||||||
|
${table.entityName} ${paramsName} = ${paramsName}Mapper.selectById(id);
|
||||||
|
return ${paramsName};
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% { %>
|
||||||
|
@Override
|
||||||
|
public Integer create(${table.entityName} ${paramsName}) {
|
||||||
|
return ${paramsName}Mapper.insert(${paramsName});
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% { %>
|
||||||
|
@Override
|
||||||
|
public Integer delete(Long id) {
|
||||||
|
return ${paramsName}Mapper.deleteById(id);
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% { %>
|
||||||
|
@Override
|
||||||
|
public Integer update(${table.entityName} ${paramsName}) {
|
||||||
|
return ${paramsName}Mapper.updateById(${paramsName});
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
}
|
||||||
|
<% } %>
|
|
@ -0,0 +1,80 @@
|
||||||
|
package ${package.Service};
|
||||||
|
|
||||||
|
import ${package.Entity}.${entity};
|
||||||
|
import ${superServiceClassPackage};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* ${table.comment!} 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
public interface ${table.serviceName} {
|
||||||
|
|
||||||
|
<%
|
||||||
|
var paramsName = @cn.hutool.core.util.StrUtil.lowerFirst(table.entityName);
|
||||||
|
%>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 分页列表查询
|
||||||
|
* </p>
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
Page<${table.entityName}> list(Integer pageNo, Integer pageSize);
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 详情接口
|
||||||
|
* </p>
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
${table.entityName} getById(Long id);
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 新增接口
|
||||||
|
* </p>
|
||||||
|
* @param ${paramsName}
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
Integer create(${table.entityName} ${paramsName});
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 逻辑删除接口
|
||||||
|
* </p>
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
Integer delete(Long id);
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 更新接口
|
||||||
|
* </p>
|
||||||
|
* @param ${paramsName}
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
Integer update(${table.entityName} ${paramsName});
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
<% } %>
|
|
@ -0,0 +1,65 @@
|
||||||
|
package ${package.Service}.impl;
|
||||||
|
|
||||||
|
import ${package.Entity}.${entity};
|
||||||
|
import ${superServiceClassPackage};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* ${table.comment!} 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @since ${date}
|
||||||
|
*/
|
||||||
|
<% { %>
|
||||||
|
|
||||||
|
public class ${table.serviceImplName} extends ServiceImpl<${table.entityName}Mapper,${table.entityName}> implements ${table.serviceName} {
|
||||||
|
|
||||||
|
<%
|
||||||
|
var paramsName = @cn.hutool.core.util.StrUtil.lowerFirst(table.entityName);
|
||||||
|
%>
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ${table.entityName}Mapper ${paramsName}Mapper;
|
||||||
|
|
||||||
|
<% { %>
|
||||||
|
@Override
|
||||||
|
public Page<${table.entityName}> list(Integer pageNo, Integer pageSize) {
|
||||||
|
return ${paramsName}Mapper.selectPage(new Page<>(pageNo, pageSize), new QueryWrapper<>());
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% { %>
|
||||||
|
@Override
|
||||||
|
public ${table.entityName} getById(Long id) {
|
||||||
|
${table.entityName} ${paramsName} = ${paramsName}Mapper.selectById(id);
|
||||||
|
return ${paramsName};
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% { %>
|
||||||
|
@Override
|
||||||
|
public Integer create(${table.entityName} ${paramsName}) {
|
||||||
|
return ${paramsName}Mapper.insert(${paramsName});
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% { %>
|
||||||
|
@Override
|
||||||
|
public Integer delete(Long id) {
|
||||||
|
${table.entityName} ${paramsName} = new ${table.entityName}();
|
||||||
|
${paramsName}.setId(id);
|
||||||
|
${paramsName}.setDelFlag(1);
|
||||||
|
return ${paramsName}Mapper.updateById(${paramsName});
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<% { %>
|
||||||
|
@Override
|
||||||
|
public Integer update(${table.entityName} ${paramsName}) {
|
||||||
|
return ${paramsName}Mapper.updateById(${paramsName});
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
}
|
||||||
|
<% } %>
|
|
@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="sex" column="sex" />
|
<result property="sex" column="sex" />
|
||||||
<result property="avatar" column="avatar" />
|
<result property="avatar" column="avatar" />
|
||||||
<result property="password" column="password" />
|
<result property="password" column="password" />
|
||||||
|
<result property="employedStatus" column="employed_status" />
|
||||||
<result property="status" column="status" />
|
<result property="status" column="status" />
|
||||||
<result property="delFlag" column="del_flag" />
|
<result property="delFlag" column="del_flag" />
|
||||||
<result property="loginIp" column="login_ip" />
|
<result property="loginIp" column="login_ip" />
|
||||||
|
@ -57,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
|
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.employed_status, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
where u.del_flag = '0'
|
where u.del_flag = '0'
|
||||||
<if test="userId != null and userId != 0">
|
<if test="userId != null and userId != 0">
|
||||||
|
|
Loading…
Reference in New Issue