mirror of
https://gitee.com/y_project/RuoYi-Vue.git
synced 2025-12-08 15:02:29 +08:00
Compare commits
266 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e64a93d11 | |||
| 4aabf5d8be | |||
| cf6254a8d5 | |||
| 883cff5de9 | |||
| 7e79c4f249 | |||
| 504638eb41 | |||
| 2adac4a899 | |||
| 56a943bf48 | |||
| 77ebca264a | |||
| 7b94ae3a9a | |||
| bd1edc6dcc | |||
| 09d166e97d | |||
| f3e5d908d6 | |||
| 9651a7d7fc | |||
| b2914cbcb1 | |||
| d0a4d6b111 | |||
| b431703262 | |||
| 99726be9ac | |||
| 32f333a00e | |||
| be5c19b764 | |||
| dd384e4a31 | |||
| bdde195e2b | |||
| 14ea071306 | |||
| 50034301ac | |||
| 85ed712c50 | |||
| f67d682345 | |||
| 3f1427eef9 | |||
| 7d0f5e94ef | |||
| 62081aebb9 | |||
| 3f07632cd4 | |||
| 2c94587263 | |||
| 2575c17f47 | |||
| b6f13c546b | |||
| e60a69b670 | |||
| cb18eec802 | |||
| bef080c60a | |||
| de73cf300b | |||
| cbcee86d2c | |||
| cc50224d90 | |||
| ff09e1cf55 | |||
| fe2ccbdc1b | |||
| c8df1f5e1f | |||
| e71c00e6fa | |||
| dcb9839596 | |||
| f13b6d92d2 | |||
| 6595c68df1 | |||
| 5a2a0c09b6 | |||
| 9aac65ff32 | |||
| 5f2350569a | |||
| ccf05b697d | |||
| 6810243ab7 | |||
| b56b8846d9 | |||
| 8e1e4cd8fe | |||
| 9fa5c79713 | |||
| 40a72c2b7e | |||
| 6fe9a358b7 | |||
| 9f6bc13e64 | |||
| ba5ab4b091 | |||
| 17407d0127 | |||
| 30f330f4a0 | |||
| 6ca7870393 | |||
| 2a7342ec43 | |||
| fc57e91b80 | |||
| 347f36ceff | |||
| 9b9c1b999f | |||
| ec627704b2 | |||
| 9e6b2a1265 | |||
| 266a5e844f | |||
| 0822680158 | |||
| 090e258bf9 | |||
| 505fa06dc3 | |||
| 6cf53bfacb | |||
| 881dc3fcf0 | |||
| b65c8d4512 | |||
| 67371a9028 | |||
| 01b545e4ab | |||
| c2e9200626 | |||
| 9502203bbe | |||
| c0f1569ad9 | |||
| 61432480c8 | |||
| 78deee063d | |||
| 4ad003649e | |||
| 616f5a6aca | |||
| fea3ff7b2a | |||
| f938a24df0 | |||
| 45fa686a64 | |||
| 0d8c3b4940 | |||
| 64e807f27b | |||
| 9a384a2fc2 | |||
| 339b932a3d | |||
| 0b5c7f4c96 | |||
| 265e3010aa | |||
| b7a36bfe8a | |||
| 3a51c53823 | |||
| df504c5c14 | |||
| baeed2e8d3 | |||
| 2903de1561 | |||
| cca2f5c62d | |||
| ce54416e4f | |||
| bd19892aff | |||
| 14a859899c | |||
| f3cb18c836 | |||
| 7d0eb3b8c7 | |||
| 654aa6b30c | |||
| b7cdd10f9f | |||
| 9bd35cb7be | |||
| 7a86c714fc | |||
| edd090a098 | |||
| 3cd886785b | |||
| ae5a0f9774 | |||
| 074b3c735d | |||
| a118738d0f | |||
| 56fa3912ae | |||
| 2116ee1822 | |||
| 57a2eb4217 | |||
| 647af5b485 | |||
| 3f33219134 | |||
| a04bb71777 | |||
| 63992ac906 | |||
| 0187344798 | |||
| a9c6ba12e6 | |||
| ba068eae65 | |||
| 1a87ee7c19 | |||
| 3c4b01ab83 | |||
| 886ce995af | |||
| 52264b6e2a | |||
| fd7e88a518 | |||
| 854a6f805f | |||
| 1caec85f46 | |||
| c86dc20743 | |||
| ecc7a8be46 | |||
| e23ad20186 | |||
| 6cf2a8edeb | |||
| 67198aede9 | |||
| 4f33da2a3f | |||
| 8988d0b4ab | |||
| ceefa20aa2 | |||
| 89e1f2a53f | |||
| 6800a12014 | |||
| e8f63b2994 | |||
| ecfe7006e2 | |||
| 9e387dc447 | |||
| 231bbf6928 | |||
| d6eac2dc8d | |||
| b368ad764f | |||
| ffd5f0ce5d | |||
| a50beae599 | |||
| cf7f51a633 | |||
| 4d46f4c1b5 | |||
| a941c1b488 | |||
| d6b6151aea | |||
| fbc071a573 | |||
| 6cfff90b4a | |||
| 474cca921e | |||
| 1657e06be6 | |||
| c01eeb8521 | |||
| f90899d72a | |||
| 7e78a9167f | |||
| 563e11d9c1 | |||
| ef92ad4d8c | |||
| d8b006c15f | |||
| 0e2b97a886 | |||
| 1c7a5faae8 | |||
| 23868c4fad | |||
| 3b2669d148 | |||
| 1147ea5f8a | |||
| a1bf5aaf8e | |||
| 2797c1eb3a | |||
| 1791d7cf40 | |||
| 01861f0aae | |||
| a69cc94f35 | |||
| c666faed66 | |||
| 6072239a40 | |||
| a3b86d6f6d | |||
| fd831d5a90 | |||
| e83412b9a5 | |||
| 90ac416e02 | |||
| 5b63f0cab9 | |||
| 8f145bba3a | |||
| 6bb166b89f | |||
| 823e95667e | |||
| 566053da0c | |||
| 0ef007240d | |||
| 0a75dcdd85 | |||
| 4c2626ffec | |||
| 082b19e33a | |||
| b779cf053d | |||
| 212012dc62 | |||
| 7de2cf77b4 | |||
| 2b9d46439f | |||
| 79265d59b7 | |||
| 093ba5b389 | |||
| 3807b11290 | |||
| c9f25cb34e | |||
| 203b54e5aa | |||
| 403f5c5dcf | |||
| c6d0b9a9ae | |||
| 08df2c93a9 | |||
| fbbdd94999 | |||
| 0cae7d0058 | |||
| b0965653bf | |||
| e472f62523 | |||
| 69256940df | |||
| b9f686be53 | |||
| 521ff51238 | |||
| f67c97e095 | |||
| dd721ff894 | |||
| ae4290bdda | |||
| c19fec2cf8 | |||
| 669c42795a | |||
| 0d79f10c2f | |||
| d3595cd930 | |||
| 5b0525d05c | |||
| fb07677c32 | |||
| a82a3d9465 | |||
| 28bceda630 | |||
| 69829827fe | |||
| 89607fb028 | |||
| 1aa18c523d | |||
| abeb8d7fd8 | |||
| 478fae0d28 | |||
| 0ecf27f8d6 | |||
| 0a5bb34fbf | |||
| 9e38c7de2e | |||
| 9ca28d6dbf | |||
| 497f98ba90 | |||
| a948affb2d | |||
| 57b49dd5fa | |||
| 9c0ed9c424 | |||
| 70ab18052c | |||
| aeb02c79d8 | |||
| 33793d8eff | |||
| 9652906954 | |||
| 9fccc7de40 | |||
| 599be64fa8 | |||
| 50ac363682 | |||
| f84b157419 | |||
| f4536d5d2e | |||
| aed958b1be | |||
| 0a51f7d743 | |||
| 3fd9147afb | |||
| 4f86b6d9ca | |||
| a65c287075 | |||
| 1af0d1665c | |||
| 4e32788b36 | |||
| 068c3e6f0d | |||
| dd6640086e | |||
| be54188ba6 | |||
| a4e2339f90 | |||
| bf771ae5c8 | |||
| fa5596bb20 | |||
| eb30fc4b1a | |||
| 0446d211df | |||
| da146c2a70 | |||
| 7de5358dcd | |||
| 549c7ee97a | |||
| 5fcf342f5a | |||
| c89722a7dd | |||
| 61e10f2783 | |||
| c6912ca1d5 | |||
| 5c4f0c5503 | |||
| 4f7702b22a | |||
| 04e294b3e5 | |||
| d596d5bb8e | |||
| 0070297fe1 | |||
| 650359c357 |
18
README.md
18
README.md
@ -1,14 +1,17 @@
|
|||||||
## 平台简介
|
## 平台简介
|
||||||
|
|
||||||
|
若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
|
||||||
|
|
||||||
* 前端采用Vue、Element UI。
|
* 前端采用Vue、Element UI。
|
||||||
* 后端采用Spring Boot、Spring Security、Redis & Jwt。
|
* 后端采用Spring Boot、Spring Security、Redis & Jwt。
|
||||||
* 权限认证使用Jwt,支持多终端认证系统。
|
* 权限认证使用Jwt,支持多终端认证系统。
|
||||||
* 支持加载动态权限菜单,多方式轻松权限控制。
|
* 支持加载动态权限菜单,多方式轻松权限控制。
|
||||||
* 高效率开发,使用代码生成器可以一键生成前后端代码。
|
* 高效率开发,使用代码生成器可以一键生成前后端代码。
|
||||||
* 提供了一个Oracle版本[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle),保持同步更新。
|
* 提供了单应用版本[RuoYi-Vue-fast](https://github.com/yangzongzhuan/RuoYi-Vue-fast),Oracle版本[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle),保持同步更新。
|
||||||
* 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi),微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud)
|
* 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi),微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud)
|
||||||
* 感谢[Vue-Element-Admin](https://github.com/PanJiaChen/vue-element-admin),[eladmin-web](https://gitee.com/elunez/eladmin-web?_from=gitee_search)。
|
* 特别鸣谢:[element](https://github.com/ElemeFE/element),[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin),[eladmin-web](https://github.com/elunez/eladmin-web)。
|
||||||
* 阿里云优惠券:[点我进入](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link),腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)
|
* 阿里云折扣场:[点我进入](http://aly.ruoyi.vip),腾讯云秒杀场:[点我进入](http://txy.ruoyi.vip)
|
||||||
|
* 阿里云优惠券:[点我领取](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link),腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)
|
||||||
|
|
||||||
## 内置功能
|
## 内置功能
|
||||||
|
|
||||||
@ -27,8 +30,9 @@
|
|||||||
13. 代码生成:前后端代码的生成(java、html、xml、sql)支持CRUD下载 。
|
13. 代码生成:前后端代码的生成(java、html、xml、sql)支持CRUD下载 。
|
||||||
14. 系统接口:根据业务代码自动生成相关的api接口文档。
|
14. 系统接口:根据业务代码自动生成相关的api接口文档。
|
||||||
15. 服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。
|
15. 服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。
|
||||||
16. 在线构建器:拖动表单元素生成相应的HTML代码。
|
16. 缓存监控:对系统的缓存信息查询,命令统计等。
|
||||||
17. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。
|
17. 在线构建器:拖动表单元素生成相应的HTML代码。
|
||||||
|
18. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。
|
||||||
|
|
||||||
## 在线体验
|
## 在线体验
|
||||||
|
|
||||||
@ -71,11 +75,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="https://oscimg.oschina.net/oscnet/b6115bc8c31de52951982e509930b20684a.jpg"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/b6115bc8c31de52951982e509930b20684a.jpg"/></td>
|
||||||
<td><img src="https://oscimg.oschina.net/oscnet/up-6d73c2140ce694e3de4c05035fdc1868d4c.png"/></td>
|
<td><img src="https://oscimg.oschina.net/oscnet/up-5e4daac0bb59612c5038448acbcef235e3a.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
## 若依前后端分离交流群
|
## 若依前后端分离交流群
|
||||||
|
|
||||||
QQ群: [](https://jq.qq.com/?_wv=1027&k=5bVB1og) [](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [](https://jq.qq.com/?_wv=1027&k=51G72yr) 点击按钮入群。
|
QQ群: [](https://jq.qq.com/?_wv=1027&k=5bVB1og) [](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [](https://jq.qq.com/?_wv=1027&k=51G72yr) [](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [](https://jq.qq.com/?_wv=1027&k=5vYAqA05) 点击按钮入群。
|
||||||
95
pom.xml
95
pom.xml
@ -6,73 +6,95 @@
|
|||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.5.0</version>
|
||||||
|
|
||||||
<name>ruoyi</name>
|
<name>ruoyi</name>
|
||||||
<url>http://www.ruoyi.vip</url>
|
<url>http://www.ruoyi.vip</url>
|
||||||
<description>若依管理系统</description>
|
<description>若依管理系统</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<ruoyi.version>3.1.0</ruoyi.version>
|
<ruoyi.version>3.5.0</ruoyi.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<mybatis.boot.version>1.3.2</mybatis.boot.version>
|
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||||
<druid.version>1.1.14</druid.version>
|
<druid.version>1.2.6</druid.version>
|
||||||
<bitwalker.version>1.19</bitwalker.version>
|
<bitwalker.version>1.21</bitwalker.version>
|
||||||
<swagger.version>2.9.2</swagger.version>
|
<swagger.version>2.9.2</swagger.version>
|
||||||
<kaptcha.version>2.3.2</kaptcha.version>
|
<kaptcha.version>2.3.2</kaptcha.version>
|
||||||
<pagehelper.boot.version>1.2.5</pagehelper.boot.version>
|
<mybatis-spring-boot.version>2.1.4</mybatis-spring-boot.version>
|
||||||
<fastjson.version>1.2.70</fastjson.version>
|
<pagehelper.boot.version>1.3.0</pagehelper.boot.version>
|
||||||
<oshi.version>3.9.1</oshi.version>
|
<fastjson.version>1.2.76</fastjson.version>
|
||||||
|
<oshi.version>5.6.0</oshi.version>
|
||||||
|
<jna.version>5.7.0</jna.version>
|
||||||
<commons.io.version>2.5</commons.io.version>
|
<commons.io.version>2.5</commons.io.version>
|
||||||
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
||||||
<poi.version>3.17</poi.version>
|
<commons.collections.version>3.2.2</commons.collections.version>
|
||||||
|
<poi.version>4.1.2</poi.version>
|
||||||
<velocity.version>1.7</velocity.version>
|
<velocity.version>1.7</velocity.version>
|
||||||
<jwt.version>0.9.0</jwt.version>
|
<jwt.version>0.9.1</jwt.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- SpringBoot的依赖配置-->
|
<!-- SpringBoot的依赖配置-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
<version>2.1.1.RELEASE</version>
|
<version>2.2.13.RELEASE</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--阿里数据库连接池 -->
|
<!--阿里数据库连接池 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
<version>${druid.version}</version>
|
<version>${druid.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 解析客户端操作系统、浏览器等 -->
|
<!-- 解析客户端操作系统、浏览器等 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>eu.bitwalker</groupId>
|
<groupId>eu.bitwalker</groupId>
|
||||||
<artifactId>UserAgentUtils</artifactId>
|
<artifactId>UserAgentUtils</artifactId>
|
||||||
<version>${bitwalker.version}</version>
|
<version>${bitwalker.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot集成mybatis框架 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>${mybatis-spring-boot.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- pagehelper 分页插件 -->
|
<!-- pagehelper 分页插件 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.pagehelper</groupId>
|
<groupId>com.github.pagehelper</groupId>
|
||||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
<version>${pagehelper.boot.version}</version>
|
<version>${pagehelper.boot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 获取系统信息 -->
|
<!-- 获取系统信息 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.oshi</groupId>
|
<groupId>com.github.oshi</groupId>
|
||||||
<artifactId>oshi-core</artifactId>
|
<artifactId>oshi-core</artifactId>
|
||||||
<version>${oshi.version}</version>
|
<version>${oshi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.dev.jna</groupId>
|
||||||
|
<artifactId>jna</artifactId>
|
||||||
|
<version>${jna.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.dev.jna</groupId>
|
||||||
|
<artifactId>jna-platform</artifactId>
|
||||||
|
<version>${jna.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- swagger2-->
|
<!-- swagger2-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
@ -89,91 +111,104 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- swagger2-UI-->
|
<!-- swagger2-UI-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>${swagger.version}</version>
|
<version>${swagger.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--io常用工具类 -->
|
<!--io常用工具类 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>${commons.io.version}</version>
|
<version>${commons.io.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--文件上传工具类 -->
|
<!--文件上传工具类 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-fileupload</groupId>
|
<groupId>commons-fileupload</groupId>
|
||||||
<artifactId>commons-fileupload</artifactId>
|
<artifactId>commons-fileupload</artifactId>
|
||||||
<version>${commons.fileupload.version}</version>
|
<version>${commons.fileupload.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- excel工具 -->
|
<!-- excel工具 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
<version>${poi.version}</version>
|
<version>${poi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--velocity代码生成使用模板 -->
|
<!--velocity代码生成使用模板 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
<artifactId>velocity</artifactId>
|
<artifactId>velocity</artifactId>
|
||||||
<version>${velocity.version}</version>
|
<version>${velocity.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-collections</groupId>
|
||||||
|
<artifactId>commons-collections</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- collections工具类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-collections</groupId>
|
||||||
|
<artifactId>commons-collections</artifactId>
|
||||||
|
<version>${commons.collections.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 阿里JSON解析器 -->
|
<!-- 阿里JSON解析器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>${fastjson.version}</version>
|
<version>${fastjson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--Token生成与解析-->
|
<!--Token生成与解析-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
<artifactId>jjwt</artifactId>
|
<artifactId>jjwt</artifactId>
|
||||||
<version>${jwt.version}</version>
|
<version>${jwt.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--验证码 -->
|
<!--验证码 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.penggle</groupId>
|
<groupId>com.github.penggle</groupId>
|
||||||
<artifactId>kaptcha</artifactId>
|
<artifactId>kaptcha</artifactId>
|
||||||
<version>${kaptcha.version}</version>
|
<version>${kaptcha.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 定时任务-->
|
<!-- 定时任务-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-quartz</artifactId>
|
<artifactId>ruoyi-quartz</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 代码生成-->
|
<!-- 代码生成-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-generator</artifactId>
|
<artifactId>ruoyi-generator</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 核心模块-->
|
<!-- 核心模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-framework</artifactId>
|
<artifactId>ruoyi-framework</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 系统模块-->
|
<!-- 系统模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-system</artifactId>
|
<artifactId>ruoyi-system</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 通用工具-->
|
<!-- 通用工具-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.1.0</version>
|
<version>3.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@ -41,17 +42,15 @@ public class CommonController
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!FileUtils.isValidFilename(fileName))
|
if (!FileUtils.checkAllowDownload(fileName))
|
||||||
{
|
{
|
||||||
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
||||||
}
|
}
|
||||||
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
||||||
String filePath = RuoYiConfig.getDownloadPath() + fileName;
|
String filePath = RuoYiConfig.getDownloadPath() + fileName;
|
||||||
|
|
||||||
response.setCharacterEncoding("utf-8");
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||||
response.setContentType("multipart/form-data");
|
FileUtils.setAttachmentResponseHeader(response, realFileName);
|
||||||
response.setHeader("Content-Disposition",
|
|
||||||
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
|
|
||||||
FileUtils.writeBytes(filePath, response.getOutputStream());
|
FileUtils.writeBytes(filePath, response.getOutputStream());
|
||||||
if (delete)
|
if (delete)
|
||||||
{
|
{
|
||||||
@ -92,18 +91,28 @@ public class CommonController
|
|||||||
* 本地资源通用下载
|
* 本地资源通用下载
|
||||||
*/
|
*/
|
||||||
@GetMapping("/common/download/resource")
|
@GetMapping("/common/download/resource")
|
||||||
public void resourceDownload(String name, HttpServletRequest request, HttpServletResponse response) throws Exception
|
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
// 本地资源路径
|
try
|
||||||
String localPath = RuoYiConfig.getProfile();
|
{
|
||||||
// 数据库资源地址
|
if (!FileUtils.checkAllowDownload(resource))
|
||||||
String downloadPath = localPath + StringUtils.substringAfter(name, Constants.RESOURCE_PREFIX);
|
{
|
||||||
// 下载名称
|
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
|
||||||
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
}
|
||||||
response.setCharacterEncoding("utf-8");
|
// 本地资源路径
|
||||||
response.setContentType("multipart/form-data");
|
String localPath = RuoYiConfig.getProfile();
|
||||||
response.setHeader("Content-Disposition",
|
// 数据库资源地址
|
||||||
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName));
|
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
|
||||||
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
// 下载名称
|
||||||
|
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
||||||
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||||
|
FileUtils.setAttachmentResponseHeader(response, downloadName);
|
||||||
|
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.error("下载文件失败", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,53 @@
|
|||||||
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisCallback;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存监控
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/monitor/cache")
|
||||||
|
public class CacheController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String, String> redisTemplate;
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||||
|
@GetMapping()
|
||||||
|
public AjaxResult getInfo() throws Exception
|
||||||
|
{
|
||||||
|
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
|
||||||
|
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
||||||
|
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>(3);
|
||||||
|
result.put("info", info);
|
||||||
|
result.put("dbSize", dbSize);
|
||||||
|
|
||||||
|
List<Map<String, String>> pieList = new ArrayList<>();
|
||||||
|
commandStats.stringPropertyNames().forEach(key -> {
|
||||||
|
Map<String, String> data = new HashMap<>(2);
|
||||||
|
String property = commandStats.getProperty(key);
|
||||||
|
data.put("name", StringUtils.removeStart(key, "cmdstat_"));
|
||||||
|
data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
|
||||||
|
pieList.add(data);
|
||||||
|
});
|
||||||
|
result.put("commandStats", pieList);
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,7 +4,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.framework.web.domain.Server;
|
import com.ruoyi.framework.web.domain.Server;
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ import com.ruoyi.framework.web.domain.Server;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/server")
|
@RequestMapping("/monitor/server")
|
||||||
public class ServerController extends BaseController
|
public class ServerController
|
||||||
{
|
{
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
|
|||||||
@ -38,18 +38,18 @@ public class SysLogininforController extends BaseController
|
|||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "登陆日志", businessType = BusinessType.EXPORT)
|
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(SysLogininfor logininfor)
|
public AjaxResult export(SysLogininfor logininfor)
|
||||||
{
|
{
|
||||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||||
return util.exportExcel(list, "登陆日志");
|
return util.exportExcel(list, "登录日志");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||||
@Log(title = "登陆日志", businessType = BusinessType.DELETE)
|
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{infoIds}")
|
@DeleteMapping("/{infoIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] infoIds)
|
public AjaxResult remove(@PathVariable Long[] infoIds)
|
||||||
{
|
{
|
||||||
@ -57,7 +57,7 @@ public class SysLogininforController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||||
@Log(title = "登陆日志", businessType = BusinessType.CLEAN)
|
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
||||||
@DeleteMapping("/clean")
|
@DeleteMapping("/clean")
|
||||||
public AjaxResult clean()
|
public AjaxResult clean()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -48,6 +48,7 @@ public class SysOperlogController extends BaseController
|
|||||||
return util.exportExcel(list, "操作日志");
|
return util.exportExcel(list, "操作日志");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||||
@DeleteMapping("/{operIds}")
|
@DeleteMapping("/{operIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] operIds)
|
public AjaxResult remove(@PathVariable Long[] operIds)
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@ -19,6 +20,7 @@ import com.ruoyi.common.core.domain.entity.SysDictData;
|
|||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.service.ISysDictDataService;
|
import com.ruoyi.system.service.ISysDictDataService;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
@ -73,7 +75,12 @@ public class SysDictDataController extends BaseController
|
|||||||
@GetMapping(value = "/type/{dictType}")
|
@GetMapping(value = "/type/{dictType}")
|
||||||
public AjaxResult dictType(@PathVariable String dictType)
|
public AjaxResult dictType(@PathVariable String dictType)
|
||||||
{
|
{
|
||||||
return AjaxResult.success(dictTypeService.selectDictDataByType(dictType));
|
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||||
|
if (StringUtils.isNull(data))
|
||||||
|
{
|
||||||
|
data = new ArrayList<SysDictData>();
|
||||||
|
}
|
||||||
|
return AjaxResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -126,11 +126,11 @@ public class SysMenuController extends BaseController
|
|||||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
|
||||||
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
|
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
}
|
}
|
||||||
else if (menu.getMenuId().equals(menu.getParentId()))
|
else if (menu.getMenuId().equals(menu.getParentId()))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
||||||
}
|
}
|
||||||
menu.setUpdateBy(SecurityUtils.getUsername());
|
menu.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return toAjax(menuService.updateMenu(menu));
|
return toAjax(menuService.updateMenu(menu));
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
@ -19,6 +20,7 @@ import com.ruoyi.common.core.domain.model.LoginUser;
|
|||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||||
import com.ruoyi.framework.web.service.TokenService;
|
import com.ruoyi.framework.web.service.TokenService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
@ -59,6 +61,16 @@ public class SysProfileController extends BaseController
|
|||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult updateProfile(@RequestBody SysUser user)
|
public AjaxResult updateProfile(@RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
|
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
|
{
|
||||||
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||||
|
{
|
||||||
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
|
}
|
||||||
if (userService.updateUserProfile(user) > 0)
|
if (userService.updateUserProfile(user) > 0)
|
||||||
{
|
{
|
||||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||||
|
|||||||
@ -127,11 +127,13 @@ public class SysUserController extends BaseController
|
|||||||
{
|
{
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
else if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
@ -149,11 +151,13 @@ public class SysUserController extends BaseController
|
|||||||
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
else if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
@ -175,7 +179,7 @@ public class SysUserController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 重置密码
|
* 重置密码
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/resetPwd")
|
@PutMapping("/resetPwd")
|
||||||
public AjaxResult resetPwd(@RequestBody SysUser user)
|
public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||||
|
|||||||
@ -43,8 +43,8 @@ spring:
|
|||||||
allow:
|
allow:
|
||||||
url-pattern: /druid/*
|
url-pattern: /druid/*
|
||||||
# 控制台管理用户名和密码
|
# 控制台管理用户名和密码
|
||||||
login-username:
|
login-username: ruoyi
|
||||||
login-password:
|
login-password: 123456
|
||||||
filter:
|
filter:
|
||||||
stat:
|
stat:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@ -3,9 +3,9 @@ ruoyi:
|
|||||||
# 名称
|
# 名称
|
||||||
name: RuoYi
|
name: RuoYi
|
||||||
# 版本
|
# 版本
|
||||||
version: 3.1.0
|
version: 3.5.0
|
||||||
# 版权年份
|
# 版权年份
|
||||||
copyrightYear: 2019
|
copyrightYear: 2021
|
||||||
# 实例演示开关
|
# 实例演示开关
|
||||||
demoEnabled: true
|
demoEnabled: true
|
||||||
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
||||||
@ -62,6 +62,8 @@ spring:
|
|||||||
host: localhost
|
host: localhost
|
||||||
# 端口,默认为6379
|
# 端口,默认为6379
|
||||||
port: 6379
|
port: 6379
|
||||||
|
# 数据库索引
|
||||||
|
database: 0
|
||||||
# 密码
|
# 密码
|
||||||
password:
|
password:
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.1.0</version>
|
<version>3.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import java.lang.annotation.ElementType;
|
|||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义导出Excel数据注解
|
* 自定义导出Excel数据注解
|
||||||
@ -30,7 +31,7 @@ public @interface Excel
|
|||||||
public String dateFormat() default "";
|
public String dateFormat() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果是字典类型,请设置字典的type值
|
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
|
||||||
*/
|
*/
|
||||||
public String dictType() default "";
|
public String dictType() default "";
|
||||||
|
|
||||||
@ -44,6 +45,16 @@ public @interface Excel
|
|||||||
*/
|
*/
|
||||||
public String separator() default ",";
|
public String separator() default ",";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
||||||
|
*/
|
||||||
|
public int scale() default -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
||||||
|
*/
|
||||||
|
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出类型(0数字 1字符串)
|
* 导出类型(0数字 1字符串)
|
||||||
*/
|
*/
|
||||||
@ -89,6 +100,32 @@ public @interface Excel
|
|||||||
*/
|
*/
|
||||||
public String targetAttr() default "";
|
public String targetAttr() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否自动统计数据,在最后追加一行统计数据总和
|
||||||
|
*/
|
||||||
|
public boolean isStatistics() default false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出字段对齐方式(0:默认;1:靠左;2:居中;3:靠右)
|
||||||
|
*/
|
||||||
|
Align align() default Align.AUTO;
|
||||||
|
|
||||||
|
public enum Align
|
||||||
|
{
|
||||||
|
AUTO(0), LEFT(1), CENTER(2), RIGHT(3);
|
||||||
|
private final int value;
|
||||||
|
|
||||||
|
Align(int value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int value()
|
||||||
|
{
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||||
*/
|
*/
|
||||||
@ -112,7 +149,7 @@ public @interface Excel
|
|||||||
|
|
||||||
public enum ColumnType
|
public enum ColumnType
|
||||||
{
|
{
|
||||||
NUMERIC(0), STRING(1);
|
NUMERIC(0), STRING(1), IMAGE(2);
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
ColumnType(int value)
|
ColumnType(int value)
|
||||||
|
|||||||
@ -13,6 +13,9 @@ public class GenConstants
|
|||||||
/** 树表(增删改查) */
|
/** 树表(增删改查) */
|
||||||
public static final String TPL_TREE = "tree";
|
public static final String TPL_TREE = "tree";
|
||||||
|
|
||||||
|
/** 主子表(增删改查) */
|
||||||
|
public static final String TPL_SUB = "sub";
|
||||||
|
|
||||||
/** 树编码字段 */
|
/** 树编码字段 */
|
||||||
public static final String TREE_CODE = "treeCode";
|
public static final String TREE_CODE = "treeCode";
|
||||||
|
|
||||||
@ -29,15 +32,17 @@ public class GenConstants
|
|||||||
public static final String PARENT_MENU_NAME = "parentMenuName";
|
public static final String PARENT_MENU_NAME = "parentMenuName";
|
||||||
|
|
||||||
/** 数据库字符串类型 */
|
/** 数据库字符串类型 */
|
||||||
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "narchar", "varchar2", "tinytext", "text",
|
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
|
||||||
"mediumtext", "longtext" };
|
|
||||||
|
/** 数据库文本类型 */
|
||||||
|
public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
|
||||||
|
|
||||||
/** 数据库时间类型 */
|
/** 数据库时间类型 */
|
||||||
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
||||||
|
|
||||||
/** 数据库数字类型 */
|
/** 数据库数字类型 */
|
||||||
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
||||||
"bigint", "float", "float", "double", "decimal" };
|
"bit", "bigint", "float", "double", "decimal" };
|
||||||
|
|
||||||
/** 页面不需要编辑字段 */
|
/** 页面不需要编辑字段 */
|
||||||
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
||||||
@ -74,6 +79,15 @@ public class GenConstants
|
|||||||
/** 日期控件 */
|
/** 日期控件 */
|
||||||
public static final String HTML_DATETIME = "datetime";
|
public static final String HTML_DATETIME = "datetime";
|
||||||
|
|
||||||
|
/** 图片上传控件 */
|
||||||
|
public static final String HTML_IMAGE_UPLOAD = "imageUpload";
|
||||||
|
|
||||||
|
/** 文件上传控件 */
|
||||||
|
public static final String HTML_FILE_UPLOAD = "fileUpload";
|
||||||
|
|
||||||
|
/** 富文本控件 */
|
||||||
|
public static final String HTML_EDITOR = "editor";
|
||||||
|
|
||||||
/** 字符串类型 */
|
/** 字符串类型 */
|
||||||
public static final String TYPE_STRING = "String";
|
public static final String TYPE_STRING = "String";
|
||||||
|
|
||||||
|
|||||||
@ -54,6 +54,9 @@ public class UserConstants
|
|||||||
/** Layout组件标识 */
|
/** Layout组件标识 */
|
||||||
public final static String LAYOUT = "Layout";
|
public final static String LAYOUT = "Layout";
|
||||||
|
|
||||||
|
/** ParentView组件标识 */
|
||||||
|
public final static String PARENT_VIEW = "ParentView";
|
||||||
|
|
||||||
/** 校验返回结果码 */
|
/** 校验返回结果码 */
|
||||||
public final static String UNIQUE = "0";
|
public final static String UNIQUE = "0";
|
||||||
public final static String NOT_UNIQUE = "1";
|
public final static String NOT_UNIQUE = "1";
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import com.ruoyi.common.utils.sql.SqlUtil;
|
|||||||
*/
|
*/
|
||||||
public class BaseController
|
public class BaseController
|
||||||
{
|
{
|
||||||
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||||
@ -84,6 +84,49 @@ public class BaseController
|
|||||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应返回结果
|
||||||
|
*
|
||||||
|
* @param result 结果
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
protected AjaxResult toAjax(boolean result)
|
||||||
|
{
|
||||||
|
return result ? success() : error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功
|
||||||
|
*/
|
||||||
|
public AjaxResult success()
|
||||||
|
{
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回失败消息
|
||||||
|
*/
|
||||||
|
public AjaxResult error()
|
||||||
|
{
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*/
|
||||||
|
public AjaxResult success(String message)
|
||||||
|
{
|
||||||
|
return AjaxResult.success(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回失败消息
|
||||||
|
*/
|
||||||
|
public AjaxResult error(String message)
|
||||||
|
{
|
||||||
|
return AjaxResult.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面跳转
|
* 页面跳转
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity基类
|
* Entity基类
|
||||||
@ -36,14 +35,6 @@ public class BaseEntity implements Serializable
|
|||||||
/** 备注 */
|
/** 备注 */
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/** 开始时间 */
|
|
||||||
@JsonIgnore
|
|
||||||
private String beginTime;
|
|
||||||
|
|
||||||
/** 结束时间 */
|
|
||||||
@JsonIgnore
|
|
||||||
private String endTime;
|
|
||||||
|
|
||||||
/** 请求参数 */
|
/** 请求参数 */
|
||||||
private Map<String, Object> params;
|
private Map<String, Object> params;
|
||||||
|
|
||||||
@ -107,26 +98,6 @@ public class BaseEntity implements Serializable
|
|||||||
this.remark = remark;
|
this.remark = remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBeginTime()
|
|
||||||
{
|
|
||||||
return beginTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBeginTime(String beginTime)
|
|
||||||
{
|
|
||||||
this.beginTime = beginTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEndTime()
|
|
||||||
{
|
|
||||||
return endTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEndTime(String endTime)
|
|
||||||
{
|
|
||||||
this.endTime = endTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Object> getParams()
|
public Map<String, Object> getParams()
|
||||||
{
|
{
|
||||||
if (params == null)
|
if (params == null)
|
||||||
|
|||||||
@ -41,6 +41,9 @@ public class SysMenu extends BaseEntity
|
|||||||
/** 是否为外链(0是 1否) */
|
/** 是否为外链(0是 1否) */
|
||||||
private String isFrame;
|
private String isFrame;
|
||||||
|
|
||||||
|
/** 是否缓存(0缓存 1不缓存) */
|
||||||
|
private String isCache;
|
||||||
|
|
||||||
/** 类型(M目录 C菜单 F按钮) */
|
/** 类型(M目录 C菜单 F按钮) */
|
||||||
private String menuType;
|
private String menuType;
|
||||||
|
|
||||||
@ -144,6 +147,16 @@ public class SysMenu extends BaseEntity
|
|||||||
this.isFrame = isFrame;
|
this.isFrame = isFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getIsCache()
|
||||||
|
{
|
||||||
|
return isCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsCache(String isCache)
|
||||||
|
{
|
||||||
|
this.isCache = isCache;
|
||||||
|
}
|
||||||
|
|
||||||
@NotBlank(message = "菜单类型不能为空")
|
@NotBlank(message = "菜单类型不能为空")
|
||||||
public String getMenuType()
|
public String getMenuType()
|
||||||
{
|
{
|
||||||
@ -216,6 +229,7 @@ public class SysMenu extends BaseEntity
|
|||||||
.append("path", getPath())
|
.append("path", getPath())
|
||||||
.append("component", getComponent())
|
.append("component", getComponent())
|
||||||
.append("isFrame", getIsFrame())
|
.append("isFrame", getIsFrame())
|
||||||
|
.append("IsCache", getIsCache())
|
||||||
.append("menuType", getMenuType())
|
.append("menuType", getMenuType())
|
||||||
.append("visible", getVisible())
|
.append("visible", getVisible())
|
||||||
.append("status ", getStatus())
|
.append("status ", getStatus())
|
||||||
|
|||||||
@ -37,6 +37,12 @@ public class SysRole extends BaseEntity
|
|||||||
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
|
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
|
||||||
private String dataScope;
|
private String dataScope;
|
||||||
|
|
||||||
|
/** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */
|
||||||
|
private boolean menuCheckStrictly;
|
||||||
|
|
||||||
|
/** 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) */
|
||||||
|
private boolean deptCheckStrictly;
|
||||||
|
|
||||||
/** 角色状态(0正常 1停用) */
|
/** 角色状态(0正常 1停用) */
|
||||||
@Excel(name = "角色状态", readConverterExp = "0=正常,1=停用")
|
@Excel(name = "角色状态", readConverterExp = "0=正常,1=停用")
|
||||||
private String status;
|
private String status;
|
||||||
@ -128,6 +134,26 @@ public class SysRole extends BaseEntity
|
|||||||
this.dataScope = dataScope;
|
this.dataScope = dataScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMenuCheckStrictly()
|
||||||
|
{
|
||||||
|
return menuCheckStrictly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMenuCheckStrictly(boolean menuCheckStrictly)
|
||||||
|
{
|
||||||
|
this.menuCheckStrictly = menuCheckStrictly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDeptCheckStrictly()
|
||||||
|
{
|
||||||
|
return deptCheckStrictly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeptCheckStrictly(boolean deptCheckStrictly)
|
||||||
|
{
|
||||||
|
this.deptCheckStrictly = deptCheckStrictly;
|
||||||
|
}
|
||||||
|
|
||||||
public String getStatus()
|
public String getStatus()
|
||||||
{
|
{
|
||||||
return status;
|
return status;
|
||||||
@ -186,6 +212,8 @@ public class SysRole extends BaseEntity
|
|||||||
.append("roleKey", getRoleKey())
|
.append("roleKey", getRoleKey())
|
||||||
.append("roleSort", getRoleSort())
|
.append("roleSort", getRoleSort())
|
||||||
.append("dataScope", getDataScope())
|
.append("dataScope", getDataScope())
|
||||||
|
.append("menuCheckStrictly", isMenuCheckStrictly())
|
||||||
|
.append("deptCheckStrictly", isDeptCheckStrictly())
|
||||||
.append("status", getStatus())
|
.append("status", getStatus())
|
||||||
.append("delFlag", getDelFlag())
|
.append("delFlag", getDelFlag())
|
||||||
.append("createBy", getCreateBy())
|
.append("createBy", getCreateBy())
|
||||||
|
|||||||
@ -68,12 +68,12 @@ public class SysUser extends BaseEntity
|
|||||||
/** 删除标志(0代表存在 2代表删除) */
|
/** 删除标志(0代表存在 2代表删除) */
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
/** 最后登陆IP */
|
/** 最后登录IP */
|
||||||
@Excel(name = "最后登陆IP", type = Type.EXPORT)
|
@Excel(name = "最后登录IP", type = Type.EXPORT)
|
||||||
private String loginIp;
|
private String loginIp;
|
||||||
|
|
||||||
/** 最后登陆时间 */
|
/** 最后登录时间 */
|
||||||
@Excel(name = "最后登陆时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
||||||
private Date loginDate;
|
private Date loginDate;
|
||||||
|
|
||||||
/** 部门对象 */
|
/** 部门对象 */
|
||||||
|
|||||||
@ -22,7 +22,7 @@ public class LoginUser implements UserDetails
|
|||||||
private String token;
|
private String token;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登陆时间
|
* 登录时间
|
||||||
*/
|
*/
|
||||||
private Long loginTime;
|
private Long loginTime;
|
||||||
|
|
||||||
|
|||||||
@ -18,8 +18,8 @@ public class PageDomain
|
|||||||
/** 排序列 */
|
/** 排序列 */
|
||||||
private String orderByColumn;
|
private String orderByColumn;
|
||||||
|
|
||||||
/** 排序的方向 "desc" 或者 "asc". */
|
/** 排序的方向desc或者asc */
|
||||||
private String isAsc;
|
private String isAsc = "asc";
|
||||||
|
|
||||||
public String getOrderBy()
|
public String getOrderBy()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
package com.ruoyi.common.core.redis;
|
package com.ruoyi.common.core.redis;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.BoundSetOperations;
|
||||||
import org.springframework.data.redis.core.HashOperations;
|
import org.springframework.data.redis.core.HashOperations;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.core.ValueOperations;
|
import org.springframework.data.redis.core.ValueOperations;
|
||||||
@ -136,10 +138,15 @@ public class RedisCache
|
|||||||
* @param dataSet 缓存的数据
|
* @param dataSet 缓存的数据
|
||||||
* @return 缓存数据的对象
|
* @return 缓存数据的对象
|
||||||
*/
|
*/
|
||||||
public <T> long setCacheSet(final String key, final Set<T> dataSet)
|
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
|
||||||
{
|
{
|
||||||
Long count = redisTemplate.opsForSet().add(key, dataSet);
|
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||||
return count == null ? 0 : count;
|
Iterator<T> it = dataSet.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
setOperation.add(it.next());
|
||||||
|
}
|
||||||
|
return setOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public class CharsetKit
|
|||||||
|
|
||||||
if (null == destCharset)
|
if (null == destCharset)
|
||||||
{
|
{
|
||||||
srcCharset = StandardCharsets.UTF_8;
|
destCharset = StandardCharsets.UTF_8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
|
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
|
||||||
|
|||||||
@ -7,10 +7,11 @@ import java.nio.charset.Charset;
|
|||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型转换器
|
* 类型转换器
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class Convert
|
public class Convert
|
||||||
@ -19,7 +20,7 @@ public class Convert
|
|||||||
* 转换为字符串<br>
|
* 转换为字符串<br>
|
||||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -41,7 +42,7 @@ public class Convert
|
|||||||
* 转换为字符串<br>
|
* 转换为字符串<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -54,7 +55,7 @@ public class Convert
|
|||||||
* 转换为字符<br>
|
* 转换为字符<br>
|
||||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -78,7 +79,7 @@ public class Convert
|
|||||||
* 转换为字符<br>
|
* 转换为字符<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -91,7 +92,7 @@ public class Convert
|
|||||||
* 转换为byte<br>
|
* 转换为byte<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -129,7 +130,7 @@ public class Convert
|
|||||||
* 转换为byte<br>
|
* 转换为byte<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -142,7 +143,7 @@ public class Convert
|
|||||||
* 转换为Short<br>
|
* 转换为Short<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -180,7 +181,7 @@ public class Convert
|
|||||||
* 转换为Short<br>
|
* 转换为Short<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -193,7 +194,7 @@ public class Convert
|
|||||||
* 转换为Number<br>
|
* 转换为Number<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -227,7 +228,7 @@ public class Convert
|
|||||||
* 转换为Number<br>
|
* 转换为Number<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -240,7 +241,7 @@ public class Convert
|
|||||||
* 转换为int<br>
|
* 转换为int<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -278,7 +279,7 @@ public class Convert
|
|||||||
* 转换为int<br>
|
* 转换为int<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -289,7 +290,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为Integer数组<br>
|
* 转换为Integer数组<br>
|
||||||
*
|
*
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -300,7 +301,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为Long数组<br>
|
* 转换为Long数组<br>
|
||||||
*
|
*
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -311,7 +312,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为Integer数组<br>
|
* 转换为Integer数组<br>
|
||||||
*
|
*
|
||||||
* @param split 分隔符
|
* @param split 分隔符
|
||||||
* @param split 被转换的值
|
* @param split 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -334,7 +335,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为Long数组<br>
|
* 转换为Long数组<br>
|
||||||
*
|
*
|
||||||
* @param split 分隔符
|
* @param split 分隔符
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -357,7 +358,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为String数组<br>
|
* 转换为String数组<br>
|
||||||
*
|
*
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -368,7 +369,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为String数组<br>
|
* 转换为String数组<br>
|
||||||
*
|
*
|
||||||
* @param split 分隔符
|
* @param split 分隔符
|
||||||
* @param split 被转换的值
|
* @param split 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -382,7 +383,7 @@ public class Convert
|
|||||||
* 转换为long<br>
|
* 转换为long<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -421,7 +422,7 @@ public class Convert
|
|||||||
* 转换为long<br>
|
* 转换为long<br>
|
||||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -434,7 +435,7 @@ public class Convert
|
|||||||
* 转换为double<br>
|
* 转换为double<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -473,7 +474,7 @@ public class Convert
|
|||||||
* 转换为double<br>
|
* 转换为double<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -486,7 +487,7 @@ public class Convert
|
|||||||
* 转换为Float<br>
|
* 转换为Float<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -524,7 +525,7 @@ public class Convert
|
|||||||
* 转换为Float<br>
|
* 转换为Float<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -537,7 +538,7 @@ public class Convert
|
|||||||
* 转换为boolean<br>
|
* 转换为boolean<br>
|
||||||
* String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
|
* String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -583,7 +584,7 @@ public class Convert
|
|||||||
* 转换为boolean<br>
|
* 转换为boolean<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -595,7 +596,7 @@ public class Convert
|
|||||||
/**
|
/**
|
||||||
* 转换为Enum对象<br>
|
* 转换为Enum对象<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
*
|
*
|
||||||
* @param clazz Enum的Class
|
* @param clazz Enum的Class
|
||||||
* @param value 值
|
* @param value 值
|
||||||
* @param defaultValue 默认值
|
* @param defaultValue 默认值
|
||||||
@ -631,7 +632,7 @@ public class Convert
|
|||||||
/**
|
/**
|
||||||
* 转换为Enum对象<br>
|
* 转换为Enum对象<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||||
*
|
*
|
||||||
* @param clazz Enum的Class
|
* @param clazz Enum的Class
|
||||||
* @param value 值
|
* @param value 值
|
||||||
* @return Enum
|
* @return Enum
|
||||||
@ -645,7 +646,7 @@ public class Convert
|
|||||||
* 转换为BigInteger<br>
|
* 转换为BigInteger<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -683,7 +684,7 @@ public class Convert
|
|||||||
* 转换为BigInteger<br>
|
* 转换为BigInteger<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -696,7 +697,7 @@ public class Convert
|
|||||||
* 转换为BigDecimal<br>
|
* 转换为BigDecimal<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -742,7 +743,7 @@ public class Convert
|
|||||||
* 转换为BigDecimal<br>
|
* 转换为BigDecimal<br>
|
||||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -754,7 +755,7 @@ public class Convert
|
|||||||
/**
|
/**
|
||||||
* 将对象转为字符串<br>
|
* 将对象转为字符串<br>
|
||||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||||
*
|
*
|
||||||
* @param obj 对象
|
* @param obj 对象
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
*/
|
*/
|
||||||
@ -766,7 +767,7 @@ public class Convert
|
|||||||
/**
|
/**
|
||||||
* 将对象转为字符串<br>
|
* 将对象转为字符串<br>
|
||||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||||
*
|
*
|
||||||
* @param obj 对象
|
* @param obj 对象
|
||||||
* @param charsetName 字符集
|
* @param charsetName 字符集
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
@ -779,7 +780,7 @@ public class Convert
|
|||||||
/**
|
/**
|
||||||
* 将对象转为字符串<br>
|
* 将对象转为字符串<br>
|
||||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||||
*
|
*
|
||||||
* @param obj 对象
|
* @param obj 对象
|
||||||
* @param charset 字符集
|
* @param charset 字符集
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
@ -795,9 +796,14 @@ public class Convert
|
|||||||
{
|
{
|
||||||
return (String) obj;
|
return (String) obj;
|
||||||
}
|
}
|
||||||
else if (obj instanceof byte[] || obj instanceof Byte[])
|
else if (obj instanceof byte[])
|
||||||
{
|
{
|
||||||
return str((Byte[]) obj, charset);
|
return str((byte[]) obj, charset);
|
||||||
|
}
|
||||||
|
else if (obj instanceof Byte[])
|
||||||
|
{
|
||||||
|
byte[] bytes = ArrayUtils.toPrimitive((Byte[]) obj);
|
||||||
|
return str(bytes, charset);
|
||||||
}
|
}
|
||||||
else if (obj instanceof ByteBuffer)
|
else if (obj instanceof ByteBuffer)
|
||||||
{
|
{
|
||||||
@ -808,7 +814,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 将byte数组转为字符串
|
* 将byte数组转为字符串
|
||||||
*
|
*
|
||||||
* @param bytes byte数组
|
* @param bytes byte数组
|
||||||
* @param charset 字符集
|
* @param charset 字符集
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
@ -820,7 +826,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 解码字节码
|
* 解码字节码
|
||||||
*
|
*
|
||||||
* @param data 字符串
|
* @param data 字符串
|
||||||
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
|
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
|
||||||
* @return 解码后的字符串
|
* @return 解码后的字符串
|
||||||
@ -841,7 +847,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 将编码的byteBuffer数据转换为字符串
|
* 将编码的byteBuffer数据转换为字符串
|
||||||
*
|
*
|
||||||
* @param data 数据
|
* @param data 数据
|
||||||
* @param charset 字符集,如果为空使用当前系统字符集
|
* @param charset 字符集,如果为空使用当前系统字符集
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
@ -858,7 +864,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 将编码的byteBuffer数据转换为字符串
|
* 将编码的byteBuffer数据转换为字符串
|
||||||
*
|
*
|
||||||
* @param data 数据
|
* @param data 数据
|
||||||
* @param charset 字符集,如果为空使用当前系统字符集
|
* @param charset 字符集,如果为空使用当前系统字符集
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
@ -875,7 +881,7 @@ public class Convert
|
|||||||
// ----------------------------------------------------------------------- 全角半角转换
|
// ----------------------------------------------------------------------- 全角半角转换
|
||||||
/**
|
/**
|
||||||
* 半角转全角
|
* 半角转全角
|
||||||
*
|
*
|
||||||
* @param input String.
|
* @param input String.
|
||||||
* @return 全角字符串.
|
* @return 全角字符串.
|
||||||
*/
|
*/
|
||||||
@ -886,7 +892,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 半角转全角
|
* 半角转全角
|
||||||
*
|
*
|
||||||
* @param input String
|
* @param input String
|
||||||
* @param notConvertSet 不替换的字符集合
|
* @param notConvertSet 不替换的字符集合
|
||||||
* @return 全角字符串.
|
* @return 全角字符串.
|
||||||
@ -917,7 +923,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 全角转半角
|
* 全角转半角
|
||||||
*
|
*
|
||||||
* @param input String.
|
* @param input String.
|
||||||
* @return 半角字符串
|
* @return 半角字符串
|
||||||
*/
|
*/
|
||||||
@ -928,7 +934,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 替换全角为半角
|
* 替换全角为半角
|
||||||
*
|
*
|
||||||
* @param text 文本
|
* @param text 文本
|
||||||
* @param notConvertSet 不替换的字符集合
|
* @param notConvertSet 不替换的字符集合
|
||||||
* @return 替换后的字符
|
* @return 替换后的字符
|
||||||
@ -960,7 +966,7 @@ public class Convert
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
|
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
|
||||||
*
|
*
|
||||||
* @param n 数字
|
* @param n 数字
|
||||||
* @return 中文大写数字
|
* @return 中文大写数字
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -68,4 +68,14 @@ public class InvalidExtensionException extends FileUploadException
|
|||||||
super(allowedExtension, extension, filename);
|
super(allowedExtension, extension, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class InvalidVideoExtensionException extends InvalidExtensionException
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename)
|
||||||
|
{
|
||||||
|
super(allowedExtension, extension, filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,8 +29,8 @@ public class RepeatableFilter implements Filter
|
|||||||
throws IOException, ServletException
|
throws IOException, ServletException
|
||||||
{
|
{
|
||||||
ServletRequest requestWrapper = null;
|
ServletRequest requestWrapper = null;
|
||||||
if (request instanceof HttpServletRequest && StringUtils.equalsAnyIgnoreCase(request.getContentType(),
|
if (request instanceof HttpServletRequest
|
||||||
MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE))
|
&& StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE))
|
||||||
{
|
{
|
||||||
requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
|
requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,18 +38,21 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper
|
|||||||
@Override
|
@Override
|
||||||
public ServletInputStream getInputStream() throws IOException
|
public ServletInputStream getInputStream() throws IOException
|
||||||
{
|
{
|
||||||
|
|
||||||
final ByteArrayInputStream bais = new ByteArrayInputStream(body);
|
final ByteArrayInputStream bais = new ByteArrayInputStream(body);
|
||||||
|
|
||||||
return new ServletInputStream()
|
return new ServletInputStream()
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read() throws IOException
|
public int read() throws IOException
|
||||||
{
|
{
|
||||||
return bais.read();
|
return bais.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int available() throws IOException
|
||||||
|
{
|
||||||
|
return body.length;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished()
|
public boolean isFinished()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -99,7 +99,6 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
|
|||||||
public boolean isJsonRequest()
|
public boolean isJsonRequest()
|
||||||
{
|
{
|
||||||
String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
|
String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
|
||||||
return MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(header)
|
return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
|
||||||
|| MediaType.APPLICATION_JSON_UTF8_VALUE.equalsIgnoreCase(header);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,114 +1,114 @@
|
|||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 精确的浮点数运算
|
* 精确的浮点数运算
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class Arith
|
public class Arith
|
||||||
{
|
{
|
||||||
|
|
||||||
/** 默认除法运算精度 */
|
/** 默认除法运算精度 */
|
||||||
private static final int DEF_DIV_SCALE = 10;
|
private static final int DEF_DIV_SCALE = 10;
|
||||||
|
|
||||||
/** 这个类不能实例化 */
|
/** 这个类不能实例化 */
|
||||||
private Arith()
|
private Arith()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供精确的加法运算。
|
* 提供精确的加法运算。
|
||||||
* @param v1 被加数
|
* @param v1 被加数
|
||||||
* @param v2 加数
|
* @param v2 加数
|
||||||
* @return 两个参数的和
|
* @return 两个参数的和
|
||||||
*/
|
*/
|
||||||
public static double add(double v1, double v2)
|
public static double add(double v1, double v2)
|
||||||
{
|
{
|
||||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||||
return b1.add(b2).doubleValue();
|
return b1.add(b2).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供精确的减法运算。
|
* 提供精确的减法运算。
|
||||||
* @param v1 被减数
|
* @param v1 被减数
|
||||||
* @param v2 减数
|
* @param v2 减数
|
||||||
* @return 两个参数的差
|
* @return 两个参数的差
|
||||||
*/
|
*/
|
||||||
public static double sub(double v1, double v2)
|
public static double sub(double v1, double v2)
|
||||||
{
|
{
|
||||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||||
return b1.subtract(b2).doubleValue();
|
return b1.subtract(b2).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供精确的乘法运算。
|
* 提供精确的乘法运算。
|
||||||
* @param v1 被乘数
|
* @param v1 被乘数
|
||||||
* @param v2 乘数
|
* @param v2 乘数
|
||||||
* @return 两个参数的积
|
* @return 两个参数的积
|
||||||
*/
|
*/
|
||||||
public static double mul(double v1, double v2)
|
public static double mul(double v1, double v2)
|
||||||
{
|
{
|
||||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||||
return b1.multiply(b2).doubleValue();
|
return b1.multiply(b2).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
|
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
|
||||||
* 小数点以后10位,以后的数字四舍五入。
|
* 小数点以后10位,以后的数字四舍五入。
|
||||||
* @param v1 被除数
|
* @param v1 被除数
|
||||||
* @param v2 除数
|
* @param v2 除数
|
||||||
* @return 两个参数的商
|
* @return 两个参数的商
|
||||||
*/
|
*/
|
||||||
public static double div(double v1, double v2)
|
public static double div(double v1, double v2)
|
||||||
{
|
{
|
||||||
return div(v1, v2, DEF_DIV_SCALE);
|
return div(v1, v2, DEF_DIV_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指
|
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指
|
||||||
* 定精度,以后的数字四舍五入。
|
* 定精度,以后的数字四舍五入。
|
||||||
* @param v1 被除数
|
* @param v1 被除数
|
||||||
* @param v2 除数
|
* @param v2 除数
|
||||||
* @param scale 表示表示需要精确到小数点以后几位。
|
* @param scale 表示表示需要精确到小数点以后几位。
|
||||||
* @return 两个参数的商
|
* @return 两个参数的商
|
||||||
*/
|
*/
|
||||||
public static double div(double v1, double v2, int scale)
|
public static double div(double v1, double v2, int scale)
|
||||||
{
|
{
|
||||||
if (scale < 0)
|
if (scale < 0)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"The scale must be a positive integer or zero");
|
"The scale must be a positive integer or zero");
|
||||||
}
|
}
|
||||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||||
if (b1.compareTo(BigDecimal.ZERO) == 0)
|
if (b1.compareTo(BigDecimal.ZERO) == 0)
|
||||||
{
|
{
|
||||||
return BigDecimal.ZERO.doubleValue();
|
return BigDecimal.ZERO.doubleValue();
|
||||||
}
|
}
|
||||||
return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
|
return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供精确的小数位四舍五入处理。
|
* 提供精确的小数位四舍五入处理。
|
||||||
* @param v 需要四舍五入的数字
|
* @param v 需要四舍五入的数字
|
||||||
* @param scale 小数点后保留几位
|
* @param scale 小数点后保留几位
|
||||||
* @return 四舍五入后的结果
|
* @return 四舍五入后的结果
|
||||||
*/
|
*/
|
||||||
public static double round(double v, int scale)
|
public static double round(double v, int scale)
|
||||||
{
|
{
|
||||||
if (scale < 0)
|
if (scale < 0)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"The scale must be a positive integer or zero");
|
"The scale must be a positive integer or zero");
|
||||||
}
|
}
|
||||||
BigDecimal b = new BigDecimal(Double.toString(v));
|
BigDecimal b = new BigDecimal(Double.toString(v));
|
||||||
BigDecimal one = new BigDecimal("1");
|
BigDecimal one = BigDecimal.ONE;
|
||||||
return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();
|
return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ public class ExceptionUtil
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRootErrorMseeage(Exception e)
|
public static String getRootErrorMessage(Exception e)
|
||||||
{
|
{
|
||||||
Throwable root = ExceptionUtils.getRootCause(e);
|
Throwable root = ExceptionUtils.getRootCause(e);
|
||||||
root = (root == null ? e : root);
|
root = (root == null ? e : root);
|
||||||
|
|||||||
@ -312,7 +312,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下划线转驼峰命名
|
* 驼峰转下划线命名
|
||||||
*/
|
*/
|
||||||
public static String toUnderScoreCase(String str)
|
public static String toUnderScoreCase(String str)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -0,0 +1,76 @@
|
|||||||
|
package com.ruoyi.common.utils.file;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件类型工具类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class FileTypeUtils
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取文件类型
|
||||||
|
* <p>
|
||||||
|
* 例如: ruoyi.txt, 返回: txt
|
||||||
|
*
|
||||||
|
* @param file 文件名
|
||||||
|
* @return 后缀(不含".")
|
||||||
|
*/
|
||||||
|
public static String getFileType(File file)
|
||||||
|
{
|
||||||
|
if (null == file)
|
||||||
|
{
|
||||||
|
return StringUtils.EMPTY;
|
||||||
|
}
|
||||||
|
return getFileType(file.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件类型
|
||||||
|
* <p>
|
||||||
|
* 例如: ruoyi.txt, 返回: txt
|
||||||
|
*
|
||||||
|
* @param fileName 文件名
|
||||||
|
* @return 后缀(不含".")
|
||||||
|
*/
|
||||||
|
public static String getFileType(String fileName)
|
||||||
|
{
|
||||||
|
int separatorIndex = fileName.lastIndexOf(".");
|
||||||
|
if (separatorIndex < 0)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return fileName.substring(separatorIndex + 1).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件类型
|
||||||
|
*
|
||||||
|
* @param photoByte 文件字节码
|
||||||
|
* @return 后缀(不含".")
|
||||||
|
*/
|
||||||
|
public static String getFileExtendName(byte[] photoByte)
|
||||||
|
{
|
||||||
|
String strFileExtendName = "JPG";
|
||||||
|
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
|
||||||
|
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
|
||||||
|
{
|
||||||
|
strFileExtendName = "GIF";
|
||||||
|
}
|
||||||
|
else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70))
|
||||||
|
{
|
||||||
|
strFileExtendName = "JPG";
|
||||||
|
}
|
||||||
|
else if ((photoByte[0] == 66) && (photoByte[1] == 77))
|
||||||
|
{
|
||||||
|
strFileExtendName = "BMP";
|
||||||
|
}
|
||||||
|
else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71))
|
||||||
|
{
|
||||||
|
strFileExtendName = "PNG";
|
||||||
|
}
|
||||||
|
return strFileExtendName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -131,13 +131,12 @@ public class FileUploadUtils
|
|||||||
{
|
{
|
||||||
File desc = new File(uploadDir + File.separator + fileName);
|
File desc = new File(uploadDir + File.separator + fileName);
|
||||||
|
|
||||||
if (!desc.getParentFile().exists())
|
|
||||||
{
|
|
||||||
desc.getParentFile().mkdirs();
|
|
||||||
}
|
|
||||||
if (!desc.exists())
|
if (!desc.exists())
|
||||||
{
|
{
|
||||||
desc.createNewFile();
|
if (!desc.getParentFile().exists())
|
||||||
|
{
|
||||||
|
desc.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
@ -186,6 +185,11 @@ public class FileUploadUtils
|
|||||||
throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
|
throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
|
||||||
fileName);
|
fileName);
|
||||||
}
|
}
|
||||||
|
else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION)
|
||||||
|
{
|
||||||
|
throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension,
|
||||||
|
fileName);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new InvalidExtensionException(allowedExtension, extension, fileName);
|
throw new InvalidExtensionException(allowedExtension, extension, fileName);
|
||||||
|
|||||||
@ -7,7 +7,11 @@ import java.io.IOException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件处理工具类
|
* 文件处理工具类
|
||||||
@ -104,6 +108,30 @@ public class FileUtils extends org.apache.commons.io.FileUtils
|
|||||||
return filename.matches(FILENAME_PATTERN);
|
return filename.matches(FILENAME_PATTERN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查文件是否可下载
|
||||||
|
*
|
||||||
|
* @param resource 需要下载的文件
|
||||||
|
* @return true 正常 false 非法
|
||||||
|
*/
|
||||||
|
public static boolean checkAllowDownload(String resource)
|
||||||
|
{
|
||||||
|
// 禁止目录上跳级别
|
||||||
|
if (StringUtils.contains(resource, ".."))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查允许下载的文件规则
|
||||||
|
if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不在允许下载的文件规则
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载文件名重新编码
|
* 下载文件名重新编码
|
||||||
*
|
*
|
||||||
@ -111,8 +139,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils
|
|||||||
* @param fileName 文件名
|
* @param fileName 文件名
|
||||||
* @return 编码后的文件名
|
* @return 编码后的文件名
|
||||||
*/
|
*/
|
||||||
public static String setFileDownloadHeader(HttpServletRequest request, String fileName)
|
public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException
|
||||||
throws UnsupportedEncodingException
|
|
||||||
{
|
{
|
||||||
final String agent = request.getHeader("USER-AGENT");
|
final String agent = request.getHeader("USER-AGENT");
|
||||||
String filename = fileName;
|
String filename = fileName;
|
||||||
@ -139,4 +166,38 @@ public class FileUtils extends org.apache.commons.io.FileUtils
|
|||||||
}
|
}
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载文件名重新编码
|
||||||
|
*
|
||||||
|
* @param response 响应对象
|
||||||
|
* @param realFileName 真实文件名
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException
|
||||||
|
{
|
||||||
|
String percentEncodedFileName = percentEncode(realFileName);
|
||||||
|
|
||||||
|
StringBuilder contentDispositionValue = new StringBuilder();
|
||||||
|
contentDispositionValue.append("attachment; filename=")
|
||||||
|
.append(percentEncodedFileName)
|
||||||
|
.append(";")
|
||||||
|
.append("filename*=")
|
||||||
|
.append("utf-8''")
|
||||||
|
.append(percentEncodedFileName);
|
||||||
|
|
||||||
|
response.setHeader("Content-disposition", contentDispositionValue.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 百分号编码工具方法
|
||||||
|
*
|
||||||
|
* @param s 需要百分号编码的字符串
|
||||||
|
* @return 百分号编码后的字符串
|
||||||
|
*/
|
||||||
|
public static String percentEncode(String s) throws UnsupportedEncodingException
|
||||||
|
{
|
||||||
|
String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString());
|
||||||
|
return encode.replaceAll("\\+", "%20");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,100 @@
|
|||||||
|
package com.ruoyi.common.utils.file;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import org.apache.poi.util.IOUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
|
import com.ruoyi.common.constant.Constants;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片处理工具类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class ImageUtils
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ImageUtils.class);
|
||||||
|
|
||||||
|
public static byte[] getImage(String imagePath)
|
||||||
|
{
|
||||||
|
InputStream is = getFile(imagePath);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return IOUtils.toByteArray(is);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.error("图片加载异常 {}", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtils.closeQuietly(is);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InputStream getFile(String imagePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte[] result = readFile(imagePath);
|
||||||
|
result = Arrays.copyOf(result, result.length);
|
||||||
|
return new ByteArrayInputStream(result);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.error("获取图片异常 {}", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取文件为字节数据
|
||||||
|
*
|
||||||
|
* @param key 地址
|
||||||
|
* @return 字节数据
|
||||||
|
*/
|
||||||
|
public static byte[] readFile(String url)
|
||||||
|
{
|
||||||
|
InputStream in = null;
|
||||||
|
ByteArrayOutputStream baos = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (url.startsWith("http"))
|
||||||
|
{
|
||||||
|
// 网络地址
|
||||||
|
URL urlObj = new URL(url);
|
||||||
|
URLConnection urlConnection = urlObj.openConnection();
|
||||||
|
urlConnection.setConnectTimeout(30 * 1000);
|
||||||
|
urlConnection.setReadTimeout(60 * 1000);
|
||||||
|
urlConnection.setDoInput(true);
|
||||||
|
in = urlConnection.getInputStream();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 本机地址
|
||||||
|
String localPath = RuoYiConfig.getProfile();
|
||||||
|
String downloadPath = localPath + StringUtils.substringAfter(url, Constants.RESOURCE_PREFIX);
|
||||||
|
in = new FileInputStream(downloadPath);
|
||||||
|
}
|
||||||
|
return IOUtils.toByteArray(in);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.error("获取文件路径异常 {}", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtils.closeQuietly(baos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -24,6 +24,8 @@ public class MimeTypeUtils
|
|||||||
public static final String[] MEDIA_EXTENSION = { "swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg",
|
public static final String[] MEDIA_EXTENSION = { "swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg",
|
||||||
"asf", "rm", "rmvb" };
|
"asf", "rm", "rmvb" };
|
||||||
|
|
||||||
|
public static final String[] VIDEO_EXTENSION = { "mp4", "avi", "rmvb" };
|
||||||
|
|
||||||
public static final String[] DEFAULT_ALLOWED_EXTENSION = {
|
public static final String[] DEFAULT_ALLOWED_EXTENSION = {
|
||||||
// 图片
|
// 图片
|
||||||
"bmp", "gif", "jpg", "jpeg", "png",
|
"bmp", "gif", "jpg", "jpeg", "png",
|
||||||
@ -31,6 +33,8 @@ public class MimeTypeUtils
|
|||||||
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt",
|
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt",
|
||||||
// 压缩文件
|
// 压缩文件
|
||||||
"rar", "zip", "gz", "bz2",
|
"rar", "zip", "gz", "bz2",
|
||||||
|
// 视频格式
|
||||||
|
"mp4", "avi", "rmvb",
|
||||||
// pdf
|
// pdf
|
||||||
"pdf" };
|
"pdf" };
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ public class EscapeUtil
|
|||||||
|
|
||||||
// special HTML characters
|
// special HTML characters
|
||||||
TEXT['\''] = "'".toCharArray(); // 单引号
|
TEXT['\''] = "'".toCharArray(); // 单引号
|
||||||
TEXT['"'] = """.toCharArray(); // 单引号
|
TEXT['"'] = """.toCharArray(); // 双引号
|
||||||
TEXT['&'] = "&".toCharArray(); // &符
|
TEXT['&'] = "&".toCharArray(); // &符
|
||||||
TEXT['<'] = "<".toCharArray(); // 小于号
|
TEXT['<'] = "<".toCharArray(); // 小于号
|
||||||
TEXT['>'] = ">".toCharArray(); // 大于号
|
TEXT['>'] = ">".toCharArray(); // 大于号
|
||||||
|
|||||||
@ -6,8 +6,8 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -15,17 +15,19 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
||||||
import org.apache.poi.ss.usermodel.BorderStyle;
|
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.CellStyle;
|
import org.apache.poi.ss.usermodel.CellStyle;
|
||||||
import org.apache.poi.ss.usermodel.CellType;
|
import org.apache.poi.ss.usermodel.CellType;
|
||||||
|
import org.apache.poi.ss.usermodel.ClientAnchor;
|
||||||
import org.apache.poi.ss.usermodel.DataValidation;
|
import org.apache.poi.ss.usermodel.DataValidation;
|
||||||
import org.apache.poi.ss.usermodel.DataValidationConstraint;
|
import org.apache.poi.ss.usermodel.DataValidationConstraint;
|
||||||
import org.apache.poi.ss.usermodel.DataValidationHelper;
|
import org.apache.poi.ss.usermodel.DataValidationHelper;
|
||||||
import org.apache.poi.ss.usermodel.DateUtil;
|
import org.apache.poi.ss.usermodel.DateUtil;
|
||||||
|
import org.apache.poi.ss.usermodel.Drawing;
|
||||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||||
import org.apache.poi.ss.usermodel.Font;
|
import org.apache.poi.ss.usermodel.Font;
|
||||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||||
@ -37,6 +39,7 @@ import org.apache.poi.ss.usermodel.Workbook;
|
|||||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
|
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -51,6 +54,8 @@ import com.ruoyi.common.exception.CustomException;
|
|||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.DictUtils;
|
import com.ruoyi.common.utils.DictUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.file.FileTypeUtils;
|
||||||
|
import com.ruoyi.common.utils.file.ImageUtils;
|
||||||
import com.ruoyi.common.utils.reflect.ReflectUtils;
|
import com.ruoyi.common.utils.reflect.ReflectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,6 +107,21 @@ public class ExcelUtil<T>
|
|||||||
*/
|
*/
|
||||||
private List<Object[]> fields;
|
private List<Object[]> fields;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最大高度
|
||||||
|
*/
|
||||||
|
private short maxHeight;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计列表
|
||||||
|
*/
|
||||||
|
private Map<Integer, Double> statistics = new HashMap<Integer, Double>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字格式
|
||||||
|
*/
|
||||||
|
private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("######0.00");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实体对象
|
* 实体对象
|
||||||
*/
|
*/
|
||||||
@ -209,6 +229,10 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
// 从第2行开始取数据,默认第一行是表头.
|
// 从第2行开始取数据,默认第一行是表头.
|
||||||
Row row = sheet.getRow(i);
|
Row row = sheet.getRow(i);
|
||||||
|
if(row == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
T entity = null;
|
T entity = null;
|
||||||
for (Map.Entry<Integer, Field> entry : fieldsMap.entrySet())
|
for (Map.Entry<Integer, Field> entry : fieldsMap.entrySet())
|
||||||
{
|
{
|
||||||
@ -229,22 +253,30 @@ public class ExcelUtil<T>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
val = Convert.toStr(val);
|
String dateFormat = field.getAnnotation(Excel.class).dateFormat();
|
||||||
|
if (StringUtils.isNotEmpty(dateFormat))
|
||||||
|
{
|
||||||
|
val = DateUtils.parseDateToStr(dateFormat, (Date) val);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
val = Convert.toStr(val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType))
|
else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val)))
|
||||||
{
|
{
|
||||||
val = Convert.toInt(val);
|
val = Convert.toInt(val);
|
||||||
}
|
}
|
||||||
else if ((Long.TYPE == fieldType) || (Long.class == fieldType))
|
else if (Long.TYPE == fieldType || Long.class == fieldType)
|
||||||
{
|
{
|
||||||
val = Convert.toLong(val);
|
val = Convert.toLong(val);
|
||||||
}
|
}
|
||||||
else if ((Double.TYPE == fieldType) || (Double.class == fieldType))
|
else if (Double.TYPE == fieldType || Double.class == fieldType)
|
||||||
{
|
{
|
||||||
val = Convert.toDouble(val);
|
val = Convert.toDouble(val);
|
||||||
}
|
}
|
||||||
else if ((Float.TYPE == fieldType) || (Float.class == fieldType))
|
else if (Float.TYPE == fieldType || Float.class == fieldType)
|
||||||
{
|
{
|
||||||
val = Convert.toFloat(val);
|
val = Convert.toFloat(val);
|
||||||
}
|
}
|
||||||
@ -263,6 +295,10 @@ public class ExcelUtil<T>
|
|||||||
val = DateUtil.getJavaDate((Double) val);
|
val = DateUtil.getJavaDate((Double) val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (Boolean.TYPE == fieldType || Boolean.class == fieldType)
|
||||||
|
{
|
||||||
|
val = Convert.toBool(val, false);
|
||||||
|
}
|
||||||
if (StringUtils.isNotNull(fieldType))
|
if (StringUtils.isNotNull(fieldType))
|
||||||
{
|
{
|
||||||
Excel attr = field.getAnnotation(Excel.class);
|
Excel attr = field.getAnnotation(Excel.class);
|
||||||
@ -341,6 +377,7 @@ public class ExcelUtil<T>
|
|||||||
if (Type.EXPORT.equals(type))
|
if (Type.EXPORT.equals(type))
|
||||||
{
|
{
|
||||||
fillExcelData(index, row);
|
fillExcelData(index, row);
|
||||||
|
addStatisticsRow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String filename = encodingFilename(sheetName);
|
String filename = encodingFilename(sheetName);
|
||||||
@ -447,6 +484,30 @@ public class ExcelUtil<T>
|
|||||||
headerFont.setColor(IndexedColors.WHITE.getIndex());
|
headerFont.setColor(IndexedColors.WHITE.getIndex());
|
||||||
style.setFont(headerFont);
|
style.setFont(headerFont);
|
||||||
styles.put("header", style);
|
styles.put("header", style);
|
||||||
|
|
||||||
|
style = wb.createCellStyle();
|
||||||
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
Font totalFont = wb.createFont();
|
||||||
|
totalFont.setFontName("Arial");
|
||||||
|
totalFont.setFontHeightInPoints((short) 10);
|
||||||
|
style.setFont(totalFont);
|
||||||
|
styles.put("total", style);
|
||||||
|
|
||||||
|
style = wb.createCellStyle();
|
||||||
|
style.cloneStyleFrom(styles.get("data"));
|
||||||
|
style.setAlignment(HorizontalAlignment.LEFT);
|
||||||
|
styles.put("data1", style);
|
||||||
|
|
||||||
|
style = wb.createCellStyle();
|
||||||
|
style.cloneStyleFrom(styles.get("data"));
|
||||||
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
styles.put("data2", style);
|
||||||
|
|
||||||
|
style = wb.createCellStyle();
|
||||||
|
style.cloneStyleFrom(styles.get("data"));
|
||||||
|
style.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
styles.put("data3", style);
|
||||||
|
|
||||||
return styles;
|
return styles;
|
||||||
}
|
}
|
||||||
@ -476,14 +537,56 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
if (ColumnType.STRING == attr.cellType())
|
if (ColumnType.STRING == attr.cellType())
|
||||||
{
|
{
|
||||||
cell.setCellType(CellType.STRING);
|
|
||||||
cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
|
cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
|
||||||
}
|
}
|
||||||
else if (ColumnType.NUMERIC == attr.cellType())
|
else if (ColumnType.NUMERIC == attr.cellType())
|
||||||
{
|
{
|
||||||
cell.setCellType(CellType.NUMERIC);
|
if (StringUtils.isNotNull(value))
|
||||||
cell.setCellValue(Integer.parseInt(value + ""));
|
{
|
||||||
|
cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (ColumnType.IMAGE == attr.cellType())
|
||||||
|
{
|
||||||
|
ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 1),
|
||||||
|
cell.getRow().getRowNum() + 1);
|
||||||
|
String imagePath = Convert.toStr(value);
|
||||||
|
if (StringUtils.isNotEmpty(imagePath))
|
||||||
|
{
|
||||||
|
byte[] data = ImageUtils.getImage(imagePath);
|
||||||
|
getDrawingPatriarch(cell.getSheet()).createPicture(anchor,
|
||||||
|
cell.getSheet().getWorkbook().addPicture(data, getImageType(data)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取画布
|
||||||
|
*/
|
||||||
|
public static Drawing<?> getDrawingPatriarch(Sheet sheet)
|
||||||
|
{
|
||||||
|
if (sheet.getDrawingPatriarch() == null)
|
||||||
|
{
|
||||||
|
sheet.createDrawingPatriarch();
|
||||||
|
}
|
||||||
|
return sheet.getDrawingPatriarch();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取图片类型,设置图片插入类型
|
||||||
|
*/
|
||||||
|
public int getImageType(byte[] value)
|
||||||
|
{
|
||||||
|
String type = FileTypeUtils.getFileExtendName(value);
|
||||||
|
if ("JPG".equalsIgnoreCase(type))
|
||||||
|
{
|
||||||
|
return Workbook.PICTURE_TYPE_JPEG;
|
||||||
|
}
|
||||||
|
else if ("PNG".equalsIgnoreCase(type))
|
||||||
|
{
|
||||||
|
return Workbook.PICTURE_TYPE_PNG;
|
||||||
|
}
|
||||||
|
return Workbook.PICTURE_TYPE_JPEG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -499,7 +602,6 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
// 设置列宽
|
// 设置列宽
|
||||||
sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
|
sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
|
||||||
row.setHeight((short) (attr.height() * 20));
|
|
||||||
}
|
}
|
||||||
// 如果设置了提示信息则鼠标放上去提示.
|
// 如果设置了提示信息则鼠标放上去提示.
|
||||||
if (StringUtils.isNotEmpty(attr.prompt()))
|
if (StringUtils.isNotEmpty(attr.prompt()))
|
||||||
@ -524,13 +626,14 @@ public class ExcelUtil<T>
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 设置行高
|
// 设置行高
|
||||||
row.setHeight((short) (attr.height() * 20));
|
row.setHeight(maxHeight);
|
||||||
// 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列.
|
// 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列.
|
||||||
if (attr.isExport())
|
if (attr.isExport())
|
||||||
{
|
{
|
||||||
// 创建cell
|
// 创建cell
|
||||||
cell = row.createCell(column);
|
cell = row.createCell(column);
|
||||||
cell.setCellStyle(styles.get("data"));
|
int align = attr.align().value();
|
||||||
|
cell.setCellStyle(styles.get("data" + (align >= 1 && align <= 3 ? align : "")));
|
||||||
|
|
||||||
// 用于读取对象中的属性
|
// 用于读取对象中的属性
|
||||||
Object value = getTargetValue(vo, field, attr);
|
Object value = getTargetValue(vo, field, attr);
|
||||||
@ -546,15 +649,20 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator));
|
cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator));
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(dictType))
|
else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value))
|
||||||
{
|
{
|
||||||
cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator));
|
cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator));
|
||||||
}
|
}
|
||||||
|
else if (value instanceof BigDecimal && -1 != attr.scale())
|
||||||
|
{
|
||||||
|
cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 设置列类型
|
// 设置列类型
|
||||||
setCellVo(value, attr, cell);
|
setCellVo(value, attr, cell);
|
||||||
}
|
}
|
||||||
|
addStatisticsData(column, Convert.toStr(value), attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -694,7 +802,7 @@ public class ExcelUtil<T>
|
|||||||
}
|
}
|
||||||
return StringUtils.stripEnd(propertyString.toString(), separator);
|
return StringUtils.stripEnd(propertyString.toString(), separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析字典值
|
* 解析字典值
|
||||||
*
|
*
|
||||||
@ -720,6 +828,53 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
return DictUtils.getDictValue(dictType, dictLabel, separator);
|
return DictUtils.getDictValue(dictType, dictLabel, separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合计统计信息
|
||||||
|
*/
|
||||||
|
private void addStatisticsData(Integer index, String text, Excel entity)
|
||||||
|
{
|
||||||
|
if (entity != null && entity.isStatistics())
|
||||||
|
{
|
||||||
|
Double temp = 0D;
|
||||||
|
if (!statistics.containsKey(index))
|
||||||
|
{
|
||||||
|
statistics.put(index, temp);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
temp = Double.valueOf(text);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
statistics.put(index, statistics.get(index) + temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建统计行
|
||||||
|
*/
|
||||||
|
public void addStatisticsRow()
|
||||||
|
{
|
||||||
|
if (statistics.size() > 0)
|
||||||
|
{
|
||||||
|
Cell cell = null;
|
||||||
|
Row row = sheet.createRow(sheet.getLastRowNum() + 1);
|
||||||
|
Set<Integer> keys = statistics.keySet();
|
||||||
|
cell = row.createCell(0);
|
||||||
|
cell.setCellStyle(styles.get("total"));
|
||||||
|
cell.setCellValue("合计");
|
||||||
|
|
||||||
|
for (Integer key : keys)
|
||||||
|
{
|
||||||
|
cell = row.createCell(key);
|
||||||
|
cell.setCellStyle(styles.get("total"));
|
||||||
|
cell.setCellValue(DOUBLE_FORMAT.format(statistics.get(key)));
|
||||||
|
}
|
||||||
|
statistics.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码文件名
|
* 编码文件名
|
||||||
@ -787,12 +942,12 @@ public class ExcelUtil<T>
|
|||||||
*/
|
*/
|
||||||
private Object getValue(Object o, String name) throws Exception
|
private Object getValue(Object o, String name) throws Exception
|
||||||
{
|
{
|
||||||
if (StringUtils.isNotEmpty(name))
|
if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name))
|
||||||
{
|
{
|
||||||
Class<?> clazz = o.getClass();
|
Class<?> clazz = o.getClass();
|
||||||
String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1);
|
Field field = clazz.getDeclaredField(name);
|
||||||
Method method = clazz.getMethod(methodName);
|
field.setAccessible(true);
|
||||||
o = method.invoke(o);
|
o = field.get(o);
|
||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
@ -826,6 +981,21 @@ public class ExcelUtil<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList());
|
this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList());
|
||||||
|
this.maxHeight = getRowHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据注解获取最大行高
|
||||||
|
*/
|
||||||
|
public short getRowHeight()
|
||||||
|
{
|
||||||
|
double maxHeight = 0;
|
||||||
|
for (Object[] os : this.fields)
|
||||||
|
{
|
||||||
|
Excel excel = (Excel) os[1];
|
||||||
|
maxHeight = maxHeight > excel.height() ? maxHeight : excel.height();
|
||||||
|
}
|
||||||
|
return (short) (maxHeight * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -887,27 +1057,34 @@ public class ExcelUtil<T>
|
|||||||
Cell cell = row.getCell(column);
|
Cell cell = row.getCell(column);
|
||||||
if (StringUtils.isNotNull(cell))
|
if (StringUtils.isNotNull(cell))
|
||||||
{
|
{
|
||||||
if (cell.getCellTypeEnum() == CellType.NUMERIC || cell.getCellTypeEnum() == CellType.FORMULA)
|
if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA)
|
||||||
{
|
{
|
||||||
val = cell.getNumericCellValue();
|
val = cell.getNumericCellValue();
|
||||||
if (HSSFDateUtil.isCellDateFormatted(cell))
|
if (DateUtil.isCellDateFormatted(cell))
|
||||||
{
|
{
|
||||||
val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换
|
val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
val = new BigDecimal(val.toString()); // 浮点格式处理
|
if ((Double) val % 1 != 0)
|
||||||
|
{
|
||||||
|
val = new BigDecimal(val.toString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
val = new DecimalFormat("0").format(val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cell.getCellTypeEnum() == CellType.STRING)
|
else if (cell.getCellType() == CellType.STRING)
|
||||||
{
|
{
|
||||||
val = cell.getStringCellValue();
|
val = cell.getStringCellValue();
|
||||||
}
|
}
|
||||||
else if (cell.getCellTypeEnum() == CellType.BOOLEAN)
|
else if (cell.getCellType() == CellType.BOOLEAN)
|
||||||
{
|
{
|
||||||
val = cell.getBooleanCellValue();
|
val = cell.getBooleanCellValue();
|
||||||
}
|
}
|
||||||
else if (cell.getCellTypeEnum() == CellType.ERROR)
|
else if (cell.getCellType() == CellType.ERROR)
|
||||||
{
|
{
|
||||||
val = cell.getErrorCellValue();
|
val = cell.getErrorCellValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -204,6 +204,10 @@ public class ReflectUtils
|
|||||||
args[i] = DateUtil.getJavaDate((Double) args[i]);
|
args[i] = DateUtil.getJavaDate((Double) args[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (cs[i] == boolean.class || cs[i] == Boolean.class)
|
||||||
|
{
|
||||||
|
args[i] = Convert.toBool(args[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (E) method.invoke(obj, args);
|
return (E) method.invoke(obj, args);
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
package com.ruoyi.common.utils.uuid;
|
package com.ruoyi.common.utils.uuid;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.uuid.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID生成器工具类
|
* ID生成器工具类
|
||||||
*
|
*
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.1.0</version>
|
<version>3.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -53,16 +53,6 @@
|
|||||||
<artifactId>oshi-core</artifactId>
|
<artifactId>oshi-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.java.dev.jna</groupId>
|
|
||||||
<artifactId>jna</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.java.dev.jna</groupId>
|
|
||||||
<artifactId>jna-platform</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 系统模块-->
|
<!-- 系统模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
|
|||||||
@ -79,11 +79,11 @@ public class DataScopeAspect
|
|||||||
}
|
}
|
||||||
// 获取当前的用户
|
// 获取当前的用户
|
||||||
LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
|
LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
|
||||||
SysUser currentUser = loginUser.getUser();
|
if (StringUtils.isNotNull(loginUser))
|
||||||
if (currentUser != null)
|
|
||||||
{
|
{
|
||||||
|
SysUser currentUser = loginUser.getUser();
|
||||||
// 如果是超级管理员,则不过滤数据
|
// 如果是超级管理员,则不过滤数据
|
||||||
if (!currentUser.isAdmin())
|
if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin())
|
||||||
{
|
{
|
||||||
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
|
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
|
||||||
controllerDataScope.userAlias());
|
controllerDataScope.userAlias());
|
||||||
@ -142,8 +142,12 @@ public class DataScopeAspect
|
|||||||
|
|
||||||
if (StringUtils.isNotBlank(sqlString.toString()))
|
if (StringUtils.isNotBlank(sqlString.toString()))
|
||||||
{
|
{
|
||||||
BaseEntity baseEntity = (BaseEntity) joinPoint.getArgs()[0];
|
Object params = joinPoint.getArgs()[0];
|
||||||
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
|
if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
|
||||||
|
{
|
||||||
|
BaseEntity baseEntity = (BaseEntity) params;
|
||||||
|
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.framework.aspectj;
|
package com.ruoyi.framework.aspectj;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -14,6 +16,7 @@ import org.aspectj.lang.reflect.MethodSignature;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.servlet.HandlerMapping;
|
import org.springframework.web.servlet.HandlerMapping;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
@ -194,7 +197,7 @@ public class LogAspect
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < paramsArray.length; i++)
|
for (int i = 0; i < paramsArray.length; i++)
|
||||||
{
|
{
|
||||||
if (!isFilterObject(paramsArray[i]))
|
if (StringUtils.isNotNull(paramsArray[i]) && !isFilterObject(paramsArray[i]))
|
||||||
{
|
{
|
||||||
Object jsonObj = JSON.toJSON(paramsArray[i]);
|
Object jsonObj = JSON.toJSON(paramsArray[i]);
|
||||||
params += jsonObj.toString() + " ";
|
params += jsonObj.toString() + " ";
|
||||||
@ -210,8 +213,32 @@ public class LogAspect
|
|||||||
* @param o 对象信息。
|
* @param o 对象信息。
|
||||||
* @return 如果是需要过滤的对象,则返回true;否则返回false。
|
* @return 如果是需要过滤的对象,则返回true;否则返回false。
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public boolean isFilterObject(final Object o)
|
public boolean isFilterObject(final Object o)
|
||||||
{
|
{
|
||||||
return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse;
|
Class<?> clazz = o.getClass();
|
||||||
|
if (clazz.isArray())
|
||||||
|
{
|
||||||
|
return clazz.getComponentType().isAssignableFrom(MultipartFile.class);
|
||||||
|
}
|
||||||
|
else if (Collection.class.isAssignableFrom(clazz))
|
||||||
|
{
|
||||||
|
Collection collection = (Collection) o;
|
||||||
|
for (Iterator iter = collection.iterator(); iter.hasNext();)
|
||||||
|
{
|
||||||
|
return iter.next() instanceof MultipartFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Map.class.isAssignableFrom(clazz))
|
||||||
|
{
|
||||||
|
Map map = (Map) o;
|
||||||
|
for (Iterator iter = map.entrySet().iterator(); iter.hasNext();)
|
||||||
|
{
|
||||||
|
Map.Entry entry = (Map.Entry) iter.next();
|
||||||
|
return entry.getValue() instanceof MultipartFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse
|
||||||
|
|| o instanceof BindingResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.ruoyi.framework.config;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
@ -21,6 +22,7 @@ import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
|||||||
import org.springframework.core.type.classreading.MetadataReader;
|
import org.springframework.core.type.classreading.MetadataReader;
|
||||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mybatis支持*匹配扫描包
|
* Mybatis支持*匹配扫描包
|
||||||
@ -89,6 +91,28 @@ public class MyBatisConfig
|
|||||||
return typeAliasesPackage;
|
return typeAliasesPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Resource[] resolveMapperLocations(String[] mapperLocations)
|
||||||
|
{
|
||||||
|
ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
|
||||||
|
List<Resource> resources = new ArrayList<Resource>();
|
||||||
|
if (mapperLocations != null)
|
||||||
|
{
|
||||||
|
for (String mapperLocation : mapperLocations)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Resource[] mappers = resourceResolver.getResources(mapperLocation);
|
||||||
|
resources.addAll(Arrays.asList(mappers));
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resources.toArray(new Resource[resources.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
|
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
|
||||||
{
|
{
|
||||||
@ -101,7 +125,7 @@ public class MyBatisConfig
|
|||||||
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
||||||
sessionFactory.setDataSource(dataSource);
|
sessionFactory.setDataSource(dataSource);
|
||||||
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
|
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
|
||||||
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(mapperLocations));
|
sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
|
||||||
sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
|
sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
|
||||||
return sessionFactory.getObject();
|
return sessionFactory.getObject();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,8 +8,10 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* redis配置
|
* redis配置
|
||||||
@ -31,12 +33,17 @@ public class RedisConfig extends CachingConfigurerSupport
|
|||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||||
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||||
serializer.setObjectMapper(mapper);
|
serializer.setObjectMapper(mapper);
|
||||||
|
|
||||||
template.setValueSerializer(serializer);
|
|
||||||
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
||||||
template.setKeySerializer(new StringRedisSerializer());
|
template.setKeySerializer(new StringRedisSerializer());
|
||||||
|
template.setValueSerializer(serializer);
|
||||||
|
|
||||||
|
// Hash的key也采用StringRedisSerializer的序列化方式
|
||||||
|
template.setHashKeySerializer(new StringRedisSerializer());
|
||||||
|
template.setHashValueSerializer(serializer);
|
||||||
|
|
||||||
template.afterPropertiesSet();
|
template.afterPropertiesSet();
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,7 +88,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||||||
protected void configure(HttpSecurity httpSecurity) throws Exception
|
protected void configure(HttpSecurity httpSecurity) throws Exception
|
||||||
{
|
{
|
||||||
httpSecurity
|
httpSecurity
|
||||||
// CRSF禁用,因为不使用session
|
// CSRF禁用,因为不使用session
|
||||||
.csrf().disable()
|
.csrf().disable()
|
||||||
// 认证失败处理类
|
// 认证失败处理类
|
||||||
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
|
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
|
||||||
|
|||||||
@ -78,9 +78,9 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 唯一标识(指定key + 消息头)
|
// 唯一标识(指定key + 消息头)
|
||||||
String cache_repeat_key = Constants.REPEAT_SUBMIT_KEY + submitKey;
|
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + submitKey;
|
||||||
|
|
||||||
Object sessionObj = redisCache.getCacheObject(cache_repeat_key);
|
Object sessionObj = redisCache.getCacheObject(cacheRepeatKey);
|
||||||
if (sessionObj != null)
|
if (sessionObj != null)
|
||||||
{
|
{
|
||||||
Map<String, Object> sessionMap = (Map<String, Object>) sessionObj;
|
Map<String, Object> sessionMap = (Map<String, Object>) sessionObj;
|
||||||
@ -95,7 +95,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
|
|||||||
}
|
}
|
||||||
Map<String, Object> cacheMap = new HashMap<String, Object>();
|
Map<String, Object> cacheMap = new HashMap<String, Object>();
|
||||||
cacheMap.put(url, nowDataMap);
|
cacheMap.put(url, nowDataMap);
|
||||||
redisCache.setCacheObject(cache_repeat_key, cacheMap, intervalTime, TimeUnit.SECONDS);
|
redisCache.setCacheObject(cacheRepeatKey, cacheMap, intervalTime, TimeUnit.SECONDS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ public class AsyncFactory
|
|||||||
private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user");
|
private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录登陆信息
|
* 记录登录信息
|
||||||
*
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param status 状态
|
* @param status 状态
|
||||||
|
|||||||
@ -189,7 +189,7 @@ public class Server
|
|||||||
private void setSysFiles(OperatingSystem os)
|
private void setSysFiles(OperatingSystem os)
|
||||||
{
|
{
|
||||||
FileSystem fileSystem = os.getFileSystem();
|
FileSystem fileSystem = os.getFileSystem();
|
||||||
OSFileStore[] fsArray = fileSystem.getFileStores();
|
List<OSFileStore> fsArray = fileSystem.getFileStores();
|
||||||
for (OSFileStore fs : fsArray)
|
for (OSFileStore fs : fsArray)
|
||||||
{
|
{
|
||||||
long free = fs.getUsableSpace();
|
long free = fs.getUsableSpace();
|
||||||
|
|||||||
@ -109,7 +109,7 @@ public class PermissionService
|
|||||||
for (SysRole sysRole : loginUser.getUser().getRoles())
|
for (SysRole sysRole : loginUser.getUser().getRoles())
|
||||||
{
|
{
|
||||||
String roleKey = sysRole.getRoleKey();
|
String roleKey = sysRole.getRoleKey();
|
||||||
if (SUPER_ADMIN.contains(roleKey) || roleKey.contains(StringUtils.trim(role)))
|
if (SUPER_ADMIN.equals(roleKey) || roleKey.equals(StringUtils.trim(role)))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,15 +8,20 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
|
|||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
import com.ruoyi.common.exception.CustomException;
|
import com.ruoyi.common.exception.CustomException;
|
||||||
import com.ruoyi.common.exception.user.CaptchaException;
|
import com.ruoyi.common.exception.user.CaptchaException;
|
||||||
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
||||||
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.MessageUtils;
|
import com.ruoyi.common.utils.MessageUtils;
|
||||||
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
|
import com.ruoyi.common.utils.ip.IpUtils;
|
||||||
import com.ruoyi.framework.manager.AsyncManager;
|
import com.ruoyi.framework.manager.AsyncManager;
|
||||||
import com.ruoyi.framework.manager.factory.AsyncFactory;
|
import com.ruoyi.framework.manager.factory.AsyncFactory;
|
||||||
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录校验方法
|
* 登录校验方法
|
||||||
@ -34,6 +39,9 @@ public class SysLoginService
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService userService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录验证
|
* 登录验证
|
||||||
@ -82,7 +90,18 @@ public class SysLoginService
|
|||||||
}
|
}
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
||||||
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||||
|
recordLoginInfo(loginUser.getUser());
|
||||||
// 生成token
|
// 生成token
|
||||||
return tokenService.createToken(loginUser);
|
return tokenService.createToken(loginUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录登录信息
|
||||||
|
*/
|
||||||
|
public void recordLoginInfo(SysUser user)
|
||||||
|
{
|
||||||
|
user.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
||||||
|
user.setLoginDate(DateUtils.getNowDate());
|
||||||
|
userService.updateUserProfile(user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.1.0</version>
|
<version>3.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -23,6 +23,12 @@
|
|||||||
<artifactId>velocity</artifactId>
|
<artifactId>velocity</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- collections工具类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-collections</groupId>
|
||||||
|
<artifactId>commons-collections</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 通用工具-->
|
<!-- 通用工具-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
|
|||||||
@ -63,10 +63,12 @@ public class GenController extends BaseController
|
|||||||
public AjaxResult getInfo(@PathVariable Long talbleId)
|
public AjaxResult getInfo(@PathVariable Long talbleId)
|
||||||
{
|
{
|
||||||
GenTable table = genTableService.selectGenTableById(talbleId);
|
GenTable table = genTableService.selectGenTableById(talbleId);
|
||||||
|
List<GenTable> tables = genTableService.selectGenTableAll();
|
||||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
|
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
map.put("info", table);
|
map.put("info", table);
|
||||||
map.put("rows", list);
|
map.put("rows", list);
|
||||||
|
map.put("tables", tables);
|
||||||
return AjaxResult.success(map);
|
return AjaxResult.success(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +101,7 @@ public class GenController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 导入表结构(保存)
|
* 导入表结构(保存)
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('tool:gen:list')")
|
@PreAuthorize("@ss.hasPermi('tool:gen:import')")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
||||||
@PostMapping("/importTable")
|
@PostMapping("/importTable")
|
||||||
public AjaxResult importTableSave(String tables)
|
public AjaxResult importTableSave(String tables)
|
||||||
@ -165,12 +167,24 @@ public class GenController extends BaseController
|
|||||||
@PreAuthorize("@ss.hasPermi('tool:gen:code')")
|
@PreAuthorize("@ss.hasPermi('tool:gen:code')")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
||||||
@GetMapping("/genCode/{tableName}")
|
@GetMapping("/genCode/{tableName}")
|
||||||
public AjaxResult genCode(HttpServletResponse response, @PathVariable("tableName") String tableName)
|
public AjaxResult genCode(@PathVariable("tableName") String tableName)
|
||||||
{
|
{
|
||||||
genTableService.generatorCode(tableName);
|
genTableService.generatorCode(tableName);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步数据库
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('tool:gen:edit')")
|
||||||
|
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
||||||
|
@GetMapping("/synchDb/{tableName}")
|
||||||
|
public AjaxResult synchDb(@PathVariable("tableName") String tableName)
|
||||||
|
{
|
||||||
|
genTableService.synchDb(tableName);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量生成代码
|
* 批量生成代码
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -28,11 +28,17 @@ public class GenTable extends BaseEntity
|
|||||||
@NotBlank(message = "表描述不能为空")
|
@NotBlank(message = "表描述不能为空")
|
||||||
private String tableComment;
|
private String tableComment;
|
||||||
|
|
||||||
|
/** 关联父表的表名 */
|
||||||
|
private String subTableName;
|
||||||
|
|
||||||
|
/** 本表关联父表的外键名 */
|
||||||
|
private String subTableFkName;
|
||||||
|
|
||||||
/** 实体类名称(首字母大写) */
|
/** 实体类名称(首字母大写) */
|
||||||
@NotBlank(message = "实体类名称不能为空")
|
@NotBlank(message = "实体类名称不能为空")
|
||||||
private String className;
|
private String className;
|
||||||
|
|
||||||
/** 使用的模板(crud单表操作 tree树表操作) */
|
/** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
|
||||||
private String tplCategory;
|
private String tplCategory;
|
||||||
|
|
||||||
/** 生成包路径 */
|
/** 生成包路径 */
|
||||||
@ -64,6 +70,9 @@ public class GenTable extends BaseEntity
|
|||||||
/** 主键信息 */
|
/** 主键信息 */
|
||||||
private GenTableColumn pkColumn;
|
private GenTableColumn pkColumn;
|
||||||
|
|
||||||
|
/** 子表信息 */
|
||||||
|
private GenTable subTable;
|
||||||
|
|
||||||
/** 表列信息 */
|
/** 表列信息 */
|
||||||
@Valid
|
@Valid
|
||||||
private List<GenTableColumn> columns;
|
private List<GenTableColumn> columns;
|
||||||
@ -116,6 +125,26 @@ public class GenTable extends BaseEntity
|
|||||||
this.tableComment = tableComment;
|
this.tableComment = tableComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSubTableName()
|
||||||
|
{
|
||||||
|
return subTableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubTableName(String subTableName)
|
||||||
|
{
|
||||||
|
this.subTableName = subTableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubTableFkName()
|
||||||
|
{
|
||||||
|
return subTableFkName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubTableFkName(String subTableFkName)
|
||||||
|
{
|
||||||
|
this.subTableFkName = subTableFkName;
|
||||||
|
}
|
||||||
|
|
||||||
public String getClassName()
|
public String getClassName()
|
||||||
{
|
{
|
||||||
return className;
|
return className;
|
||||||
@ -216,6 +245,16 @@ public class GenTable extends BaseEntity
|
|||||||
this.pkColumn = pkColumn;
|
this.pkColumn = pkColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GenTable getSubTable()
|
||||||
|
{
|
||||||
|
return subTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubTable(GenTable subTable)
|
||||||
|
{
|
||||||
|
this.subTable = subTable;
|
||||||
|
}
|
||||||
|
|
||||||
public List<GenTableColumn> getColumns()
|
public List<GenTableColumn> getColumns()
|
||||||
{
|
{
|
||||||
return columns;
|
return columns;
|
||||||
@ -286,6 +325,16 @@ public class GenTable extends BaseEntity
|
|||||||
this.parentMenuName = parentMenuName;
|
this.parentMenuName = parentMenuName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSub()
|
||||||
|
{
|
||||||
|
return isSub(this.tplCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSub(String tplCategory)
|
||||||
|
{
|
||||||
|
return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isTree()
|
public boolean isTree()
|
||||||
{
|
{
|
||||||
return isTree(this.tplCategory);
|
return isTree(this.tplCategory);
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public class GenTableColumn extends BaseEntity
|
|||||||
/** 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) */
|
/** 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) */
|
||||||
private String queryType;
|
private String queryType;
|
||||||
|
|
||||||
/** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件) */
|
/** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件) */
|
||||||
private String htmlType;
|
private String htmlType;
|
||||||
|
|
||||||
/** 字典类型 */
|
/** 字典类型 */
|
||||||
@ -138,6 +138,11 @@ public class GenTableColumn extends BaseEntity
|
|||||||
return javaField;
|
return javaField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCapJavaField()
|
||||||
|
{
|
||||||
|
return StringUtils.capitalize(javaField);
|
||||||
|
}
|
||||||
|
|
||||||
public void setIsPk(String isPk)
|
public void setIsPk(String isPk)
|
||||||
{
|
{
|
||||||
this.isPk = isPk;
|
this.isPk = isPk;
|
||||||
@ -340,7 +345,7 @@ public class GenTableColumn extends BaseEntity
|
|||||||
public static boolean isUsableColumn(String javaField)
|
public static boolean isUsableColumn(String javaField)
|
||||||
{
|
{
|
||||||
// isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单
|
// isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单
|
||||||
return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum");
|
return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String readConverterExp()
|
public String readConverterExp()
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public interface GenTableColumnMapper
|
|||||||
* @return 列信息
|
* @return 列信息
|
||||||
*/
|
*/
|
||||||
public List<GenTableColumn> selectDbTableColumnsByName(String tableName);
|
public List<GenTableColumn> selectDbTableColumnsByName(String tableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询业务字段列表
|
* 查询业务字段列表
|
||||||
*
|
*
|
||||||
@ -42,6 +42,14 @@ public interface GenTableColumnMapper
|
|||||||
*/
|
*/
|
||||||
public int updateGenTableColumn(GenTableColumn genTableColumn);
|
public int updateGenTableColumn(GenTableColumn genTableColumn);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除业务字段
|
||||||
|
*
|
||||||
|
* @param genTableColumns 列数据
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteGenTableColumns(List<GenTableColumn> genTableColumns);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除业务字段
|
* 批量删除业务字段
|
||||||
*
|
*
|
||||||
|
|||||||
@ -34,6 +34,13 @@ public interface GenTableMapper
|
|||||||
*/
|
*/
|
||||||
public List<GenTable> selectDbTableListByNames(String[] tableNames);
|
public List<GenTable> selectDbTableListByNames(String[] tableNames);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有表信息
|
||||||
|
*
|
||||||
|
* @return 表信息集合
|
||||||
|
*/
|
||||||
|
public List<GenTable> selectGenTableAll();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询表ID业务信息
|
* 查询表ID业务信息
|
||||||
*
|
*
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import java.io.StringWriter;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
@ -101,6 +102,17 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
return genTableMapper.selectDbTableListByNames(tableNames);
|
return genTableMapper.selectDbTableListByNames(tableNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有表信息
|
||||||
|
*
|
||||||
|
* @return 表信息集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<GenTable> selectGenTableAll()
|
||||||
|
{
|
||||||
|
return genTableMapper.selectGenTableAll();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改业务
|
* 修改业务
|
||||||
*
|
*
|
||||||
@ -184,9 +196,10 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
Map<String, String> dataMap = new LinkedHashMap<>();
|
Map<String, String> dataMap = new LinkedHashMap<>();
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
GenTable table = genTableMapper.selectGenTableById(tableId);
|
GenTable table = genTableMapper.selectGenTableById(tableId);
|
||||||
// 查询列信息
|
// 设置主子表信息
|
||||||
List<GenTableColumn> columns = table.getColumns();
|
setSubTable(table);
|
||||||
setPkColumn(table, columns);
|
// 设置主键列信息
|
||||||
|
setPkColumn(table);
|
||||||
VelocityInitializer.initVelocity();
|
VelocityInitializer.initVelocity();
|
||||||
|
|
||||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||||
@ -224,16 +237,16 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
* 生成代码(自定义路径)
|
* 生成代码(自定义路径)
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
* @return 数据
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void generatorCode(String tableName)
|
public void generatorCode(String tableName)
|
||||||
{
|
{
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
// 查询列信息
|
// 设置主子表信息
|
||||||
List<GenTableColumn> columns = table.getColumns();
|
setSubTable(table);
|
||||||
setPkColumn(table, columns);
|
// 设置主键列信息
|
||||||
|
setPkColumn(table);
|
||||||
|
|
||||||
VelocityInitializer.initVelocity();
|
VelocityInitializer.initVelocity();
|
||||||
|
|
||||||
@ -262,6 +275,41 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步数据库
|
||||||
|
*
|
||||||
|
* @param tableName 表名称
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void synchDb(String tableName)
|
||||||
|
{
|
||||||
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
|
List<GenTableColumn> tableColumns = table.getColumns();
|
||||||
|
List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
||||||
|
|
||||||
|
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
||||||
|
if (StringUtils.isEmpty(dbTableColumns))
|
||||||
|
{
|
||||||
|
throw new CustomException("同步数据失败,原表结构不存在");
|
||||||
|
}
|
||||||
|
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
||||||
|
|
||||||
|
dbTableColumns.forEach(column -> {
|
||||||
|
if (!tableColumnNames.contains(column.getColumnName()))
|
||||||
|
{
|
||||||
|
GenUtils.initColumnField(column, table);
|
||||||
|
genTableColumnMapper.insertGenTableColumn(column);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
|
||||||
|
if (StringUtils.isNotEmpty(delColumns))
|
||||||
|
{
|
||||||
|
genTableColumnMapper.deleteGenTableColumns(delColumns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量生成代码(下载方式)
|
* 批量生成代码(下载方式)
|
||||||
*
|
*
|
||||||
@ -288,9 +336,10 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
{
|
{
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
// 查询列信息
|
// 设置主子表信息
|
||||||
List<GenTableColumn> columns = table.getColumns();
|
setSubTable(table);
|
||||||
setPkColumn(table, columns);
|
// 设置主键列信息
|
||||||
|
setPkColumn(table);
|
||||||
|
|
||||||
VelocityInitializer.initVelocity();
|
VelocityInitializer.initVelocity();
|
||||||
|
|
||||||
@ -344,6 +393,17 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
{
|
{
|
||||||
throw new CustomException("树名称字段不能为空");
|
throw new CustomException("树名称字段不能为空");
|
||||||
}
|
}
|
||||||
|
else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory()))
|
||||||
|
{
|
||||||
|
if (StringUtils.isEmpty(genTable.getSubTableName()))
|
||||||
|
{
|
||||||
|
throw new CustomException("关联子表的表名不能为空");
|
||||||
|
}
|
||||||
|
else if (StringUtils.isEmpty(genTable.getSubTableFkName()))
|
||||||
|
{
|
||||||
|
throw new CustomException("子表关联的外键名不能为空");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,11 +411,10 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
* 设置主键列信息
|
* 设置主键列信息
|
||||||
*
|
*
|
||||||
* @param table 业务表信息
|
* @param table 业务表信息
|
||||||
* @param columns 业务字段列表
|
|
||||||
*/
|
*/
|
||||||
public void setPkColumn(GenTable table, List<GenTableColumn> columns)
|
public void setPkColumn(GenTable table)
|
||||||
{
|
{
|
||||||
for (GenTableColumn column : columns)
|
for (GenTableColumn column : table.getColumns())
|
||||||
{
|
{
|
||||||
if (column.isPk())
|
if (column.isPk())
|
||||||
{
|
{
|
||||||
@ -365,7 +424,36 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
}
|
}
|
||||||
if (StringUtils.isNull(table.getPkColumn()))
|
if (StringUtils.isNull(table.getPkColumn()))
|
||||||
{
|
{
|
||||||
table.setPkColumn(columns.get(0));
|
table.setPkColumn(table.getColumns().get(0));
|
||||||
|
}
|
||||||
|
if (GenConstants.TPL_SUB.equals(table.getTplCategory()))
|
||||||
|
{
|
||||||
|
for (GenTableColumn column : table.getSubTable().getColumns())
|
||||||
|
{
|
||||||
|
if (column.isPk())
|
||||||
|
{
|
||||||
|
table.getSubTable().setPkColumn(column);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (StringUtils.isNull(table.getSubTable().getPkColumn()))
|
||||||
|
{
|
||||||
|
table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置主子表信息
|
||||||
|
*
|
||||||
|
* @param table 业务表信息
|
||||||
|
*/
|
||||||
|
public void setSubTable(GenTable table)
|
||||||
|
{
|
||||||
|
String subTableName = table.getSubTableName();
|
||||||
|
if (StringUtils.isNotEmpty(subTableName))
|
||||||
|
{
|
||||||
|
table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,13 @@ public interface IGenTableService
|
|||||||
*/
|
*/
|
||||||
public List<GenTable> selectDbTableListByNames(String[] tableNames);
|
public List<GenTable> selectDbTableListByNames(String[] tableNames);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有表信息
|
||||||
|
*
|
||||||
|
* @return 表信息集合
|
||||||
|
*/
|
||||||
|
public List<GenTable> selectGenTableAll();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询业务信息
|
* 查询业务信息
|
||||||
*
|
*
|
||||||
@ -90,6 +97,13 @@ public interface IGenTableService
|
|||||||
*/
|
*/
|
||||||
public void generatorCode(String tableName);
|
public void generatorCode(String tableName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步数据库
|
||||||
|
*
|
||||||
|
* @param tableName 表名称
|
||||||
|
*/
|
||||||
|
public void synchDb(String tableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量生成代码(下载方式)
|
* 批量生成代码(下载方式)
|
||||||
*
|
*
|
||||||
|
|||||||
@ -40,13 +40,14 @@ public class GenUtils
|
|||||||
column.setCreateBy(table.getCreateBy());
|
column.setCreateBy(table.getCreateBy());
|
||||||
// 设置java字段名
|
// 设置java字段名
|
||||||
column.setJavaField(StringUtils.toCamelCase(columnName));
|
column.setJavaField(StringUtils.toCamelCase(columnName));
|
||||||
|
// 设置默认类型
|
||||||
|
column.setJavaType(GenConstants.TYPE_STRING);
|
||||||
|
|
||||||
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType))
|
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType))
|
||||||
{
|
{
|
||||||
column.setJavaType(GenConstants.TYPE_STRING);
|
|
||||||
// 字符串长度超过500设置为文本域
|
// 字符串长度超过500设置为文本域
|
||||||
Integer columnLength = getColumnLength(column.getColumnType());
|
Integer columnLength = getColumnLength(column.getColumnType());
|
||||||
String htmlType = columnLength >= 500 ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
|
String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
|
||||||
column.setHtmlType(htmlType);
|
column.setHtmlType(htmlType);
|
||||||
}
|
}
|
||||||
else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType))
|
else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType))
|
||||||
@ -111,6 +112,21 @@ public class GenUtils
|
|||||||
{
|
{
|
||||||
column.setHtmlType(GenConstants.HTML_SELECT);
|
column.setHtmlType(GenConstants.HTML_SELECT);
|
||||||
}
|
}
|
||||||
|
// 图片字段设置图片上传控件
|
||||||
|
else if (StringUtils.endsWithIgnoreCase(columnName, "image"))
|
||||||
|
{
|
||||||
|
column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD);
|
||||||
|
}
|
||||||
|
// 文件字段设置文件上传控件
|
||||||
|
else if (StringUtils.endsWithIgnoreCase(columnName, "file"))
|
||||||
|
{
|
||||||
|
column.setHtmlType(GenConstants.HTML_FILE_UPLOAD);
|
||||||
|
}
|
||||||
|
// 内容字段设置富文本控件
|
||||||
|
else if (StringUtils.endsWithIgnoreCase(columnName, "content"))
|
||||||
|
{
|
||||||
|
column.setHtmlType(GenConstants.HTML_EDITOR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import com.ruoyi.common.constant.Constants;
|
|||||||
/**
|
/**
|
||||||
* VelocityEngine工厂
|
* VelocityEngine工厂
|
||||||
*
|
*
|
||||||
* @author RuoYi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class VelocityInitializer
|
public class VelocityInitializer
|
||||||
{
|
{
|
||||||
@ -22,7 +22,7 @@ public class VelocityInitializer
|
|||||||
// 加载classpath目录下的vm文件
|
// 加载classpath目录下的vm文件
|
||||||
p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
||||||
// 定义字符集
|
// 定义字符集
|
||||||
p.setProperty(Velocity.ENCODING_DEFAULT, Constants.UTF8);
|
p.setProperty(Velocity.INPUT_ENCODING, Constants.UTF8);
|
||||||
p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8);
|
p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8);
|
||||||
// 初始化Velocity引擎,指定配置Properties
|
// 初始化Velocity引擎,指定配置Properties
|
||||||
Velocity.init(p);
|
Velocity.init(p);
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public class VelocityUtils
|
|||||||
velocityContext.put("author", genTable.getFunctionAuthor());
|
velocityContext.put("author", genTable.getFunctionAuthor());
|
||||||
velocityContext.put("datetime", DateUtils.getDate());
|
velocityContext.put("datetime", DateUtils.getDate());
|
||||||
velocityContext.put("pkColumn", genTable.getPkColumn());
|
velocityContext.put("pkColumn", genTable.getPkColumn());
|
||||||
velocityContext.put("importList", getImportList(genTable.getColumns()));
|
velocityContext.put("importList", getImportList(genTable));
|
||||||
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
|
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
|
||||||
velocityContext.put("columns", genTable.getColumns());
|
velocityContext.put("columns", genTable.getColumns());
|
||||||
velocityContext.put("table", genTable);
|
velocityContext.put("table", genTable);
|
||||||
@ -63,6 +63,10 @@ public class VelocityUtils
|
|||||||
{
|
{
|
||||||
setTreeVelocityContext(velocityContext, genTable);
|
setTreeVelocityContext(velocityContext, genTable);
|
||||||
}
|
}
|
||||||
|
if (GenConstants.TPL_SUB.equals(tplCategory))
|
||||||
|
{
|
||||||
|
setSubVelocityContext(velocityContext, genTable);
|
||||||
|
}
|
||||||
return velocityContext;
|
return velocityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +100,24 @@ public class VelocityUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setSubVelocityContext(VelocityContext context, GenTable genTable)
|
||||||
|
{
|
||||||
|
GenTable subTable = genTable.getSubTable();
|
||||||
|
String subTableName = genTable.getSubTableName();
|
||||||
|
String subTableFkName = genTable.getSubTableFkName();
|
||||||
|
String subClassName = genTable.getSubTable().getClassName();
|
||||||
|
String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName);
|
||||||
|
|
||||||
|
context.put("subTable", subTable);
|
||||||
|
context.put("subTableName", subTableName);
|
||||||
|
context.put("subTableFkName", subTableFkName);
|
||||||
|
context.put("subTableFkClassName", subTableFkClassName);
|
||||||
|
context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName));
|
||||||
|
context.put("subClassName", subClassName);
|
||||||
|
context.put("subclassName", StringUtils.uncapitalize(subClassName));
|
||||||
|
context.put("subImportList", getImportList(genTable.getSubTable()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取模板信息
|
* 获取模板信息
|
||||||
*
|
*
|
||||||
@ -120,6 +142,11 @@ public class VelocityUtils
|
|||||||
{
|
{
|
||||||
templates.add("vm/vue/index-tree.vue.vm");
|
templates.add("vm/vue/index-tree.vue.vm");
|
||||||
}
|
}
|
||||||
|
else if (GenConstants.TPL_SUB.equals(tplCategory))
|
||||||
|
{
|
||||||
|
templates.add("vm/vue/index.vue.vm");
|
||||||
|
templates.add("vm/java/sub-domain.java.vm");
|
||||||
|
}
|
||||||
return templates;
|
return templates;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,6 +174,10 @@ public class VelocityUtils
|
|||||||
{
|
{
|
||||||
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
|
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
|
||||||
}
|
}
|
||||||
|
if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
|
||||||
|
{
|
||||||
|
fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
|
||||||
|
}
|
||||||
else if (template.contains("mapper.java.vm"))
|
else if (template.contains("mapper.java.vm"))
|
||||||
{
|
{
|
||||||
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
|
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
|
||||||
@ -201,13 +232,19 @@ public class VelocityUtils
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据列类型获取导入包
|
* 根据列类型获取导入包
|
||||||
*
|
*
|
||||||
* @param columns 列集合
|
* @param genTable 业务表对象
|
||||||
* @return 返回需要导入的包列表
|
* @return 返回需要导入的包列表
|
||||||
*/
|
*/
|
||||||
public static HashSet<String> getImportList(List<GenTableColumn> columns)
|
public static HashSet<String> getImportList(GenTable genTable)
|
||||||
{
|
{
|
||||||
|
List<GenTableColumn> columns = genTable.getColumns();
|
||||||
|
GenTable subGenTable = genTable.getSubTable();
|
||||||
HashSet<String> importList = new HashSet<String>();
|
HashSet<String> importList = new HashSet<String>();
|
||||||
|
if (StringUtils.isNotNull(subGenTable))
|
||||||
|
{
|
||||||
|
importList.add("java.util.List");
|
||||||
|
}
|
||||||
for (GenTableColumn column : columns)
|
for (GenTableColumn column : columns)
|
||||||
{
|
{
|
||||||
if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType()))
|
if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType()))
|
||||||
|
|||||||
@ -117,4 +117,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteGenTableColumns">
|
||||||
|
delete from gen_table_column where column_id in
|
||||||
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||||||
|
#{item.columnId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@ -5,24 +5,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<mapper namespace="com.ruoyi.generator.mapper.GenTableMapper">
|
<mapper namespace="com.ruoyi.generator.mapper.GenTableMapper">
|
||||||
|
|
||||||
<resultMap type="GenTable" id="GenTableResult">
|
<resultMap type="GenTable" id="GenTableResult">
|
||||||
<id property="tableId" column="table_id" />
|
<id property="tableId" column="table_id" />
|
||||||
<result property="tableName" column="table_name" />
|
<result property="tableName" column="table_name" />
|
||||||
<result property="tableComment" column="table_comment" />
|
<result property="tableComment" column="table_comment" />
|
||||||
<result property="className" column="class_name" />
|
<result property="subTableName" column="sub_table_name" />
|
||||||
<result property="tplCategory" column="tpl_category" />
|
<result property="subTableFkName" column="sub_table_fk_name" />
|
||||||
<result property="packageName" column="package_name" />
|
<result property="className" column="class_name" />
|
||||||
<result property="moduleName" column="module_name" />
|
<result property="tplCategory" column="tpl_category" />
|
||||||
<result property="businessName" column="business_name" />
|
<result property="packageName" column="package_name" />
|
||||||
<result property="functionName" column="function_name" />
|
<result property="moduleName" column="module_name" />
|
||||||
<result property="functionAuthor" column="function_author" />
|
<result property="businessName" column="business_name" />
|
||||||
<result property="genType" column="gen_type" />
|
<result property="functionName" column="function_name" />
|
||||||
<result property="genPath" column="gen_path" />
|
<result property="functionAuthor" column="function_author" />
|
||||||
<result property="options" column="options" />
|
<result property="genType" column="gen_type" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="genPath" column="gen_path" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="options" column="options" />
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="createTime" column="create_time" />
|
||||||
<result property="remark" column="remark" />
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGenTableVo">
|
<sql id="selectGenTableVo">
|
||||||
select table_id, table_name, table_comment, 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
|
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>
|
</sql>
|
||||||
|
|
||||||
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
||||||
@ -64,11 +66,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="tableComment != null and tableComment != ''">
|
<if test="tableComment != null and tableComment != ''">
|
||||||
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
||||||
</if>
|
</if>
|
||||||
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
AND date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
AND date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
@ -84,11 +86,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="tableComment != null and tableComment != ''">
|
<if test="tableComment != null and tableComment != ''">
|
||||||
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
||||||
</if>
|
</if>
|
||||||
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
AND date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
AND date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -108,7 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||||
FROM gen_table t
|
FROM gen_table t
|
||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
@ -116,13 +118,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||||
FROM gen_table t
|
FROM gen_table t
|
||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
where t.table_name = #{tableName} order by c.sort
|
where t.table_name = #{tableName} order by c.sort
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
||||||
|
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
|
||||||
|
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||||
|
FROM gen_table t
|
||||||
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
|
order by c.sort
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
|
<insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
|
||||||
insert into gen_table (
|
insert into gen_table (
|
||||||
<if test="tableName != null">table_name,</if>
|
<if test="tableName != null">table_name,</if>
|
||||||
@ -162,6 +172,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<set>
|
<set>
|
||||||
<if test="tableName != null">table_name = #{tableName},</if>
|
<if test="tableName != null">table_name = #{tableName},</if>
|
||||||
<if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
|
<if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
|
||||||
|
<if test="subTableName != null">sub_table_name = #{subTableName},</if>
|
||||||
|
<if test="subTableFkName != null">sub_table_fk_name = #{subTableFkName},</if>
|
||||||
<if test="className != null and className != ''">class_name = #{className},</if>
|
<if test="className != null and className != ''">class_name = #{className},</if>
|
||||||
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
||||||
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
||||||
@ -186,4 +198,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@ -1,114 +1,114 @@
|
|||||||
package ${packageName}.controller;
|
package ${packageName}.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
import ${packageName}.service.I${ClassName}Service;
|
import ${packageName}.service.I${ClassName}Service;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
#if($table.crud)
|
#if($table.crud || $table.sub)
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
#end
|
#end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Controller
|
* ${functionName}Controller
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/${moduleName}/${businessName}")
|
@RequestMapping("/${moduleName}/${businessName}")
|
||||||
public class ${ClassName}Controller extends BaseController
|
public class ${ClassName}Controller extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private I${ClassName}Service ${className}Service;
|
private I${ClassName}Service ${className}Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}列表
|
* 查询${functionName}列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
#if($table.crud)
|
#if($table.crud || $table.sub)
|
||||||
public TableDataInfo list(${ClassName} ${className})
|
public TableDataInfo list(${ClassName} ${className})
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
public AjaxResult list(${ClassName} ${className})
|
public AjaxResult list(${ClassName} ${className})
|
||||||
{
|
{
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出${functionName}列表
|
* 导出${functionName}列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(${ClassName} ${className})
|
public AjaxResult export(${ClassName} ${className})
|
||||||
{
|
{
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||||
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
|
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
|
||||||
return util.exportExcel(list, "${businessName}");
|
return util.exportExcel(list, "${functionName}数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取${functionName}详细信息
|
* 获取${functionName}详细信息
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
||||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
@GetMapping(value = "/{${pkColumn.javaField}}")
|
||||||
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
||||||
{
|
{
|
||||||
return AjaxResult.success(${className}Service.select${ClassName}ById(${pkColumn.javaField}));
|
return AjaxResult.success(${className}Service.select${ClassName}ById(${pkColumn.javaField}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增${functionName}
|
* 新增${functionName}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody ${ClassName} ${className})
|
public AjaxResult add(@RequestBody ${ClassName} ${className})
|
||||||
{
|
{
|
||||||
return toAjax(${className}Service.insert${ClassName}(${className}));
|
return toAjax(${className}Service.insert${ClassName}(${className}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改${functionName}
|
* 修改${functionName}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody ${ClassName} ${className})
|
public AjaxResult edit(@RequestBody ${ClassName} ${className})
|
||||||
{
|
{
|
||||||
return toAjax(${className}Service.update${ClassName}(${className}));
|
return toAjax(${className}Service.update${ClassName}(${className}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除${functionName}
|
* 删除${functionName}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
|
||||||
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||||
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||||
{
|
{
|
||||||
return toAjax(${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s));
|
return toAjax(${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import ${import};
|
|||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.ruoyi.common.annotation.Excel;
|
import com.ruoyi.common.annotation.Excel;
|
||||||
#if($table.crud)
|
#if($table.crud || $table.sub)
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
import com.ruoyi.common.core.domain.TreeEntity;
|
import com.ruoyi.common.core.domain.TreeEntity;
|
||||||
@ -18,7 +18,7 @@ import com.ruoyi.common.core.domain.TreeEntity;
|
|||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
#if($table.crud)
|
#if($table.crud || $table.sub)
|
||||||
#set($Entity="BaseEntity")
|
#set($Entity="BaseEntity")
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
#set($Entity="TreeEntity")
|
#set($Entity="TreeEntity")
|
||||||
@ -49,6 +49,11 @@ public class ${ClassName} extends ${Entity}
|
|||||||
private $column.javaType $column.javaField;
|
private $column.javaType $column.javaField;
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
/** $table.subTable.functionName信息 */
|
||||||
|
private List<${subClassName}> ${subclassName}List;
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if(!$table.isSuperColumn($column.javaField))
|
#if(!$table.isSuperColumn($column.javaField))
|
||||||
@ -69,6 +74,18 @@ public class ${ClassName} extends ${Entity}
|
|||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
#if($table.sub)
|
||||||
|
public List<${subClassName}> get${subClassName}List()
|
||||||
|
{
|
||||||
|
return ${subclassName}List;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
|
||||||
|
{
|
||||||
|
this.${subclassName}List = ${subclassName}List;
|
||||||
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
@ -79,6 +96,9 @@ public class ${ClassName} extends ${Entity}
|
|||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
#end
|
#end
|
||||||
.append("${column.javaField}", get${AttrName}())
|
.append("${column.javaField}", get${AttrName}())
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
.append("${subclassName}List", get${subClassName}List())
|
||||||
#end
|
#end
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,61 +1,91 @@
|
|||||||
package ${packageName}.mapper;
|
package ${packageName}.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
|
#if($table.sub)
|
||||||
/**
|
import ${packageName}.domain.${subClassName};
|
||||||
* ${functionName}Mapper接口
|
#end
|
||||||
*
|
|
||||||
* @author ${author}
|
/**
|
||||||
* @date ${datetime}
|
* ${functionName}Mapper接口
|
||||||
*/
|
*
|
||||||
public interface ${ClassName}Mapper
|
* @author ${author}
|
||||||
{
|
* @date ${datetime}
|
||||||
/**
|
*/
|
||||||
* 查询${functionName}
|
public interface ${ClassName}Mapper
|
||||||
*
|
{
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
/**
|
||||||
* @return ${functionName}
|
* 查询${functionName}
|
||||||
*/
|
*
|
||||||
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
* @param ${pkColumn.javaField} ${functionName}ID
|
||||||
|
* @return ${functionName}
|
||||||
/**
|
*/
|
||||||
* 查询${functionName}列表
|
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
/**
|
||||||
* @return ${functionName}集合
|
* 查询${functionName}列表
|
||||||
*/
|
*
|
||||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
* @param ${className} ${functionName}
|
||||||
|
* @return ${functionName}集合
|
||||||
/**
|
*/
|
||||||
* 新增${functionName}
|
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
/**
|
||||||
* @return 结果
|
* 新增${functionName}
|
||||||
*/
|
*
|
||||||
public int insert${ClassName}(${ClassName} ${className});
|
* @param ${className} ${functionName}
|
||||||
|
* @return 结果
|
||||||
/**
|
*/
|
||||||
* 修改${functionName}
|
public int insert${ClassName}(${ClassName} ${className});
|
||||||
*
|
|
||||||
* @param ${className} ${functionName}
|
/**
|
||||||
* @return 结果
|
* 修改${functionName}
|
||||||
*/
|
*
|
||||||
public int update${ClassName}(${ClassName} ${className});
|
* @param ${className} ${functionName}
|
||||||
|
* @return 结果
|
||||||
/**
|
*/
|
||||||
* 删除${functionName}
|
public int update${ClassName}(${ClassName} ${className});
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField} ${functionName}ID
|
/**
|
||||||
* @return 结果
|
* 删除${functionName}
|
||||||
*/
|
*
|
||||||
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
* @param ${pkColumn.javaField} ${functionName}ID
|
||||||
|
* @return 结果
|
||||||
/**
|
*/
|
||||||
* 批量删除${functionName}
|
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
*
|
|
||||||
* @param ${pkColumn.javaField}s 需要删除的数据ID
|
/**
|
||||||
* @return 结果
|
* 批量删除${functionName}
|
||||||
*/
|
*
|
||||||
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
* @param ${pkColumn.javaField}s 需要删除的数据ID
|
||||||
}
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||||
|
#if($table.sub)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除${subTable.functionName}
|
||||||
|
*
|
||||||
|
* @param customerIds 需要删除的数据ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增${subTable.functionName}
|
||||||
|
*
|
||||||
|
* @param ${subclassName}List ${subTable.functionName}列表
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过${functionName}ID删除${subTable.functionName}信息
|
||||||
|
*
|
||||||
|
* @param ${pkColumn.javaField} ${functionName}ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
|||||||
@ -9,6 +9,12 @@ import com.ruoyi.common.utils.DateUtils;
|
|||||||
#end
|
#end
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
#if($table.sub)
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ${packageName}.domain.${subClassName};
|
||||||
|
#end
|
||||||
import ${packageName}.mapper.${ClassName}Mapper;
|
import ${packageName}.mapper.${ClassName}Mapper;
|
||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
import ${packageName}.service.I${ClassName}Service;
|
import ${packageName}.service.I${ClassName}Service;
|
||||||
@ -55,6 +61,9 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||||||
* @param ${className} ${functionName}
|
* @param ${className} ${functionName}
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
#if($table.sub)
|
||||||
|
@Transactional
|
||||||
|
#end
|
||||||
@Override
|
@Override
|
||||||
public int insert${ClassName}(${ClassName} ${className})
|
public int insert${ClassName}(${ClassName} ${className})
|
||||||
{
|
{
|
||||||
@ -63,7 +72,13 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||||||
${className}.setCreateTime(DateUtils.getNowDate());
|
${className}.setCreateTime(DateUtils.getNowDate());
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
int rows = ${className}Mapper.insert${ClassName}(${className});
|
||||||
|
insert${subClassName}(${className});
|
||||||
|
return rows;
|
||||||
|
#else
|
||||||
return ${className}Mapper.insert${ClassName}(${className});
|
return ${className}Mapper.insert${ClassName}(${className});
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,6 +87,9 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||||||
* @param ${className} ${functionName}
|
* @param ${className} ${functionName}
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
#if($table.sub)
|
||||||
|
@Transactional
|
||||||
|
#end
|
||||||
@Override
|
@Override
|
||||||
public int update${ClassName}(${ClassName} ${className})
|
public int update${ClassName}(${ClassName} ${className})
|
||||||
{
|
{
|
||||||
@ -79,6 +97,10 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||||||
#if($column.javaField == 'updateTime')
|
#if($column.javaField == 'updateTime')
|
||||||
${className}.setUpdateTime(DateUtils.getNowDate());
|
${className}.setUpdateTime(DateUtils.getNowDate());
|
||||||
#end
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
|
||||||
|
insert${subClassName}(${className});
|
||||||
#end
|
#end
|
||||||
return ${className}Mapper.update${ClassName}(${className});
|
return ${className}Mapper.update${ClassName}(${className});
|
||||||
}
|
}
|
||||||
@ -89,9 +111,15 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||||||
* @param ${pkColumn.javaField}s 需要删除的${functionName}ID
|
* @param ${pkColumn.javaField}s 需要删除的${functionName}ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
#if($table.sub)
|
||||||
|
@Transactional
|
||||||
|
#end
|
||||||
@Override
|
@Override
|
||||||
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||||
{
|
{
|
||||||
|
#if($table.sub)
|
||||||
|
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
|
||||||
|
#end
|
||||||
return ${className}Mapper.delete${ClassName}ByIds(${pkColumn.javaField}s);
|
return ${className}Mapper.delete${ClassName}ByIds(${pkColumn.javaField}s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +132,35 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
|||||||
@Override
|
@Override
|
||||||
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
|
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
|
||||||
{
|
{
|
||||||
|
#if($table.sub)
|
||||||
|
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
|
||||||
|
#end
|
||||||
return ${className}Mapper.delete${ClassName}ById(${pkColumn.javaField});
|
return ${className}Mapper.delete${ClassName}ById(${pkColumn.javaField});
|
||||||
}
|
}
|
||||||
|
#if($table.sub)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增${subTable.functionName}信息
|
||||||
|
*
|
||||||
|
* @param ${className} ${functionName}对象
|
||||||
|
*/
|
||||||
|
public void insert${subClassName}(${ClassName} ${className})
|
||||||
|
{
|
||||||
|
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
|
||||||
|
Long ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
|
||||||
|
if (StringUtils.isNotNull(${subclassName}List))
|
||||||
|
{
|
||||||
|
List<${subClassName}> list = new ArrayList<${subClassName}>();
|
||||||
|
for (${subClassName} ${subclassName} : ${subclassName}List)
|
||||||
|
{
|
||||||
|
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
|
||||||
|
list.add(${subclassName});
|
||||||
|
}
|
||||||
|
if (list.size() > 0)
|
||||||
|
{
|
||||||
|
${className}Mapper.batch${subClassName}(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,76 @@
|
|||||||
|
package ${packageName}.domain;
|
||||||
|
|
||||||
|
#foreach ($import in $subImportList)
|
||||||
|
import ${import};
|
||||||
|
#end
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ${subTable.functionName}对象 ${subTableName}
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @date ${datetime}
|
||||||
|
*/
|
||||||
|
public class ${subClassName} extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
#foreach ($column in $subTable.columns)
|
||||||
|
#if(!$table.isSuperColumn($column.javaField))
|
||||||
|
/** $column.columnComment */
|
||||||
|
#if($column.list)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||||
|
#elseif($column.javaType == 'Date')
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
#else
|
||||||
|
@Excel(name = "${comment}")
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
private $column.javaType $column.javaField;
|
||||||
|
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach ($column in $subTable.columns)
|
||||||
|
#if(!$table.isSuperColumn($column.javaField))
|
||||||
|
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||||
|
#set($AttrName=$column.javaField)
|
||||||
|
#else
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
#end
|
||||||
|
public void set${AttrName}($column.javaType $column.javaField)
|
||||||
|
{
|
||||||
|
this.$column.javaField = $column.javaField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public $column.javaType get${AttrName}()
|
||||||
|
{
|
||||||
|
return $column.javaField;
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
#foreach ($column in $subTable.columns)
|
||||||
|
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||||
|
#set($AttrName=$column.javaField)
|
||||||
|
#else
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
#end
|
||||||
|
.append("${column.javaField}", get${AttrName}())
|
||||||
|
#end
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,22 +1,22 @@
|
|||||||
-- 菜单 SQL
|
-- 菜单 SQL
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单');
|
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单');
|
||||||
|
|
||||||
-- 按钮父菜单ID
|
-- 按钮父菜单ID
|
||||||
SELECT @parentId := LAST_INSERT_ID();
|
SELECT @parentId := LAST_INSERT_ID();
|
||||||
|
|
||||||
-- 按钮 SQL
|
-- 按钮 SQL
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values('${functionName}查询', @parentId, '1', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, '');
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values('${functionName}新增', @parentId, '2', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
values('${functionName}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', sysdate(), '', null, '');
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values('${functionName}修改', @parentId, '3', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', sysdate(), '', null, '');
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values('${functionName}删除', @parentId, '4', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, '');
|
||||||
|
|
||||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values('${functionName}导出', @parentId, '5', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, '');
|
||||||
@ -38,20 +38,33 @@
|
|||||||
<el-option label="请选择字典生成" value="" />
|
<el-option label="请选择字典生成" value="" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime")
|
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-date-picker clearable size="small" style="width: 200px"
|
<el-date-picker clearable size="small"
|
||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
placeholder="选择${comment}">
|
placeholder="选择${comment}">
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
<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-date-picker>
|
||||||
|
</el-form-item>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<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-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
@ -60,13 +73,14 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
plain
|
||||||
icon="el-icon-plus"
|
icon="el-icon-plus"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="handleAdd"
|
@click="handleAdd"
|
||||||
v-hasPermi="['${moduleName}:${businessName}:add']"
|
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||||
>新增</el-button>
|
>新增</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
@ -94,8 +108,12 @@
|
|||||||
#elseif($column.list && "" != $column.dictType)
|
#elseif($column.list && "" != $column.dictType)
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" :formatter="${javaField}Format" />
|
<el-table-column label="${comment}" align="center" prop="${javaField}" :formatter="${javaField}Format" />
|
||||||
#elseif($column.list && "" != $javaField)
|
#elseif($column.list && "" != $javaField)
|
||||||
|
#if(${foreach.index} == 1)
|
||||||
|
<el-table-column label="${comment}" prop="${javaField}" />
|
||||||
|
#else
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||||
#end
|
#end
|
||||||
|
#end
|
||||||
#end
|
#end
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@ -106,6 +124,13 @@
|
|||||||
@click="handleUpdate(scope.row)"
|
@click="handleUpdate(scope.row)"
|
||||||
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||||
>修改</el-button>
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
@click="handleAdd(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||||
|
>新增</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
@ -139,8 +164,20 @@
|
|||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "select" && "" != $dictType)
|
#elseif($column.htmlType == "imageUpload")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
|
<imageUpload v-model="form.${field}"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "fileUpload")
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<fileUpload v-model="form.${field}"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "editor")
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<editor v-model="form.${field}" :min-height="192"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in ${field}Options"
|
v-for="dict in ${field}Options"
|
||||||
@ -152,7 +189,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "select" && $dictType)
|
#elseif($column.htmlType == "select" && $dictType)
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
<el-option label="请选择字典生成" value="" />
|
<el-option label="请选择字典生成" value="" />
|
||||||
</el-select>
|
</el-select>
|
||||||
@ -193,7 +230,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime")
|
#elseif($column.htmlType == "datetime")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-date-picker clearable size="small" style="width: 200px"
|
<el-date-picker clearable size="small"
|
||||||
v-model="form.${field}"
|
v-model="form.${field}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
@ -221,10 +258,48 @@
|
|||||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
||||||
import Treeselect from "@riophae/vue-treeselect";
|
import Treeselect from "@riophae/vue-treeselect";
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
|
||||||
|
import ImageUpload from '@/components/ImageUpload';
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
|
||||||
|
import FileUpload from '@/components/FileUpload';
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
|
||||||
|
import Editor from '@/components/Editor';
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "${BusinessName}",
|
name: "${BusinessName}",
|
||||||
components: { Treeselect },
|
components: {
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
|
||||||
|
ImageUpload,
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
|
||||||
|
FileUpload,
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
|
||||||
|
Editor,
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
Treeselect
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
@ -249,6 +324,10 @@ export default {
|
|||||||
#if(${column.dictType} != '')
|
#if(${column.dictType} != '')
|
||||||
// $comment字典
|
// $comment字典
|
||||||
${column.javaField}Options: [],
|
${column.javaField}Options: [],
|
||||||
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
// $comment时间范围
|
||||||
|
daterange${AttrName}: [],
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
// 查询参数
|
// 查询参数
|
||||||
@ -272,9 +351,8 @@ export default {
|
|||||||
#else
|
#else
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
$column.javaField: [
|
$column.javaField: [
|
||||||
{ required: true, message: "$comment不能为空", trigger: "blur" }
|
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||||
]#if($velocityCount != $columns.size()),#end
|
]#if($velocityCount != $columns.size()),#end
|
||||||
|
|
||||||
#end
|
#end
|
||||||
@ -296,6 +374,21 @@ export default {
|
|||||||
/** 查询${functionName}列表 */
|
/** 查询${functionName}列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
this.queryParams.params = {};
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
|
||||||
|
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
|
||||||
|
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
list${BusinessName}(this.queryParams).then(response => {
|
list${BusinessName}(this.queryParams).then(response => {
|
||||||
this.${businessName}List = this.handleTree(response.data, "${treeCode}", "${treeParentCode}");
|
this.${businessName}List = this.handleTree(response.data, "${treeCode}", "${treeParentCode}");
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
@ -312,7 +405,7 @@ export default {
|
|||||||
children: node.children
|
children: node.children
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
/** 查询部门下拉树结构 */
|
/** 查询${functionName}下拉树结构 */
|
||||||
getTreeselect() {
|
getTreeselect() {
|
||||||
list${BusinessName}().then(response => {
|
list${BusinessName}().then(response => {
|
||||||
this.${businessName}Options = [];
|
this.${businessName}Options = [];
|
||||||
@ -364,20 +457,31 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
this.daterange${AttrName} = [];
|
||||||
|
#end
|
||||||
|
#end
|
||||||
this.resetForm("queryForm");
|
this.resetForm("queryForm");
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleAdd() {
|
handleAdd(row) {
|
||||||
this.reset();
|
this.reset();
|
||||||
this.getTreeselect();
|
this.getTreeselect();
|
||||||
|
if (row != null && row.${treeCode}) {
|
||||||
|
this.form.${treeParentCode} = row.${treeCode};
|
||||||
|
} else {
|
||||||
|
this.form.${treeParentCode} = 0;
|
||||||
|
}
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "添加${functionName}";
|
this.title = "添加${functionName}";
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.reset();
|
this.reset();
|
||||||
this.getTreeselect();
|
this.getTreeselect();
|
||||||
if (row != null) {
|
if (row != null) {
|
||||||
this.form.${treeParentCode} = row.${treeCode};
|
this.form.${treeParentCode} = row.${treeCode};
|
||||||
}
|
}
|
||||||
@ -403,19 +507,15 @@ export default {
|
|||||||
#end
|
#end
|
||||||
if (this.form.${pkColumn.javaField} != null) {
|
if (this.form.${pkColumn.javaField} != null) {
|
||||||
update${BusinessName}(this.form).then(response => {
|
update${BusinessName}(this.form).then(response => {
|
||||||
if (response.code === 200) {
|
this.msgSuccess("修改成功");
|
||||||
this.msgSuccess("修改成功");
|
this.open = false;
|
||||||
this.open = false;
|
this.getList();
|
||||||
this.getList();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
add${BusinessName}(this.form).then(response => {
|
add${BusinessName}(this.form).then(response => {
|
||||||
if (response.code === 200) {
|
this.msgSuccess("新增成功");
|
||||||
this.msgSuccess("新增成功");
|
this.open = false;
|
||||||
this.open = false;
|
this.getList();
|
||||||
this.getList();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -432,7 +532,7 @@ export default {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.getList();
|
this.getList();
|
||||||
this.msgSuccess("删除成功");
|
this.msgSuccess("删除成功");
|
||||||
}).catch(function() {});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -38,20 +38,33 @@
|
|||||||
<el-option label="请选择字典生成" value="" />
|
<el-option label="请选择字典生成" value="" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime")
|
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-date-picker clearable size="small" style="width: 200px"
|
<el-date-picker clearable size="small"
|
||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
placeholder="选择${comment}">
|
placeholder="选择${comment}">
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
<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-date-picker>
|
||||||
|
</el-form-item>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<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-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
@ -60,6 +73,7 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
plain
|
||||||
icon="el-icon-plus"
|
icon="el-icon-plus"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="handleAdd"
|
@click="handleAdd"
|
||||||
@ -69,6 +83,7 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="success"
|
type="success"
|
||||||
|
plain
|
||||||
icon="el-icon-edit"
|
icon="el-icon-edit"
|
||||||
size="mini"
|
size="mini"
|
||||||
:disabled="single"
|
:disabled="single"
|
||||||
@ -79,6 +94,7 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
|
plain
|
||||||
icon="el-icon-delete"
|
icon="el-icon-delete"
|
||||||
size="mini"
|
size="mini"
|
||||||
:disabled="multiple"
|
:disabled="multiple"
|
||||||
@ -89,13 +105,15 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="warning"
|
type="warning"
|
||||||
|
plain
|
||||||
icon="el-icon-download"
|
icon="el-icon-download"
|
||||||
size="mini"
|
size="mini"
|
||||||
|
:loading="exportLoading"
|
||||||
@click="handleExport"
|
@click="handleExport"
|
||||||
v-hasPermi="['${moduleName}:${businessName}:export']"
|
v-hasPermi="['${moduleName}:${businessName}:export']"
|
||||||
>导出</el-button>
|
>导出</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
|
||||||
@ -168,8 +186,20 @@
|
|||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "select" && "" != $dictType)
|
#elseif($column.htmlType == "imageUpload")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
|
<imageUpload v-model="form.${field}"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "fileUpload")
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<fileUpload v-model="form.${field}"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "editor")
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<editor v-model="form.${field}" :min-height="192"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in ${field}Options"
|
v-for="dict in ${field}Options"
|
||||||
@ -181,7 +211,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "select" && $dictType)
|
#elseif($column.htmlType == "select" && $dictType)
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
<el-option label="请选择字典生成" value="" />
|
<el-option label="请选择字典生成" value="" />
|
||||||
</el-select>
|
</el-select>
|
||||||
@ -222,7 +252,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime")
|
#elseif($column.htmlType == "datetime")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-date-picker clearable size="small" style="width: 200px"
|
<el-date-picker clearable size="small"
|
||||||
v-model="form.${field}"
|
v-model="form.${field}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
@ -236,6 +266,38 @@
|
|||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
<el-divider content-position="center">${subTable.functionName}信息</el-divider>
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd${subClassName}">添加</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDelete${subClassName}">删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
|
||||||
|
<el-table-column type="selection" width="50" align="center" />
|
||||||
|
<el-table-column label="序号" align="center" prop="index" width="50"/>
|
||||||
|
#foreach($column in $subTable.columns)
|
||||||
|
#set($javaField=$column.javaField)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($column.pk || $javaField == ${subTableFkclassName})
|
||||||
|
#elseif($column.list && "" != $javaField)
|
||||||
|
<el-table-column label="$comment" prop="${javaField}">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
</el-table>
|
||||||
#end
|
#end
|
||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
@ -248,15 +310,59 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
|
||||||
|
import ImageUpload from '@/components/ImageUpload';
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
|
||||||
|
import FileUpload from '@/components/FileUpload';
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
|
||||||
|
import Editor from '@/components/Editor';
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "${BusinessName}",
|
name: "${BusinessName}",
|
||||||
|
components: {
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
|
||||||
|
ImageUpload,
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
|
||||||
|
FileUpload,
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
|
||||||
|
Editor,
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
|
// 导出遮罩层
|
||||||
|
exportLoading: false,
|
||||||
// 选中数组
|
// 选中数组
|
||||||
ids: [],
|
ids: [],
|
||||||
|
#if($table.sub)
|
||||||
|
// 子表选中数据
|
||||||
|
checked${subClassName}: [],
|
||||||
|
#end
|
||||||
// 非单个禁用
|
// 非单个禁用
|
||||||
single: true,
|
single: true,
|
||||||
// 非多个禁用
|
// 非多个禁用
|
||||||
@ -267,6 +373,10 @@ export default {
|
|||||||
total: 0,
|
total: 0,
|
||||||
// ${functionName}表格数据
|
// ${functionName}表格数据
|
||||||
${businessName}List: [],
|
${businessName}List: [],
|
||||||
|
#if($table.sub)
|
||||||
|
// ${subTable.functionName}表格数据
|
||||||
|
${subclassName}List: [],
|
||||||
|
#end
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: "",
|
title: "",
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
@ -281,6 +391,10 @@ export default {
|
|||||||
#if(${column.dictType} != '')
|
#if(${column.dictType} != '')
|
||||||
// $comment字典
|
// $comment字典
|
||||||
${column.javaField}Options: [],
|
${column.javaField}Options: [],
|
||||||
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
// $comment时间范围
|
||||||
|
daterange${AttrName}: [],
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
// 查询参数
|
// 查询参数
|
||||||
@ -306,9 +420,8 @@ export default {
|
|||||||
#else
|
#else
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
#set($comment=$column.columnComment)
|
|
||||||
$column.javaField: [
|
$column.javaField: [
|
||||||
{ required: true, message: "$comment不能为空", trigger: "blur" }
|
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||||
]#if($velocityCount != $columns.size()),#end
|
]#if($velocityCount != $columns.size()),#end
|
||||||
|
|
||||||
#end
|
#end
|
||||||
@ -330,6 +443,21 @@ export default {
|
|||||||
/** 查询${functionName}列表 */
|
/** 查询${functionName}列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
this.queryParams.params = {};
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
|
||||||
|
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
|
||||||
|
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
list${BusinessName}(this.queryParams).then(response => {
|
list${BusinessName}(this.queryParams).then(response => {
|
||||||
this.${businessName}List = response.rows;
|
this.${businessName}List = response.rows;
|
||||||
this.total = response.total;
|
this.total = response.total;
|
||||||
@ -371,6 +499,9 @@ export default {
|
|||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
};
|
};
|
||||||
|
#if($table.sub)
|
||||||
|
this.${subclassName}List = [];
|
||||||
|
#end
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
@ -380,6 +511,12 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
this.daterange${AttrName} = [];
|
||||||
|
#end
|
||||||
|
#end
|
||||||
this.resetForm("queryForm");
|
this.resetForm("queryForm");
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
@ -405,6 +542,9 @@ export default {
|
|||||||
#if($column.htmlType == "checkbox")
|
#if($column.htmlType == "checkbox")
|
||||||
this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
||||||
#end
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
this.${subclassName}List = response.data.${subclassName}List;
|
||||||
#end
|
#end
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "修改${functionName}";
|
this.title = "修改${functionName}";
|
||||||
@ -418,22 +558,21 @@ export default {
|
|||||||
#if($column.htmlType == "checkbox")
|
#if($column.htmlType == "checkbox")
|
||||||
this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
||||||
#end
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
this.form.${subclassName}List = this.${subclassName}List;
|
||||||
#end
|
#end
|
||||||
if (this.form.${pkColumn.javaField} != null) {
|
if (this.form.${pkColumn.javaField} != null) {
|
||||||
update${BusinessName}(this.form).then(response => {
|
update${BusinessName}(this.form).then(response => {
|
||||||
if (response.code === 200) {
|
this.msgSuccess("修改成功");
|
||||||
this.msgSuccess("修改成功");
|
this.open = false;
|
||||||
this.open = false;
|
this.getList();
|
||||||
this.getList();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
add${BusinessName}(this.form).then(response => {
|
add${BusinessName}(this.form).then(response => {
|
||||||
if (response.code === 200) {
|
this.msgSuccess("新增成功");
|
||||||
this.msgSuccess("新增成功");
|
this.open = false;
|
||||||
this.open = false;
|
this.getList();
|
||||||
this.getList();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -451,8 +590,42 @@ export default {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.getList();
|
this.getList();
|
||||||
this.msgSuccess("删除成功");
|
this.msgSuccess("删除成功");
|
||||||
}).catch(function() {});
|
})
|
||||||
},
|
},
|
||||||
|
#if($table.sub)
|
||||||
|
/** ${subTable.functionName}序号 */
|
||||||
|
row${subClassName}Index({ row, rowIndex }) {
|
||||||
|
row.index = rowIndex + 1;
|
||||||
|
},
|
||||||
|
/** ${subTable.functionName}添加按钮操作 */
|
||||||
|
handleAdd${subClassName}() {
|
||||||
|
let obj = {};
|
||||||
|
#foreach($column in $subTable.columns)
|
||||||
|
#if($column.pk || $column.javaField == ${subTableFkclassName})
|
||||||
|
#elseif($column.list && "" != $javaField)
|
||||||
|
obj.$column.javaField = "";
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
this.${subclassName}List.push(obj);
|
||||||
|
},
|
||||||
|
/** ${subTable.functionName}删除按钮操作 */
|
||||||
|
handleDelete${subClassName}() {
|
||||||
|
if (this.checked${subClassName}.length == 0) {
|
||||||
|
this.$alert("请先选择要删除的${subTable.functionName}数据", "提示", { confirmButtonText: "确定", });
|
||||||
|
} else {
|
||||||
|
this.${subclassName}List.splice(this.checked${subClassName}[0].index - 1, 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 单选框选中数据 */
|
||||||
|
handle${subClassName}SelectionChange(selection) {
|
||||||
|
if (selection.length > 1) {
|
||||||
|
this.$refs.${subclassName}.clearSelection();
|
||||||
|
this.$refs.${subclassName}.toggleRowSelection(selection.pop());
|
||||||
|
} else {
|
||||||
|
this.checked${subClassName} = selection;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
#end
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
const queryParams = this.queryParams;
|
const queryParams = this.queryParams;
|
||||||
@ -460,11 +633,13 @@ export default {
|
|||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
}).then(function() {
|
}).then(() => {
|
||||||
|
this.exportLoading = true;
|
||||||
return export${BusinessName}(queryParams);
|
return export${BusinessName}(queryParams);
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
this.download(response.msg);
|
this.download(response.msg);
|
||||||
}).catch(function() {});
|
this.exportLoading = false;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -9,6 +9,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="${column.javaField}" column="${column.columnName}" />
|
<result property="${column.javaField}" column="${column.columnName}" />
|
||||||
#end
|
#end
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
#if($table.sub)
|
||||||
|
|
||||||
|
<resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result">
|
||||||
|
<collection property="${subclassName}List" notNullColumn="sub_${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap type="${subClassName}" id="${subClassName}Result">
|
||||||
|
#foreach ($column in $subTable.columns)
|
||||||
|
<result property="${column.javaField}" column="sub_${column.columnName}" />
|
||||||
|
#end
|
||||||
|
</resultMap>
|
||||||
|
#end
|
||||||
|
|
||||||
<sql id="select${ClassName}Vo">
|
<sql id="select${ClassName}Vo">
|
||||||
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
||||||
@ -46,9 +58,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="${ClassName}Result">
|
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
||||||
|
#if($table.crud || $table.tree)
|
||||||
<include refid="select${ClassName}Vo"/>
|
<include refid="select${ClassName}Vo"/>
|
||||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||||
|
#elseif($table.sub)
|
||||||
|
select#foreach($column in $columns) a.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
||||||
|
#foreach($column in $subTable.columns) b.$column.columnName as sub_$column.columnName#if($velocityCount != $subTable.columns.size()),#end#end
|
||||||
|
|
||||||
|
from ${tableName} a
|
||||||
|
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
|
||||||
|
where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||||
|
#end
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
|
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
|
||||||
@ -91,5 +112,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
#{${pkColumn.javaField}}
|
#{${pkColumn.javaField}}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
#if($table.sub)
|
||||||
|
|
||||||
|
<delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">
|
||||||
|
delete from ${subTableName} where ${subTableFkName} in
|
||||||
|
<foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")">
|
||||||
|
#{${subTableFkclassName}}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="Long">
|
||||||
|
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<insert id="batch${subClassName}">
|
||||||
|
insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($velocityCount != $subTable.columns.size()),#end#end) values
|
||||||
|
<foreach item="item" index="index" collection="list" separator=",">
|
||||||
|
(#foreach($column in $subTable.columns) #{item.$column.javaField}#if($velocityCount != $subTable.columns.size()),#end#end)
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
#end
|
||||||
</mapper>
|
</mapper>
|
||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.1.0</version>
|
<version>3.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.ruoyi.quartz.domain;
|
package com.ruoyi.quartz.domain;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
@ -19,7 +18,7 @@ import com.ruoyi.quartz.util.CronUtils;
|
|||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class SysJob extends BaseEntity implements Serializable
|
public class SysJob extends BaseEntity
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ -88,7 +87,7 @@ public class SysJob extends BaseEntity implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotBlank(message = "调用目标字符串不能为空")
|
@NotBlank(message = "调用目标字符串不能为空")
|
||||||
@Size(min = 0, max = 1000, message = "调用目标字符串长度不能超过500个字符")
|
@Size(min = 0, max = 500, message = "调用目标字符串长度不能超过500个字符")
|
||||||
public String getInvokeTarget()
|
public String getInvokeTarget()
|
||||||
{
|
{
|
||||||
return invokeTarget;
|
return invokeTarget;
|
||||||
|
|||||||
@ -35,11 +35,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="invokeTarget != null and invokeTarget != ''">
|
<if test="invokeTarget != null and invokeTarget != ''">
|
||||||
AND invoke_target like concat('%', #{invokeTarget}, '%')
|
AND invoke_target like concat('%', #{invokeTarget}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
and date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
and date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.1.0</version>
|
<version>3.5.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -13,10 +13,15 @@ public class MetaVo
|
|||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置该路由的图标,对应路径src/icons/svg
|
* 设置该路由的图标,对应路径src/assets/icons/svg
|
||||||
*/
|
*/
|
||||||
private String icon;
|
private String icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置为true,则不会被 <keep-alive>缓存
|
||||||
|
*/
|
||||||
|
private boolean noCache;
|
||||||
|
|
||||||
public MetaVo()
|
public MetaVo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -27,6 +32,23 @@ public class MetaVo
|
|||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MetaVo(String title, String icon, boolean noCache)
|
||||||
|
{
|
||||||
|
this.title = title;
|
||||||
|
this.icon = icon;
|
||||||
|
this.noCache = noCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNoCache()
|
||||||
|
{
|
||||||
|
return noCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNoCache(boolean noCache)
|
||||||
|
{
|
||||||
|
this.noCache = noCache;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTitle()
|
public String getTitle()
|
||||||
{
|
{
|
||||||
return title;
|
return title;
|
||||||
|
|||||||
@ -23,9 +23,10 @@ public interface SysDeptMapper
|
|||||||
* 根据角色ID查询部门树信息
|
* 根据角色ID查询部门树信息
|
||||||
*
|
*
|
||||||
* @param roleId 角色ID
|
* @param roleId 角色ID
|
||||||
|
* @param deptCheckStrictly 部门树选择项是否关联显示
|
||||||
* @return 选中部门列表
|
* @return 选中部门列表
|
||||||
*/
|
*/
|
||||||
public List<Integer> selectDeptListByRoleId(Long roleId);
|
public List<Integer> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门ID查询信息
|
* 根据部门ID查询信息
|
||||||
|
|||||||
@ -59,11 +59,12 @@ public interface SysMenuMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色ID查询菜单树信息
|
* 根据角色ID查询菜单树信息
|
||||||
*
|
*
|
||||||
* @param roleId 角色ID
|
* @param roleId 角色ID
|
||||||
|
* @param menuCheckStrictly 菜单树选择项是否关联显示
|
||||||
* @return 选中菜单列表
|
* @return 选中菜单列表
|
||||||
*/
|
*/
|
||||||
public List<Integer> selectMenuListByRoleId(Long roleId);
|
public List<Integer> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据菜单ID查询信息
|
* 根据菜单ID查询信息
|
||||||
|
|||||||
@ -26,6 +26,14 @@ public interface SysRoleMenuMapper
|
|||||||
*/
|
*/
|
||||||
public int deleteRoleMenuByRoleId(Long roleId);
|
public int deleteRoleMenuByRoleId(Long roleId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除角色菜单关联信息
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteRoleMenu(Long[] ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量新增角色菜单信息
|
* 批量新增角色菜单信息
|
||||||
*
|
*
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import com.ruoyi.common.constant.UserConstants;
|
|||||||
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
import com.ruoyi.common.enums.DataSourceType;
|
import com.ruoyi.common.enums.DataSourceType;
|
||||||
|
import com.ruoyi.common.exception.CustomException;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.domain.SysConfig;
|
import com.ruoyi.system.domain.SysConfig;
|
||||||
import com.ruoyi.system.mapper.SysConfigMapper;
|
import com.ruoyi.system.mapper.SysConfigMapper;
|
||||||
@ -138,6 +139,14 @@ public class SysConfigServiceImpl implements ISysConfigService
|
|||||||
@Override
|
@Override
|
||||||
public int deleteConfigByIds(Long[] configIds)
|
public int deleteConfigByIds(Long[] configIds)
|
||||||
{
|
{
|
||||||
|
for (Long configId : configIds)
|
||||||
|
{
|
||||||
|
SysConfig config = selectConfigById(configId);
|
||||||
|
if (StringUtils.equals(UserConstants.YES, config.getConfigType()))
|
||||||
|
{
|
||||||
|
throw new CustomException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
|
||||||
|
}
|
||||||
|
}
|
||||||
int count = configMapper.deleteConfigByIds(configIds);
|
int count = configMapper.deleteConfigByIds(configIds);
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,9 +10,11 @@ import com.ruoyi.common.annotation.DataScope;
|
|||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.TreeSelect;
|
import com.ruoyi.common.core.domain.TreeSelect;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.exception.CustomException;
|
import com.ruoyi.common.exception.CustomException;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.mapper.SysDeptMapper;
|
import com.ruoyi.system.mapper.SysDeptMapper;
|
||||||
|
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,6 +28,9 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysDeptMapper deptMapper;
|
private SysDeptMapper deptMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysRoleMapper roleMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门管理数据
|
* 查询部门管理数据
|
||||||
*
|
*
|
||||||
@ -93,7 +98,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
@Override
|
@Override
|
||||||
public List<Integer> selectDeptListByRoleId(Long roleId)
|
public List<Integer> selectDeptListByRoleId(Long roleId)
|
||||||
{
|
{
|
||||||
return deptMapper.selectDeptListByRoleId(roleId);
|
SysRole role = roleMapper.selectRoleById(roleId);
|
||||||
|
return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -235,7 +241,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
|
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
|
||||||
for (SysDept child : children)
|
for (SysDept child : children)
|
||||||
{
|
{
|
||||||
child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors));
|
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
|
||||||
}
|
}
|
||||||
if (children.size() > 0)
|
if (children.size() > 0)
|
||||||
{
|
{
|
||||||
@ -267,13 +273,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
{
|
{
|
||||||
if (hasChild(list, tChild))
|
if (hasChild(list, tChild))
|
||||||
{
|
{
|
||||||
// 判断是否有子节点
|
recursionFn(list, tChild);
|
||||||
Iterator<SysDept> it = childList.iterator();
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
SysDept n = (SysDept) it.next();
|
|
||||||
recursionFn(list, n);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,12 +76,12 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|||||||
public List<SysDictData> selectDictDataByType(String dictType)
|
public List<SysDictData> selectDictDataByType(String dictType)
|
||||||
{
|
{
|
||||||
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
||||||
if (StringUtils.isNotNull(dictDatas))
|
if (StringUtils.isNotEmpty(dictDatas))
|
||||||
{
|
{
|
||||||
return dictDatas;
|
return dictDatas;
|
||||||
}
|
}
|
||||||
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||||
if (StringUtils.isNotNull(dictDatas))
|
if (StringUtils.isNotEmpty(dictDatas))
|
||||||
{
|
{
|
||||||
DictUtils.setDictCache(dictType, dictDatas);
|
DictUtils.setDictCache(dictType, dictDatas);
|
||||||
return dictDatas;
|
return dictDatas;
|
||||||
|
|||||||
@ -1,445 +1,466 @@
|
|||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.TreeSelect;
|
import com.ruoyi.common.core.domain.TreeSelect;
|
||||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.domain.vo.MetaVo;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.domain.vo.RouterVo;
|
import com.ruoyi.system.domain.vo.MetaVo;
|
||||||
import com.ruoyi.system.mapper.SysMenuMapper;
|
import com.ruoyi.system.domain.vo.RouterVo;
|
||||||
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
import com.ruoyi.system.mapper.SysMenuMapper;
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||||
|
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
||||||
/**
|
import com.ruoyi.system.service.ISysMenuService;
|
||||||
* 菜单 业务层处理
|
|
||||||
*
|
/**
|
||||||
* @author ruoyi
|
* 菜单 业务层处理
|
||||||
*/
|
*
|
||||||
@Service
|
* @author ruoyi
|
||||||
public class SysMenuServiceImpl implements ISysMenuService
|
*/
|
||||||
{
|
@Service
|
||||||
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
|
public class SysMenuServiceImpl implements ISysMenuService
|
||||||
|
{
|
||||||
@Autowired
|
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
|
||||||
private SysMenuMapper menuMapper;
|
|
||||||
|
@Autowired
|
||||||
@Autowired
|
private SysMenuMapper menuMapper;
|
||||||
private SysRoleMenuMapper roleMenuMapper;
|
|
||||||
|
@Autowired
|
||||||
/**
|
private SysRoleMapper roleMapper;
|
||||||
* 根据用户查询系统菜单列表
|
|
||||||
*
|
@Autowired
|
||||||
* @param userId 用户ID
|
private SysRoleMenuMapper roleMenuMapper;
|
||||||
* @return 菜单列表
|
|
||||||
*/
|
/**
|
||||||
@Override
|
* 根据用户查询系统菜单列表
|
||||||
public List<SysMenu> selectMenuList(Long userId)
|
*
|
||||||
{
|
* @param userId 用户ID
|
||||||
return selectMenuList(new SysMenu(), userId);
|
* @return 菜单列表
|
||||||
}
|
*/
|
||||||
|
@Override
|
||||||
/**
|
public List<SysMenu> selectMenuList(Long userId)
|
||||||
* 查询系统菜单列表
|
{
|
||||||
*
|
return selectMenuList(new SysMenu(), userId);
|
||||||
* @param menu 菜单信息
|
}
|
||||||
* @return 菜单列表
|
|
||||||
*/
|
/**
|
||||||
@Override
|
* 查询系统菜单列表
|
||||||
public List<SysMenu> selectMenuList(SysMenu menu, Long userId)
|
*
|
||||||
{
|
* @param menu 菜单信息
|
||||||
List<SysMenu> menuList = null;
|
* @return 菜单列表
|
||||||
// 管理员显示所有菜单信息
|
*/
|
||||||
if (SysUser.isAdmin(userId))
|
@Override
|
||||||
{
|
public List<SysMenu> selectMenuList(SysMenu menu, Long userId)
|
||||||
menuList = menuMapper.selectMenuList(menu);
|
{
|
||||||
}
|
List<SysMenu> menuList = null;
|
||||||
else
|
// 管理员显示所有菜单信息
|
||||||
{
|
if (SysUser.isAdmin(userId))
|
||||||
menu.getParams().put("userId", userId);
|
{
|
||||||
menuList = menuMapper.selectMenuListByUserId(menu);
|
menuList = menuMapper.selectMenuList(menu);
|
||||||
}
|
}
|
||||||
return menuList;
|
else
|
||||||
}
|
{
|
||||||
|
menu.getParams().put("userId", userId);
|
||||||
/**
|
menuList = menuMapper.selectMenuListByUserId(menu);
|
||||||
* 根据用户ID查询权限
|
}
|
||||||
*
|
return menuList;
|
||||||
* @param userId 用户ID
|
}
|
||||||
* @return 权限列表
|
|
||||||
*/
|
/**
|
||||||
@Override
|
* 根据用户ID查询权限
|
||||||
public Set<String> selectMenuPermsByUserId(Long userId)
|
*
|
||||||
{
|
* @param userId 用户ID
|
||||||
List<String> perms = menuMapper.selectMenuPermsByUserId(userId);
|
* @return 权限列表
|
||||||
Set<String> permsSet = new HashSet<>();
|
*/
|
||||||
for (String perm : perms)
|
@Override
|
||||||
{
|
public Set<String> selectMenuPermsByUserId(Long userId)
|
||||||
if (StringUtils.isNotEmpty(perm))
|
{
|
||||||
{
|
List<String> perms = menuMapper.selectMenuPermsByUserId(userId);
|
||||||
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
Set<String> permsSet = new HashSet<>();
|
||||||
}
|
for (String perm : perms)
|
||||||
}
|
{
|
||||||
return permsSet;
|
if (StringUtils.isNotEmpty(perm))
|
||||||
}
|
{
|
||||||
|
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
||||||
/**
|
}
|
||||||
* 根据用户ID查询菜单
|
}
|
||||||
*
|
return permsSet;
|
||||||
* @param userId 用户名称
|
}
|
||||||
* @return 菜单列表
|
|
||||||
*/
|
/**
|
||||||
@Override
|
* 根据用户ID查询菜单
|
||||||
public List<SysMenu> selectMenuTreeByUserId(Long userId)
|
*
|
||||||
{
|
* @param userId 用户名称
|
||||||
List<SysMenu> menus = null;
|
* @return 菜单列表
|
||||||
if (SecurityUtils.isAdmin(userId))
|
*/
|
||||||
{
|
@Override
|
||||||
menus = menuMapper.selectMenuTreeAll();
|
public List<SysMenu> selectMenuTreeByUserId(Long userId)
|
||||||
}
|
{
|
||||||
else
|
List<SysMenu> menus = null;
|
||||||
{
|
if (SecurityUtils.isAdmin(userId))
|
||||||
menus = menuMapper.selectMenuTreeByUserId(userId);
|
{
|
||||||
}
|
menus = menuMapper.selectMenuTreeAll();
|
||||||
return getChildPerms(menus, 0);
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
/**
|
menus = menuMapper.selectMenuTreeByUserId(userId);
|
||||||
* 根据角色ID查询菜单树信息
|
}
|
||||||
*
|
return getChildPerms(menus, 0);
|
||||||
* @param roleId 角色ID
|
}
|
||||||
* @return 选中菜单列表
|
|
||||||
*/
|
/**
|
||||||
@Override
|
* 根据角色ID查询菜单树信息
|
||||||
public List<Integer> selectMenuListByRoleId(Long roleId)
|
*
|
||||||
{
|
* @param roleId 角色ID
|
||||||
return menuMapper.selectMenuListByRoleId(roleId);
|
* @return 选中菜单列表
|
||||||
}
|
*/
|
||||||
|
@Override
|
||||||
/**
|
public List<Integer> selectMenuListByRoleId(Long roleId)
|
||||||
* 构建前端路由所需要的菜单
|
{
|
||||||
*
|
SysRole role = roleMapper.selectRoleById(roleId);
|
||||||
* @param menus 菜单列表
|
return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
|
||||||
* @return 路由列表
|
}
|
||||||
*/
|
|
||||||
@Override
|
/**
|
||||||
public List<RouterVo> buildMenus(List<SysMenu> menus)
|
* 构建前端路由所需要的菜单
|
||||||
{
|
*
|
||||||
List<RouterVo> routers = new LinkedList<RouterVo>();
|
* @param menus 菜单列表
|
||||||
for (SysMenu menu : menus)
|
* @return 路由列表
|
||||||
{
|
*/
|
||||||
RouterVo router = new RouterVo();
|
@Override
|
||||||
router.setHidden("1".equals(menu.getVisible()));
|
public List<RouterVo> buildMenus(List<SysMenu> menus)
|
||||||
router.setName(getRouteName(menu));
|
{
|
||||||
router.setPath(getRouterPath(menu));
|
List<RouterVo> routers = new LinkedList<RouterVo>();
|
||||||
router.setComponent(getComponent(menu));
|
for (SysMenu menu : menus)
|
||||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
{
|
||||||
List<SysMenu> cMenus = menu.getChildren();
|
RouterVo router = new RouterVo();
|
||||||
if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
router.setHidden("1".equals(menu.getVisible()));
|
||||||
{
|
router.setName(getRouteName(menu));
|
||||||
router.setAlwaysShow(true);
|
router.setPath(getRouterPath(menu));
|
||||||
router.setRedirect("noRedirect");
|
router.setComponent(getComponent(menu));
|
||||||
router.setChildren(buildMenus(cMenus));
|
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache())));
|
||||||
}
|
List<SysMenu> cMenus = menu.getChildren();
|
||||||
else if (isMeunFrame(menu))
|
if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
||||||
{
|
{
|
||||||
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
router.setAlwaysShow(true);
|
||||||
RouterVo children = new RouterVo();
|
router.setRedirect("noRedirect");
|
||||||
children.setPath(menu.getPath());
|
router.setChildren(buildMenus(cMenus));
|
||||||
children.setComponent(menu.getComponent());
|
}
|
||||||
children.setName(StringUtils.capitalize(menu.getPath()));
|
else if (isMenuFrame(menu))
|
||||||
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
{
|
||||||
childrenList.add(children);
|
router.setMeta(null);
|
||||||
router.setChildren(childrenList);
|
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||||
}
|
RouterVo children = new RouterVo();
|
||||||
routers.add(router);
|
children.setPath(menu.getPath());
|
||||||
}
|
children.setComponent(menu.getComponent());
|
||||||
return routers;
|
children.setName(StringUtils.capitalize(menu.getPath()));
|
||||||
}
|
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache())));
|
||||||
|
childrenList.add(children);
|
||||||
/**
|
router.setChildren(childrenList);
|
||||||
* 构建前端所需要树结构
|
}
|
||||||
*
|
routers.add(router);
|
||||||
* @param menus 菜单列表
|
}
|
||||||
* @return 树结构列表
|
return routers;
|
||||||
*/
|
}
|
||||||
@Override
|
|
||||||
public List<SysMenu> buildMenuTree(List<SysMenu> menus)
|
/**
|
||||||
{
|
* 构建前端所需要树结构
|
||||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
*
|
||||||
for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext();)
|
* @param menus 菜单列表
|
||||||
{
|
* @return 树结构列表
|
||||||
SysMenu t = (SysMenu) iterator.next();
|
*/
|
||||||
// 根据传入的某个父节点ID,遍历该父节点的所有子节点
|
@Override
|
||||||
if (t.getParentId() == 0)
|
public List<SysMenu> buildMenuTree(List<SysMenu> menus)
|
||||||
{
|
{
|
||||||
recursionFn(menus, t);
|
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
||||||
returnList.add(t);
|
List<Long> tempList = new ArrayList<Long>();
|
||||||
}
|
for (SysMenu dept : menus)
|
||||||
}
|
{
|
||||||
if (returnList.isEmpty())
|
tempList.add(dept.getMenuId());
|
||||||
{
|
}
|
||||||
returnList = menus;
|
for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext();)
|
||||||
}
|
{
|
||||||
return returnList;
|
SysMenu menu = (SysMenu) iterator.next();
|
||||||
}
|
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||||
|
if (!tempList.contains(menu.getParentId()))
|
||||||
/**
|
{
|
||||||
* 构建前端所需要下拉树结构
|
recursionFn(menus, menu);
|
||||||
*
|
returnList.add(menu);
|
||||||
* @param menus 菜单列表
|
}
|
||||||
* @return 下拉树结构列表
|
}
|
||||||
*/
|
if (returnList.isEmpty())
|
||||||
@Override
|
{
|
||||||
public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus)
|
returnList = menus;
|
||||||
{
|
}
|
||||||
List<SysMenu> menuTrees = buildMenuTree(menus);
|
return returnList;
|
||||||
return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 构建前端所需要下拉树结构
|
||||||
* 根据菜单ID查询信息
|
*
|
||||||
*
|
* @param menus 菜单列表
|
||||||
* @param menuId 菜单ID
|
* @return 下拉树结构列表
|
||||||
* @return 菜单信息
|
*/
|
||||||
*/
|
@Override
|
||||||
@Override
|
public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus)
|
||||||
public SysMenu selectMenuById(Long menuId)
|
{
|
||||||
{
|
List<SysMenu> menuTrees = buildMenuTree(menus);
|
||||||
return menuMapper.selectMenuById(menuId);
|
return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否存在菜单子节点
|
* 根据菜单ID查询信息
|
||||||
*
|
*
|
||||||
* @param menuId 菜单ID
|
* @param menuId 菜单ID
|
||||||
* @return 结果
|
* @return 菜单信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean hasChildByMenuId(Long menuId)
|
public SysMenu selectMenuById(Long menuId)
|
||||||
{
|
{
|
||||||
int result = menuMapper.hasChildByMenuId(menuId);
|
return menuMapper.selectMenuById(menuId);
|
||||||
return result > 0 ? true : false;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 是否存在菜单子节点
|
||||||
* 查询菜单使用数量
|
*
|
||||||
*
|
* @param menuId 菜单ID
|
||||||
* @param menuId 菜单ID
|
* @return 结果
|
||||||
* @return 结果
|
*/
|
||||||
*/
|
@Override
|
||||||
@Override
|
public boolean hasChildByMenuId(Long menuId)
|
||||||
public boolean checkMenuExistRole(Long menuId)
|
{
|
||||||
{
|
int result = menuMapper.hasChildByMenuId(menuId);
|
||||||
int result = roleMenuMapper.checkMenuExistRole(menuId);
|
return result > 0 ? true : false;
|
||||||
return result > 0 ? true : false;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* 查询菜单使用数量
|
||||||
* 新增保存菜单信息
|
*
|
||||||
*
|
* @param menuId 菜单ID
|
||||||
* @param menu 菜单信息
|
* @return 结果
|
||||||
* @return 结果
|
*/
|
||||||
*/
|
@Override
|
||||||
@Override
|
public boolean checkMenuExistRole(Long menuId)
|
||||||
public int insertMenu(SysMenu menu)
|
{
|
||||||
{
|
int result = roleMenuMapper.checkMenuExistRole(menuId);
|
||||||
return menuMapper.insertMenu(menu);
|
return result > 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存菜单信息
|
* 新增保存菜单信息
|
||||||
*
|
*
|
||||||
* @param menu 菜单信息
|
* @param menu 菜单信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateMenu(SysMenu menu)
|
public int insertMenu(SysMenu menu)
|
||||||
{
|
{
|
||||||
return menuMapper.updateMenu(menu);
|
return menuMapper.insertMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单管理信息
|
* 修改保存菜单信息
|
||||||
*
|
*
|
||||||
* @param menuId 菜单ID
|
* @param menu 菜单信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteMenuById(Long menuId)
|
public int updateMenu(SysMenu menu)
|
||||||
{
|
{
|
||||||
return menuMapper.deleteMenuById(menuId);
|
return menuMapper.updateMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验菜单名称是否唯一
|
* 删除菜单管理信息
|
||||||
*
|
*
|
||||||
* @param menu 菜单信息
|
* @param menuId 菜单ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String checkMenuNameUnique(SysMenu menu)
|
public int deleteMenuById(Long menuId)
|
||||||
{
|
{
|
||||||
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
return menuMapper.deleteMenuById(menuId);
|
||||||
SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
|
}
|
||||||
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue())
|
|
||||||
{
|
/**
|
||||||
return UserConstants.NOT_UNIQUE;
|
* 校验菜单名称是否唯一
|
||||||
}
|
*
|
||||||
return UserConstants.UNIQUE;
|
* @param menu 菜单信息
|
||||||
}
|
* @return 结果
|
||||||
|
*/
|
||||||
/**
|
@Override
|
||||||
* 获取路由名称
|
public String checkMenuNameUnique(SysMenu menu)
|
||||||
*
|
{
|
||||||
* @param menu 菜单信息
|
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
||||||
* @return 路由名称
|
SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
|
||||||
*/
|
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue())
|
||||||
public String getRouteName(SysMenu menu)
|
{
|
||||||
{
|
return UserConstants.NOT_UNIQUE;
|
||||||
String routerName = StringUtils.capitalize(menu.getPath());
|
}
|
||||||
// 非外链并且是一级目录(类型为目录)
|
return UserConstants.UNIQUE;
|
||||||
if (isMeunFrame(menu))
|
}
|
||||||
{
|
|
||||||
routerName = StringUtils.EMPTY;
|
/**
|
||||||
}
|
* 获取路由名称
|
||||||
return routerName;
|
*
|
||||||
}
|
* @param menu 菜单信息
|
||||||
|
* @return 路由名称
|
||||||
/**
|
*/
|
||||||
* 获取路由地址
|
public String getRouteName(SysMenu menu)
|
||||||
*
|
{
|
||||||
* @param menu 菜单信息
|
String routerName = StringUtils.capitalize(menu.getPath());
|
||||||
* @return 路由地址
|
// 非外链并且是一级目录(类型为目录)
|
||||||
*/
|
if (isMenuFrame(menu))
|
||||||
public String getRouterPath(SysMenu menu)
|
{
|
||||||
{
|
routerName = StringUtils.EMPTY;
|
||||||
String routerPath = menu.getPath();
|
}
|
||||||
// 非外链并且是一级目录(类型为目录)
|
return routerName;
|
||||||
if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType())
|
}
|
||||||
&& UserConstants.NO_FRAME.equals(menu.getIsFrame()))
|
|
||||||
{
|
/**
|
||||||
routerPath = "/" + menu.getPath();
|
* 获取路由地址
|
||||||
}
|
*
|
||||||
// 非外链并且是一级目录(类型为菜单)
|
* @param menu 菜单信息
|
||||||
else if (isMeunFrame(menu))
|
* @return 路由地址
|
||||||
{
|
*/
|
||||||
routerPath = "/";
|
public String getRouterPath(SysMenu menu)
|
||||||
}
|
{
|
||||||
return routerPath;
|
String routerPath = menu.getPath();
|
||||||
}
|
// 非外链并且是一级目录(类型为目录)
|
||||||
|
if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType())
|
||||||
/**
|
&& UserConstants.NO_FRAME.equals(menu.getIsFrame()))
|
||||||
* 获取组件信息
|
{
|
||||||
*
|
routerPath = "/" + menu.getPath();
|
||||||
* @param menu 菜单信息
|
}
|
||||||
* @return 组件信息
|
// 非外链并且是一级目录(类型为菜单)
|
||||||
*/
|
else if (isMenuFrame(menu))
|
||||||
public String getComponent(SysMenu menu)
|
{
|
||||||
{
|
routerPath = "/";
|
||||||
String component = UserConstants.LAYOUT;
|
}
|
||||||
if (StringUtils.isNotEmpty(menu.getComponent()) && !isMeunFrame(menu))
|
return routerPath;
|
||||||
{
|
}
|
||||||
component = menu.getComponent();
|
|
||||||
}
|
/**
|
||||||
return component;
|
* 获取组件信息
|
||||||
}
|
*
|
||||||
|
* @param menu 菜单信息
|
||||||
/**
|
* @return 组件信息
|
||||||
* 是否为菜单内部跳转
|
*/
|
||||||
*
|
public String getComponent(SysMenu menu)
|
||||||
* @param menu 菜单信息
|
{
|
||||||
* @return 结果
|
String component = UserConstants.LAYOUT;
|
||||||
*/
|
if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu))
|
||||||
public boolean isMeunFrame(SysMenu menu)
|
{
|
||||||
{
|
component = menu.getComponent();
|
||||||
return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType())
|
}
|
||||||
&& menu.getIsFrame().equals(UserConstants.NO_FRAME);
|
else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu))
|
||||||
}
|
{
|
||||||
|
component = UserConstants.PARENT_VIEW;
|
||||||
/**
|
}
|
||||||
* 根据父节点的ID获取所有子节点
|
return component;
|
||||||
*
|
}
|
||||||
* @param list 分类表
|
|
||||||
* @param parentId 传入的父节点ID
|
/**
|
||||||
* @return String
|
* 是否为菜单内部跳转
|
||||||
*/
|
*
|
||||||
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId)
|
* @param menu 菜单信息
|
||||||
{
|
* @return 结果
|
||||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
*/
|
||||||
for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext();)
|
public boolean isMenuFrame(SysMenu menu)
|
||||||
{
|
{
|
||||||
SysMenu t = (SysMenu) iterator.next();
|
return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType())
|
||||||
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
|
&& menu.getIsFrame().equals(UserConstants.NO_FRAME);
|
||||||
if (t.getParentId() == parentId)
|
}
|
||||||
{
|
|
||||||
recursionFn(list, t);
|
/**
|
||||||
returnList.add(t);
|
* 是否为parent_view组件
|
||||||
}
|
*
|
||||||
}
|
* @param menu 菜单信息
|
||||||
return returnList;
|
* @return 结果
|
||||||
}
|
*/
|
||||||
|
public boolean isParentView(SysMenu menu)
|
||||||
/**
|
{
|
||||||
* 递归列表
|
return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType());
|
||||||
*
|
}
|
||||||
* @param list
|
|
||||||
* @param t
|
/**
|
||||||
*/
|
* 根据父节点的ID获取所有子节点
|
||||||
private void recursionFn(List<SysMenu> list, SysMenu t)
|
*
|
||||||
{
|
* @param list 分类表
|
||||||
// 得到子节点列表
|
* @param parentId 传入的父节点ID
|
||||||
List<SysMenu> childList = getChildList(list, t);
|
* @return String
|
||||||
t.setChildren(childList);
|
*/
|
||||||
for (SysMenu tChild : childList)
|
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId)
|
||||||
{
|
{
|
||||||
if (hasChild(list, tChild))
|
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
||||||
{
|
for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext();)
|
||||||
// 判断是否有子节点
|
{
|
||||||
Iterator<SysMenu> it = childList.iterator();
|
SysMenu t = (SysMenu) iterator.next();
|
||||||
while (it.hasNext())
|
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
|
||||||
{
|
if (t.getParentId() == parentId)
|
||||||
SysMenu n = (SysMenu) it.next();
|
{
|
||||||
recursionFn(list, n);
|
recursionFn(list, t);
|
||||||
}
|
returnList.add(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return returnList;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 得到子节点列表
|
/**
|
||||||
*/
|
* 递归列表
|
||||||
private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t)
|
*
|
||||||
{
|
* @param list
|
||||||
List<SysMenu> tlist = new ArrayList<SysMenu>();
|
* @param t
|
||||||
Iterator<SysMenu> it = list.iterator();
|
*/
|
||||||
while (it.hasNext())
|
private void recursionFn(List<SysMenu> list, SysMenu t)
|
||||||
{
|
{
|
||||||
SysMenu n = (SysMenu) it.next();
|
// 得到子节点列表
|
||||||
if (n.getParentId().longValue() == t.getMenuId().longValue())
|
List<SysMenu> childList = getChildList(list, t);
|
||||||
{
|
t.setChildren(childList);
|
||||||
tlist.add(n);
|
for (SysMenu tChild : childList)
|
||||||
}
|
{
|
||||||
}
|
if (hasChild(list, tChild))
|
||||||
return tlist;
|
{
|
||||||
}
|
recursionFn(list, tChild);
|
||||||
|
}
|
||||||
/**
|
}
|
||||||
* 判断是否有子节点
|
}
|
||||||
*/
|
|
||||||
private boolean hasChild(List<SysMenu> list, SysMenu t)
|
/**
|
||||||
{
|
* 得到子节点列表
|
||||||
return getChildList(list, t).size() > 0 ? true : false;
|
*/
|
||||||
}
|
private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t)
|
||||||
}
|
{
|
||||||
|
List<SysMenu> tlist = new ArrayList<SysMenu>();
|
||||||
|
Iterator<SysMenu> it = list.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
SysMenu n = (SysMenu) it.next();
|
||||||
|
if (n.getParentId().longValue() == t.getMenuId().longValue())
|
||||||
|
{
|
||||||
|
tlist.add(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否有子节点
|
||||||
|
*/
|
||||||
|
private boolean hasChild(List<SysMenu> list, SysMenu t)
|
||||||
|
{
|
||||||
|
return getChildList(list, t).size() > 0 ? true : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -290,8 +290,13 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public int deleteRoleById(Long roleId)
|
public int deleteRoleById(Long roleId)
|
||||||
{
|
{
|
||||||
|
// 删除角色与菜单关联
|
||||||
|
roleMenuMapper.deleteRoleMenuByRoleId(roleId);
|
||||||
|
// 删除角色与部门关联
|
||||||
|
roleDeptMapper.deleteRoleDeptByRoleId(roleId);
|
||||||
return roleMapper.deleteRoleById(roleId);
|
return roleMapper.deleteRoleById(roleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,6 +307,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public int deleteRoleByIds(Long[] roleIds)
|
public int deleteRoleByIds(Long[] roleIds)
|
||||||
{
|
{
|
||||||
for (Long roleId : roleIds)
|
for (Long roleId : roleIds)
|
||||||
@ -313,6 +319,10 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||||||
throw new CustomException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
throw new CustomException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 删除角色与菜单关联
|
||||||
|
roleMenuMapper.deleteRoleMenu(roleIds);
|
||||||
|
// 删除角色与部门关联
|
||||||
|
roleDeptMapper.deleteRoleDept(roleIds);
|
||||||
return roleMapper.deleteRoleByIds(roleIds);
|
return roleMapper.deleteRoleByIds(roleIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -363,6 +363,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public int deleteUserById(Long userId)
|
public int deleteUserById(Long userId)
|
||||||
{
|
{
|
||||||
// 删除用户与角色关联
|
// 删除用户与角色关联
|
||||||
@ -379,12 +380,17 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public int deleteUserByIds(Long[] userIds)
|
public int deleteUserByIds(Long[] userIds)
|
||||||
{
|
{
|
||||||
for (Long userId : userIds)
|
for (Long userId : userIds)
|
||||||
{
|
{
|
||||||
checkUserAllowed(new SysUser(userId));
|
checkUserAllowed(new SysUser(userId));
|
||||||
}
|
}
|
||||||
|
// 删除用户与角色关联
|
||||||
|
userRoleMapper.deleteUserRole(userIds);
|
||||||
|
// 删除用户与岗位关联
|
||||||
|
userPostMapper.deleteUserPost(userIds);
|
||||||
return userMapper.deleteUserByIds(userIds);
|
return userMapper.deleteUserByIds(userIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,11 +50,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="configKey != null and configKey != ''">
|
<if test="configKey != null and configKey != ''">
|
||||||
AND config_key like concat('%', #{configKey}, '%')
|
AND config_key like concat('%', #{configKey}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
and date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
and date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@ -44,12 +44,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
order by d.parent_id, d.order_num
|
order by d.parent_id, d.order_num
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDeptListByRoleId" parameterType="Long" resultType="Integer">
|
<select id="selectDeptListByRoleId" resultType="Integer">
|
||||||
select d.dept_id, d.parent_id
|
select d.dept_id
|
||||||
from sys_dept d
|
from sys_dept d
|
||||||
left join sys_role_dept rd on d.dept_id = rd.dept_id
|
left join sys_role_dept rd on d.dept_id = rd.dept_id
|
||||||
where rd.role_id = #{roleId}
|
where rd.role_id = #{roleId}
|
||||||
and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
|
<if test="deptCheckStrictly">
|
||||||
|
and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
|
||||||
|
</if>
|
||||||
order by d.parent_id, d.order_num
|
order by d.parent_id, d.order_num
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@ -32,11 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="dictType != null and dictType != ''">
|
<if test="dictType != null and dictType != ''">
|
||||||
AND dict_type like concat('%', #{dictType}, '%')
|
AND dict_type like concat('%', #{dictType}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
and date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
and date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@ -33,11 +33,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="userName != null and userName != ''">
|
<if test="userName != null and userName != ''">
|
||||||
AND user_name like concat('%', #{userName}, '%')
|
AND user_name like concat('%', #{userName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
and date_format(login_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
and date_format(login_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
and date_format(login_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
and date_format(login_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by info_id desc
|
order by info_id desc
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
<result property="path" column="path" />
|
<result property="path" column="path" />
|
||||||
<result property="component" column="component" />
|
<result property="component" column="component" />
|
||||||
<result property="isFrame" column="is_frame" />
|
<result property="isFrame" column="is_frame" />
|
||||||
|
<result property="isCache" column="is_cache" />
|
||||||
<result property="menuType" column="menu_type" />
|
<result property="menuType" column="menu_type" />
|
||||||
<result property="visible" column="visible" />
|
<result property="visible" column="visible" />
|
||||||
<result property="status" column="status" />
|
<result property="status" column="status" />
|
||||||
@ -26,7 +27,7 @@
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectMenuVo">
|
<sql id="selectMenuVo">
|
||||||
select menu_id, menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
|
select menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
|
||||||
from sys_menu
|
from sys_menu
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
@ -47,13 +48,13 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMenuTreeAll" resultMap="SysMenuResult">
|
<select id="selectMenuTreeAll" resultMap="SysMenuResult">
|
||||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.menu_type, m.icon, m.order_num, m.create_time
|
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||||
from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0
|
from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0
|
||||||
order by m.parent_id, m.order_num
|
order by m.parent_id, m.order_num
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
|
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
|
||||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.menu_type, m.icon, m.order_num, m.create_time
|
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||||
from sys_menu m
|
from sys_menu m
|
||||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||||
@ -72,7 +73,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
|
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
|
||||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.menu_type, m.icon, m.order_num, m.create_time
|
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||||
from sys_menu m
|
from sys_menu m
|
||||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||||
@ -82,12 +83,14 @@
|
|||||||
order by m.parent_id, m.order_num
|
order by m.parent_id, m.order_num
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMenuListByRoleId" parameterType="Long" resultType="Integer">
|
<select id="selectMenuListByRoleId" resultType="Integer">
|
||||||
select m.menu_id, m.parent_id
|
select m.menu_id
|
||||||
from sys_menu m
|
from sys_menu m
|
||||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||||
where rm.role_id = #{roleId}
|
where rm.role_id = #{roleId}
|
||||||
and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_role_menu rm on m.menu_id = rm.menu_id and rm.role_id = #{roleId})
|
<if test="menuCheckStrictly">
|
||||||
|
and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_role_menu rm on m.menu_id = rm.menu_id and rm.role_id = #{roleId})
|
||||||
|
</if>
|
||||||
order by m.parent_id, m.order_num
|
order by m.parent_id, m.order_num
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -128,8 +131,9 @@
|
|||||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||||
<if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
|
<if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
|
||||||
<if test="path != null and path != ''">path = #{path},</if>
|
<if test="path != null and path != ''">path = #{path},</if>
|
||||||
<if test="component != null and component != ''">component = #{component},</if>
|
<if test="component != null">component = #{component},</if>
|
||||||
<if test="isFrame != null and isFrame != ''">is_frame = #{isFrame},</if>
|
<if test="isFrame != null and isFrame != ''">is_frame = #{isFrame},</if>
|
||||||
|
<if test="isCache != null and isCache != ''">is_cache = #{isCache},</if>
|
||||||
<if test="menuType != null and menuType != ''">menu_type = #{menuType},</if>
|
<if test="menuType != null and menuType != ''">menu_type = #{menuType},</if>
|
||||||
<if test="visible != null">visible = #{visible},</if>
|
<if test="visible != null">visible = #{visible},</if>
|
||||||
<if test="status != null">status = #{status},</if>
|
<if test="status != null">status = #{status},</if>
|
||||||
@ -151,6 +155,7 @@
|
|||||||
<if test="path != null and path != ''">path,</if>
|
<if test="path != null and path != ''">path,</if>
|
||||||
<if test="component != null and component != ''">component,</if>
|
<if test="component != null and component != ''">component,</if>
|
||||||
<if test="isFrame != null and isFrame != ''">is_frame,</if>
|
<if test="isFrame != null and isFrame != ''">is_frame,</if>
|
||||||
|
<if test="isCache != null and isCache != ''">is_cache,</if>
|
||||||
<if test="menuType != null and menuType != ''">menu_type,</if>
|
<if test="menuType != null and menuType != ''">menu_type,</if>
|
||||||
<if test="visible != null">visible,</if>
|
<if test="visible != null">visible,</if>
|
||||||
<if test="status != null">status,</if>
|
<if test="status != null">status,</if>
|
||||||
@ -167,6 +172,7 @@
|
|||||||
<if test="path != null and path != ''">#{path},</if>
|
<if test="path != null and path != ''">#{path},</if>
|
||||||
<if test="component != null and component != ''">#{component},</if>
|
<if test="component != null and component != ''">#{component},</if>
|
||||||
<if test="isFrame != null and isFrame != ''">#{isFrame},</if>
|
<if test="isFrame != null and isFrame != ''">#{isFrame},</if>
|
||||||
|
<if test="isCache != null and isCache != ''">#{isCache},</if>
|
||||||
<if test="menuType != null and menuType != ''">#{menuType},</if>
|
<if test="menuType != null and menuType != ''">#{menuType},</if>
|
||||||
<if test="visible != null">#{visible},</if>
|
<if test="visible != null">#{visible},</if>
|
||||||
<if test="status != null">#{status},</if>
|
<if test="status != null">#{status},</if>
|
||||||
|
|||||||
@ -18,7 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectNoticeVo">
|
<sql id="selectNoticeVo">
|
||||||
select notice_id, notice_title, notice_type, notice_content, status, create_by, create_time, update_by, update_time, remark
|
select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark
|
||||||
from sys_notice
|
from sys_notice
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|||||||
@ -54,11 +54,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="operName != null and operName != ''">
|
<if test="operName != null and operName != ''">
|
||||||
AND oper_name like concat('%', #{operName}, '%')
|
AND oper_name like concat('%', #{operName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
and date_format(oper_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
and date_format(oper_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
and date_format(oper_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
and date_format(oper_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by oper_id desc
|
order by oper_id desc
|
||||||
|
|||||||
@ -5,22 +5,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<mapper namespace="com.ruoyi.system.mapper.SysRoleMapper">
|
<mapper namespace="com.ruoyi.system.mapper.SysRoleMapper">
|
||||||
|
|
||||||
<resultMap type="SysRole" id="SysRoleResult">
|
<resultMap type="SysRole" id="SysRoleResult">
|
||||||
<id property="roleId" column="role_id" />
|
<id property="roleId" column="role_id" />
|
||||||
<result property="roleName" column="role_name" />
|
<result property="roleName" column="role_name" />
|
||||||
<result property="roleKey" column="role_key" />
|
<result property="roleKey" column="role_key" />
|
||||||
<result property="roleSort" column="role_sort" />
|
<result property="roleSort" column="role_sort" />
|
||||||
<result property="dataScope" column="data_scope" />
|
<result property="dataScope" column="data_scope" />
|
||||||
<result property="status" column="status" />
|
<result property="menuCheckStrictly" column="menu_check_strictly" />
|
||||||
<result property="delFlag" column="del_flag" />
|
<result property="deptCheckStrictly" column="dept_check_strictly" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="status" column="status" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="delFlag" column="del_flag" />
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="createTime" column="create_time" />
|
||||||
<result property="remark" column="remark" />
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectRoleVo">
|
<sql id="selectRoleVo">
|
||||||
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope,
|
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
|
||||||
r.status, r.del_flag, r.create_time, r.remark
|
r.status, r.del_flag, r.create_time, r.remark
|
||||||
from sys_role r
|
from sys_role r
|
||||||
left join sys_user_role ur on ur.role_id = r.role_id
|
left join sys_user_role ur on ur.role_id = r.role_id
|
||||||
@ -40,11 +42,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="roleKey != null and roleKey != ''">
|
<if test="roleKey != null and roleKey != ''">
|
||||||
AND r.role_key like concat('%', #{roleKey}, '%')
|
AND r.role_key like concat('%', #{roleKey}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
and date_format(r.create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
and date_format(r.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
and date_format(r.create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
<!-- 数据范围过滤 -->
|
<!-- 数据范围过滤 -->
|
||||||
${params.dataScope}
|
${params.dataScope}
|
||||||
@ -95,6 +97,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="roleKey != null and roleKey != ''">role_key,</if>
|
<if test="roleKey != null and roleKey != ''">role_key,</if>
|
||||||
<if test="roleSort != null and roleSort != ''">role_sort,</if>
|
<if test="roleSort != null and roleSort != ''">role_sort,</if>
|
||||||
<if test="dataScope != null and dataScope != ''">data_scope,</if>
|
<if test="dataScope != null and dataScope != ''">data_scope,</if>
|
||||||
|
<if test="menuCheckStrictly != null">menu_check_strictly,</if>
|
||||||
|
<if test="deptCheckStrictly != null">dept_check_strictly,</if>
|
||||||
<if test="status != null and status != ''">status,</if>
|
<if test="status != null and status != ''">status,</if>
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
@ -105,6 +109,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="roleKey != null and roleKey != ''">#{roleKey},</if>
|
<if test="roleKey != null and roleKey != ''">#{roleKey},</if>
|
||||||
<if test="roleSort != null and roleSort != ''">#{roleSort},</if>
|
<if test="roleSort != null and roleSort != ''">#{roleSort},</if>
|
||||||
<if test="dataScope != null and dataScope != ''">#{dataScope},</if>
|
<if test="dataScope != null and dataScope != ''">#{dataScope},</if>
|
||||||
|
<if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
|
||||||
|
<if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
@ -119,6 +125,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
|
<if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
|
||||||
<if test="roleSort != null and roleSort != ''">role_sort = #{roleSort},</if>
|
<if test="roleSort != null and roleSort != ''">role_sort = #{roleSort},</if>
|
||||||
<if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if>
|
<if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if>
|
||||||
|
<if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
|
||||||
|
<if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
|
||||||
<if test="status != null and status != ''">status = #{status},</if>
|
<if test="status != null and status != ''">status = #{status},</if>
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
@ -127,12 +135,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
where role_id = #{roleId}
|
where role_id = #{roleId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateRoleStatus" parameterType="SysRole">
|
|
||||||
update sys_user set status = #{status} where user_id = #{userId}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteRoleById" parameterType="Long">
|
<delete id="deleteRoleById" parameterType="Long">
|
||||||
delete from sys_role where role_id = #{roleId}
|
update sys_role set del_flag = '2' where role_id = #{roleId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteRoleByIds" parameterType="Long">
|
<delete id="deleteRoleByIds" parameterType="Long">
|
||||||
|
|||||||
@ -17,6 +17,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
delete from sys_role_menu where role_id=#{roleId}
|
delete from sys_role_menu where role_id=#{roleId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteRoleMenu" parameterType="Long">
|
||||||
|
delete from sys_role_menu where role_id in
|
||||||
|
<foreach collection="array" item="roleId" open="(" separator="," close=")">
|
||||||
|
#{roleId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
<insert id="batchRoleMenu">
|
<insert id="batchRoleMenu">
|
||||||
insert into sys_role_menu(role_id, menu_id) values
|
insert into sys_role_menu(role_id, menu_id) values
|
||||||
<foreach item="item" index="index" collection="list" separator=",">
|
<foreach item="item" index="index" collection="list" separator=",">
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user