正式发布 v2.0.0

This commit is contained in:
疯狂的狮子li
2021-05-14 21:39:30 +08:00
parent b608002e89
commit 687d746b1b
82 changed files with 1221 additions and 576 deletions

View File

@ -1,79 +1,79 @@
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://192.168.0.222:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true
username: root
password: root
# 从库数据源
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: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# redis 配置
redis:
# 地址
host: 192.168.0.222
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true
username: root
password: root
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 初始连接数
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: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# redis 配置
redis:
# 地址
host: localhost
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms

View File

@ -1,79 +1,79 @@
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true
username: root
password: root
# 从库数据源
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: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# redis 配置
redis:
# 地址
host: 192.168.0.222
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true
username: root
password: root
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 初始连接数
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: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# redis 配置
redis:
# 地址
host: 192.168.0.222
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms

View File

@ -37,12 +37,13 @@ server:
# 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理
# 每块buffer的空间大小,越小的空间被利用越充分
buffer-size: 512
# 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程
io-threads: 8
# 阻塞任务线程池, 当执行类似servlet请求阻塞操作, undertow会从这个线程池中取得线程,它的值设置取决于系统的负载
worker-threads: 256
# 是否分配的直接内存
direct-buffers: true
threads:
# 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程
io: 8
# 阻塞任务线程池, 当执行类似servlet请求阻塞操作, undertow会从这个线程池中取得线程,它的值设置取决于系统的负载
worker: 256
# # tomcat 配置
# tomcat:
# # tomcat的URI编码
@ -65,15 +66,15 @@ spring:
messages:
# 国际化资源文件路径
basename: i18n/messages
profiles:
profiles:
active: @profiles.active@
# 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 10MB
# 设置总上传的文件大小
max-request-size: 20MB
multipart:
# 单个文件大小
max-file-size: 10MB
# 设置总上传的文件大小
max-request-size: 20MB
# 服务模块
devtools:
restart:
@ -83,44 +84,17 @@ spring:
thymeleaf:
# 将系统模板放置到最前面 否则会与 springboot-admin 页面冲突
template-resolver-order: 1
application:
name: ruoyi-vue-plus
boot:
admin:
# Spring Boot Admin Client 客户端的相关配置
client:
# 设置 Spring Boot Admin Server 地址
url: http://localhost:${server.port}${spring.boot.admin.context-path}
instance:
prefer-ip: true # 注册实例时,优先使用 IP
# username: ruoyi
# password: 123456
# Spring Boot Admin Server 服务端的相关配置
context-path: /admin # 配置 Spring
# Actuator 监控端点的配置项
management:
endpoints:
web:
# Actuator 提供的 API 接口的根目录。默认为 /actuator
base-path: /actuator
exposure:
# 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
include: '*'
endpoint:
logfile:
external-file: ./logs/sys-console.log
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期默认30分钟
expireTime: 30
# MyBatis配置
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期默认30分钟
expireTime: 30
# MyBatisPlus配置
# https://baomidou.com/config/
mybatis-plus:
mapperPackage: com.ruoyi.**.mapper
@ -209,13 +183,6 @@ mybatis-plus:
# 字段验证策略之 select,在 select 的时候的字段验证策略既 wrapper 根据内部 entity 生成的 where 条件
selectStrategy: NOT_EMPTY
# PageHelper分页插件
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
# Swagger配置
swagger:
# 是否开启swagger
@ -230,7 +197,7 @@ swagger:
version: '版本号: ${ruoyi-vue-plus.version}'
# 防止XSS攻击
xss:
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
@ -238,6 +205,7 @@ xss:
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
# 全局线程池相关配置
threadPoolConfig:
# 是否开启线程池
enabled: false
@ -256,6 +224,7 @@ threadPoolConfig:
# AbortPolicy 中止
rejectedExecutionHandler: CallerRunsPolicy
# feign 相关配置
feign:
package: com.ruoyi.**.feign
# 开启压缩
@ -267,4 +236,65 @@ feign:
okhttp:
enabled: true
hystrix:
enabled: true
enabled: true
--- # 定时任务配置
spring:
quartz:
scheduler-name: RuoyiScheduler
startup-delay: 1s
overwrite-existing-jobs: true
auto-startup: true
job-store-type: jdbc
properties:
org:
quartz:
# Scheduler 相关配置
scheduler:
instanceName: RuoyiScheduler
instanceId: AUTO
# 线程池相关配置
threadPool:
class: org.quartz.simpl.SimpleThreadPool
threadCount: 20
threadPriority: 5
# JobStore 集群配置
jobStore:
class: org.quartz.impl.jdbcjobstore.JobStoreTX
isClustered: true
clusterCheckinInterval: 15000
txIsolationLevelSerializable: true
misfireThreshold: 60000
tablePrefix: QRTZ_
# sqlserver 启用
# selectWithLockSQL: SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?
--- # 监控配置
spring:
application:
name: ruoyi-vue-plus
boot:
admin:
# Spring Boot Admin Client 客户端的相关配置
client:
# 设置 Spring Boot Admin Server 地址
url: http://localhost:${server.port}${spring.boot.admin.context-path}
instance:
prefer-ip: true # 注册实例时,优先使用 IP
# username: ruoyi
# password: 123456
# Spring Boot Admin Server 服务端的相关配置
context-path: /admin # 配置 Spring
# Actuator 监控端点的配置项
management:
endpoints:
web:
# Actuator 提供的 API 接口的根目录。默认为 /actuator
base-path: /actuator
exposure:
# 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
include: '*'
endpoint:
logfile:
external-file: ./logs/sys-console.log

View File

@ -56,8 +56,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectGenTableVo">
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
</sql>
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
<select id="selectPageGenTableList" parameterType="GenTable" resultMap="GenTableResult">
<include refid="selectGenTableVo"/>
<where>
<if test="genTable.tableName != null and genTable.tableName != ''">
AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%'))
</if>
<if test="genTable.tableComment != null and genTable.tableComment != ''">
AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%'))
</if>
<if test="genTable.params.beginTime != null and genTable.params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{genTable.params.beginTime},'%y%m%d')
</if>
<if test="genTable.params.endTime != null and genTable.params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{genTable.params.endTime},'%y%m%d')
</if>
</where>
</select>
<select id="selectPageDbTableList" parameterType="GenTable" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_schema = (select database())
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
AND table_name NOT IN (select table_name from gen_table)
<if test="genTable.tableName != null and genTable.tableName != ''">
AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%'))
</if>
<if test="genTable.tableComment != null and genTable.tableComment != ''">
AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%'))
</if>
<if test="genTable.params.beginTime != null and genTable.params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{genTable.params.beginTime},'%y%m%d')
</if>
<if test="genTable.params.endTime != null and genTable.params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{genTable.params.endTime},'%y%m%d')
</if>
</select>
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
<include refid="selectGenTableVo"/>
<where>
<if test="tableName != null and tableName != ''">

View File

@ -39,6 +39,29 @@
left join sys_dept d on u.dept_id = d.dept_id
</sql>
<select id="selectPageRoleList" parameterType="SysRole" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
where r.del_flag = '0'
<if test="role.roleName != null and role.roleName != ''">
AND r.role_name like concat('%', #{role.roleName}, '%')
</if>
<if test="role.status != null and role.status != ''">
AND r.status = #{role.status}
</if>
<if test="role.roleKey != null and role.roleKey != ''">
AND r.role_key like concat('%', #{role.roleKey}, '%')
</if>
<if test="role.params.beginTime != null and role.params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(r.create_time,'%y%m%d') &gt;= date_format(#{role.params.beginTime},'%y%m%d')
</if>
<if test="role.params.endTime != null and role.params.endTime != ''"><!-- 结束时间检索 -->
and date_format(r.create_time,'%y%m%d') &lt;= date_format(#{role.params.endTime},'%y%m%d')
</if>
<!-- 数据范围过滤 -->
${role.params.dataScope}
order by r.role_sort
</select>
<select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
where r.del_flag = '0'

View File

@ -80,6 +80,35 @@
left join sys_role r on r.role_id = ur.role_id
</sql>
<select id="selectPageUserList" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.password, 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
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
<if test="user.userName != null and user.userName != ''">
AND u.user_name like concat('%', #{user.userName}, '%')
</if>
<if test="user.status != null and user.status != ''">
AND u.status = #{user.status}
</if>
<if test="user.phonenumber != null and user.phonenumber != ''">
AND u.phonenumber like concat('%', #{user.phonenumber}, '%')
</if>
<if test="user.params.beginTime != null and user.params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{user.params.beginTime},'%y%m%d')
</if>
<if test="user.params.endTime != null and user.params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{user.params.endTime},'%y%m%d')
</if>
<if test="user.deptId != null and user.deptId != 0">
AND (u.dept_id = #{user.deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{user.deptId},
ancestors) ))
</if>
<!-- 数据范围过滤 -->
${user.params.dataScope}
</select>
<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.password, 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

View File

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import javax.validation.constraints.*;
#foreach ($import in $importList)
@ -27,6 +28,11 @@ public class ${ClassName}AddBo {
@ApiModelProperty("$column.columnComment")
#if($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
#end
#if($column.javaType == 'String')
@NotBlank(message = "$column.columnComment不能为空")
#else
@NotNull(message = "$column.columnComment不能为空")
#end
private $column.javaType $column.javaField;
#end

View File

@ -4,16 +4,11 @@ import java.util.List;
import java.util.Arrays;
import lombok.RequiredArgsConstructor;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -52,13 +47,11 @@ public class ${ClassName}Controller extends BaseController {
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
@GetMapping("/list")
#if($table.crud || $table.sub)
public TableDataInfo<${ClassName}Vo> list(${ClassName}QueryBo bo) {
startPage();
List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo);
return getDataTable(list);
public TableDataInfo<${ClassName}Vo> list(@Validated ${ClassName}QueryBo bo) {
return i${ClassName}Service.queryPageList(bo);
}
#elseif($table.tree)
public AjaxResult<${ClassName}Vo> list(${ClassName}QueryBo bo) {
public AjaxResult<List<${ClassName}Vo>> list(@Validated ${ClassName}QueryBo bo) {
List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo);
return AjaxResult.success(list);
}
@ -71,7 +64,7 @@ public class ${ClassName}Controller extends BaseController {
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult<${ClassName}Vo> export(${ClassName}QueryBo bo) {
public AjaxResult<${ClassName}Vo> export(@Validated ${ClassName}QueryBo bo) {
List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo);
ExcelUtil<${ClassName}Vo> util = new ExcelUtil<${ClassName}Vo>(${ClassName}Vo.class);
return util.exportExcel(list, "${functionName}");
@ -83,7 +76,8 @@ public class ${ClassName}Controller extends BaseController {
@ApiOperation("获取${functionName}详细信息")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
@GetMapping("/{${pkColumn.javaField}}")
public AjaxResult<${ClassName}Vo> getInfo(@PathVariable("${pkColumn.javaField}" ) ${pkColumn.javaType} ${pkColumn.javaField}) {
public AjaxResult<${ClassName}Vo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
return AjaxResult.success(i${ClassName}Service.queryById(${pkColumn.javaField}));
}
@ -94,7 +88,7 @@ public class ${ClassName}Controller extends BaseController {
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
@PostMapping()
public AjaxResult<Void> add(@RequestBody ${ClassName}AddBo bo) {
public AjaxResult<Void> add(@Validated @RequestBody ${ClassName}AddBo bo) {
return toAjax(i${ClassName}Service.insertByAddBo(bo) ? 1 : 0);
}
@ -105,7 +99,7 @@ public class ${ClassName}Controller extends BaseController {
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
@PutMapping()
public AjaxResult<Void> edit(@RequestBody ${ClassName}EditBo bo) {
public AjaxResult<Void> edit(@Validated @RequestBody ${ClassName}EditBo bo) {
return toAjax(i${ClassName}Service.updateByEditBo(bo) ? 1 : 0);
}
@ -116,7 +110,8 @@ public class ${ClassName}Controller extends BaseController {
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
@Log(title = "${functionName}" , businessType = BusinessType.DELETE)
@DeleteMapping("/{${pkColumn.javaField}s}")
public AjaxResult<Void> remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
return toAjax(i${ClassName}Service.deleteWithValidByIds(Arrays.asList(${pkColumn.javaField}s), true) ? 1 : 0);
}
}

View File

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import javax.validation.constraints.*;
#foreach ($import in $importList)
import ${import};
@ -27,6 +28,11 @@ public class ${ClassName}EditBo {
@ApiModelProperty("$column.columnComment")
#if($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
#end
#if($column.javaType == 'String')
@NotBlank(message = "$column.columnComment不能为空")
#else
@NotNull(message = "$column.columnComment不能为空")
#end
private $column.javaType $column.javaField;
#end

View File

@ -1,7 +1,7 @@
package ${packageName}.mapper;
import ${packageName}.domain.${ClassName};
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.page.BaseMapperPlus;
/**
* ${functionName}Mapper接口
@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author ${author}
* @date ${datetime}
*/
public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> {
public interface ${ClassName}Mapper extends BaseMapperPlus<${ClassName}> {
}

View File

@ -6,8 +6,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.Map;
import java.util.HashMap;
#foreach ($import in $importList)
import ${import};
@ -29,6 +27,7 @@ import com.ruoyi.common.core.domain.TreeEntity;
#elseif($table.tree)
#set($Entity="TreeEntity")
#end
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("${functionName}分页查询对象")

View File

@ -5,7 +5,10 @@ import ${packageName}.vo.${ClassName}Vo;
import ${packageName}.bo.${ClassName}QueryBo;
import ${packageName}.bo.${ClassName}AddBo;
import ${packageName}.bo.${ClassName}EditBo;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.page.IServicePlus;
#if($table.crud || $table.sub)
import com.ruoyi.common.core.page.TableDataInfo;
#end
import java.util.Collection;
import java.util.List;
@ -16,13 +19,19 @@ import java.util.List;
* @author ${author}
* @date ${datetime}
*/
public interface I${ClassName}Service extends IService<${ClassName}> {
public interface I${ClassName}Service extends IServicePlus<${ClassName}> {
/**
* 查询单个
* @return
*/
${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField});
#if($table.crud || $table.sub)
/**
* 查询列表
*/
TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}QueryBo bo);
#end
/**
* 查询列表
*/

View File

@ -2,11 +2,15 @@ package ${packageName}.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
#if($table.crud || $table.sub)
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.core.page.PagePlus;
import com.ruoyi.common.core.page.TableDataInfo;
#end
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.Page;
import ${packageName}.bo.${ClassName}AddBo;
import ${packageName}.bo.${ClassName}QueryBo;
import ${packageName}.bo.${ClassName}EditBo;
@ -15,10 +19,9 @@ import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.vo.${ClassName}Vo;
import ${packageName}.service.I${ClassName}Service;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Map;
import java.util.Collection;
/**
* ${functionName}Service业务层处理
@ -31,12 +34,24 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${C
@Override
public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}){
${ClassName} db = this.baseMapper.selectById(${pkColumn.javaField});
return BeanUtil.toBean(db, ${ClassName}Vo.class);
return getVoById(${pkColumn.javaField}, ${ClassName}Vo.class);
}
#if($table.crud || $table.sub)
@Override
public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}QueryBo bo) {
PagePlus<${ClassName}, ${ClassName}Vo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ${ClassName}Vo.class);
return PageUtils.buildDataInfo(result);
}
#end
@Override
public List<${ClassName}Vo> queryList(${ClassName}QueryBo bo) {
return listVo(buildQueryWrapper(bo), ${ClassName}Vo.class);
}
private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName}QueryBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery();
#foreach($column in $columns)
#if($column.query)
@ -54,50 +69,26 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${C
#end
lqw.$mpMethod($condition, ${ClassName}::get$AttrName, bo.get$AttrName());
#else
Object dataScope = bo.getParams().get("dataScope");
lqw.apply(dataScope != null, dataScope != null ? dataScope.toString() : null);
Map<String, Object> params = bo.getParams();
if (params.get("begin$AttrName") != null && params.get("end$AttrName") != null) {
lqw.between(${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName"));
}
lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null,
${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName"));
#end
#end
#end
return entity2Vo(this.list(lqw));
}
/**
* 实体类转化成视图对象
*
* @param collection 实体类集合
* @return
*/
private List<${ClassName}Vo> entity2Vo(Collection<${ClassName}> collection) {
List<${ClassName}Vo> voList = collection.stream()
.map(any -> BeanUtil.toBean(any, ${ClassName}Vo.class))
.collect(Collectors.toList());
if (collection instanceof Page) {
Page<${ClassName}> page = (Page<${ClassName}>)collection;
Page<${ClassName}Vo> pageVo = new Page<>();
BeanUtil.copyProperties(page,pageVo);
pageVo.addAll(voList);
voList = pageVo;
}
return voList;
return lqw;
}
@Override
public Boolean insertByAddBo(${ClassName}AddBo bo) {
${ClassName} add = BeanUtil.toBean(bo, ${ClassName}.class);
validEntityBeforeSave(add);
return this.save(add);
return save(add);
}
@Override
public Boolean updateByEditBo(${ClassName}EditBo bo) {
${ClassName} update = BeanUtil.toBean(bo, ${ClassName}.class);
validEntityBeforeSave(update);
return this.updateById(update);
return updateById(update);
}
/**
@ -114,6 +105,6 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${C
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return this.removeByIds(ids);
return removeByIds(ids);
}
}