mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-31 19:34:06 +08:00
再次调整项目结构
This commit is contained in:
@@ -0,0 +1 @@
|
||||
cn.iocoder.dashboard.framework.apollo.internals.DefaultXInjector
|
@@ -0,0 +1,2 @@
|
||||
org.springframework.boot.env.EnvironmentPostProcessor=\
|
||||
cn.iocoder.dashboard.framework.apollo.spring.boot.ApolloApplicationContextInitializer
|
186
yudao-admin-server/src/main/resources/application-dev.yaml
Normal file
186
yudao-admin-server/src/main/resources/application-dev.yaml
Normal file
@@ -0,0 +1,186 @@
|
||||
server:
|
||||
port: 48080
|
||||
|
||||
--- #################### 数据库相关配置 ####################
|
||||
|
||||
spring:
|
||||
# 数据源配置项
|
||||
autoconfigure:
|
||||
exclude:
|
||||
- com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
|
||||
datasource:
|
||||
druid: # Druid 【监控】相关的全局配置
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
allow: # 设置白名单,不填则允许所有访问
|
||||
url-pattern: /druid/*
|
||||
login-username: # 控制台管理用户名和密码
|
||||
login-password:
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
log-slow-sql: true # 慢 SQL 记录
|
||||
slow-sql-millis: 100
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
dynamic: # 多数据源配置
|
||||
druid: # Druid 【连接池】相关的全局配置
|
||||
initial-size: 5 # 初始连接数
|
||||
min-idle: 10 # 最小连接池数量
|
||||
max-active: 20 # 最大连接池数量
|
||||
max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
|
||||
time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒
|
||||
min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒
|
||||
max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒
|
||||
validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
primary: master
|
||||
datasource:
|
||||
master:
|
||||
name: ruoyi-vue-pro
|
||||
url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 3WLiVUBEwTbvAfsh
|
||||
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||
name: ruoyi-vue-pro
|
||||
url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 3WLiVUBEwTbvAfsh
|
||||
|
||||
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
||||
redis:
|
||||
host: 400-infra.server.iocoder.cn # 地址
|
||||
port: 6379 # 端口
|
||||
database: 1 # 数据库索引
|
||||
|
||||
--- #################### 定时任务相关配置 ####################
|
||||
|
||||
# Quartz 配置项,对应 QuartzProperties 配置类
|
||||
spring:
|
||||
quartz:
|
||||
scheduler-name: schedulerName # Scheduler 名字。默认为 schedulerName
|
||||
job-store-type: jdbc # Job 存储器类型。默认为 memory 表示内存,可选 jdbc 使用数据库。
|
||||
wait-for-jobs-to-complete-on-shutdown: true # 应用关闭时,是否等待定时任务执行完成。默认为 false ,建议设置为 true
|
||||
properties: # 添加 Quartz Scheduler 附加属性,更多可以看 http://www.quartz-scheduler.org/documentation/2.4.0-SNAPSHOT/configuration.html 文档
|
||||
org:
|
||||
quartz:
|
||||
# Scheduler 相关配置
|
||||
scheduler:
|
||||
instanceName: schedulerName
|
||||
instanceId: AUTO # 自动生成 instance ID
|
||||
# JobStore 相关配置
|
||||
jobStore:
|
||||
class: org.quartz.impl.jdbcjobstore.JobStoreTX # JobStore 实现类
|
||||
isClustered: true # 是集群模式
|
||||
clusterCheckinInterval: 15000 # 集群检查频率,单位:毫秒。默认为 15000,即 15 秒
|
||||
misfireThreshold: 60000 # misfire 阀值,单位:毫秒。
|
||||
# 线程池相关配置
|
||||
threadPool:
|
||||
threadCount: 25 # 线程池大小。默认为 10 。
|
||||
threadPriority: 5 # 线程优先级
|
||||
class: org.quartz.simpl.SimpleThreadPool # 线程池类型
|
||||
jdbc: # 使用 JDBC 的 JobStore 的时候,JDBC 的配置
|
||||
initialize-schema: NEVER # 是否自动使用 SQL 初始化 Quartz 表结构。这里设置成 never ,我们手动创建表结构。
|
||||
|
||||
--- #################### 配置中心相关配置 ####################
|
||||
|
||||
# Apollo 配置中心
|
||||
apollo:
|
||||
bootstrap:
|
||||
enabled: true # 设置 Apollo 在启动阶段生效
|
||||
eagerLoad:
|
||||
enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置
|
||||
jdbc: # 自定义的 JDBC 配置项,用于数据库的地址
|
||||
url: ${spring.datasource.dynamic.datasource.master.url}
|
||||
username: ${spring.datasource.dynamic.datasource.master.username}
|
||||
password: ${spring.datasource.dynamic.datasource.master.password}
|
||||
|
||||
--- #################### 服务保障相关配置 ####################
|
||||
|
||||
# Lock4j 配置项
|
||||
lock4j:
|
||||
acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒
|
||||
expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒
|
||||
|
||||
# Resilience4j 配置项
|
||||
resilience4j:
|
||||
ratelimiter:
|
||||
instances:
|
||||
backendA:
|
||||
limit-for-period: 1 # 每个周期内,允许的请求数。默认为 50
|
||||
limit-refresh-period: 60s # 每个周期的时长,单位:微秒。默认为 500
|
||||
timeout-duration: 1s # 被限流时,阻塞等待的时长,单位:微秒。默认为 5s
|
||||
register-health-indicator: true # 是否注册到健康监测
|
||||
|
||||
--- #################### 监控相关配置 ####################
|
||||
|
||||
# Actuator 监控端点的配置项
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator
|
||||
exposure:
|
||||
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
|
||||
|
||||
# Spring Boot Admin 配置项
|
||||
spring:
|
||||
boot:
|
||||
admin:
|
||||
# Spring Boot Admin Client 客户端的相关配置
|
||||
client:
|
||||
url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path} # 设置 Spring Boot Admin Server 地址
|
||||
instance:
|
||||
prefer-ip: true # 注册实例时,优先使用 IP
|
||||
# Spring Boot Admin Server 服务端的相关配置
|
||||
context-path: /admin # 配置 Spring
|
||||
|
||||
# 日志文件配置
|
||||
logging:
|
||||
file:
|
||||
name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径
|
||||
|
||||
--- #################### 芋道相关配置 ####################
|
||||
|
||||
# 芋道配置项,设置当前项目所有自定义的配置
|
||||
yudao:
|
||||
info:
|
||||
version: 1.0.0
|
||||
base-package: cn.iocoder.dashboard
|
||||
web:
|
||||
api-prefix: /api
|
||||
controller-package: ${yudao.info.base-package}
|
||||
security:
|
||||
token-header: Authorization
|
||||
token-secret: abcdefghijklmnopqrstuvwxyz
|
||||
token-timeout: 1d
|
||||
session-timeout: 30m
|
||||
mock-enable: true
|
||||
mock-secret: test
|
||||
swagger:
|
||||
title: 管理后台
|
||||
description: 提供管理员管理的所有功能
|
||||
version: ${yudao.info.version}
|
||||
base-package: ${yudao.info.base-package}.modules
|
||||
captcha:
|
||||
timeout: 5m
|
||||
width: 160
|
||||
height: 60
|
||||
file:
|
||||
base-path: http://127.0.0.1:${server.port}${yudao.web.api-prefix}/system/file/get/
|
||||
codegen:
|
||||
base-package: ${yudao.info.base-package}
|
||||
db-schemas: ${spring.datasource.dynamic.datasource.master.name}
|
||||
xss:
|
||||
enable: false
|
||||
exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系
|
||||
- ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求
|
||||
- ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求
|
||||
demo: true # 开启演示模式
|
186
yudao-admin-server/src/main/resources/application-local.yaml
Normal file
186
yudao-admin-server/src/main/resources/application-local.yaml
Normal file
@@ -0,0 +1,186 @@
|
||||
server:
|
||||
port: 48080
|
||||
|
||||
--- #################### 数据库相关配置 ####################
|
||||
|
||||
spring:
|
||||
# 数据源配置项
|
||||
autoconfigure:
|
||||
exclude:
|
||||
- com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
|
||||
datasource:
|
||||
druid: # Druid 【监控】相关的全局配置
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
allow: # 设置白名单,不填则允许所有访问
|
||||
url-pattern: /druid/*
|
||||
login-username: # 控制台管理用户名和密码
|
||||
login-password:
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
log-slow-sql: true # 慢 SQL 记录
|
||||
slow-sql-millis: 100
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
dynamic: # 多数据源配置
|
||||
druid: # Druid 【连接池】相关的全局配置
|
||||
initial-size: 5 # 初始连接数
|
||||
min-idle: 10 # 最小连接池数量
|
||||
max-active: 20 # 最大连接池数量
|
||||
max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
|
||||
time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒
|
||||
min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒
|
||||
max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒
|
||||
validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
primary: master
|
||||
datasource:
|
||||
master:
|
||||
name: ruoyi-vue-pro
|
||||
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 123456
|
||||
slave: # 模拟从库,可根据自己需要修改
|
||||
name: ruoyi-vue-pro
|
||||
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 123456
|
||||
|
||||
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
||||
redis:
|
||||
host: 127.0.0.1 # 地址
|
||||
port: 6379 # 端口
|
||||
database: 0 # 数据库索引
|
||||
|
||||
--- #################### 定时任务相关配置 ####################
|
||||
|
||||
# Quartz 配置项,对应 QuartzProperties 配置类
|
||||
spring:
|
||||
quartz:
|
||||
scheduler-name: schedulerName # Scheduler 名字。默认为 schedulerName
|
||||
job-store-type: jdbc # Job 存储器类型。默认为 memory 表示内存,可选 jdbc 使用数据库。
|
||||
wait-for-jobs-to-complete-on-shutdown: true # 应用关闭时,是否等待定时任务执行完成。默认为 false ,建议设置为 true
|
||||
properties: # 添加 Quartz Scheduler 附加属性,更多可以看 http://www.quartz-scheduler.org/documentation/2.4.0-SNAPSHOT/configuration.html 文档
|
||||
org:
|
||||
quartz:
|
||||
# Scheduler 相关配置
|
||||
scheduler:
|
||||
instanceName: schedulerName
|
||||
instanceId: AUTO # 自动生成 instance ID
|
||||
# JobStore 相关配置
|
||||
jobStore:
|
||||
class: org.quartz.impl.jdbcjobstore.JobStoreTX # JobStore 实现类
|
||||
isClustered: true # 是集群模式
|
||||
clusterCheckinInterval: 15000 # 集群检查频率,单位:毫秒。默认为 15000,即 15 秒
|
||||
misfireThreshold: 60000 # misfire 阀值,单位:毫秒。
|
||||
# 线程池相关配置
|
||||
threadPool:
|
||||
threadCount: 25 # 线程池大小。默认为 10 。
|
||||
threadPriority: 5 # 线程优先级
|
||||
class: org.quartz.simpl.SimpleThreadPool # 线程池类型
|
||||
jdbc: # 使用 JDBC 的 JobStore 的时候,JDBC 的配置
|
||||
initialize-schema: NEVER # 是否自动使用 SQL 初始化 Quartz 表结构。这里设置成 never ,我们手动创建表结构。
|
||||
|
||||
--- #################### 配置中心相关配置 ####################
|
||||
|
||||
# Apollo 配置中心
|
||||
apollo:
|
||||
bootstrap:
|
||||
enabled: true # 设置 Apollo 在启动阶段生效
|
||||
eagerLoad:
|
||||
enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置
|
||||
jdbc: # 自定义的 JDBC 配置项,用于数据库的地址
|
||||
url: ${spring.datasource.dynamic.datasource.master.url}
|
||||
username: ${spring.datasource.dynamic.datasource.master.username}
|
||||
password: ${spring.datasource.dynamic.datasource.master.password}
|
||||
|
||||
--- #################### 服务保障相关配置 ####################
|
||||
|
||||
# Lock4j 配置项
|
||||
lock4j:
|
||||
acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒
|
||||
expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒
|
||||
|
||||
# Resilience4j 配置项
|
||||
resilience4j:
|
||||
ratelimiter:
|
||||
instances:
|
||||
backendA:
|
||||
limit-for-period: 1 # 每个周期内,允许的请求数。默认为 50
|
||||
limit-refresh-period: 60s # 每个周期的时长,单位:微秒。默认为 500
|
||||
timeout-duration: 1s # 被限流时,阻塞等待的时长,单位:微秒。默认为 5s
|
||||
register-health-indicator: true # 是否注册到健康监测
|
||||
|
||||
--- #################### 监控相关配置 ####################
|
||||
|
||||
# Actuator 监控端点的配置项
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator
|
||||
exposure:
|
||||
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
|
||||
|
||||
# Spring Boot Admin 配置项
|
||||
spring:
|
||||
boot:
|
||||
admin:
|
||||
# Spring Boot Admin Client 客户端的相关配置
|
||||
client:
|
||||
url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path} # 设置 Spring Boot Admin Server 地址
|
||||
instance:
|
||||
prefer-ip: true # 注册实例时,优先使用 IP
|
||||
# Spring Boot Admin Server 服务端的相关配置
|
||||
context-path: /admin # 配置 Spring
|
||||
|
||||
# 日志文件配置
|
||||
logging:
|
||||
file:
|
||||
name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径
|
||||
|
||||
--- #################### 芋道相关配置 ####################
|
||||
|
||||
# 芋道配置项,设置当前项目所有自定义的配置
|
||||
yudao:
|
||||
info:
|
||||
version: 1.0.0
|
||||
base-package: cn.iocoder.dashboard
|
||||
web:
|
||||
api-prefix: /api
|
||||
controller-package: ${yudao.info.base-package}
|
||||
security:
|
||||
token-header: Authorization
|
||||
token-secret: abcdefghijklmnopqrstuvwxyz
|
||||
token-timeout: 1d
|
||||
session-timeout: 30m
|
||||
mock-enable: true
|
||||
mock-secret: test
|
||||
swagger:
|
||||
title: 管理后台
|
||||
description: 提供管理员管理的所有功能
|
||||
version: ${yudao.info.version}
|
||||
base-package: ${yudao.info.base-package}.modules
|
||||
captcha:
|
||||
timeout: 5m
|
||||
width: 160
|
||||
height: 60
|
||||
file:
|
||||
base-path: http://127.0.0.1:${server.port}${yudao.web.api-prefix}/system/file/get/
|
||||
codegen:
|
||||
base-package: ${yudao.info.base-package}
|
||||
db-schemas: ${spring.datasource.dynamic.datasource.master.name}
|
||||
xss:
|
||||
enable: false
|
||||
exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系
|
||||
- ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求
|
||||
- ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求
|
||||
demo: false # 关闭演示模式
|
42
yudao-admin-server/src/main/resources/application.yaml
Normal file
42
yudao-admin-server/src/main/resources/application.yaml
Normal file
@@ -0,0 +1,42 @@
|
||||
spring:
|
||||
application:
|
||||
name: dashboard
|
||||
|
||||
profiles:
|
||||
active: local
|
||||
|
||||
# Servlet 配置
|
||||
servlet:
|
||||
# 文件上传相关配置项
|
||||
multipart:
|
||||
max-file-size: 16MB # 单个文件大小
|
||||
max-request-size: 32MB # 设置总上传的文件大小
|
||||
|
||||
# Jackson 配置项
|
||||
jackson:
|
||||
serialization:
|
||||
write-dates-as-timestamps: true # 设置 Date 的格式,使用时间戳
|
||||
write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401
|
||||
write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳
|
||||
fail-on-empty-beans: false # 允许序列化无属性的 Bean
|
||||
|
||||
# MyBatis Plus 的配置项
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印日志
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: AUTO # 自增 ID
|
||||
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
|
||||
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
|
||||
mapper-locations: classpath*:mapper/*.xml
|
||||
type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject
|
||||
|
||||
--- #################### 芋道相关配置 ####################
|
||||
|
||||
yudao:
|
||||
error-code: # 错误码相关配置项
|
||||
constants-class-list:
|
||||
- cn.iocoder.dashboard.modules.infra.enums.InfErrorCodeConstants
|
||||
- cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants
|
17
yudao-admin-server/src/main/resources/banner.txt
Normal file
17
yudao-admin-server/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
芋道源码 http://www.iocoder.cn
|
||||
Application Version: ${yudao.info.version}
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
|
||||
.__ __. ______ .______ __ __ _______
|
||||
| \ | | / __ \ | _ \ | | | | / _____|
|
||||
| \| | | | | | | |_) | | | | | | | __
|
||||
| . ` | | | | | | _ < | | | | | | |_ |
|
||||
| |\ | | `--' | | |_) | | `--' | | |__| |
|
||||
|__| \__| \______/ |______/ \______/ \______|
|
||||
|
||||
███╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗
|
||||
████╗ ██║██╔═══██╗ ██╔══██╗██║ ██║██╔════╝
|
||||
██╔██╗ ██║██║ ██║ ██████╔╝██║ ██║██║ ███╗
|
||||
██║╚██╗██║██║ ██║ ██╔══██╗██║ ██║██║ ██║
|
||||
██║ ╚████║╚██████╔╝ ██████╔╝╚██████╔╝╚██████╔╝
|
||||
╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝
|
@@ -0,0 +1,102 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName};
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import ${PageResultClassName};
|
||||
import ${CommonResultClassName};
|
||||
import static ${CommonResultClassName}.success;
|
||||
|
||||
import ${ExcelUtilsClassName};
|
||||
|
||||
import ${OperateLogClassName};
|
||||
import static ${OperateTypeEnumClassName}.*;
|
||||
|
||||
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*;
|
||||
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
|
||||
import ${basePackage}.modules.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
|
||||
import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.${table.className}Service;
|
||||
|
||||
@Api(tags = "${table.classComment}")
|
||||
@RestController
|
||||
##二级的 businessName 暂时不算在 HTTP 路径上,可以根据需要写
|
||||
@RequestMapping("/${table.moduleName}/${simpleClassName_strikeCase}")
|
||||
@Validated
|
||||
public class ${table.className}Controller {
|
||||
|
||||
@Resource
|
||||
private ${table.className}Service ${classNameVar}Service;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建${table.classComment}")
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")
|
||||
public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid @RequestBody ${table.className}CreateReqVO createReqVO) {
|
||||
return success(${classNameVar}Service.create${simpleClassName}(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新${table.classComment}")
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")
|
||||
public CommonResult<Boolean> update${simpleClassName}(@Valid @RequestBody ${table.className}UpdateReqVO updateReqVO) {
|
||||
${classNameVar}Service.update${simpleClassName}(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除${table.classComment}")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")
|
||||
public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
||||
${classNameVar}Service.delete${simpleClassName}(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得${table.classComment}")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = ${primaryColumn.javaType}.class)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
public CommonResult<${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
||||
${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id);
|
||||
return success(${table.className}Convert.INSTANCE.convert(${classNameVar}));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得${table.classComment}列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
public CommonResult<List<${table.className}RespVO>> get${simpleClassName}List(@RequestParam("ids") Collection<${primaryColumn.javaType}> ids) {
|
||||
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(ids);
|
||||
return success(${table.className}Convert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得${table.classComment}分页")
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
public CommonResult<PageResult<${table.className}RespVO>> get${simpleClassName}Page(@Valid ${table.className}PageReqVO pageVO) {
|
||||
PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageVO);
|
||||
return success(${table.className}Convert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出${table.classComment} Excel")
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void export${simpleClassName}Excel(@Valid ${table.className}ExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<${table.className}ExcelVO> datas = ${table.className}Convert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${table.className}ExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
## 提供给 baseVO、createVO、updateVO 生成字段
|
||||
@ApiModelProperty(value = "${column.columnComment}"#if (!${column.nullable}), required = true#end#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
#if (!${column.nullable})## 判断 @NotEmpty 和 @NotNull 注解
|
||||
#if (${field.fieldType} == 'String')
|
||||
@NotEmpty(message = "${column.columnComment}不能为空")
|
||||
#else
|
||||
@NotNull(message = "${column.columnComment}不能为空")
|
||||
#end
|
||||
#end
|
||||
#if (${column.javaType} == "Date")## 时间类型
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
#end
|
||||
private ${column.javaType} ${column.javaField};
|
@@ -0,0 +1,31 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
## 处理 Date 字段的引入
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.createOperation} && ${column.updateOperation} && ${column.listOperationResult}
|
||||
&& ${column.javaType} == "Date")## 时间类型
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${table.classComment} Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class ${table.className}BaseVO {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.createOperation} && ${column.updateOperation} && ${column.listOperationResult})##通用操作
|
||||
#parse("codegen/java/controller/vo/_column.vm")
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
## 处理 Date 字段的引入
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.createOperation} && (!${column.updateOperation} || !${column.listOperationResult})
|
||||
&& ${column.javaType} == "Date")## 时间类型
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
|
||||
@ApiModel("${table.classComment}创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ${table.className}CreateReqVO extends ${table.className}BaseVO {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.createOperation} && (!${column.updateOperation} || !${column.listOperationResult}))##不是通用字段
|
||||
#parse("codegen/java/controller/vo/_column.vm")
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
#foreach ($column in $columns)
|
||||
#if ("$!column.dictType" != "")## 有设置数据字典
|
||||
import ${DictFormatClassName};
|
||||
import ${DictConvertClassName};
|
||||
|
||||
import static ${SysDictTypeEnumClassName}.*;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${table.classComment} Excel VO
|
||||
*
|
||||
* @author ${table.author}
|
||||
*/
|
||||
@Data
|
||||
public class ${table.className}ExcelVO {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.listOperationResult})##返回字段
|
||||
#if ("$!column.dictType" != "")##处理枚举值
|
||||
@ExcelProperty(value = "${column.columnComment}", converter = DictConvert.class)
|
||||
@DictFormat(${column.dictType.toUpperCase()})
|
||||
#else
|
||||
@ExcelProperty("${column.columnComment}")
|
||||
#end
|
||||
private ${column.javaType} ${column.javaField};
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import ${PageParamClassName};
|
||||
## 处理 Date 字段的引入
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.listOperation} && ${column.javaType} == "Date")## 时间类型
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
## 字段模板
|
||||
#macro(columnTpl $prefix $prefixStr)
|
||||
#if (${column.javaType} == "Date")## 时间类型
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
#end
|
||||
@ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end;
|
||||
#end
|
||||
|
||||
@ApiModel(value = "${table.classComment} Excel 导出 Request VO", description = "参数和 ${table.className}PageReqVO 是一致的")
|
||||
@Data
|
||||
public class ${table.className}ExportReqVO {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写
|
||||
#if (${column.listOperation})##查询操作
|
||||
#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候
|
||||
#columnTpl('begin', '开始')
|
||||
|
||||
#columnTpl('end', '结束')
|
||||
#else##情况二,非 Between 的时间
|
||||
#columnTpl('', '')
|
||||
#end
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import ${PageParamClassName};
|
||||
## 处理 Date 字段的引入
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.listOperation} && ${column.javaType} == "Date")## 时间类型
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
## 字段模板
|
||||
#macro(columnTpl $prefix $prefixStr)
|
||||
#if (${column.javaType} == "Date")## 时间类型
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
#end
|
||||
@ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end;
|
||||
#end
|
||||
|
||||
@ApiModel("${table.classComment}分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ${table.className}PageReqVO extends PageParam {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写
|
||||
#if (${column.listOperation})##查询操作
|
||||
#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候
|
||||
#columnTpl('begin', '开始')
|
||||
|
||||
#columnTpl('end', '结束')
|
||||
#else##情况二,非 Between 的时间
|
||||
#columnTpl('', '')
|
||||
#end
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@ApiModel("${table.classComment} Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ${table.className}RespVO extends ${table.className}BaseVO {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.listOperationResult} && (!${column.createOperation} || !${column.updateOperation}))##不是通用字段
|
||||
@ApiModelProperty(value = "${column.columnComment}"#if (!${column.nullable}), required = true#end#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||
private ${column.javaType} ${column.javaField};
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
## 处理 Date 字段的引入
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.updateOperation} && (!${column.createOperation} || !${column.listOperationResult})
|
||||
&& ${column.javaType} == "Date"))## 时间类型
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
|
||||
@ApiModel("${table.classComment}更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ${table.className}UpdateReqVO extends ${table.className}BaseVO {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.updateOperation} && (!${column.createOperation} || !${column.listOperationResult}))##不是通用字段
|
||||
#parse("codegen/java/controller/vo/_column.vm")
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.convert.${table.businessName};
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import ${PageResultClassName};
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*;
|
||||
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
|
||||
|
||||
/**
|
||||
* ${table.classComment} Convert
|
||||
*
|
||||
* @author ${table.author}
|
||||
*/
|
||||
@Mapper
|
||||
public interface ${table.className}Convert {
|
||||
|
||||
${table.className}Convert INSTANCE = Mappers.getMapper(${table.className}Convert.class);
|
||||
|
||||
${table.className}DO convert(${table.className}CreateReqVO bean);
|
||||
|
||||
${table.className}DO convert(${table.className}UpdateReqVO bean);
|
||||
|
||||
${table.className}RespVO convert(${table.className}DO bean);
|
||||
|
||||
List<${table.className}RespVO> convertList(List<${table.className}DO> list);
|
||||
|
||||
PageResult<${table.className}RespVO> convertPage(PageResult<${table.className}DO> page);
|
||||
|
||||
List<${table.className}ExcelVO> convertList02(List<${table.className}DO> list);
|
||||
|
||||
}
|
38
yudao-admin-server/src/main/resources/codegen/java/dal/do.vm
Normal file
38
yudao-admin-server/src/main/resources/codegen/java/dal/do.vm
Normal file
@@ -0,0 +1,38 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName};
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import ${BaseDOClassName};
|
||||
|
||||
/**
|
||||
* ${table.classComment} DO
|
||||
*
|
||||
* @author ${table.author}
|
||||
*/
|
||||
@TableName("${table.tableName}")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ${table.className}DO extends BaseDO {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段
|
||||
/**
|
||||
* ${column.columnComment}
|
||||
#if ("$!column.dictType" != "")##处理枚举值
|
||||
*
|
||||
* 枚举 {@link TODO ${column.dictType} 对应的类}
|
||||
#end
|
||||
*/
|
||||
#if (${column.primaryKey})##处理主键
|
||||
@TableId#if (${column.javaType} == 'String')type = IdType.INPUT)#end
|
||||
#end
|
||||
private ${column.javaType} ${column.javaField};
|
||||
#end
|
||||
#end
|
||||
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.dal.mysql.${table.businessName};
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import ${PageResultClassName};
|
||||
import ${QueryWrapperClassName};
|
||||
import ${BaseMapperClassName};
|
||||
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*;
|
||||
|
||||
## 字段模板
|
||||
#macro(listCondition)
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.listOperation})
|
||||
#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写
|
||||
#if (${column.listOperationCondition} == "=")##情况一,= 的时候
|
||||
.eqIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == "!=")##情况二,!= 的时候
|
||||
.neIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == ">")##情况三,> 的时候
|
||||
.gtIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == ">=")##情况四,>= 的时候
|
||||
.geIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == "<")##情况五,< 的时候
|
||||
.ltIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == "<=")##情况五,<= 的时候
|
||||
.leIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == "LIKE")##情况七,Like 的时候
|
||||
.likeIfPresent("${column.columnName}", reqVO.get${JavaField}())
|
||||
#end
|
||||
#if (${column.listOperationCondition} == "BETWEEN")##情况八,Between 的时候
|
||||
.betweenIfPresent("${column.columnName}", reqVO.getBegin${JavaField}(), reqVO.getEnd${JavaField}())
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
/**
|
||||
* ${table.classComment} Mapper
|
||||
*
|
||||
* @author ${table.author}
|
||||
*/
|
||||
@Mapper
|
||||
public interface ${table.className}Mapper extends BaseMapperX<${table.className}DO> {
|
||||
|
||||
default PageResult<${table.className}DO> selectPage(${table.className}PageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<${table.className}DO>()
|
||||
#listCondition()
|
||||
.orderByDesc("id")## 大多数情况下,id 倒序
|
||||
);
|
||||
}
|
||||
|
||||
default List<${table.className}DO> selectList(${table.className}ExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<${table.className}DO>()
|
||||
#listCondition()
|
||||
.orderByDesc("id")## 大多数情况下,id 倒序
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
// ========== ${table.classComment} TODO 补充编号 ==========
|
||||
ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS = new ErrorCode(TODO 补充编号, "${table.classComment}不存在");
|
@@ -0,0 +1,70 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.service.${table.businessName};
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*;
|
||||
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
|
||||
import ${PageResultClassName};
|
||||
|
||||
/**
|
||||
* ${table.classComment} Service 接口
|
||||
*
|
||||
* @author ${table.author}
|
||||
*/
|
||||
public interface ${table.className}Service {
|
||||
|
||||
/**
|
||||
* 创建${table.classComment}
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
${primaryColumn.javaType} create${simpleClassName}(@Valid ${table.className}CreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新${table.classComment}
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void update${simpleClassName}(@Valid ${table.className}UpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除${table.classComment}
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void delete${simpleClassName}(${primaryColumn.javaType} id);
|
||||
|
||||
/**
|
||||
* 获得${table.classComment}
|
||||
*
|
||||
* @param id 编号
|
||||
* @return ${table.classComment}
|
||||
*/
|
||||
${table.className}DO get${simpleClassName}(${primaryColumn.javaType} id);
|
||||
|
||||
/**
|
||||
* 获得${table.classComment}列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return ${table.classComment}列表
|
||||
*/
|
||||
List<${table.className}DO> get${simpleClassName}List(Collection<${primaryColumn.javaType}> ids);
|
||||
|
||||
/**
|
||||
* 获得${table.classComment}分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return ${table.classComment}分页
|
||||
*/
|
||||
PageResult<${table.className}DO> get${simpleClassName}Page(${table.className}PageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得${table.classComment}列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return ${table.classComment}列表
|
||||
*/
|
||||
List<${table.className}DO> get${simpleClassName}List(${table.className}ExportReqVO exportReqVO);
|
||||
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*;
|
||||
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
|
||||
import ${PageResultClassName};
|
||||
|
||||
import ${basePackage}.modules.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
|
||||
import ${basePackage}.modules.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper;
|
||||
import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.${table.className}Service;
|
||||
|
||||
import ${ServiceExceptionUtilClassName};
|
||||
|
||||
import static cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static ${basePackage}.modules.${table.moduleName}.enums.${simpleModuleName_upperFirst}ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* ${table.classComment} Service 实现类
|
||||
*
|
||||
* @author ${table.author}
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ${table.className}ServiceImpl implements ${table.className}Service {
|
||||
|
||||
@Resource
|
||||
private ${table.className}Mapper ${classNameVar}Mapper;
|
||||
|
||||
@Override
|
||||
public ${primaryColumn.javaType} create${simpleClassName}(${table.className}CreateReqVO createReqVO) {
|
||||
// 插入
|
||||
${table.className}DO ${classNameVar} = ${table.className}Convert.INSTANCE.convert(createReqVO);
|
||||
${classNameVar}Mapper.insert(${classNameVar});
|
||||
// 返回
|
||||
return ${classNameVar}.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update${simpleClassName}(${table.className}UpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validate${simpleClassName}Exists(updateReqVO.getId());
|
||||
// 更新
|
||||
${table.className}DO updateObj = ${table.className}Convert.INSTANCE.convert(updateReqVO);
|
||||
${classNameVar}Mapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete${simpleClassName}(${primaryColumn.javaType} id) {
|
||||
// 校验存在
|
||||
this.validate${simpleClassName}Exists(id);
|
||||
// 删除
|
||||
${classNameVar}Mapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validate${simpleClassName}Exists(${primaryColumn.javaType} id) {
|
||||
if (${classNameVar}Mapper.selectById(id) == null) {
|
||||
throw exception(${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ${table.className}DO get${simpleClassName}(${primaryColumn.javaType} id) {
|
||||
return ${classNameVar}Mapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<${table.className}DO> get${simpleClassName}List(Collection<${primaryColumn.javaType}> ids) {
|
||||
return ${classNameVar}Mapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<${table.className}DO> get${simpleClassName}Page(${table.className}PageReqVO pageReqVO) {
|
||||
return ${classNameVar}Mapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<${table.className}DO> get${simpleClassName}List(${table.className}ExportReqVO exportReqVO) {
|
||||
return ${classNameVar}Mapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,161 @@
|
||||
package ${basePackage}.modules.${table.moduleName}.service.${table.businessName};
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import ${basePackage}.BaseDbUnitTest;
|
||||
import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.impl.${table.className}ServiceImpl;
|
||||
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*;
|
||||
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
|
||||
import ${basePackage}.modules.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper;
|
||||
import ${basePackage}.util.object.ObjectUtils;
|
||||
import ${PageResultClassName};
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static ${basePackage}.modules.${table.moduleName}.enums.${simpleModuleName_upperFirst}ErrorCodeConstants.*;
|
||||
import static ${basePackage}.util.AssertUtils.*;
|
||||
import static ${basePackage}.util.RandomUtils.*;
|
||||
import static ${basePackage}.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
## 字段模板
|
||||
#macro(getPageCondition $VO)
|
||||
// mock 数据
|
||||
${table.className}DO db${simpleClassName} = randomPojo(${table.className}DO.class, o -> { // 等会查询到
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.listOperation})
|
||||
#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写
|
||||
o.set$JavaField(null);
|
||||
#end
|
||||
#end
|
||||
});
|
||||
${classNameVar}Mapper.insert(db${simpleClassName});
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.listOperation})
|
||||
#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写
|
||||
// 测试 ${column.javaField} 不匹配
|
||||
${classNameVar}Mapper.insert(ObjectUtils.clone(db${simpleClassName}, o -> o.set$JavaField(null)));
|
||||
#end
|
||||
#end
|
||||
// 准备参数
|
||||
${table.className}${VO} reqVO = new ${table.className}${VO}();
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.listOperation})
|
||||
#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写
|
||||
#if (${column.listOperationCondition} == "BETWEEN")## BETWEEN 的情况
|
||||
reqVO.setBegin${JavaField}(null);
|
||||
reqVO.setEnd${JavaField}(null);
|
||||
#else
|
||||
reqVO.set$JavaField(null);
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
/**
|
||||
* {@link ${table.className}ServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author ${table.author}
|
||||
*/
|
||||
@Import(${table.className}ServiceImpl.class)
|
||||
public class ${table.className}ServiceTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ${table.className}ServiceImpl ${classNameVar}Service;
|
||||
|
||||
@Resource
|
||||
private ${table.className}Mapper ${classNameVar}Mapper;
|
||||
|
||||
@Test
|
||||
public void testCreate${simpleClassName}_success() {
|
||||
// 准备参数
|
||||
${table.className}CreateReqVO reqVO = randomPojo(${table.className}CreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
${primaryColumn.javaType} ${classNameVar}Id = ${classNameVar}Service.create${simpleClassName}(reqVO);
|
||||
// 断言
|
||||
assertNotNull(${classNameVar}Id);
|
||||
// 校验记录的属性是否正确
|
||||
${table.className}DO ${classNameVar} = ${classNameVar}Mapper.selectById(${classNameVar}Id);
|
||||
assertPojoEquals(reqVO, ${classNameVar});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate${simpleClassName}_success() {
|
||||
// mock 数据
|
||||
${table.className}DO db${simpleClassName} = randomPojo(${table.className}DO.class);
|
||||
${classNameVar}Mapper.insert(db${simpleClassName});// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
${table.className}UpdateReqVO reqVO = randomPojo(${table.className}UpdateReqVO.class, o -> {
|
||||
o.setId(db${simpleClassName}.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
${classNameVar}Service.update${simpleClassName}(reqVO);
|
||||
// 校验是否更新正确
|
||||
${table.className}DO ${classNameVar} = ${classNameVar}Mapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, ${classNameVar});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate${simpleClassName}_notExists() {
|
||||
// 准备参数
|
||||
${table.className}UpdateReqVO reqVO = randomPojo(${table.className}UpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> ${classNameVar}Service.update${simpleClassName}(reqVO), ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete${simpleClassName}_success() {
|
||||
// mock 数据
|
||||
${table.className}DO db${simpleClassName} = randomPojo(${table.className}DO.class);
|
||||
${classNameVar}Mapper.insert(db${simpleClassName});// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
${primaryColumn.javaType} id = db${simpleClassName}.getId();
|
||||
|
||||
// 调用
|
||||
${classNameVar}Service.delete${simpleClassName}(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(${classNameVar}Mapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete${simpleClassName}_notExists() {
|
||||
// 准备参数
|
||||
${primaryColumn.javaType} id = random${primaryColumn.javaType}Id();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> ${classNameVar}Service.delete${simpleClassName}(id), ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test // TODO 请修改 null 为需要的值
|
||||
public void testGet${simpleClassName}Page() {
|
||||
#getPageCondition("PageReqVO")
|
||||
|
||||
// 调用
|
||||
PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(db${simpleClassName}, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test // TODO 请修改 null 为需要的值
|
||||
public void testGet${simpleClassName}List() {
|
||||
#getPageCondition("ExportReqVO")
|
||||
|
||||
// 调用
|
||||
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(db${simpleClassName}, list.get(0));
|
||||
}
|
||||
|
||||
}
|
27
yudao-admin-server/src/main/resources/codegen/sql/sql.vm
Normal file
27
yudao-admin-server/src/main/resources/codegen/sql/sql.vm
Normal file
@@ -0,0 +1,27 @@
|
||||
-- 菜单 SQL
|
||||
INSERT INTO `sys_menu`(
|
||||
`name`, `permission`, `menu_type`, `sort`, `parent_id`,
|
||||
`path`, `icon`, `component`, `status`
|
||||
)
|
||||
VALUES (
|
||||
'${table.classComment}管理', '', 2, 0, ${table.parentMenuId},
|
||||
'${simpleClassName_strikeCase}', '', '${table.moduleName}/${classNameVar}/index', 0
|
||||
);
|
||||
|
||||
-- 按钮父菜单ID
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
|
||||
-- 按钮 SQL
|
||||
#set ($functionNames = ['查询', '创建', '更新', '删除', '导出'])
|
||||
#set ($functionOps = ['query', 'create', 'update', 'delete', 'export'])
|
||||
#foreach ($functionName in $functionNames)
|
||||
#set ($index = $foreach.count - 1)
|
||||
INSERT INTO `sys_menu`(
|
||||
`name`, `permission`, `menu_type`, `sort`, `parent_id`,
|
||||
`path`, `icon`, `component`, `status`
|
||||
)
|
||||
VALUES (
|
||||
'${table.classComment}${functionName}', '${permissionPrefix}:${functionOps.get($index)}', 3, $foreach.count, @parentId,
|
||||
'', '', '', 0
|
||||
);
|
||||
#end
|
@@ -0,0 +1,55 @@
|
||||
import request from '@/utils/request'
|
||||
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
|
||||
|
||||
// 创建${table.classComment}
|
||||
export function create${simpleClassName}(data) {
|
||||
return request({
|
||||
url: '${baseURL}/create',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新${table.classComment}
|
||||
export function update${simpleClassName}(data) {
|
||||
return request({
|
||||
url: '${baseURL}/update',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除${table.classComment}
|
||||
export function delete${simpleClassName}(id) {
|
||||
return request({
|
||||
url: '${baseURL}/delete?id=' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 获得${table.classComment}
|
||||
export function get${simpleClassName}(id) {
|
||||
return request({
|
||||
url: '${baseURL}/get?id=' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 获得${table.classComment}分页
|
||||
export function get${simpleClassName}Page(query) {
|
||||
return request({
|
||||
url: '${baseURL}/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 导出${table.classComment} Excel
|
||||
export function export${simpleClassName}Excel(query) {
|
||||
return request({
|
||||
url: '${baseURL}/export-excel',
|
||||
method: 'get',
|
||||
params: query,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
@@ -0,0 +1,403 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
#foreach($column in $columns)
|
||||
#if ($column.listOperation)
|
||||
#set ($dictType=$column.dictType)
|
||||
#set ($javaField = $column.javaField)
|
||||
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set ($comment=$column.columnComment)
|
||||
#if ($column.htmlType == "input")
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-input v-model="queryParams.${javaField}" placeholder="请输入${comment}" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||
</el-form-item>
|
||||
#elseif ($column.htmlType == "select" || $column.htmlType == "radio")
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-select v-model="queryParams.${javaField}" placeholder="请选择${comment}" clearable size="small">
|
||||
#if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
||||
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.$dictType.toUpperCase())"
|
||||
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
#else## 未设置 dictType 数据字典的情况
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
#end
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime")
|
||||
#if ($column.listOperationCondition != "BETWEEN")## 非范围
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-date-picker clearable size="small" v-model="queryParams.${javaField}" type="date" value-format="yyyy-MM-dd" placeholder="选择${comment}" />
|
||||
</el-form-item>
|
||||
#else## 范围
|
||||
<el-form-item label="${comment}">
|
||||
<el-date-picker v-model="dateRange${AttrName}" size="small" style="width: 240px" value-format="yyyy-MM-dd"
|
||||
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 操作工具栏 -->
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||
v-hasPermi="['${permissionPrefix}:create']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
||||
v-hasPermi="['${permissionPrefix}:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<!-- 列表 -->
|
||||
<el-table v-loading="loading" :data="list">
|
||||
#foreach($column in $columns)
|
||||
#if ($column.listOperationResult)
|
||||
#set ($dictType=$column.dictType)
|
||||
#set ($javaField = $column.javaField)
|
||||
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set ($comment=$column.columnComment)
|
||||
#if ($column.javaType == "Date")## 时间类型
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.${javaField}) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif("" != $column.dictType)## 数据字典
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ getDictDataLabel(DICT_TYPE.$dictType.toUpperCase(), scope.row.${column.javaField}) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#else
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['${permissionPrefix}:update']">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['${permissionPrefix}:delete']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页组件 -->
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"/>
|
||||
|
||||
<!-- 对话框(添加 / 修改) -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
#foreach($column in $columns)
|
||||
#if ($column.createOperation || $column.updateOperation)
|
||||
#set ($dictType = $column.dictType)
|
||||
#set ($javaField = $column.javaField)
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set ($comment = $column.columnComment)
|
||||
#if ($column.htmlType == "input")
|
||||
#if (!$column.primaryKey)## 忽略主键,不用在表单里
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-input v-model="form.${javaField}" placeholder="请输入${comment}" />
|
||||
</el-form-item>
|
||||
#end
|
||||
#elseif($column.htmlType == "imageUpload")## 图片上传
|
||||
#set ($hasImageUploadColumn = true)
|
||||
<el-form-item label="${comment}">
|
||||
<imageUpload v-model="form.${javaField}"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "fileUpload")## 文件上传
|
||||
#set ($hasFileUploadColumn = true)
|
||||
<el-form-item label="${comment}">
|
||||
<fileUpload v-model="form.${javaField}"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||
#set ($hasEditorColumn = true)
|
||||
<el-form-item label="${comment}">
|
||||
<editor v-model="form.${javaField}" :min-height="192"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "select")## 下拉框
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-select v-model="form.${javaField}" placeholder="请选择${comment}">
|
||||
#if ("" != $dictType)## 有数据字典
|
||||
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.$dictType.toUpperCase())"
|
||||
:key="dict.value" :label="dict.label" #if ($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end />
|
||||
#else##没数据字典
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
#end
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "checkbox")## 多选框
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-checkbox-group v-model="form.${javaField}">
|
||||
#if ("" != $dictType)## 有数据字典
|
||||
<el-checkbox v-for="dict in this.getDictDatas(DICT_TYPE.$dictType.toUpperCase())"
|
||||
:key="dict.value" #if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end>{{dict.label}}</el-checkbox>
|
||||
#else##没数据字典
|
||||
<el-checkbox>请选择字典生成</el-checkbox>
|
||||
#end
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "radio")## 单选框
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-radio-group v-model="form.${javaField}">
|
||||
#if ("" != $dictType)## 有数据字典
|
||||
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.$dictType.toUpperCase())"
|
||||
:key="dict.value" #if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end>{{dict.label}}</el-radio>
|
||||
#else##没数据字典
|
||||
<el-radio label="1">请选择字典生成</el-radio>
|
||||
#end
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime")## 时间框
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-date-picker clearable size="small" v-model="form.${javaField}" type="date" value-format="yyyy-MM-dd" placeholder="选择${comment}" />
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "textarea")## 文本框
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-input v-model="form.${javaField}" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { create${simpleClassName}, update${simpleClassName}, delete${simpleClassName}, get${simpleClassName}, get${simpleClassName}Page, export${simpleClassName}Excel } from "@/api/${table.moduleName}/${classNameVar}";
|
||||
#if ($hasImageUploadColumn)
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
#end
|
||||
#if ($hasFileUploadColumn)
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
#end
|
||||
#if ($hasEditorColumn)
|
||||
import Editor from '@/components/Editor';
|
||||
#end
|
||||
|
||||
export default {
|
||||
name: "${simpleClassName}",
|
||||
components: {
|
||||
#if ($hasImageUploadColumn)
|
||||
ImageUpload,
|
||||
#end
|
||||
#if ($hasFileUploadColumn)
|
||||
FileUpload,
|
||||
#end
|
||||
#if ($hasEditorColumn)
|
||||
Editor,
|
||||
#end
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// ${table.classComment}列表
|
||||
list: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
#foreach ($column in $columns)## 时间范围
|
||||
#if ($column.listOperation)
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
dateRange${AttrName}: [],
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.listOperation && $column.listOperationCondition != 'BETWEEN')
|
||||
$column.javaField: null,
|
||||
#end
|
||||
#end
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
#foreach ($column in $columns)
|
||||
#if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键
|
||||
#set($comment=$column.columnComment)
|
||||
$column.javaField: [{ required: true, message: "${comment}不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }],
|
||||
#end
|
||||
#end
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
// 处理查询参数
|
||||
let params = {...this.queryParams};
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.listOperation)
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.addBeginAndEndTime(params, this.dateRange${AttrName}, '${column.javaField}');
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
// 执行查询
|
||||
get${simpleClassName}Page(params).then(response => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 取消按钮 */
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
/** 表单重置 */
|
||||
reset() {
|
||||
this.form = {
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.createOperation || $column.updateOperation)
|
||||
#if ($column.htmlType == "checkbox")
|
||||
$column.javaField: [],
|
||||
#else
|
||||
$column.javaField: undefined,
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.listOperation)
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.dateRange${AttrName} = [];
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加${table.classComment}";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const ${primaryColumn.javaField} = row.${primaryColumn.javaField};
|
||||
get${simpleClassName}(${primaryColumn.javaField}).then(response => {
|
||||
this.form = response.data;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")## checkbox 特殊处理
|
||||
this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
||||
#end
|
||||
#end
|
||||
this.open = true;
|
||||
this.title = "修改${table.classComment}";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.#[[$]]#refs["form"].validate(valid => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
||||
#end
|
||||
#end
|
||||
// 修改的提交
|
||||
if (this.form.${primaryColumn.javaField} != null) {
|
||||
update${simpleClassName}(this.form).then(response => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
create${simpleClassName}(this.form).then(response => {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ${primaryColumn.javaField} = row.${primaryColumn.javaField};
|
||||
this.$confirm('是否确认删除${table.classComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return delete${simpleClassName}(${primaryColumn.javaField});
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
// 处理查询参数
|
||||
let params = {...this.queryParams};
|
||||
params.pageNo = undefined;
|
||||
params.pageSize = undefined;
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.listOperation)
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.addBeginAndEndTime(params, this.dateRange${AttrName}, '${column.javaField}');
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
// 执行导出
|
||||
this.$confirm('是否确认导出所有${table.classComment}数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return export${simpleClassName}Excel(params);
|
||||
}).then(response => {
|
||||
this.downloadExcel(response, '${table.classComment}.xls');
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
76
yudao-admin-server/src/main/resources/logback-spring.xml
Normal file
76
yudao-admin-server/src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,76 @@
|
||||
<configuration>
|
||||
<!-- 引用 Spring Boot 的 logback 基础配置 -->
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
||||
<!-- 变量 yudao.info.base-package,基础业务包 -->
|
||||
<springProperty scope="context" name="yudao.info.base-package" source="yudao.info.base-package"/>
|
||||
<!-- 格式化输出:%d 表示日期,%X{tid} SkWalking 链路追踪编号,%thread 表示线程名,%-5level:级别从左显示 5 个字符宽度,%msg:日志消息,%n是换行符 -->
|
||||
<property name="PATTERN_DEFAULT" value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%thread] [%tid] %-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
|
||||
|
||||
<!-- 控制台 Appender -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
||||
<pattern>${PATTERN_DEFAULT}</pattern>
|
||||
</layout>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 文件 Appender -->
|
||||
<!-- 参考 Spring Boot 的 file-appender.xml 编写 -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
||||
<pattern>${PATTERN_DEFAULT}</pattern>
|
||||
</layout>
|
||||
</encoder>
|
||||
<!-- 日志文件名 -->
|
||||
<file>${LOG_FILE}</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!-- 滚动后的日志文件名 -->
|
||||
<fileNamePattern>${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
|
||||
<!-- 启动服务时,是否清理历史日志,一般不建议清理 -->
|
||||
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
|
||||
<!-- 日志文件,到达多少容量,进行滚动 -->
|
||||
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
|
||||
<!-- 日志文件的总大小,0 表示不限制 -->
|
||||
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
|
||||
<!-- 日志文件的保留天数 -->
|
||||
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30}</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
<!-- 异步写入日志,提升性能 -->
|
||||
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<!-- 不丢失日志。默认的,如果队列的 80% 已满,则会丢弃 TRACT、DEBUG、INFO 级别的日志 -->
|
||||
<discardingThreshold>0</discardingThreshold>
|
||||
<!-- 更改默认的队列的深度,该值会影响性能。默认值为 256 -->
|
||||
<queueSize>256</queueSize>
|
||||
<appender-ref ref="FILE"/>
|
||||
</appender>
|
||||
|
||||
<!-- SkyWalking GRPC 日志收集,实现日志中心。注意:SkyWalking 8.4.0 版本开始支持 -->
|
||||
<appender name="GRPC" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
|
||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
||||
<pattern>${PATTERN_DEFAULT}</pattern>
|
||||
</layout>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 本地环境 -->
|
||||
<springProfile name="local">
|
||||
<logger name="${yudao.info.base-package}" level="INFO" additivity="false">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="GRPC"/> <!-- 本地环境下,如果不想接入 SkyWalking 日志服务,可以注释掉本行 -->
|
||||
<appender-ref ref="ASYNC"/> <!-- 本地环境下,如果不想打印日志,可以注释掉本行 -->
|
||||
</logger>
|
||||
</springProfile>
|
||||
<!-- 其它环境 -->
|
||||
<springProfile name="default">
|
||||
<logger name="${yudao.info.base-package}" level="INFO" additivity="false">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="ASYNC"/>
|
||||
<appender-ref ref="GRPC"/>
|
||||
</logger>
|
||||
</springProfile>
|
||||
|
||||
</configuration>
|
Reference in New Issue
Block a user