Pre Merge pull request !213 from 刘星/master
This commit is contained in:
commit
762be0b685
17
README.md
17
README.md
|
|
@ -1,5 +1,22 @@
|
|||
## 平台简介
|
||||
|
||||
本项目FORK自 [若依/RuoYi](https://gitee.com/y_project/RuoYi)
|
||||
|
||||
花了点时间做了以下改动:
|
||||
###### 更新springboot
|
||||
更新springboot版本至2.1.17.RELEASE
|
||||
|
||||
###### 集成mybatis-plus
|
||||
一直在项目中使用mybatis-plus,觉得这个方便好用,尽量保持原代码以方便从主干合并,
|
||||
core包提供BaseCrudMapper、BaseService、BaseServiceImpl继承即可,并且在代码生成器中已更新
|
||||
|
||||
###### 添加lombok
|
||||
为开发方便集成了lombok以提高开发效率
|
||||
|
||||
###### 控制台日志分等级彩色渲染和多环境修改
|
||||
具体看logback-spring.xml和application.xml改动
|
||||
|
||||
|
||||
一直想做一款后台管理系统,看了很多优秀的开源项目但是发现没有合适的。于是利用空闲休息时间开始自己写了一套后台系统。如此有了若依。她可以用于所有的Web应用程序,如网站管理后台,网站会员中心,CMS,CRM,OA。所有前端后台代码封装过后十分精简易上手,出错概率低。同时支持移动客户端访问。系统会陆续更新一些实用功能。
|
||||
|
||||
性别男,若依是给还没有出生女儿取的名字(寓意:你若不离不弃,我必生死相依)
|
||||
|
|
|
|||
12
pom.xml
12
pom.xml
|
|
@ -20,11 +20,12 @@
|
|||
<shiro.version>1.6.0</shiro.version>
|
||||
<thymeleaf.extras.shiro.version>2.0.0</thymeleaf.extras.shiro.version>
|
||||
<mybatis.boot.version>1.3.2</mybatis.boot.version>
|
||||
<druid.version>1.1.22</druid.version>
|
||||
<druid.version>1.1.23</druid.version>
|
||||
<bitwalker.version>1.19</bitwalker.version>
|
||||
<kaptcha.version>2.3.2</kaptcha.version>
|
||||
<swagger.version>2.9.2</swagger.version>
|
||||
<pagehelper.boot.version>1.2.5</pagehelper.boot.version>
|
||||
<pagehelper.boot.version>1.3.0</pagehelper.boot.version>
|
||||
<mybatis.plus.version>3.4.0</mybatis.plus.version>
|
||||
<fastjson.version>1.2.73</fastjson.version>
|
||||
<oshi.version>3.9.1</oshi.version>
|
||||
<commons.io.version>2.5</commons.io.version>
|
||||
|
|
@ -102,6 +103,13 @@
|
|||
<version>${pagehelper.boot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- MyBatis Plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis.plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 获取系统信息 -->
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,10 @@
|
|||
server:
|
||||
# 服务器的HTTP端口,默认为80
|
||||
port: 8081
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
|
||||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
|
|
@ -6,9 +13,9 @@ spring:
|
|||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: password
|
||||
url: jdbc:mysql://106.75.99.248:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: ry
|
||||
password: hyWaxqSnANWgYRnmjABmdEk6SbMyCzma
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
server:
|
||||
# 服务器的HTTP端口,默认为80
|
||||
port: 8081
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
|
||||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://106.75.99.248:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: ry
|
||||
password: hyWaxqSnANWgYRnmjABmdEk6SbMyCzma
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
enabled: false
|
||||
url:
|
||||
username:
|
||||
password:
|
||||
# 初始连接数
|
||||
initialSize: 5
|
||||
# 最小连接池数量
|
||||
minIdle: 10
|
||||
# 最大连接池数量
|
||||
maxActive: 20
|
||||
# 配置获取连接等待超时的时间
|
||||
maxWait: 60000
|
||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||
maxEvictableIdleTimeMillis: 900000
|
||||
# 配置检测连接是否有效
|
||||
validationQuery: SELECT 1 FROM DUAL
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
webStatFilter:
|
||||
enabled: true
|
||||
statViewServlet:
|
||||
enabled: true
|
||||
# 设置白名单,不填则允许所有访问
|
||||
allow:
|
||||
url-pattern: /druid/*
|
||||
# 控制台管理用户名和密码
|
||||
login-username:
|
||||
login-password:
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
# 慢SQL记录
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 1000
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
|
|
@ -15,11 +15,6 @@ ruoyi:
|
|||
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为80
|
||||
port: 80
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
tomcat:
|
||||
# tomcat的URI编码
|
||||
uri-encoding: UTF-8
|
||||
|
|
@ -27,6 +22,7 @@ server:
|
|||
max-threads: 800
|
||||
# Tomcat启动初始化的线程数,默认值25
|
||||
min-spare-threads: 30
|
||||
connection-timeout: 5000
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
|
|
@ -56,7 +52,7 @@ spring:
|
|||
time-zone: GMT+8
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
profiles:
|
||||
active: druid
|
||||
active: dev
|
||||
# 文件上传
|
||||
servlet:
|
||||
multipart:
|
||||
|
|
@ -70,14 +66,34 @@ spring:
|
|||
# 热部署开关
|
||||
enabled: true
|
||||
|
||||
# MyBatis
|
||||
mybatis:
|
||||
# 搜索指定包别名
|
||||
typeAliasesPackage: com.ruoyi.**.domain
|
||||
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||
# 加载全局的配置文件
|
||||
configLocation: classpath:mybatis/mybatis-config.xml
|
||||
# MyBatis Plus
|
||||
mybatis-plus:
|
||||
# MyBaits 别名包扫描路径,通过该属性可以给包中的类注册别名,注册后在 Mapper 对应的 XML 文件中可以直接使用类名,而不用使用全限定的类名 (即 XML 中调用的时候不用包含包名)
|
||||
type-aliases-package: com.ruoyi.**.domain
|
||||
# MyBatis Mapper 所对应的 XML 文件位置,如果您在 Mapper 中有自定义方法 (XML 中有自定义实现),需要进行该配置,告诉 Mapper 所对应的 XML 文件位置。Maven 多模块项目的扫描路径需以 classpath*: 开头 (即加载多个 jar 包下的 XML 文件)
|
||||
mapper-locations: classpath*:mapper/**/*.xml
|
||||
# MyBatis 配置文件位置,如果您有单独的 MyBatis 配置,请将其路径配置到 configLocation 中
|
||||
# config-location: classpath:mybatis/mybatis-config.xml
|
||||
global-config:
|
||||
db-config:
|
||||
# 全局默认主键类型
|
||||
id-type: auto
|
||||
# 逻辑已删除值,默认为 1
|
||||
logic-delete-value: -1
|
||||
# 逻辑未删除值,默认为 0
|
||||
logic-not-delete-value: 0
|
||||
banner: false
|
||||
configuration:
|
||||
# 全局地开启或关闭配置文件中的所有映射器已经配置的任何缓存,默认为 true
|
||||
cache-enabled: false
|
||||
# 允许 JDBC 支持自动生成主键,默认为 true
|
||||
# use-generated-keys: true
|
||||
# 配置默认的执行器
|
||||
default-executor-type: reuse
|
||||
# 指定所用日志的具体实现
|
||||
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
call-setters-on-nulls: true
|
||||
jdbc-type-for-null: 'null'
|
||||
|
||||
# PageHelper分页插件
|
||||
pagehelper:
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="/home/ruoyi/logs" />
|
||||
<property name="log.path" value="logs" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.colorPattern" value="%d{yyyy-MM-dd HH:mm:ss} | %highlight(%-5level) | %boldYellow(%thread) | %boldGreen(%logger) | %msg%n"/>
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
<pattern>${log.colorPattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
|
|
|||
|
|
@ -722,13 +722,9 @@ var table = {
|
|||
$.modal.alert(content, modal_status.WARNING);
|
||||
},
|
||||
// 关闭窗体
|
||||
close: function (index) {
|
||||
if($.common.isEmpty(index)){
|
||||
var index = parent.layer.getFrameIndex(window.name);
|
||||
parent.layer.close(index);
|
||||
} else {
|
||||
layer.close(index);
|
||||
}
|
||||
close: function () {
|
||||
var index = parent.layer.getFrameIndex(window.name);
|
||||
parent.layer.close(index);
|
||||
},
|
||||
// 关闭全部窗体
|
||||
closeAll: function () {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@
|
|||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MyBatis Plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 自定义验证注解 -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
|
|
@ -101,6 +107,11 @@
|
|||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -179,4 +179,17 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
{
|
||||
return new AjaxResult(Type.ERROR, msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 方便链式调用
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import java.io.Serializable;
|
|||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
|
|
@ -16,6 +18,7 @@ public class BaseEntity implements Serializable
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 搜索值 */
|
||||
@TableField(exist = false)
|
||||
private String searchValue;
|
||||
|
||||
/** 创建者 */
|
||||
|
|
@ -36,6 +39,7 @@ public class BaseEntity implements Serializable
|
|||
private String remark;
|
||||
|
||||
/** 请求参数 */
|
||||
@TableField(exist = false)
|
||||
private Map<String, Object> params;
|
||||
|
||||
public String getSearchValue()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.ruoyi.common.core.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
|
||||
/**
|
||||
* Tree基类
|
||||
*
|
||||
|
|
@ -10,6 +12,7 @@ public class TreeEntity extends BaseEntity
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 父菜单名称 */
|
||||
@TableField(exist = false)
|
||||
private String parentName;
|
||||
|
||||
/** 父菜单ID */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.common.core.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 基础CRUD的父类Mapper
|
||||
*
|
||||
* @author liuxing
|
||||
*/
|
||||
public interface BaseCrudMapper<T> extends BaseMapper<T> {
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.common.core.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 基础服务Service
|
||||
*
|
||||
* @author liuxing
|
||||
*/
|
||||
public interface BaseService<T> extends IService<T> {
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.common.core.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.mapper.BaseCrudMapper;
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
|
||||
/**
|
||||
* @author liuxing
|
||||
*/
|
||||
public class BaseServiceImpl<M extends BaseCrudMapper<T>, T> extends ServiceImpl<M, T> implements BaseService<T> {
|
||||
}
|
||||
|
|
@ -249,19 +249,19 @@ public class ExcelUtil<T>
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val)))
|
||||
else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType))
|
||||
{
|
||||
val = Convert.toInt(val);
|
||||
}
|
||||
else if (Long.TYPE == fieldType || Long.class == fieldType)
|
||||
else if ((Long.TYPE == fieldType) || (Long.class == fieldType))
|
||||
{
|
||||
val = Convert.toLong(val);
|
||||
}
|
||||
else if (Double.TYPE == fieldType || Double.class == fieldType)
|
||||
else if ((Double.TYPE == fieldType) || (Double.class == fieldType))
|
||||
{
|
||||
val = Convert.toDouble(val);
|
||||
}
|
||||
else if (Float.TYPE == fieldType || Float.class == fieldType)
|
||||
else if ((Float.TYPE == fieldType) || (Float.class == fieldType))
|
||||
{
|
||||
val = Convert.toFloat(val);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,108 +0,0 @@
|
|||
package com.ruoyi.framework.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
@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(new PathMatchingResourcePatternResolver().getResources(mapperLocations));
|
||||
sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
|
||||
return sessionFactory.getObject();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.ruoyi.framework.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* mybatis-plus配置
|
||||
*
|
||||
* @author Mark sunlightcs@gmail.com
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
@Bean
|
||||
public ISqlInjector sqlInjector() {
|
||||
return new DefaultSqlInjector();
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,10 @@ package ${packageName}.domain;
|
|||
#foreach ($import in $importList)
|
||||
import ${import};
|
||||
#end
|
||||
import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
|
|
@ -23,6 +27,8 @@ import com.ruoyi.common.core.domain.TreeEntity;
|
|||
#elseif($table.tree)
|
||||
#set($Entity="TreeEntity")
|
||||
#end
|
||||
@Data
|
||||
@TableName("${tableName}")
|
||||
public class ${ClassName} extends ${Entity}
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -44,6 +50,9 @@ public class ${ClassName} extends ${Entity}
|
|||
#else
|
||||
@Excel(name = "${comment}")
|
||||
#end
|
||||
#end
|
||||
#if($column.pk)
|
||||
@TableId(type = IdType.AUTO)
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
|
|
@ -54,51 +63,51 @@ public class ${ClassName} extends ${Entity}
|
|||
private List<${subClassName}> ${subclassName}List;
|
||||
|
||||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
public void set${AttrName}($column.javaType $column.javaField)
|
||||
{
|
||||
this.$column.javaField = $column.javaField;
|
||||
}
|
||||
|
||||
public $column.javaType get${AttrName}()
|
||||
{
|
||||
return $column.javaField;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
#if($table.sub)
|
||||
public List<${subClassName}> get${subClassName}List()
|
||||
{
|
||||
return ${subclassName}List;
|
||||
}
|
||||
|
||||
public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
|
||||
{
|
||||
this.${subclassName}List = ${subclassName}List;
|
||||
}
|
||||
|
||||
#end
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
.append("${column.javaField}", get${AttrName}())
|
||||
#end
|
||||
#if($table.sub)
|
||||
.append("${subclassName}List", get${subClassName}List())
|
||||
#end
|
||||
.toString();
|
||||
}
|
||||
###foreach ($column in $columns)
|
||||
###if(!$table.isSuperColumn($column.javaField))
|
||||
###if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
###set($AttrName=$column.javaField)
|
||||
###else
|
||||
###set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
###end
|
||||
## public void set${AttrName}($column.javaType $column.javaField)
|
||||
## {
|
||||
## this.$column.javaField = $column.javaField;
|
||||
## }
|
||||
##
|
||||
## public $column.javaType get${AttrName}()
|
||||
## {
|
||||
## return $column.javaField;
|
||||
## }
|
||||
###end
|
||||
###end
|
||||
##
|
||||
###if($table.sub)
|
||||
## public List<${subClassName}> get${subClassName}List()
|
||||
## {
|
||||
## return ${subclassName}List;
|
||||
## }
|
||||
##
|
||||
## public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
|
||||
## {
|
||||
## this.${subclassName}List = ${subclassName}List;
|
||||
## }
|
||||
##
|
||||
###end
|
||||
## @Override
|
||||
## public String toString() {
|
||||
## return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
###foreach ($column in $columns)
|
||||
###if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
###set($AttrName=$column.javaField)
|
||||
###else
|
||||
###set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
###end
|
||||
## .append("${column.javaField}", get${AttrName}())
|
||||
###end
|
||||
###if($table.sub)
|
||||
## .append("${subclassName}List", get${subClassName}List())
|
||||
###end
|
||||
## .toString();
|
||||
## }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ import ${packageName}.domain.${ClassName};
|
|||
#if($table.sub)
|
||||
import ${packageName}.domain.${subClassName};
|
||||
#end
|
||||
|
||||
import com.ruoyi.common.core.mapper.BaseCrudMapper;
|
||||
/**
|
||||
* ${functionName}Mapper接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface ${ClassName}Mapper
|
||||
public interface ${ClassName}Mapper extends BaseCrudMapper<${ClassName}>
|
||||
{
|
||||
/**
|
||||
* 查询${functionName}
|
||||
|
|
@ -20,7 +20,7 @@ public interface ${ClassName}Mapper
|
|||
* @param ${pkColumn.javaField} ${functionName}ID
|
||||
* @return ${functionName}
|
||||
*/
|
||||
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
|
|
@ -28,7 +28,7 @@ public interface ${ClassName}Mapper
|
|||
* @param ${className} ${functionName}
|
||||
* @return ${functionName}集合
|
||||
*/
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
|
|
@ -36,7 +36,7 @@ public interface ${ClassName}Mapper
|
|||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${ClassName}(${ClassName} ${className});
|
||||
int insert${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
|
|
@ -44,7 +44,7 @@ public interface ${ClassName}Mapper
|
|||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${ClassName}(${ClassName} ${className});
|
||||
int update${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 删除${functionName}
|
||||
|
|
@ -52,7 +52,7 @@ public interface ${ClassName}Mapper
|
|||
* @param ${pkColumn.javaField} ${functionName}ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
|
|
@ -60,7 +60,7 @@ public interface ${ClassName}Mapper
|
|||
* @param ${pkColumn.javaField}s 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}ByIds(String[] ${pkColumn.javaField}s);
|
||||
int delete${ClassName}ByIds(String[] ${pkColumn.javaField}s);
|
||||
#if($table.sub)
|
||||
|
||||
/**
|
||||
|
|
@ -69,7 +69,7 @@ public interface ${ClassName}Mapper
|
|||
* @param customerIds 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${subClassName}By${subTableFkClassName}s(String[] ${pkColumn.javaField}s);
|
||||
int delete${subClassName}By${subTableFkClassName}s(String[] ${pkColumn.javaField}s);
|
||||
|
||||
/**
|
||||
* 批量新增${subTable.functionName}
|
||||
|
|
@ -77,7 +77,7 @@ public interface ${ClassName}Mapper
|
|||
* @param ${subclassName}List ${subTable.functionName}列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
|
||||
int batch${subClassName}(List<${subClassName}> ${subclassName}List);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -86,6 +86,6 @@ public interface ${ClassName}Mapper
|
|||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
#end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ import ${packageName}.domain.${ClassName};
|
|||
#if($table.tree)
|
||||
import com.ruoyi.common.core.domain.Ztree;
|
||||
#end
|
||||
|
||||
import com.ruoyi.common.core.service.BaseService;
|
||||
/**
|
||||
* ${functionName}Service接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface I${ClassName}Service
|
||||
public interface I${ClassName}Service extends BaseService<${ClassName}>
|
||||
{
|
||||
/**
|
||||
* 查询${functionName}
|
||||
|
|
@ -20,7 +20,7 @@ public interface I${ClassName}Service
|
|||
* @param ${pkColumn.javaField} ${functionName}ID
|
||||
* @return ${functionName}
|
||||
*/
|
||||
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
|
|
@ -28,7 +28,7 @@ public interface I${ClassName}Service
|
|||
* @param ${className} ${functionName}
|
||||
* @return ${functionName}集合
|
||||
*/
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
|
|
@ -36,7 +36,7 @@ public interface I${ClassName}Service
|
|||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${ClassName}(${ClassName} ${className});
|
||||
int insert${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
|
|
@ -44,7 +44,7 @@ public interface I${ClassName}Service
|
|||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${ClassName}(${ClassName} ${className});
|
||||
int update${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
|
|
@ -52,7 +52,7 @@ public interface I${ClassName}Service
|
|||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}ByIds(String ids);
|
||||
int delete${ClassName}ByIds(String ids);
|
||||
|
||||
/**
|
||||
* 删除${functionName}信息
|
||||
|
|
@ -60,7 +60,7 @@ public interface I${ClassName}Service
|
|||
* @param ${pkColumn.javaField} ${functionName}ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
#if($table.tree)
|
||||
|
||||
/**
|
||||
|
|
@ -68,6 +68,6 @@ public interface I${ClassName}Service
|
|||
*
|
||||
* @return 所有${functionName}信息
|
||||
*/
|
||||
public List<Ztree> select${ClassName}Tree();
|
||||
List<Ztree> select${ClassName}Tree();
|
||||
#end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.Ztree;
|
|||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
|
||||
import com.ruoyi.common.core.service.impl.BaseServiceImpl;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
#break
|
||||
#end
|
||||
|
|
@ -31,10 +32,8 @@ import com.ruoyi.common.core.text.Convert;
|
|||
* @date ${datetime}
|
||||
*/
|
||||
@Service
|
||||
public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
||||
public class ${ClassName}ServiceImpl extends BaseServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service
|
||||
{
|
||||
@Autowired
|
||||
private ${ClassName}Mapper ${className}Mapper;
|
||||
|
||||
/**
|
||||
* 查询${functionName}
|
||||
|
|
@ -45,7 +44,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||
@Override
|
||||
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
|
||||
{
|
||||
return ${className}Mapper.select${ClassName}ById(${pkColumn.javaField});
|
||||
return this.baseMapper.select${ClassName}ById(${pkColumn.javaField});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -57,7 +56,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||
@Override
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
|
||||
{
|
||||
return ${className}Mapper.select${ClassName}List(${className});
|
||||
return this.baseMapper.select${ClassName}List(${className});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -78,11 +77,11 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
int rows = ${className}Mapper.insert${ClassName}(${className});
|
||||
int rows = this.baseMapper.insert${ClassName}(${className});
|
||||
insert${subClassName}(${className});
|
||||
return rows;
|
||||
#else
|
||||
return ${className}Mapper.insert${ClassName}(${className});
|
||||
return this.baseMapper.insert${ClassName}(${className});
|
||||
#end
|
||||
}
|
||||
|
||||
|
|
@ -104,10 +103,10 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
|
||||
this.baseMapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
|
||||
insert${subClassName}(${className});
|
||||
#end
|
||||
return ${className}Mapper.update${ClassName}(${className});
|
||||
return this.baseMapper.update${ClassName}(${className});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -123,9 +122,9 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||
public int delete${ClassName}ByIds(String ids)
|
||||
{
|
||||
#if($table.sub)
|
||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(Convert.toStrArray(ids));
|
||||
this.baseMapper.delete${subClassName}By${subTableFkClassName}s(Convert.toStrArray(ids));
|
||||
#end
|
||||
return ${className}Mapper.delete${ClassName}ByIds(Convert.toStrArray(ids));
|
||||
return this.baseMapper.delete${ClassName}ByIds(Convert.toStrArray(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -138,9 +137,9 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
|
||||
{
|
||||
#if($table.sub)
|
||||
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
|
||||
this.baseMapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
|
||||
#end
|
||||
return ${className}Mapper.delete${ClassName}ById(${pkColumn.javaField});
|
||||
return this.baseMapper.delete${ClassName}ById(${pkColumn.javaField});
|
||||
}
|
||||
#if($table.tree)
|
||||
|
||||
|
|
@ -152,7 +151,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||
@Override
|
||||
public List<Ztree> select${ClassName}Tree()
|
||||
{
|
||||
List<${ClassName}> ${className}List = ${className}Mapper.select${ClassName}List(new ${ClassName}());
|
||||
List<${ClassName}> ${className}List = this.baseMapper.select${ClassName}List(new ${ClassName}());
|
||||
List<Ztree> ztrees = new ArrayList<Ztree>();
|
||||
for (${ClassName} ${className} : ${className}List)
|
||||
{
|
||||
|
|
@ -190,7 +189,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
${className}Mapper.batch${subClassName}(list);
|
||||
this.baseMapper.batch${subClassName}(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
|||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* ${subTable.functionName}对象 ${subTableName}
|
||||
|
|
@ -14,6 +15,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
|||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Data
|
||||
public class ${subClassName} extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -40,36 +42,36 @@ public class ${subClassName} extends BaseEntity
|
|||
|
||||
#end
|
||||
#end
|
||||
#foreach ($column in $subTable.columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
public void set${AttrName}($column.javaType $column.javaField)
|
||||
{
|
||||
this.$column.javaField = $column.javaField;
|
||||
}
|
||||
###foreach ($column in $subTable.columns)
|
||||
###if(!$table.isSuperColumn($column.javaField))
|
||||
###if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
###set($AttrName=$column.javaField)
|
||||
###else
|
||||
###set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
###end
|
||||
## public void set${AttrName}($column.javaType $column.javaField)
|
||||
## {
|
||||
## this.$column.javaField = $column.javaField;
|
||||
## }
|
||||
##
|
||||
## public $column.javaType get${AttrName}()
|
||||
## {
|
||||
## return $column.javaField;
|
||||
## }
|
||||
###end
|
||||
###end
|
||||
|
||||
public $column.javaType get${AttrName}()
|
||||
{
|
||||
return $column.javaField;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
#foreach ($column in $subTable.columns)
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
.append("${column.javaField}", get${AttrName}())
|
||||
#end
|
||||
.toString();
|
||||
}
|
||||
## @Override
|
||||
## public String toString() {
|
||||
## return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
###foreach ($column in $subTable.columns)
|
||||
###if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
###set($AttrName=$column.javaField)
|
||||
###else
|
||||
###set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
###end
|
||||
## .append("${column.javaField}", get${AttrName}())
|
||||
###end
|
||||
## .toString();
|
||||
## }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue