初始化仓库
This commit is contained in:
parent
91eb41ad57
commit
e08788ac91
|
@ -0,0 +1,44 @@
|
|||
######################################################################
|
||||
# Build Tools
|
||||
|
||||
.gradle
|
||||
/build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
######################################################################
|
||||
# IDE
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/*
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
||||
|
||||
######################################################################
|
||||
# Others
|
||||
*.log
|
||||
*.xml.versionsBackup
|
||||
*.swp
|
||||
|
||||
!*/build/*.java
|
||||
!*/build/*.html
|
||||
!*/build/*.xml
|
|
@ -0,0 +1,86 @@
|
|||
## 平台简介
|
||||
|
||||
若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
|
||||
|
||||
* 前端采用Vue、Element UI。
|
||||
* 后端采用Spring Boot、Spring Security、Redis & Jwt。
|
||||
* 权限认证使用Jwt,支持多终端认证系统。
|
||||
* 支持加载动态权限菜单,多方式轻松权限控制。
|
||||
* 高效率开发,使用代码生成器可以一键生成前后端代码。
|
||||
* 提供了技术栈([Vue3](https://v3.cn.vuejs.org) [Element Plus](https://element-plus.org/zh-CN) [Vite](https://cn.vitejs.dev))版本[RuoYi-Vue3](https://github.com/yangzongzhuan/RuoYi-Vue3),保持同步更新。
|
||||
* 提供了单应用版本[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)
|
||||
* 特别鸣谢:[element](https://github.com/ElemeFE/element),[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin),[eladmin-web](https://github.com/elunez/eladmin-web)。
|
||||
* 阿里云折扣场:[点我进入](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)
|
||||
|
||||
## 内置功能
|
||||
|
||||
1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
|
||||
2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
|
||||
3. 岗位管理:配置系统用户所属担任职务。
|
||||
4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。
|
||||
5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
|
||||
6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
|
||||
7. 参数管理:对系统动态配置常用参数。
|
||||
8. 通知公告:系统通知公告信息发布维护。
|
||||
9. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
|
||||
10. 登录日志:系统登录日志记录查询包含登录异常。
|
||||
11. 在线用户:当前系统中活跃用户状态监控。
|
||||
12. 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。
|
||||
13. 代码生成:前后端代码的生成(java、html、xml、sql)支持CRUD下载 。
|
||||
14. 系统接口:根据业务代码自动生成相关的api接口文档。
|
||||
15. 服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。
|
||||
16. 缓存监控:对系统的缓存信息查询,命令统计等。
|
||||
17. 在线构建器:拖动表单元素生成相应的HTML代码。
|
||||
18. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。
|
||||
|
||||
## 在线体验
|
||||
|
||||
- admin/admin123
|
||||
- 陆陆续续收到一些打赏,为了更好的体验已用于演示服务器升级。谢谢各位小伙伴。
|
||||
|
||||
演示地址:http://vue.ruoyi.vip
|
||||
文档地址:http://doc.ruoyi.vip
|
||||
|
||||
## 演示图
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/cd1f90be5f2684f4560c9519c0f2a232ee8.jpg"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/1cbcf0e6f257c7d3a063c0e3f2ff989e4b3.jpg"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-8074972883b5ba0622e13246738ebba237a.png"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-9f88719cdfca9af2e58b352a20e23d43b12.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-39bf2584ec3a529b0d5a3b70d15c9b37646.png"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-936ec82d1f4872e1bc980927654b6007307.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-b2d62ceb95d2dd9b3fbe157bb70d26001e9.png"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-d67451d308b7a79ad6819723396f7c3d77a.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/5e8c387724954459291aafd5eb52b456f53.jpg"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/644e78da53c2e92a95dfda4f76e6d117c4b.jpg"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-8370a0d02977eebf6dbf854c8450293c937.png"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-49003ed83f60f633e7153609a53a2b644f7.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-d4fe726319ece268d4746602c39cffc0621.png"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-c195234bbcd30be6927f037a6755e6ab69c.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/b6115bc8c31de52951982e509930b20684a.jpg"/></td>
|
||||
<td><img src="https://oscimg.oschina.net/oscnet/up-5e4daac0bb59612c5038448acbcef235e3a.png"/></td>
|
||||
</tr>
|
||||
</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) [](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) 点击按钮入群。
|
|
@ -0,0 +1,12 @@
|
|||
@echo off
|
||||
echo.
|
||||
echo [信息] 清理工程target生成路径。
|
||||
echo.
|
||||
|
||||
%~d0
|
||||
cd %~dp0
|
||||
|
||||
cd ..
|
||||
call mvn clean
|
||||
|
||||
pause
|
|
@ -0,0 +1,12 @@
|
|||
@echo off
|
||||
echo.
|
||||
echo [信息] 打包Web工程,生成war/jar包文件。
|
||||
echo.
|
||||
|
||||
%~d0
|
||||
cd %~dp0
|
||||
|
||||
cd ..
|
||||
call mvn clean package -Dmaven.test.skip=true
|
||||
|
||||
pause
|
|
@ -0,0 +1,14 @@
|
|||
@echo off
|
||||
echo.
|
||||
echo [信息] 使用Jar命令运行Web工程。
|
||||
echo.
|
||||
|
||||
cd %~dp0
|
||||
cd ../ruoyi-admin/target
|
||||
|
||||
set JAVA_OPTS=-Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
|
||||
|
||||
java -jar %JAVA_OPTS% ruoyi-admin.jar
|
||||
|
||||
cd bin
|
||||
pause
|
Binary file not shown.
|
@ -0,0 +1,268 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<version>3.8.0</version>
|
||||
|
||||
<name>ruoyi</name>
|
||||
<url>http://www.ruoyi.vip</url>
|
||||
<description>若依管理系统</description>
|
||||
|
||||
<properties>
|
||||
<ruoyi.version>3.8.0</ruoyi.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||
<druid.version>1.2.8</druid.version>
|
||||
<bitwalker.version>1.21</bitwalker.version>
|
||||
<swagger.version>3.0.0</swagger.version>
|
||||
<kaptcha.version>2.3.2</kaptcha.version>
|
||||
<mybatis-spring-boot.version>2.2.0</mybatis-spring-boot.version>
|
||||
<pagehelper.boot.version>1.4.0</pagehelper.boot.version>
|
||||
<fastjson.version>1.2.78</fastjson.version>
|
||||
<oshi.version>5.8.2</oshi.version>
|
||||
<jna.version>5.9.0</jna.version>
|
||||
<commons.io.version>2.11.0</commons.io.version>
|
||||
<commons.fileupload.version>1.4</commons.fileupload.version>
|
||||
<commons.collections.version>3.2.2</commons.collections.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
<velocity.version>2.3</velocity.version>
|
||||
<jwt.version>0.9.1</jwt.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringBoot的依赖配置-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>2.5.6</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里数据库连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>${druid.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 解析客户端操作系统、浏览器等 -->
|
||||
<dependency>
|
||||
<groupId>eu.bitwalker</groupId>
|
||||
<artifactId>UserAgentUtils</artifactId>
|
||||
<version>${bitwalker.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot集成mybatis框架 -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>${mybatis-spring-boot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- pagehelper 分页插件 -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>${pagehelper.boot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 获取系统信息 -->
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>${oshi.version}</version>
|
||||
</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>
|
||||
|
||||
<!-- Swagger3依赖 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- io常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 文件上传工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${commons.fileupload.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- excel工具 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- velocity代码生成使用模板 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>${velocity.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- collections工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>${commons.collections.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里JSON解析器 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Token生成与解析-->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 验证码 -->
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
<version>${kaptcha.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 定时任务-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-quartz</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 代码生成-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-generator</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-framework</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 系统模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-system</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- cms模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-cms</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<modules>
|
||||
<module>ruoyi-admin</module>
|
||||
<module>ruoyi-framework</module>
|
||||
<module>ruoyi-system</module>
|
||||
<module>ruoyi-quartz</module>
|
||||
<module>ruoyi-generator</module>
|
||||
<module>ruoyi-common</module>
|
||||
<module>ruoyi-cms</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>public</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,102 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.8.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>ruoyi-admin</artifactId>
|
||||
|
||||
<description>
|
||||
web服务入口
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- spring-boot-devtools -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
||||
</dependency>
|
||||
|
||||
<!-- swagger3-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql驱动包 -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 定时任务-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-quartz</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 代码生成-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-generator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- cms模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-cms</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.1.1.RELEASE</version>
|
||||
<configuration>
|
||||
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
<warName>${project.artifactId}</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,30 @@
|
|||
package com.ruoyi;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* 启动程序
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
||||
public class RuoYiApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
SpringApplication.run(RuoYiApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
" | _ _ \\ \\ \\ / / \n" +
|
||||
" | ( ' ) | \\ _. / ' \n" +
|
||||
" |(_ o _) / _( )_ .' \n" +
|
||||
" | (_,_).' __ ___(_ o _)' \n" +
|
||||
" | |\\ \\ | || |(_,_)' \n" +
|
||||
" | | \\ `' /| `-' / \n" +
|
||||
" | | \\ / \\ / \n" +
|
||||
" ''-' `'-' `-..-' ");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.ruoyi;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
/**
|
||||
* web容器中进行部署
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class RuoYiServletInitializer extends SpringBootServletInitializer
|
||||
{
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
|
||||
{
|
||||
return application.sources(RuoYiApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.ruoyi.web.controller.common;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Resource;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.FastByteArrayOutputStream;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.google.code.kaptcha.Producer;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.sign.Base64;
|
||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
|
||||
/**
|
||||
* 验证码操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
public class CaptchaController
|
||||
{
|
||||
@Resource(name = "captchaProducer")
|
||||
private Producer captchaProducer;
|
||||
|
||||
@Resource(name = "captchaProducerMath")
|
||||
private Producer captchaProducerMath;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
/**
|
||||
* 生成验证码
|
||||
*/
|
||||
@GetMapping("/captchaImage")
|
||||
public AjaxResult getCode(HttpServletResponse response) throws IOException
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
||||
ajax.put("captchaOnOff", captchaOnOff);
|
||||
if (!captchaOnOff)
|
||||
{
|
||||
return ajax;
|
||||
}
|
||||
|
||||
// 保存验证码信息
|
||||
String uuid = IdUtils.simpleUUID();
|
||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||
|
||||
String capStr = null, code = null;
|
||||
BufferedImage image = null;
|
||||
|
||||
// 生成验证码
|
||||
String captchaType = RuoYiConfig.getCaptchaType();
|
||||
if ("math".equals(captchaType))
|
||||
{
|
||||
String capText = captchaProducerMath.createText();
|
||||
capStr = capText.substring(0, capText.lastIndexOf("@"));
|
||||
code = capText.substring(capText.lastIndexOf("@") + 1);
|
||||
image = captchaProducerMath.createImage(capStr);
|
||||
}
|
||||
else if ("char".equals(captchaType))
|
||||
{
|
||||
capStr = code = captchaProducer.createText();
|
||||
image = captchaProducer.createImage(capStr);
|
||||
}
|
||||
|
||||
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
||||
// 转换流信息写出
|
||||
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
||||
try
|
||||
{
|
||||
ImageIO.write(image, "jpg", os);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
ajax.put("uuid", uuid);
|
||||
ajax.put("img", Base64.encode(os.toByteArray()));
|
||||
return ajax;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
package com.ruoyi.web.controller.common;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.cms.fileInfo.domain.SysFileInfo;
|
||||
import com.ruoyi.cms.fileInfo.service.ISysFileInfoService;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.unit.DataUnit;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import com.ruoyi.framework.config.ServerConfig;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用请求处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
public class CommonController
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
||||
|
||||
@Autowired
|
||||
private ServerConfig serverConfig;
|
||||
|
||||
@Autowired
|
||||
private ISysFileInfoService sysFileInfoService;
|
||||
|
||||
/**
|
||||
* 通用下载请求
|
||||
*
|
||||
* @param fileName 文件名称
|
||||
* @param delete 是否删除
|
||||
*/
|
||||
@GetMapping("common/download")
|
||||
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!FileUtils.checkAllowDownload(fileName))
|
||||
{
|
||||
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
||||
}
|
||||
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
||||
String filePath = RuoYiConfig.getDownloadPath() + fileName;
|
||||
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
FileUtils.setAttachmentResponseHeader(response, realFileName);
|
||||
FileUtils.writeBytes(filePath, response.getOutputStream());
|
||||
if (delete)
|
||||
{
|
||||
/*2021-12-29 新增文件管理*/
|
||||
SysFileInfo sysFileInfo = new SysFileInfo();
|
||||
sysFileInfo.setFileObjectName(fileName);
|
||||
List<SysFileInfo> sysFileInfos = sysFileInfoService.selectSysFileInfoList(sysFileInfo);
|
||||
sysFileInfos.forEach((SysFileInfo fileInfo)->{
|
||||
sysFileInfoService.deleteSysFileInfoByFileObjectName(fileInfo.getFileObjectName());
|
||||
});
|
||||
/*结束*/
|
||||
FileUtils.deleteFile(filePath);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("下载文件失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用上传请求
|
||||
*/
|
||||
@PostMapping("/common/upload")
|
||||
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
// 上传文件路径
|
||||
String filePath = RuoYiConfig.getUploadPath();
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
String url = serverConfig.getUrl() + fileName;
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("fileName", fileName);
|
||||
ajax.put("url", url);
|
||||
|
||||
/*2021-12-29 新增文件管理*/
|
||||
SysFileInfo sysFileInfo = new SysFileInfo();
|
||||
int newFileNameSeparatorIndex = fileName.lastIndexOf("/");
|
||||
String newFileName = fileName.substring(newFileNameSeparatorIndex + 1).toLowerCase();
|
||||
int separatorIndex = newFileName.lastIndexOf(".");
|
||||
String suffix = newFileName.substring(separatorIndex + 1).toLowerCase();
|
||||
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
|
||||
// 计算文件大小信息
|
||||
long size = file.getSize();
|
||||
String[] unitNames = new String[]{"B", "kB", "MB", "GB", "TB", "EB"};
|
||||
int digitGroups = Math.min(unitNames.length-1, (int) (Math.log10(size) / Math.log10(1024)));
|
||||
String fileSizeInfo = new DecimalFormat("#,##0.##").format(size / Math.pow(1024, digitGroups)) + " " + unitNames[digitGroups];
|
||||
|
||||
sysFileInfo.setFileOriginName(file.getOriginalFilename());
|
||||
sysFileInfo.setFileSuffix(suffix);
|
||||
sysFileInfo.setFileSizeInfo(fileSizeInfo);
|
||||
sysFileInfo.setFileObjectName(newFileName);
|
||||
sysFileInfo.setFilePath(fileName);
|
||||
sysFileInfo.setDelFlag("N");
|
||||
sysFileInfo.setCreateBy(loginUser.getUsername());
|
||||
sysFileInfoService.insertSysFileInfo(sysFileInfo);
|
||||
Long fileId = sysFileInfo.getFileId();
|
||||
ajax.put("fileId", fileId);
|
||||
/*结束*/
|
||||
|
||||
return ajax;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地资源通用下载
|
||||
*/
|
||||
@GetMapping("/common/download/resource")
|
||||
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!FileUtils.checkAllowDownload(resource))
|
||||
{
|
||||
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
|
||||
}
|
||||
// 本地资源路径
|
||||
String localPath = RuoYiConfig.getProfile();
|
||||
// 数据库资源地址
|
||||
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
|
||||
// 下载名称
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.ruoyi.web.controller.monitor;
|
||||
|
||||
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.framework.web.domain.Server;
|
||||
|
||||
/**
|
||||
* 服务器监控
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/server")
|
||||
public class ServerController
|
||||
{
|
||||
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
||||
@GetMapping()
|
||||
public AjaxResult getInfo() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
server.copyTo();
|
||||
return AjaxResult.success(server);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.ruoyi.web.controller.monitor;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.SysLogininfor;
|
||||
import com.ruoyi.system.service.ISysLogininforService;
|
||||
|
||||
/**
|
||||
* 系统访问记录
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/logininfor")
|
||||
public class SysLogininforController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysLogininforService logininforService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysLogininfor logininfor)
|
||||
{
|
||||
startPage();
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysLogininfor logininfor)
|
||||
{
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||
util.exportExcel(response, list, "登录日志");
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] infoIds)
|
||||
{
|
||||
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clean")
|
||||
public AjaxResult clean()
|
||||
{
|
||||
logininforService.cleanLogininfor();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.ruoyi.web.controller.monitor;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.SysOperLog;
|
||||
import com.ruoyi.system.service.ISysOperLogService;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/operlog")
|
||||
public class SysOperlogController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysOperLogService operLogService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysOperLog operLog)
|
||||
{
|
||||
startPage();
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysOperLog operLog)
|
||||
{
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
||||
util.exportExcel(response, list, "操作日志");
|
||||
}
|
||||
|
||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||
@DeleteMapping("/{operIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] operIds)
|
||||
{
|
||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||
}
|
||||
|
||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||
@DeleteMapping("/clean")
|
||||
public AjaxResult clean()
|
||||
{
|
||||
operLogService.cleanOperLog();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package com.ruoyi.web.controller.monitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.SysUserOnline;
|
||||
import com.ruoyi.system.service.ISysUserOnlineService;
|
||||
|
||||
/**
|
||||
* 在线用户监控
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/online")
|
||||
public class SysUserOnlineController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysUserOnlineService userOnlineService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(String ipaddr, String userName)
|
||||
{
|
||||
Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*");
|
||||
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
||||
for (String key : keys)
|
||||
{
|
||||
LoginUser user = redisCache.getCacheObject(key);
|
||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName))
|
||||
{
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername()))
|
||||
{
|
||||
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||
}
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(ipaddr))
|
||||
{
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr()))
|
||||
{
|
||||
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
||||
}
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
|
||||
{
|
||||
if (StringUtils.equals(userName, user.getUsername()))
|
||||
{
|
||||
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
|
||||
}
|
||||
}
|
||||
Collections.reverse(userOnlineList);
|
||||
userOnlineList.removeAll(Collections.singleton(null));
|
||||
return getDataTable(userOnlineList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 强退用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||
@DeleteMapping("/{tokenId}")
|
||||
public AjaxResult forceLogout(@PathVariable String tokenId)
|
||||
{
|
||||
redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.SysConfig;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
|
||||
/**
|
||||
* 参数配置 信息操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/config")
|
||||
public class SysConfigController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
/**
|
||||
* 获取参数配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysConfig config)
|
||||
{
|
||||
startPage();
|
||||
List<SysConfig> list = configService.selectConfigList(config);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysConfig config)
|
||||
{
|
||||
List<SysConfig> list = configService.selectConfigList(config);
|
||||
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
||||
util.exportExcel(response, list, "参数数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:query')")
|
||||
@GetMapping(value = "/{configId}")
|
||||
public AjaxResult getInfo(@PathVariable Long configId)
|
||||
{
|
||||
return AjaxResult.success(configService.selectConfigById(configId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数键名查询参数值
|
||||
*/
|
||||
@GetMapping(value = "/configKey/{configKey}")
|
||||
public AjaxResult getConfigKey(@PathVariable String configKey)
|
||||
{
|
||||
return AjaxResult.success(configService.selectConfigByKey(configKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增参数配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysConfig config)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
||||
{
|
||||
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
config.setCreateBy(getUsername());
|
||||
return toAjax(configService.insertConfig(config));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改参数配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:edit')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysConfig config)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
||||
{
|
||||
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
config.setUpdateBy(getUsername());
|
||||
return toAjax(configService.updateConfig(config));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除参数配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{configIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] configIds)
|
||||
{
|
||||
configService.deleteConfigByIds(configIds);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新参数缓存
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public AjaxResult refreshCache()
|
||||
{
|
||||
configService.resetConfigCache();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
|
||||
/**
|
||||
* 部门信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dept")
|
||||
public class SysDeptController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(SysDept dept)
|
||||
{
|
||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||
return AjaxResult.success(depts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门列表(排除节点)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||
@GetMapping("/list/exclude/{deptId}")
|
||||
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
|
||||
{
|
||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||
Iterator<SysDept> it = depts.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
SysDept d = (SysDept) it.next();
|
||||
if (d.getDeptId().intValue() == deptId
|
||||
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(depts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:query')")
|
||||
@GetMapping(value = "/{deptId}")
|
||||
public AjaxResult getInfo(@PathVariable Long deptId)
|
||||
{
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
return AjaxResult.success(deptService.selectDeptById(deptId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门下拉树列表
|
||||
*/
|
||||
@GetMapping("/treeselect")
|
||||
public AjaxResult treeselect(SysDept dept)
|
||||
{
|
||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载对应角色部门列表树
|
||||
*/
|
||||
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
|
||||
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
|
||||
{
|
||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:add')")
|
||||
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDept dept)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||
{
|
||||
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}
|
||||
dept.setCreateBy(getUsername());
|
||||
return toAjax(deptService.insertDept(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改部门
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
|
||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||
{
|
||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}
|
||||
else if (dept.getParentId().equals(dept.getDeptId()))
|
||||
{
|
||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||
}
|
||||
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
||||
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
|
||||
{
|
||||
return AjaxResult.error("该部门包含未停用的子部门!");
|
||||
}
|
||||
dept.setUpdateBy(getUsername());
|
||||
return toAjax(deptService.updateDept(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
|
||||
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deptId}")
|
||||
public AjaxResult remove(@PathVariable Long deptId)
|
||||
{
|
||||
if (deptService.hasChildByDeptId(deptId))
|
||||
{
|
||||
return AjaxResult.error("存在下级部门,不允许删除");
|
||||
}
|
||||
if (deptService.checkDeptExistUser(deptId))
|
||||
{
|
||||
return AjaxResult.error("部门存在用户,不允许删除");
|
||||
}
|
||||
return toAjax(deptService.deleteDeptById(deptId));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.service.ISysDictDataService;
|
||||
import com.ruoyi.system.service.ISysDictTypeService;
|
||||
|
||||
/**
|
||||
* 数据字典信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dict/data")
|
||||
public class SysDictDataController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysDictDataService dictDataService;
|
||||
|
||||
@Autowired
|
||||
private ISysDictTypeService dictTypeService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDictData dictData)
|
||||
{
|
||||
startPage();
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysDictData dictData)
|
||||
{
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
||||
util.exportExcel(response, list, "字典数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典数据详细
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||
@GetMapping(value = "/{dictCode}")
|
||||
public AjaxResult getInfo(@PathVariable Long dictCode)
|
||||
{
|
||||
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据信息
|
||||
*/
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
public AjaxResult dictType(@PathVariable String dictType)
|
||||
{
|
||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||
if (StringUtils.isNull(data))
|
||||
{
|
||||
data = new ArrayList<SysDictData>();
|
||||
}
|
||||
return AjaxResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDictData dict)
|
||||
{
|
||||
dict.setCreateBy(getUsername());
|
||||
return toAjax(dictDataService.insertDictData(dict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
|
||||
{
|
||||
dict.setUpdateBy(getUsername());
|
||||
return toAjax(dictDataService.updateDictData(dict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictCodes}")
|
||||
public AjaxResult remove(@PathVariable Long[] dictCodes)
|
||||
{
|
||||
dictDataService.deleteDictDataByIds(dictCodes);
|
||||
return success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictType;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.service.ISysDictTypeService;
|
||||
|
||||
/**
|
||||
* 数据字典信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/dict/type")
|
||||
public class SysDictTypeController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysDictTypeService dictTypeService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDictType dictType)
|
||||
{
|
||||
startPage();
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysDictType dictType)
|
||||
{
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
||||
util.exportExcel(response, list, "字典类型");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典类型详细
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||
@GetMapping(value = "/{dictId}")
|
||||
public AjaxResult getInfo(@PathVariable Long dictId)
|
||||
{
|
||||
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDictType dict)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||
{
|
||||
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dict.setCreateBy(getUsername());
|
||||
return toAjax(dictTypeService.insertDictType(dict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||
{
|
||||
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dict.setUpdateBy(getUsername());
|
||||
return toAjax(dictTypeService.updateDictType(dict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] dictIds)
|
||||
{
|
||||
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新字典缓存
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public AjaxResult refreshCache()
|
||||
{
|
||||
dictTypeService.resetDictCache();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect()
|
||||
{
|
||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||
return AjaxResult.success(dictTypes);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
public class SysIndexController
|
||||
{
|
||||
/** 系统基础配置 */
|
||||
@Autowired
|
||||
private RuoYiConfig ruoyiConfig;
|
||||
|
||||
/**
|
||||
* 访问首页,提示语
|
||||
*/
|
||||
@RequestMapping("/")
|
||||
public String index()
|
||||
{
|
||||
return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.SysLoginService;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
public class SysLoginController
|
||||
{
|
||||
@Autowired
|
||||
private SysLoginService loginService;
|
||||
|
||||
@Autowired
|
||||
private ISysMenuService menuService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
* @param loginBody 登录信息
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public AjaxResult login(@RequestBody LoginBody loginBody)
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// 生成令牌
|
||||
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
||||
loginBody.getUuid());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("getInfo")
|
||||
public AjaxResult getInfo()
|
||||
{
|
||||
SysUser user = SecurityUtils.getLoginUser().getUser();
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(user);
|
||||
// 权限集合
|
||||
Set<String> permissions = permissionService.getMenuPermission(user);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", roles);
|
||||
ajax.put("permissions", permissions);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由信息
|
||||
*
|
||||
* @return 路由信息
|
||||
*/
|
||||
@GetMapping("getRouters")
|
||||
public AjaxResult getRouters()
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||
return AjaxResult.success(menuService.buildMenus(menus));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
|
||||
/**
|
||||
* 菜单信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/menu")
|
||||
public class SysMenuController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysMenuService menuService;
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:list')")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(SysMenu menu)
|
||||
{
|
||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||
return AjaxResult.success(menus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据菜单编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:query')")
|
||||
@GetMapping(value = "/{menuId}")
|
||||
public AjaxResult getInfo(@PathVariable Long menuId)
|
||||
{
|
||||
return AjaxResult.success(menuService.selectMenuById(menuId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单下拉树列表
|
||||
*/
|
||||
@GetMapping("/treeselect")
|
||||
public AjaxResult treeselect(SysMenu menu)
|
||||
{
|
||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||
return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载对应角色菜单列表树
|
||||
*/
|
||||
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
|
||||
{
|
||||
List<SysMenu> menus = menuService.selectMenuList(getUserId());
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
||||
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增菜单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:add')")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysMenu menu)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
||||
{
|
||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
}
|
||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
|
||||
{
|
||||
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||
}
|
||||
menu.setCreateBy(getUsername());
|
||||
return toAjax(menuService.insertMenu(menu));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysMenu menu)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
||||
{
|
||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
}
|
||||
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
|
||||
{
|
||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||
}
|
||||
else if (menu.getMenuId().equals(menu.getParentId()))
|
||||
{
|
||||
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
||||
}
|
||||
menu.setUpdateBy(getUsername());
|
||||
return toAjax(menuService.updateMenu(menu));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{menuId}")
|
||||
public AjaxResult remove(@PathVariable("menuId") Long menuId)
|
||||
{
|
||||
if (menuService.hasChildByMenuId(menuId))
|
||||
{
|
||||
return AjaxResult.error("存在子菜单,不允许删除");
|
||||
}
|
||||
if (menuService.checkMenuExistRole(menuId))
|
||||
{
|
||||
return AjaxResult.error("菜单已分配,不允许删除");
|
||||
}
|
||||
return toAjax(menuService.deleteMenuById(menuId));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.system.domain.SysNotice;
|
||||
import com.ruoyi.system.service.ISysNoticeService;
|
||||
|
||||
/**
|
||||
* 公告 信息操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/notice")
|
||||
public class SysNoticeController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysNoticeService noticeService;
|
||||
|
||||
/**
|
||||
* 获取通知公告列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysNotice notice)
|
||||
{
|
||||
startPage();
|
||||
List<SysNotice> list = noticeService.selectNoticeList(notice);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据通知公告编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:query')")
|
||||
@GetMapping(value = "/{noticeId}")
|
||||
public AjaxResult getInfo(@PathVariable Long noticeId)
|
||||
{
|
||||
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增通知公告
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:add')")
|
||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysNotice notice)
|
||||
{
|
||||
notice.setCreateBy(getUsername());
|
||||
Long noticeId = noticeService.insertNotice(notice);
|
||||
if (noticeId==null){
|
||||
return AjaxResult.error();
|
||||
}
|
||||
return AjaxResult.success(noticeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改通知公告
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysNotice notice)
|
||||
{
|
||||
notice.setUpdateBy(getUsername());
|
||||
return toAjax(noticeService.updateNotice(notice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除通知公告
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
||||
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{noticeIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] noticeIds)
|
||||
{
|
||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.domain.SysPost;
|
||||
import com.ruoyi.system.service.ISysPostService;
|
||||
|
||||
/**
|
||||
* 岗位信息操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/post")
|
||||
public class SysPostController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysPostService postService;
|
||||
|
||||
/**
|
||||
* 获取岗位列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysPost post)
|
||||
{
|
||||
startPage();
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysPost post)
|
||||
{
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
||||
util.exportExcel(response, list, "岗位数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据岗位编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:query')")
|
||||
@GetMapping(value = "/{postId}")
|
||||
public AjaxResult getInfo(@PathVariable Long postId)
|
||||
{
|
||||
return AjaxResult.success(postService.selectPostById(postId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增岗位
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:add')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysPost post)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||
{
|
||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||
}
|
||||
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
||||
{
|
||||
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||
}
|
||||
post.setCreateBy(getUsername());
|
||||
return toAjax(postService.insertPost(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改岗位
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:edit')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysPost post)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||
{
|
||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||
}
|
||||
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
||||
{
|
||||
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||
}
|
||||
post.setUpdateBy(getUsername());
|
||||
return toAjax(postService.updatePost(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除岗位
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:remove')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{postIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] postIds)
|
||||
{
|
||||
return toAjax(postService.deletePostByIds(postIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取岗位选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect()
|
||||
{
|
||||
List<SysPost> posts = postService.selectPostAll();
|
||||
return AjaxResult.success(posts);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
|
||||
/**
|
||||
* 个人信息 业务处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/user/profile")
|
||||
public class SysProfileController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
/**
|
||||
* 个人信息
|
||||
*/
|
||||
@GetMapping
|
||||
public AjaxResult profile()
|
||||
{
|
||||
LoginUser loginUser = getLoginUser();
|
||||
SysUser user = loginUser.getUser();
|
||||
AjaxResult ajax = AjaxResult.success(user);
|
||||
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
|
||||
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult updateProfile(@RequestBody SysUser user)
|
||||
{
|
||||
LoginUser loginUser = getLoginUser();
|
||||
SysUser sysUser = loginUser.getUser();
|
||||
user.setUserName(sysUser.getUserName());
|
||||
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() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setUserId(sysUser.getUserId());
|
||||
user.setPassword(null);
|
||||
if (userService.updateUserProfile(user) > 0)
|
||||
{
|
||||
// 更新缓存用户信息
|
||||
sysUser.setNickName(user.getNickName());
|
||||
sysUser.setPhonenumber(user.getPhonenumber());
|
||||
sysUser.setEmail(user.getEmail());
|
||||
sysUser.setSex(user.getSex());
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error("修改个人信息异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updatePwd")
|
||||
public AjaxResult updatePwd(String oldPassword, String newPassword)
|
||||
{
|
||||
LoginUser loginUser = getLoginUser();
|
||||
String userName = loginUser.getUsername();
|
||||
String password = loginUser.getPassword();
|
||||
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
||||
{
|
||||
return AjaxResult.error("修改密码失败,旧密码错误");
|
||||
}
|
||||
if (SecurityUtils.matchesPassword(newPassword, password))
|
||||
{
|
||||
return AjaxResult.error("新密码不能与旧密码相同");
|
||||
}
|
||||
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0)
|
||||
{
|
||||
// 更新缓存用户密码
|
||||
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error("修改密码异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 头像上传
|
||||
*/
|
||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/avatar")
|
||||
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException
|
||||
{
|
||||
if (!file.isEmpty())
|
||||
{
|
||||
LoginUser loginUser = getLoginUser();
|
||||
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
|
||||
/*2021-12-29 新增删除原头像*/
|
||||
String filePath = RuoYiConfig.getProfile() + StringUtils.substringAfter(loginUser.getUser().getAvatar(), Constants.RESOURCE_PREFIX);
|
||||
FileUtils.deleteFile(filePath);
|
||||
/*结束*/
|
||||
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("imgUrl", avatar);
|
||||
// 更新缓存用户头像
|
||||
loginUser.getUser().setAvatar(avatar);
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
return AjaxResult.error("上传图片异常,请联系管理员");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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.model.RegisterBody;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.web.service.SysRegisterService;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
|
||||
/**
|
||||
* 注册验证
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
public class SysRegisterController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private SysRegisterService registerService;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
@PostMapping("/register")
|
||||
public AjaxResult register(@RequestBody RegisterBody user)
|
||||
{
|
||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
|
||||
{
|
||||
return error("当前系统没有开启注册功能!");
|
||||
}
|
||||
String msg = registerService.register(user);
|
||||
return StringUtils.isEmpty(msg) ? success() : error(msg);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,241 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.system.domain.SysUserRole;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/role")
|
||||
public class SysRoleController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysRoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysRole role)
|
||||
{
|
||||
startPage();
|
||||
List<SysRole> list = roleService.selectRoleList(role);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysRole role)
|
||||
{
|
||||
List<SysRole> list = roleService.selectRoleList(role);
|
||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||
util.exportExcel(response, list, "角色数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||
@GetMapping(value = "/{roleId}")
|
||||
public AjaxResult getInfo(@PathVariable Long roleId)
|
||||
{
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return AjaxResult.success(roleService.selectRoleById(roleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:add')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysRole role)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||
{
|
||||
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
}
|
||||
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
||||
{
|
||||
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
role.setCreateBy(getUsername());
|
||||
return toAjax(roleService.insertRole(role));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存角色
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
||||
{
|
||||
roleService.checkRoleAllowed(role);
|
||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||
{
|
||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
}
|
||||
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
||||
{
|
||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}
|
||||
role.setUpdateBy(getUsername());
|
||||
|
||||
if (roleService.updateRole(role) > 0)
|
||||
{
|
||||
// 更新缓存用户权限
|
||||
LoginUser loginUser = getLoginUser();
|
||||
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
|
||||
{
|
||||
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
|
||||
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
||||
tokenService.setLoginUser(loginUser);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存数据权限
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/dataScope")
|
||||
public AjaxResult dataScope(@RequestBody SysRole role)
|
||||
{
|
||||
roleService.checkRoleAllowed(role);
|
||||
return toAjax(roleService.authDataScope(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysRole role)
|
||||
{
|
||||
roleService.checkRoleAllowed(role);
|
||||
role.setUpdateBy(getUsername());
|
||||
return toAjax(roleService.updateRoleStatus(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:remove')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{roleIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] roleIds)
|
||||
{
|
||||
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色选择框列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect()
|
||||
{
|
||||
return AjaxResult.success(roleService.selectRoleAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已分配用户角色列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||
@GetMapping("/authUser/allocatedList")
|
||||
public TableDataInfo allocatedList(SysUser user)
|
||||
{
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectAllocatedList(user);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未分配用户角色列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||
@GetMapping("/authUser/unallocatedList")
|
||||
public TableDataInfo unallocatedList(SysUser user)
|
||||
{
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUnallocatedList(user);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消授权用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancel")
|
||||
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole)
|
||||
{
|
||||
return toAjax(roleService.deleteAuthUser(userRole));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量取消授权用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancelAll")
|
||||
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
|
||||
{
|
||||
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量选择用户授权
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/selectAll")
|
||||
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
|
||||
{
|
||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,232 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.service.ISysPostService;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/user")
|
||||
public class SysUserController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private ISysRoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private ISysPostService postService;
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysUser user)
|
||||
{
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysUser user)
|
||||
{
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
util.exportExcel(response, list, "用户数据");
|
||||
}
|
||||
|
||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:user:import')")
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||
{
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||
String operName = getUsername();
|
||||
String message = userService.importUser(userList, updateSupport, operName);
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response)
|
||||
{
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
util.importTemplateExcel(response, "用户数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
@GetMapping(value = { "/", "/{userId}" })
|
||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
||||
{
|
||||
userService.checkUserDataScope(userId);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
List<SysRole> roles = roleService.selectRoleAll();
|
||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
ajax.put("posts", postService.selectPostAll());
|
||||
if (StringUtils.isNotNull(userId))
|
||||
{
|
||||
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||
ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:add')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysUser user)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName())))
|
||||
{
|
||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||
{
|
||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||
{
|
||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setCreateBy(getUsername());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
return toAjax(userService.insertUser(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||
{
|
||||
userService.checkUserAllowed(user);
|
||||
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||
{
|
||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||
{
|
||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setUpdateBy(getUsername());
|
||||
return toAjax(userService.updateUser(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{userIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] userIds)
|
||||
{
|
||||
if (ArrayUtils.contains(userIds, getUserId()))
|
||||
{
|
||||
return error("当前用户不能删除");
|
||||
}
|
||||
return toAjax(userService.deleteUserByIds(userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/resetPwd")
|
||||
public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||
{
|
||||
userService.checkUserAllowed(user);
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
user.setUpdateBy(getUsername());
|
||||
return toAjax(userService.resetPwd(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysUser user)
|
||||
{
|
||||
userService.checkUserAllowed(user);
|
||||
user.setUpdateBy(getUsername());
|
||||
return toAjax(userService.updateUserStatus(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户编号获取授权角色
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
@GetMapping("/authRole/{userId}")
|
||||
public AjaxResult authRole(@PathVariable("userId") Long userId)
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权角色
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authRole")
|
||||
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
||||
{
|
||||
userService.insertUserAuth(userId, roleIds);
|
||||
return success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.ruoyi.web.controller.tool;
|
||||
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
|
||||
/**
|
||||
* swagger 接口
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/tool/swagger")
|
||||
public class SwaggerController extends BaseController
|
||||
{
|
||||
@PreAuthorize("@ss.hasPermi('tool:swagger:view')")
|
||||
@GetMapping()
|
||||
public String index()
|
||||
{
|
||||
return redirect("/swagger-ui.html");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
package com.ruoyi.web.controller.tool;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
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.utils.StringUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* swagger 用户测试方法
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Api("用户信息管理")
|
||||
@RestController
|
||||
@RequestMapping("/test/user")
|
||||
public class TestController extends BaseController
|
||||
{
|
||||
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
|
||||
{
|
||||
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
|
||||
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户列表")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult userList()
|
||||
{
|
||||
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
||||
return AjaxResult.success(userList);
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户详细")
|
||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
||||
@GetMapping("/{userId}")
|
||||
public AjaxResult getUser(@PathVariable Integer userId)
|
||||
{
|
||||
if (!users.isEmpty() && users.containsKey(userId))
|
||||
{
|
||||
return AjaxResult.success(users.get(userId));
|
||||
}
|
||||
else
|
||||
{
|
||||
return error("用户不存在");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("新增用户")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
|
||||
@ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
|
||||
})
|
||||
@PostMapping("/save")
|
||||
public AjaxResult save(UserEntity user)
|
||||
{
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
||||
{
|
||||
return error("用户ID不能为空");
|
||||
}
|
||||
return AjaxResult.success(users.put(user.getUserId(), user));
|
||||
}
|
||||
|
||||
@ApiOperation("更新用户")
|
||||
@PutMapping("/update")
|
||||
public AjaxResult update(@RequestBody UserEntity user)
|
||||
{
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
||||
{
|
||||
return error("用户ID不能为空");
|
||||
}
|
||||
if (users.isEmpty() || !users.containsKey(user.getUserId()))
|
||||
{
|
||||
return error("用户不存在");
|
||||
}
|
||||
users.remove(user.getUserId());
|
||||
return AjaxResult.success(users.put(user.getUserId(), user));
|
||||
}
|
||||
|
||||
@ApiOperation("删除用户信息")
|
||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
||||
@DeleteMapping("/{userId}")
|
||||
public AjaxResult delete(@PathVariable Integer userId)
|
||||
{
|
||||
if (!users.isEmpty() && users.containsKey(userId))
|
||||
{
|
||||
users.remove(userId);
|
||||
return success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return error("用户不存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ApiModel(value = "UserEntity", description = "用户实体")
|
||||
class UserEntity
|
||||
{
|
||||
@ApiModelProperty("用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty("用户名称")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty("用户密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty("用户手机")
|
||||
private String mobile;
|
||||
|
||||
public UserEntity()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public UserEntity(Integer userId, String username, String password, String mobile)
|
||||
{
|
||||
this.userId = userId;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public Integer getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username)
|
||||
{
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword()
|
||||
{
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password)
|
||||
{
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getMobile()
|
||||
{
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile)
|
||||
{
|
||||
this.mobile = mobile;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package com.ruoyi.web.core.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.models.auth.In;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.ApiKey;
|
||||
import springfox.documentation.service.AuthorizationScope;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.service.SecurityReference;
|
||||
import springfox.documentation.service.SecurityScheme;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
/**
|
||||
* Swagger2的接口配置
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Configuration
|
||||
public class SwaggerConfig
|
||||
{
|
||||
/** 系统基础配置 */
|
||||
@Autowired
|
||||
private RuoYiConfig ruoyiConfig;
|
||||
|
||||
/** 是否开启swagger */
|
||||
@Value("${swagger.enabled}")
|
||||
private boolean enabled;
|
||||
|
||||
/** 设置请求的统一前缀 */
|
||||
@Value("${swagger.pathMapping}")
|
||||
private String pathMapping;
|
||||
|
||||
/**
|
||||
* 创建API
|
||||
*/
|
||||
@Bean
|
||||
public Docket createRestApi()
|
||||
{
|
||||
return new Docket(DocumentationType.OAS_30)
|
||||
// 是否启用Swagger
|
||||
.enable(enabled)
|
||||
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
|
||||
.apiInfo(apiInfo())
|
||||
// 设置哪些接口暴露给Swagger展示
|
||||
.select()
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
// 扫描指定包中的swagger注解
|
||||
// .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
|
||||
// 扫描所有 .apis(RequestHandlerSelectors.any())
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
/* 设置安全模式,swagger可以设置访问token */
|
||||
.securitySchemes(securitySchemes())
|
||||
.securityContexts(securityContexts())
|
||||
.pathMapping(pathMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全模式,这里指定token通过Authorization头请求头传递
|
||||
*/
|
||||
private List<SecurityScheme> securitySchemes()
|
||||
{
|
||||
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
|
||||
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
|
||||
return apiKeyList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全上下文
|
||||
*/
|
||||
private List<SecurityContext> securityContexts()
|
||||
{
|
||||
List<SecurityContext> securityContexts = new ArrayList<>();
|
||||
securityContexts.add(
|
||||
SecurityContext.builder()
|
||||
.securityReferences(defaultAuth())
|
||||
.operationSelector(o -> o.requestMappingPattern().matches("/.*"))
|
||||
.build());
|
||||
return securityContexts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认的安全上引用
|
||||
*/
|
||||
private List<SecurityReference> defaultAuth()
|
||||
{
|
||||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||
authorizationScopes[0] = authorizationScope;
|
||||
List<SecurityReference> securityReferences = new ArrayList<>();
|
||||
securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
|
||||
return securityReferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加摘要信息
|
||||
*/
|
||||
private ApiInfo apiInfo()
|
||||
{
|
||||
// 用ApiInfoBuilder进行定制
|
||||
return new ApiInfoBuilder()
|
||||
// 设置标题
|
||||
.title("标题:若依管理系统_接口文档")
|
||||
// 描述
|
||||
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
|
||||
// 作者信息
|
||||
.contact(new Contact(ruoyiConfig.getName(), null, null))
|
||||
// 版本
|
||||
.version("版本号:" + ruoyiConfig.getVersion())
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
restart.include.json=/com.alibaba.fastjson.*.jar
|
|
@ -0,0 +1,57 @@
|
|||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://localhost:3306/RuoYi-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: 123456
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
enabled: false
|
||||
url:
|
||||
username:
|
||||
password:
|
||||
# 初始连接数
|
||||
initialSize: 5
|
||||
# 最小连接池数量
|
||||
minIdle: 10
|
||||
# 最大连接池数量
|
||||
maxActive: 20
|
||||
# 配置获取连接等待超时的时间
|
||||
maxWait: 60000
|
||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||
maxEvictableIdleTimeMillis: 900000
|
||||
# 配置检测连接是否有效
|
||||
validationQuery: SELECT 1 FROM DUAL
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
webStatFilter:
|
||||
enabled: true
|
||||
statViewServlet:
|
||||
enabled: true
|
||||
# 设置白名单,不填则允许所有访问
|
||||
allow:
|
||||
url-pattern: /druid/*
|
||||
# 控制台管理用户名和密码
|
||||
login-username: ruoyi
|
||||
login-password: 123456
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
# 慢SQL记录
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 1000
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
|
@ -0,0 +1,123 @@
|
|||
# 项目相关配置
|
||||
ruoyi:
|
||||
# 名称
|
||||
name: RuoYi
|
||||
# 版本
|
||||
version: 3.8.0
|
||||
# 版权年份
|
||||
copyrightYear: 2021
|
||||
# 实例演示开关
|
||||
demoEnabled: true
|
||||
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
||||
profile: D:/ruoyi/uploadPath
|
||||
# 获取ip地址开关
|
||||
addressEnabled: false
|
||||
# 验证码类型 math 数组计算 char 字符验证
|
||||
captchaType: math
|
||||
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
port: 8080
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
tomcat:
|
||||
# tomcat的URI编码
|
||||
uri-encoding: UTF-8
|
||||
# 连接数满后的排队数,默认为100
|
||||
accept-count: 1000
|
||||
threads:
|
||||
# tomcat最大线程数,默认为200
|
||||
max: 800
|
||||
# Tomcat启动初始化的线程数,默认值10
|
||||
min-spare: 100
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.ruoyi: debug
|
||||
org.springframework: warn
|
||||
|
||||
# Spring配置
|
||||
spring:
|
||||
# 资源信息
|
||||
messages:
|
||||
# 国际化资源文件路径
|
||||
basename: i18n/messages
|
||||
profiles:
|
||||
active: druid
|
||||
# 文件上传
|
||||
servlet:
|
||||
multipart:
|
||||
# 单个文件大小
|
||||
max-file-size: 10MB
|
||||
# 设置总上传的文件大小
|
||||
max-request-size: 20MB
|
||||
# 服务模块
|
||||
devtools:
|
||||
restart:
|
||||
# 热部署开关
|
||||
enabled: true
|
||||
# redis 配置
|
||||
redis:
|
||||
# 地址
|
||||
host: localhost
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 0
|
||||
# 密码
|
||||
password:
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
lettuce:
|
||||
pool:
|
||||
# 连接池中的最小空闲连接
|
||||
min-idle: 0
|
||||
# 连接池中的最大空闲连接
|
||||
max-idle: 8
|
||||
# 连接池的最大数据库连接数
|
||||
max-active: 8
|
||||
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
max-wait: -1ms
|
||||
|
||||
# token配置
|
||||
token:
|
||||
# 令牌自定义标识
|
||||
header: Authorization
|
||||
# 令牌密钥
|
||||
secret: abcdefghijklmnopqrstuvwxyz
|
||||
# 令牌有效期(默认30分钟)
|
||||
expireTime: 30
|
||||
|
||||
# MyBatis配置
|
||||
mybatis:
|
||||
# 搜索指定包别名
|
||||
typeAliasesPackage: com.ruoyi.**.domain
|
||||
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||
# 加载全局的配置文件
|
||||
configLocation: classpath:mybatis/mybatis-config.xml
|
||||
|
||||
# PageHelper分页插件
|
||||
pagehelper:
|
||||
helperDialect: mysql
|
||||
supportMethodsArguments: true
|
||||
params: count=countSql
|
||||
|
||||
# Swagger配置
|
||||
swagger:
|
||||
# 是否开启swagger
|
||||
enabled: true
|
||||
# 请求前缀
|
||||
pathMapping: /dev-api
|
||||
|
||||
# 防止XSS攻击
|
||||
xss:
|
||||
# 过滤开关
|
||||
enabled: true
|
||||
# 排除链接(多个用逗号分隔)
|
||||
excludes: /system/notice
|
||||
# 匹配链接
|
||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
|
@ -0,0 +1,24 @@
|
|||
Application Version: ${ruoyi.version}
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// _ooOoo_ //
|
||||
// o8888888o //
|
||||
// 88" . "88 //
|
||||
// (| ^_^ |) //
|
||||
// O\ = /O //
|
||||
// ____/`---'\____ //
|
||||
// .' \\| |// `. //
|
||||
// / \\||| : |||// \ //
|
||||
// / _||||| -:- |||||- \ //
|
||||
// | | \\\ - /// | | //
|
||||
// | \_| ''\---/'' | | //
|
||||
// \ .-\__ `-` ___/-. / //
|
||||
// ___`. .' /--.--\ `. . ___ //
|
||||
// ."" '< `.___\_<|>_/___.' >'"". //
|
||||
// | | : `- \`.;`\ _ /`;.`/ - ` : | | //
|
||||
// \ \ `-. \_ __\ /__ _/ .-` / / //
|
||||
// ========`-.____`-.___\_____/___.-`____.-'======== //
|
||||
// `=---=' //
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
|
||||
// 佛祖保佑 永不宕机 永无BUG //
|
||||
////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,37 @@
|
|||
#错误消息
|
||||
not.null=* 必须填写
|
||||
user.jcaptcha.error=验证码错误
|
||||
user.jcaptcha.expire=验证码已失效
|
||||
user.not.exists=用户不存在/密码错误
|
||||
user.password.not.match=用户不存在/密码错误
|
||||
user.password.retry.limit.count=密码输入错误{0}次
|
||||
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定10分钟
|
||||
user.password.delete=对不起,您的账号已被删除
|
||||
user.blocked=用户已封禁,请联系管理员
|
||||
role.blocked=角色已封禁,请联系管理员
|
||||
user.logout.success=退出成功
|
||||
|
||||
length.not.valid=长度必须在{min}到{max}个字符之间
|
||||
|
||||
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头
|
||||
user.password.not.valid=* 5-50个字符
|
||||
|
||||
user.email.not.valid=邮箱格式错误
|
||||
user.mobile.phone.number.not.valid=手机号格式错误
|
||||
user.login.success=登录成功
|
||||
user.register.success=注册成功
|
||||
user.notfound=请重新登录
|
||||
user.forcelogout=管理员强制退出,请重新登录
|
||||
user.unknown.error=未知错误,请重新登录
|
||||
|
||||
##文件上传消息
|
||||
upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB!
|
||||
upload.filename.exceed.length=上传的文件名最长{0}个字符
|
||||
|
||||
##权限
|
||||
no.permission=您没有数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="/home/ruoyi/logs" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/sys-info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/sys-error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 用户访问日志输出 -->
|
||||
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/sys-user.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 按天回滚 daily -->
|
||||
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.ruoyi" level="info" />
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn" />
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info" />
|
||||
<appender-ref ref="file_error" />
|
||||
</root>
|
||||
|
||||
<!--系统用户操作日志-->
|
||||
<logger name="sys-user" level="info">
|
||||
<appender-ref ref="sys-user"/>
|
||||
</logger>
|
||||
</configuration>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
<!-- 全局参数 -->
|
||||
<settings>
|
||||
<!-- 使全局的映射器启用或禁用缓存 -->
|
||||
<setting name="cacheEnabled" value="true" />
|
||||
<!-- 允许JDBC 支持自动生成主键 -->
|
||||
<setting name="useGeneratedKeys" value="true" />
|
||||
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
|
||||
<setting name="defaultExecutorType" value="SIMPLE" />
|
||||
<!-- 指定 MyBatis 所用日志的具体实现 -->
|
||||
<setting name="logImpl" value="SLF4J" />
|
||||
<!-- 使用驼峰命名法转换字段 -->
|
||||
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
|
||||
</settings>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.8.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-cms</artifactId>
|
||||
|
||||
<description>
|
||||
cms
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-framework</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,237 @@
|
|||
package com.ruoyi.cms.blog.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.cms.tag.domain.CmsTag;
|
||||
import com.ruoyi.cms.tag.service.ICmsTagService;
|
||||
import com.ruoyi.cms.type.domain.CmsType;
|
||||
import com.ruoyi.cms.type.service.ICmsTypeService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.cms.blog.domain.CmsBlog;
|
||||
import com.ruoyi.cms.blog.service.ICmsBlogService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
|
||||
/**
|
||||
* 文章管理Controller
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/cms/blog")
|
||||
public class CmsBlogController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICmsBlogService cmsBlogService;
|
||||
|
||||
@Autowired
|
||||
private ICmsTypeService cmsTypeService;
|
||||
|
||||
@Autowired
|
||||
private ICmsTagService cmsTagService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 首页查询文章列表
|
||||
*/
|
||||
@GetMapping("/cms/cmsList")
|
||||
public TableDataInfo cmsList(CmsBlog cmsBlog)
|
||||
{
|
||||
startPage();
|
||||
//状态为发布
|
||||
cmsBlog.setStatus("1");
|
||||
List<CmsBlog> list = cmsBlogService.selectCmsBlogList(cmsBlog);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页获取文章详细信息
|
||||
*/
|
||||
@GetMapping(value = { "/cms/detail/", "/cms/detail/{id}" })
|
||||
public AjaxResult getInfoDetail(@PathVariable(value = "id", required = false) Long id)
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
CmsType cmsType = new CmsType();
|
||||
CmsTag cmsTag = new CmsTag();
|
||||
ajax.put("types", cmsTypeService.selectCmsTypeList(cmsType));
|
||||
ajax.put("tags", cmsTagService.selectCmsTagList(cmsTag));
|
||||
if (StringUtils.isNotNull(id))
|
||||
{
|
||||
ajax.put(AjaxResult.DATA_TAG, cmsBlogService.selectCmsBlogById(id));
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页按分类查询文章列表
|
||||
*/
|
||||
@GetMapping("/cms/cmsListByType/{id}")
|
||||
public TableDataInfo cmsListByTypeId(@PathVariable(value = "id", required = false) Long id)
|
||||
{
|
||||
startPage();
|
||||
List<CmsBlog> list = cmsBlogService.selectCmsBlogListByTypeId(id);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页按标签查询文章列表
|
||||
*/
|
||||
@GetMapping("/cms/cmsListByTag/{id}")
|
||||
public TableDataInfo cmsListByTagId(@PathVariable(value = "id", required = false) Long id)
|
||||
{
|
||||
startPage();
|
||||
List<CmsBlog> list = cmsBlogService.selectCmsBlogListByTagId(id);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页查询推荐文章列表
|
||||
*/
|
||||
@GetMapping("/cms/cmsListRecommend")
|
||||
public TableDataInfo cmsListRecommend(CmsBlog cmsBlog)
|
||||
{
|
||||
startPage();
|
||||
//状态为发布
|
||||
cmsBlog.setStatus("1");
|
||||
List<CmsBlog> list = cmsBlogService.selectCmsBlogListRecommend(cmsBlog);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页增加阅读量
|
||||
*/
|
||||
@GetMapping("/cms/addBlogViews/{id}")
|
||||
public AjaxResult addBlogViews(@PathVariable(value = "id", required = false) Long id)
|
||||
{
|
||||
CmsBlog cmsBlog = cmsBlogService.selectCmsBlogById(id);
|
||||
Long views = cmsBlog.getViews();
|
||||
views+=Long.parseLong("1");
|
||||
cmsBlog.setViews(views);
|
||||
cmsBlogService.updateCmsBlog(cmsBlog);
|
||||
return AjaxResult.success(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 随笔页查询文章列表
|
||||
*/
|
||||
@GetMapping("/cms/cmsEssayList")
|
||||
public TableDataInfo cmsEssayList(CmsBlog cmsBlog)
|
||||
{
|
||||
startPage();
|
||||
//状态为发布
|
||||
cmsBlog.setStatus("1");
|
||||
List<CmsBlog> list = cmsBlogService.selectCmsBlogList(cmsBlog);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文章管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:blog:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CmsBlog cmsBlog)
|
||||
{
|
||||
startPage();
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(getLoginUser().getUser());
|
||||
if (!SecurityUtils.isAdmin(getUserId())&&!roles.contains("admin")&&!roles.contains("cms")){
|
||||
cmsBlog.setCreateBy(getUsername());
|
||||
}
|
||||
List<CmsBlog> list = cmsBlogService.selectCmsBlogList(cmsBlog);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出文章管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:blog:export')")
|
||||
@Log(title = "文章管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CmsBlog cmsBlog)
|
||||
{
|
||||
List<CmsBlog> list = cmsBlogService.selectCmsBlogList(cmsBlog);
|
||||
ExcelUtil<CmsBlog> util = new ExcelUtil<CmsBlog>(CmsBlog.class);
|
||||
util.exportExcel(response, list, "文章管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文章管理详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:blog:query')")
|
||||
@GetMapping(value = { "/", "/{id}" })
|
||||
public AjaxResult getInfo(@PathVariable(value = "id", required = false) Long id)
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
CmsType cmsType = new CmsType();
|
||||
CmsTag cmsTag = new CmsTag();
|
||||
ajax.put("types", cmsTypeService.selectCmsTypeList(cmsType));
|
||||
ajax.put("tags", cmsTagService.selectCmsTagList(cmsTag));
|
||||
if (StringUtils.isNotNull(id))
|
||||
{
|
||||
ajax.put(AjaxResult.DATA_TAG, cmsBlogService.selectCmsBlogById(id));
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增文章管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:blog:add')")
|
||||
@Log(title = "文章管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CmsBlog cmsBlog)
|
||||
{
|
||||
cmsBlog.setCreateBy(getUsername());
|
||||
Long blogId = cmsBlogService.insertCmsBlog(cmsBlog);
|
||||
if (blogId==null){
|
||||
return AjaxResult.error();
|
||||
}
|
||||
return AjaxResult.success(blogId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文章管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:blog:edit')")
|
||||
@Log(title = "文章管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CmsBlog cmsBlog)
|
||||
{
|
||||
cmsBlog.setUpdateBy(getUsername());
|
||||
return toAjax(cmsBlogService.updateCmsBlog(cmsBlog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:blog:remove')")
|
||||
@Log(title = "文章管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(cmsBlogService.deleteCmsBlogByIds(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
package com.ruoyi.cms.blog.domain;
|
||||
|
||||
import com.ruoyi.cms.tag.domain.CmsTag;
|
||||
import com.ruoyi.cms.type.domain.CmsType;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章管理对象 cms_blog
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-01
|
||||
*/
|
||||
public class CmsBlog extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@Excel(name = "标题")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Excel(name = "类型")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 置顶(0否 1是)
|
||||
*/
|
||||
@Excel(name = "置顶", readConverterExp = "0=否,1=是")
|
||||
private String top;
|
||||
|
||||
/**
|
||||
* 阅读
|
||||
*/
|
||||
@Excel(name = "阅读")
|
||||
private Long views;
|
||||
|
||||
/**
|
||||
* 状态(0暂存 1发布)
|
||||
*/
|
||||
@Excel(name = "状态", readConverterExp = "0=暂存,1=发布")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
private Long[] typeIds;
|
||||
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
private Long[] tagIds;
|
||||
|
||||
/** 角色对象 */
|
||||
private List<CmsTag> tags;
|
||||
|
||||
/** 角色对象 */
|
||||
private List<CmsType> types;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setTop(String top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
public String getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public void setViews(Long views) {
|
||||
this.views = views;
|
||||
}
|
||||
|
||||
public Long getViews() {
|
||||
return views;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Long[] getTypeIds() {
|
||||
return typeIds;
|
||||
}
|
||||
|
||||
public void setTypeIds(Long[] typeIds) {
|
||||
this.typeIds = typeIds;
|
||||
}
|
||||
|
||||
public Long[] getTagIds() {
|
||||
return tagIds;
|
||||
}
|
||||
|
||||
public void setTagIds(Long[] tagIds) {
|
||||
this.tagIds = tagIds;
|
||||
}
|
||||
|
||||
public List<CmsTag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(List<CmsTag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public List<CmsType> getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public void setTypes(List<CmsType> types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("title", getTitle())
|
||||
.append("type", getType())
|
||||
.append("content", getContent())
|
||||
.append("top", getTop())
|
||||
.append("views", getViews())
|
||||
.append("status", getStatus())
|
||||
.append("typeIds", getTypeIds())
|
||||
.append("tagIds", getTagIds())
|
||||
.append("tags", getTags())
|
||||
.append("types", getTypes())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.ruoyi.cms.blog.domain;
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈blog标签关联表 cms_blog_tag〉
|
||||
* @Date: 2022/1/2 22:54
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* @Author: WangNing
|
||||
* @Description:〈blog标签关联表 cms_blog_tag〉
|
||||
* @Date: 2022/1/2 22:54
|
||||
**/
|
||||
public class CmsBlogTag {
|
||||
private Long tagId;
|
||||
private Long blogId;
|
||||
private Long[] tagIds;
|
||||
|
||||
public Long getTagId() {
|
||||
return tagId;
|
||||
}
|
||||
|
||||
public void setTagId(Long tagId) {
|
||||
this.tagId = tagId;
|
||||
}
|
||||
|
||||
public Long getBlogId() {
|
||||
return blogId;
|
||||
}
|
||||
|
||||
public void setBlogId(Long blogId) {
|
||||
this.blogId = blogId;
|
||||
}
|
||||
|
||||
public Long[] getTagIds() {
|
||||
return tagIds;
|
||||
}
|
||||
|
||||
public void setTagIds(Long[] tagIds) {
|
||||
this.tagIds = tagIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("tagId", getTagId())
|
||||
.append("blogId", getBlogId())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.ruoyi.cms.blog.domain;
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈blog类型关联表 cms_blog_type〉
|
||||
* @Date: 2022/1/2 23:34
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* @Author: WangNing
|
||||
* @Description:〈blog分类关联表 cms_blog_type〉
|
||||
* @Date: 2022/1/2 23:34
|
||||
**/
|
||||
public class CmsBlogType {
|
||||
private Long typeId;
|
||||
private Long blogId;
|
||||
private Long[] typeIds;
|
||||
|
||||
public Long getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
public void setTypeId(Long typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public Long getBlogId() {
|
||||
return blogId;
|
||||
}
|
||||
|
||||
public void setBlogId(Long blogId) {
|
||||
this.blogId = blogId;
|
||||
}
|
||||
|
||||
public Long[] getTypeIds() {
|
||||
return typeIds;
|
||||
}
|
||||
|
||||
public void setTypeIds(Long[] typeIds) {
|
||||
this.typeIds = typeIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("typeId", getTypeId())
|
||||
.append("blogId", getBlogId())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.ruoyi.cms.blog.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.cms.blog.domain.CmsBlog;
|
||||
|
||||
/**
|
||||
* 文章管理Mapper接口
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-01
|
||||
*/
|
||||
public interface CmsBlogMapper
|
||||
{
|
||||
/**
|
||||
* 查询文章管理
|
||||
*
|
||||
* @param id 文章管理主键
|
||||
* @return 文章管理
|
||||
*/
|
||||
public CmsBlog selectCmsBlogById(Long id);
|
||||
|
||||
/**
|
||||
* 查询文章管理列表
|
||||
*
|
||||
* @param cmsBlog 文章管理
|
||||
* @return 文章管理集合
|
||||
*/
|
||||
public List<CmsBlog> selectCmsBlogList(CmsBlog cmsBlog);
|
||||
|
||||
/**
|
||||
* 查询推荐文章列表
|
||||
*/
|
||||
public List<CmsBlog> selectCmsBlogListRecommend(CmsBlog cmsBlog);
|
||||
|
||||
/**
|
||||
* 按分类查询文章管理列表
|
||||
*/
|
||||
public List<CmsBlog> selectCmsBlogListByTypeId(Long id);
|
||||
|
||||
/**
|
||||
* 按标签查询文章管理列表
|
||||
*/
|
||||
public List<CmsBlog> selectCmsBlogListByTagId(Long id);
|
||||
|
||||
/**
|
||||
* 新增文章管理
|
||||
*
|
||||
* @param cmsBlog 文章管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCmsBlog(CmsBlog cmsBlog);
|
||||
|
||||
/**
|
||||
* 修改文章管理
|
||||
*
|
||||
* @param cmsBlog 文章管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCmsBlog(CmsBlog cmsBlog);
|
||||
|
||||
/**
|
||||
* 删除文章管理
|
||||
*
|
||||
* @param id 文章管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsBlogById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除文章管理
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsBlogByIds(Long[] ids);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.ruoyi.cms.blog.mapper;
|
||||
|
||||
import com.ruoyi.cms.blog.domain.CmsBlogTag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈blog标签关联 数据层〉
|
||||
* @Date: 2022/1/2 23:12
|
||||
*/
|
||||
public interface CmsBlogTagMapper {
|
||||
/**
|
||||
* 批量新增
|
||||
*/
|
||||
public int batchBlogTag(List<CmsBlogTag> blogTagList);
|
||||
/**
|
||||
* 通过blogID删除blog文件关联
|
||||
*/
|
||||
public int deleteBlogTagByBlogId(Long blogId);
|
||||
/**
|
||||
* 批量删除blog文件关联
|
||||
*/
|
||||
public int deleteBlogTag(Long[] ids);
|
||||
/**
|
||||
* 查询文件列表
|
||||
*/
|
||||
public List<CmsBlogTag> selectBlogTagList(Long blogId);
|
||||
/**
|
||||
* 通过tagId删除blog文件关联
|
||||
*/
|
||||
public int deleteBlogTagByTagId(Long tagId);
|
||||
/**
|
||||
* 通过tagId统计blog数量
|
||||
*/
|
||||
public int countBlogByTagId(Long tagId);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.ruoyi.cms.blog.mapper;
|
||||
|
||||
import com.ruoyi.cms.blog.domain.CmsBlogType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈blog分类关联 数据层〉
|
||||
* @Date: 2022/1/2 23:37
|
||||
*/
|
||||
public interface CmsBlogTypeMapper {
|
||||
/**
|
||||
* 批量新增
|
||||
*/
|
||||
public int batchBlogType(List<CmsBlogType> blogTypeList);
|
||||
/**
|
||||
* 通过blogID删除blog文件关联
|
||||
*/
|
||||
public int deleteBlogTypeByBlogId(Long blogId);
|
||||
/**
|
||||
* 批量删除blog文件关联
|
||||
*/
|
||||
public int deleteBlogType(Long[] ids);
|
||||
/**
|
||||
* 查询博客列表
|
||||
*/
|
||||
public List<CmsBlogType> selectBlogTypeList(Long blogId);
|
||||
/**
|
||||
* 通过typeId删除blog文件关联
|
||||
*/
|
||||
public int deleteBlogTypeByTypeId(Long typeId);
|
||||
/**
|
||||
* 通过typeId统计blog数量
|
||||
*/
|
||||
public int countBlogByTypeId(Long typeId);
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.ruoyi.cms.blog.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.cms.blog.domain.CmsBlog;
|
||||
|
||||
/**
|
||||
* 文章管理Service接口
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-01
|
||||
*/
|
||||
public interface ICmsBlogService
|
||||
{
|
||||
/**
|
||||
* 查询文章管理
|
||||
*
|
||||
* @param id 文章管理主键
|
||||
* @return 文章管理
|
||||
*/
|
||||
public CmsBlog selectCmsBlogById(Long id);
|
||||
|
||||
/**
|
||||
* 查询文章管理列表
|
||||
*
|
||||
* @param cmsBlog 文章管理
|
||||
* @return 文章管理集合
|
||||
*/
|
||||
public List<CmsBlog> selectCmsBlogList(CmsBlog cmsBlog);
|
||||
|
||||
/**
|
||||
* 查询推荐文章列表
|
||||
*/
|
||||
public List<CmsBlog> selectCmsBlogListRecommend(CmsBlog cmsBlog);
|
||||
|
||||
/**
|
||||
* 按分类查询文章列表
|
||||
*/
|
||||
public List<CmsBlog> selectCmsBlogListByTypeId(Long id);
|
||||
|
||||
/**
|
||||
* 按标签查询文章列表
|
||||
*/
|
||||
public List<CmsBlog> selectCmsBlogListByTagId(Long id);
|
||||
|
||||
/**
|
||||
* 新增文章管理
|
||||
*
|
||||
* @param cmsBlog 文章管理
|
||||
* @return 结果
|
||||
*/
|
||||
public Long insertCmsBlog(CmsBlog cmsBlog);
|
||||
|
||||
/**
|
||||
* 修改文章管理
|
||||
*
|
||||
* @param cmsBlog 文章管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCmsBlog(CmsBlog cmsBlog);
|
||||
|
||||
/**
|
||||
* 批量删除文章管理
|
||||
*
|
||||
* @param ids 需要删除的文章管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsBlogByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除文章管理信息
|
||||
*
|
||||
* @param id 文章管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsBlogById(Long id);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.ruoyi.cms.blog.service;
|
||||
|
||||
import com.ruoyi.cms.blog.domain.CmsBlogTag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈${DESCRIPTION}〉
|
||||
* @Date: 2022/1/2 23:22
|
||||
*/
|
||||
public interface ICmsBlogTagService {
|
||||
/**
|
||||
* 批量新增
|
||||
*/
|
||||
public int batchBlogTag(List<CmsBlogTag> blogTagList);
|
||||
/**
|
||||
* 通过blogID删除blog标签关联
|
||||
*/
|
||||
public int deleteBlogTagByBlogId(Long blogId);
|
||||
/**
|
||||
* 批量删除blog标签关联
|
||||
*/
|
||||
public int deleteBlogTag(Long[] ids);
|
||||
/**
|
||||
* 查询标签列表
|
||||
*/
|
||||
public List<CmsBlogTag> selectBlogTagList(Long blogId);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.ruoyi.cms.blog.service;
|
||||
|
||||
import com.ruoyi.cms.blog.domain.CmsBlogType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈${DESCRIPTION}〉
|
||||
* @Date: 2022/1/2 23:42
|
||||
*/
|
||||
public interface ICmsBlogTypeService {
|
||||
/**
|
||||
* 批量新增
|
||||
*/
|
||||
public int batchBlogType(List<CmsBlogType> blogTypeList);
|
||||
/**
|
||||
* 通过blogID删除blog分类关联
|
||||
*/
|
||||
public int deleteBlogTypeByBlogId(Long blogId);
|
||||
/**
|
||||
* 批量删除blog分类关联
|
||||
*/
|
||||
public int deleteBlogType(Long[] ids);
|
||||
/**
|
||||
* 查询分类列表
|
||||
*/
|
||||
public List<CmsBlogType> selectBlogTypeList(Long blogId);
|
||||
}
|
|
@ -0,0 +1,270 @@
|
|||
package com.ruoyi.cms.blog.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.cms.blog.domain.CmsBlogTag;
|
||||
import com.ruoyi.cms.blog.domain.CmsBlogType;
|
||||
import com.ruoyi.cms.blog.mapper.CmsBlogTagMapper;
|
||||
import com.ruoyi.cms.blog.mapper.CmsBlogTypeMapper;
|
||||
import com.ruoyi.cms.tag.domain.CmsTag;
|
||||
import com.ruoyi.cms.tag.mapper.CmsTagMapper;
|
||||
import com.ruoyi.cms.type.domain.CmsType;
|
||||
import com.ruoyi.cms.type.mapper.CmsTypeMapper;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.cms.blog.mapper.CmsBlogMapper;
|
||||
import com.ruoyi.cms.blog.domain.CmsBlog;
|
||||
import com.ruoyi.cms.blog.service.ICmsBlogService;
|
||||
|
||||
/**
|
||||
* 文章管理Service业务层处理
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-01
|
||||
*/
|
||||
@Service
|
||||
public class CmsBlogServiceImpl implements ICmsBlogService
|
||||
{
|
||||
@Autowired
|
||||
private CmsBlogMapper cmsBlogMapper;
|
||||
|
||||
@Autowired
|
||||
private CmsBlogTagMapper cmsBlogTagMapper;
|
||||
|
||||
@Autowired
|
||||
private CmsTagMapper cmsTagMapper;
|
||||
|
||||
@Autowired
|
||||
private CmsBlogTypeMapper cmsBlogTypeMapper;
|
||||
|
||||
@Autowired
|
||||
private CmsTypeMapper cmsTypeMapper;
|
||||
|
||||
/**
|
||||
* 查询文章管理
|
||||
*
|
||||
* @param id 文章管理主键
|
||||
* @return 文章管理
|
||||
*/
|
||||
@Override
|
||||
public CmsBlog selectCmsBlogById(Long id)
|
||||
{
|
||||
CmsBlog blog = cmsBlogMapper.selectCmsBlogById(id);
|
||||
//查询标签列表
|
||||
List<CmsBlogTag> blogTagList = cmsBlogTagMapper.selectBlogTagList(id);
|
||||
Long[] tagIds = new Long[blogTagList.size()];
|
||||
List<CmsTag> tags = new ArrayList<>();
|
||||
List<CmsType> types = new ArrayList<>();
|
||||
for (int i = 0; i<blogTagList.size();i++){
|
||||
CmsBlogTag cmsBlogTag = blogTagList.get(i);
|
||||
Long tagId = cmsBlogTag.getTagId();
|
||||
tagIds[i] = tagId;
|
||||
CmsTag cmsTag = cmsTagMapper.selectCmsTagByTagId(tagId);
|
||||
tags.add(cmsTag);
|
||||
}
|
||||
blog.setTagIds(tagIds);
|
||||
blog.setTags(tags);
|
||||
//查询分类列表
|
||||
List<CmsBlogType> blogTypeList = cmsBlogTypeMapper.selectBlogTypeList(id);
|
||||
Long[] typeIds = new Long[blogTypeList.size()];
|
||||
for (int i = 0; i<blogTypeList.size();i++){
|
||||
CmsBlogType cmsBlogType = blogTypeList.get(i);
|
||||
Long typeId = cmsBlogType.getTypeId();
|
||||
typeIds[i] = typeId;
|
||||
CmsType cmsType = cmsTypeMapper.selectCmsTypeByTypeId(typeId);
|
||||
types.add(cmsType);
|
||||
}
|
||||
blog.setTypeIds(typeIds);
|
||||
blog.setTypes(types);
|
||||
return blog;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文章管理列表
|
||||
*
|
||||
* @param cmsBlog 文章管理
|
||||
* @return 文章管理
|
||||
*/
|
||||
@Override
|
||||
public List<CmsBlog> selectCmsBlogList(CmsBlog cmsBlog)
|
||||
{
|
||||
List<CmsBlog> cmsBlogList = cmsBlogMapper.selectCmsBlogList(cmsBlog);
|
||||
List<CmsBlog> blogList = BlogListAddTypeAndTag(cmsBlogList);
|
||||
return blogList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询推荐文章列表
|
||||
*/
|
||||
@Override
|
||||
public List<CmsBlog> selectCmsBlogListRecommend(CmsBlog cmsBlog) {
|
||||
List<CmsBlog> cmsBlogList = cmsBlogMapper.selectCmsBlogListRecommend(cmsBlog);
|
||||
List<CmsBlog> blogList = BlogListAddTypeAndTag(cmsBlogList);
|
||||
return blogList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按分类查询文章列表
|
||||
*/
|
||||
@Override
|
||||
public List<CmsBlog> selectCmsBlogListByTypeId(Long id) {
|
||||
List<CmsBlog> cmsBlogList = cmsBlogMapper.selectCmsBlogListByTypeId(id);
|
||||
List<CmsBlog> blogList = BlogListAddTypeAndTag(cmsBlogList);
|
||||
return blogList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按标签查询文章列表
|
||||
*/
|
||||
@Override
|
||||
public List<CmsBlog> selectCmsBlogListByTagId(Long id) {
|
||||
List<CmsBlog> cmsBlogList = cmsBlogMapper.selectCmsBlogListByTagId(id);
|
||||
List<CmsBlog> blogList = BlogListAddTypeAndTag(cmsBlogList);
|
||||
return blogList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增文章管理
|
||||
*
|
||||
* @param cmsBlog 文章管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public Long insertCmsBlog(CmsBlog cmsBlog)
|
||||
{
|
||||
cmsBlog.setCreateTime(DateUtils.getNowDate());
|
||||
cmsBlogMapper.insertCmsBlog(cmsBlog);
|
||||
Long blogId = cmsBlog.getId();
|
||||
//新增文章标签
|
||||
Long[] tagIds = cmsBlog.getTagIds();
|
||||
if (tagIds!=null&&tagIds.length>0){
|
||||
List<CmsBlogTag> blogTagList = new ArrayList<>();
|
||||
for (Long tagId : tagIds) {
|
||||
CmsBlogTag cmsBlogTag = new CmsBlogTag();
|
||||
cmsBlogTag.setBlogId(blogId);
|
||||
cmsBlogTag.setTagId(tagId);
|
||||
blogTagList.add(cmsBlogTag);
|
||||
}
|
||||
cmsBlogTagMapper.batchBlogTag(blogTagList);
|
||||
}
|
||||
//新增文章分类
|
||||
Long[] typeIds = cmsBlog.getTypeIds();
|
||||
if (typeIds!=null&&typeIds.length>0){
|
||||
List<CmsBlogType> blogTypeList = new ArrayList<>();
|
||||
for (Long typeId : typeIds) {
|
||||
CmsBlogType cmsBlogType = new CmsBlogType();
|
||||
cmsBlogType.setBlogId(blogId);
|
||||
cmsBlogType.setTypeId(typeId);
|
||||
blogTypeList.add(cmsBlogType);
|
||||
}
|
||||
cmsBlogTypeMapper.batchBlogType(blogTypeList);
|
||||
}
|
||||
return blogId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文章管理
|
||||
*
|
||||
* @param cmsBlog 文章管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCmsBlog(CmsBlog cmsBlog)
|
||||
{
|
||||
cmsBlog.setUpdateTime(DateUtils.getNowDate());
|
||||
Long blogId = cmsBlog.getId();
|
||||
//清空文章分类关联
|
||||
cmsBlogTypeMapper.deleteBlogTypeByBlogId(blogId);
|
||||
//清空文章标签关联
|
||||
cmsBlogTagMapper.deleteBlogTagByBlogId(blogId);
|
||||
//新增文章标签
|
||||
Long[] tagIds = cmsBlog.getTagIds();
|
||||
if (tagIds!=null&&tagIds.length>0){
|
||||
List<CmsBlogTag> blogTagList = new ArrayList<>();
|
||||
for (Long tagId : tagIds) {
|
||||
CmsBlogTag cmsBlogTag = new CmsBlogTag();
|
||||
cmsBlogTag.setBlogId(blogId);
|
||||
cmsBlogTag.setTagId(tagId);
|
||||
blogTagList.add(cmsBlogTag);
|
||||
}
|
||||
cmsBlogTagMapper.batchBlogTag(blogTagList);
|
||||
}
|
||||
//新增文章分类
|
||||
Long[] typeIds = cmsBlog.getTypeIds();
|
||||
if (typeIds!=null&&typeIds.length>0){
|
||||
List<CmsBlogType> blogTypeList = new ArrayList<>();
|
||||
for (Long typeId : typeIds) {
|
||||
CmsBlogType cmsBlogType = new CmsBlogType();
|
||||
cmsBlogType.setBlogId(blogId);
|
||||
cmsBlogType.setTypeId(typeId);
|
||||
blogTypeList.add(cmsBlogType);
|
||||
}
|
||||
cmsBlogTypeMapper.batchBlogType(blogTypeList);
|
||||
}
|
||||
return cmsBlogMapper.updateCmsBlog(cmsBlog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除文章管理
|
||||
*
|
||||
* @param ids 需要删除的文章管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCmsBlogByIds(Long[] ids)
|
||||
{
|
||||
for (Long id : ids) {
|
||||
//清空文章分类关联
|
||||
cmsBlogTypeMapper.deleteBlogTypeByBlogId(id);
|
||||
//清空文章标签关联
|
||||
cmsBlogTagMapper.deleteBlogTagByBlogId(id);
|
||||
}
|
||||
return cmsBlogMapper.deleteCmsBlogByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章管理信息
|
||||
*
|
||||
* @param id 文章管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCmsBlogById(Long id)
|
||||
{
|
||||
//清空文章分类关联
|
||||
cmsBlogTypeMapper.deleteBlogTypeByBlogId(id);
|
||||
//清空文章标签关联
|
||||
cmsBlogTagMapper.deleteBlogTagByBlogId(id);
|
||||
return cmsBlogMapper.deleteCmsBlogById(id);
|
||||
}
|
||||
|
||||
private List<CmsBlog> BlogListAddTypeAndTag(List<CmsBlog> cmsBlogList){
|
||||
if (cmsBlogList==null||cmsBlogList.size()<0){
|
||||
return cmsBlogList;
|
||||
}
|
||||
for (CmsBlog blog : cmsBlogList) {
|
||||
Long blogId = blog.getId();
|
||||
//查询标签列表
|
||||
List<CmsBlogTag> blogTagList = cmsBlogTagMapper.selectBlogTagList(blogId);
|
||||
List<CmsTag> cmsTagList = new ArrayList<>();
|
||||
blogTagList.forEach((CmsBlogTag cmsBlogTag)->{
|
||||
Long tagId = cmsBlogTag.getTagId();
|
||||
CmsTag cmsTag = cmsTagMapper.selectCmsTagByTagId(tagId);
|
||||
cmsTagList.add(cmsTag);
|
||||
});
|
||||
blog.setTags(cmsTagList);
|
||||
//查询分类列表
|
||||
List<CmsBlogType> blogTypeList = cmsBlogTypeMapper.selectBlogTypeList(blogId);
|
||||
List<CmsType> cmsTypeList = new ArrayList<>();
|
||||
blogTypeList.forEach((CmsBlogType cmsBlogType)->{
|
||||
Long typeId = cmsBlogType.getTypeId();
|
||||
CmsType cmsType = cmsTypeMapper.selectCmsTypeByTypeId(typeId);
|
||||
cmsTypeList.add(cmsType);
|
||||
});
|
||||
blog.setTypes(cmsTypeList);
|
||||
}
|
||||
return cmsBlogList;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.ruoyi.cms.blog.service.impl;
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈〉
|
||||
* @Date: 2022/1/2 23:24
|
||||
*/
|
||||
|
||||
import com.ruoyi.cms.blog.domain.CmsBlogTag;
|
||||
import com.ruoyi.cms.blog.mapper.CmsBlogTagMapper;
|
||||
import com.ruoyi.cms.blog.service.ICmsBlogTagService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: WangNing
|
||||
* @Description:〈〉
|
||||
* @Date: 2022/1/2 23:24
|
||||
**/
|
||||
@Service
|
||||
public class CmsBlogTagServiceImpl implements ICmsBlogTagService {
|
||||
|
||||
@Autowired
|
||||
CmsBlogTagMapper cmsBlogTagMapper;
|
||||
|
||||
@Override
|
||||
public int batchBlogTag(List<CmsBlogTag> blogTagList) {
|
||||
return cmsBlogTagMapper.batchBlogTag(blogTagList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBlogTagByBlogId(Long blogId) {
|
||||
return cmsBlogTagMapper.deleteBlogTagByBlogId(blogId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBlogTag(Long[] ids) {
|
||||
return cmsBlogTagMapper.deleteBlogTag(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CmsBlogTag> selectBlogTagList(Long blogId) {
|
||||
return cmsBlogTagMapper.selectBlogTagList(blogId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.ruoyi.cms.blog.service.impl;
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈〉
|
||||
* @Date: 2022/1/2 23:44
|
||||
*/
|
||||
|
||||
import com.ruoyi.cms.blog.domain.CmsBlogType;
|
||||
import com.ruoyi.cms.blog.mapper.CmsBlogTypeMapper;
|
||||
import com.ruoyi.cms.blog.service.ICmsBlogTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: WangNing
|
||||
* @Description:〈〉
|
||||
* @Date: 2022/1/2 23:44
|
||||
**/
|
||||
@Service
|
||||
public class CmsBlogTypeServiceImpl implements ICmsBlogTypeService {
|
||||
|
||||
@Autowired
|
||||
CmsBlogTypeMapper cmsBlogTypeMapper;
|
||||
|
||||
@Override
|
||||
public int batchBlogType(List<CmsBlogType> blogTypeList) {
|
||||
return cmsBlogTypeMapper.batchBlogType(blogTypeList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBlogTypeByBlogId(Long blogId) {
|
||||
return cmsBlogTypeMapper.deleteBlogTypeByBlogId(blogId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBlogType(Long[] ids) {
|
||||
return cmsBlogTypeMapper.deleteBlogType(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CmsBlogType> selectBlogTypeList(Long blogId) {
|
||||
return cmsBlogTypeMapper.selectBlogTypeList(blogId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
package com.ruoyi.cms.comment.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.cms.comment.domain.CmsCommentLike;
|
||||
import com.ruoyi.cms.message.domain.CmsMessage;
|
||||
import com.ruoyi.cms.message.domain.CmsMessageLike;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.cms.comment.domain.CmsComment;
|
||||
import com.ruoyi.cms.comment.service.ICmsCommentService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 评论管理Controller
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/cms/comment")
|
||||
public class CmsCommentController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICmsCommentService cmsCommentService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
|
||||
/**
|
||||
* 首页查询评论列表
|
||||
*/
|
||||
@GetMapping("/cms/list")
|
||||
public TableDataInfo cmsList(CmsComment cmsComment)
|
||||
{
|
||||
startPage();
|
||||
List<CmsComment> list = cmsCommentService.selectCommentList(cmsComment);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页新增评论
|
||||
*/
|
||||
@PostMapping("/cms/addComment")
|
||||
public AjaxResult addComment(@RequestBody CmsComment cmsComment)
|
||||
{
|
||||
Long parentId = cmsComment.getParentId();
|
||||
if (parentId!=null){
|
||||
CmsComment comment = cmsCommentService.selectCmsCommentById(parentId);
|
||||
if (comment.getMainId()!=null){
|
||||
cmsComment.setMainId(comment.getMainId());
|
||||
}else {
|
||||
cmsComment.setMainId(parentId);
|
||||
}
|
||||
}
|
||||
return toAjax(cmsCommentService.insertCmsComment(cmsComment));
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页新增点赞
|
||||
*/
|
||||
@PostMapping("/cms/addCmsCommentLike")
|
||||
public AjaxResult addCmsCommentLike(@RequestBody CmsCommentLike cmsCommentLike)
|
||||
{
|
||||
return toAjax(cmsCommentService.addCmsCommentLike(cmsCommentLike));
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页删除点赞
|
||||
*/
|
||||
@Log(title = "删除评论点赞", businessType = BusinessType.DELETE)
|
||||
@PostMapping("/cms/delCmsCommentLike")
|
||||
public AjaxResult delCmsCommentLike(@RequestBody CmsCommentLike cmsCommentLike)
|
||||
{
|
||||
return toAjax(cmsCommentService.delCmsCommentLike(cmsCommentLike));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询评论管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:comment:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CmsComment cmsComment)
|
||||
{
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(getLoginUser().getUser());
|
||||
if (!SecurityUtils.isAdmin(getUserId())&&!roles.contains("admin")&&!roles.contains("cms")){
|
||||
cmsComment.setCreateBy(getUsername());
|
||||
}
|
||||
cmsComment.setDelFlag("0");
|
||||
startPage();
|
||||
List<CmsComment> list = cmsCommentService.selectCmsCommentList(cmsComment);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出评论管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:comment:export')")
|
||||
@Log(title = "评论管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CmsComment cmsComment)
|
||||
{
|
||||
List<CmsComment> list = cmsCommentService.selectCmsCommentList(cmsComment);
|
||||
ExcelUtil<CmsComment> util = new ExcelUtil<CmsComment>(CmsComment.class);
|
||||
util.exportExcel(response, list, "评论管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取评论管理详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:comment:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(cmsCommentService.selectCmsCommentById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增评论管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:comment:add')")
|
||||
@Log(title = "评论管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CmsComment cmsComment)
|
||||
{
|
||||
return toAjax(cmsCommentService.insertCmsComment(cmsComment));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改评论管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:comment:edit')")
|
||||
@Log(title = "评论管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CmsComment cmsComment)
|
||||
{
|
||||
return toAjax(cmsCommentService.updateCmsComment(cmsComment));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评论管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:comment:remove')")
|
||||
@Log(title = "评论管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(cmsCommentService.deleteCmsCommentByIds(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,202 @@
|
|||
package com.ruoyi.cms.comment.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 评论管理对象 cms_comment
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-21
|
||||
*/
|
||||
public class CmsComment extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
|
||||
/** 父评论id */
|
||||
@Excel(name = "父评论id")
|
||||
private Long parentId;
|
||||
|
||||
/** 主评论id(第一级评论) */
|
||||
@Excel(name = "主评论id(第一级评论)")
|
||||
private Long mainId;
|
||||
|
||||
/** 点赞数量 */
|
||||
@Excel(name = "点赞数量")
|
||||
private Long likeNum;
|
||||
|
||||
/** 内容 */
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
/** 评论类型:对人评论,对项目评论,对资源评论 */
|
||||
@Excel(name = "评论类型:对人评论,对项目评论,对资源评论")
|
||||
private String type;
|
||||
|
||||
/** 被评论者id,可以是人、项目、资源 */
|
||||
@Excel(name = "被评论者id,可以是人、项目、资源")
|
||||
private Long blogId;
|
||||
|
||||
/** 删除标志(0代表存在 1代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
/** 评论者id */
|
||||
@Excel(name = "评论者id")
|
||||
private Long userId;
|
||||
|
||||
/** 头像 */
|
||||
private String avatar;
|
||||
|
||||
/** 回复 */
|
||||
private List<CmsComment> children;
|
||||
|
||||
/** 父留言者 */
|
||||
private String pCreateBy;
|
||||
|
||||
/** 点赞 */
|
||||
private boolean isLike;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setParentId(Long parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Long getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
public void setMainId(Long mainId)
|
||||
{
|
||||
this.mainId = mainId;
|
||||
}
|
||||
|
||||
public Long getMainId()
|
||||
{
|
||||
return mainId;
|
||||
}
|
||||
public void setLikeNum(Long likeNum)
|
||||
{
|
||||
this.likeNum = likeNum;
|
||||
}
|
||||
|
||||
public Long getLikeNum()
|
||||
{
|
||||
return likeNum;
|
||||
}
|
||||
public void setContent(String content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
public void setBlogId(Long blogId)
|
||||
{
|
||||
this.blogId = blogId;
|
||||
}
|
||||
|
||||
public Long getBlogId()
|
||||
{
|
||||
return blogId;
|
||||
}
|
||||
public void setDelFlag(String delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
public void setUserId(Long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public List<CmsComment> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<CmsComment> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public String getPCreateBy() {
|
||||
return pCreateBy;
|
||||
}
|
||||
|
||||
public void setPCreateBy(String pCreateBy) {
|
||||
this.pCreateBy = pCreateBy;
|
||||
}
|
||||
|
||||
public boolean getIsLike() {
|
||||
return isLike;
|
||||
}
|
||||
|
||||
public void setIsLike(boolean like) {
|
||||
isLike = like;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("parentId", getParentId())
|
||||
.append("mainId", getMainId())
|
||||
.append("likeNum", getLikeNum())
|
||||
.append("content", getContent())
|
||||
.append("type", getType())
|
||||
.append("blogId", getBlogId())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("userId", getUserId())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("avatar", getAvatar())
|
||||
.append("children", getChildren())
|
||||
.append("pCreateBy", getPCreateBy())
|
||||
.append("isLike", getIsLike())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.ruoyi.cms.comment.domain;
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈評論點贊实体类〉
|
||||
* @Date: 2022/1/22 17:48
|
||||
*/
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* @Author: WangNing
|
||||
* @Description:〈評論點贊实体类〉
|
||||
* @Date: 2022/1/22 17:48
|
||||
**/
|
||||
public class CmsCommentLike extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long commentId;
|
||||
private Long userId;
|
||||
|
||||
/** 点赞数量 */
|
||||
private Long likeNum;
|
||||
|
||||
public Long getCommentId() {
|
||||
return commentId;
|
||||
}
|
||||
|
||||
public void setCommentId(Long commentId) {
|
||||
this.commentId = commentId;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getLikeNum() {
|
||||
return likeNum;
|
||||
}
|
||||
|
||||
public void setLikeNum(Long likeNum) {
|
||||
this.likeNum = likeNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("commentId", getCommentId())
|
||||
.append("userId", getUserId())
|
||||
.append("likeNum", getLikeNum())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.ruoyi.cms.comment.mapper;
|
||||
|
||||
import com.ruoyi.cms.comment.domain.CmsCommentLike;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈${DESCRIPTION}〉
|
||||
* @Date: 2022/1/22 20:08
|
||||
*/
|
||||
public interface CmsCommentLikeMapper {
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
public List<CmsCommentLike> selectCmsCommentLikeList(CmsCommentLike cmsCommentLike);
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public int addCmsCommentLike(CmsCommentLike cmsCommentLike);
|
||||
/**
|
||||
* 删除关联
|
||||
*/
|
||||
public int deleteCmsCommentLike(CmsCommentLike cmsCommentLike);
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.ruoyi.cms.comment.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.cms.comment.domain.CmsComment;
|
||||
import com.ruoyi.cms.message.domain.CmsMessage;
|
||||
|
||||
/**
|
||||
* 评论管理Mapper接口
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-21
|
||||
*/
|
||||
public interface CmsCommentMapper
|
||||
{
|
||||
/**
|
||||
* 查询评论管理
|
||||
*
|
||||
* @param id 评论管理主键
|
||||
* @return 评论管理
|
||||
*/
|
||||
public CmsComment selectCmsCommentById(Long id);
|
||||
|
||||
/**
|
||||
* 查询评论管理列表
|
||||
*
|
||||
* @param cmsComment 评论管理
|
||||
* @return 评论管理集合
|
||||
*/
|
||||
public List<CmsComment> selectCmsCommentList(CmsComment cmsComment);
|
||||
|
||||
/**
|
||||
* 查询子留言列表
|
||||
*/
|
||||
public List<CmsComment> selectChildCommentList(CmsComment cmsComment);
|
||||
|
||||
/**
|
||||
* 新增评论管理
|
||||
*
|
||||
* @param cmsComment 评论管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCmsComment(CmsComment cmsComment);
|
||||
|
||||
/**
|
||||
* 修改评论管理
|
||||
*
|
||||
* @param cmsComment 评论管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCmsComment(CmsComment cmsComment);
|
||||
|
||||
/**
|
||||
* 删除评论管理
|
||||
*
|
||||
* @param id 评论管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsCommentById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除评论管理
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsCommentByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除评论管理
|
||||
*
|
||||
* @param id 评论管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDelFlagById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除评论管理
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDelFlagByIds(Long[] ids);
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.ruoyi.cms.comment.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.cms.comment.domain.CmsComment;
|
||||
import com.ruoyi.cms.comment.domain.CmsCommentLike;
|
||||
import com.ruoyi.cms.message.domain.CmsMessage;
|
||||
import com.ruoyi.cms.message.domain.CmsMessageLike;
|
||||
|
||||
/**
|
||||
* 评论管理Service接口
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-21
|
||||
*/
|
||||
public interface ICmsCommentService
|
||||
{
|
||||
/**
|
||||
* 首页查询留言列表
|
||||
*/
|
||||
public List<CmsComment> selectCommentList(CmsComment cmsComment);
|
||||
|
||||
/**
|
||||
* 首页新增点赞
|
||||
*/
|
||||
public int addCmsCommentLike(CmsCommentLike cmsCommentLike);
|
||||
|
||||
/**
|
||||
* 首页删除点赞
|
||||
*/
|
||||
public int delCmsCommentLike(CmsCommentLike cmsCommentLike);
|
||||
|
||||
/**
|
||||
* 查询评论管理
|
||||
*
|
||||
* @param id 评论管理主键
|
||||
* @return 评论管理
|
||||
*/
|
||||
public CmsComment selectCmsCommentById(Long id);
|
||||
|
||||
/**
|
||||
* 查询评论管理列表
|
||||
*
|
||||
* @param cmsComment 评论管理
|
||||
* @return 评论管理集合
|
||||
*/
|
||||
public List<CmsComment> selectCmsCommentList(CmsComment cmsComment);
|
||||
|
||||
/**
|
||||
* 新增评论管理
|
||||
*
|
||||
* @param cmsComment 评论管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCmsComment(CmsComment cmsComment);
|
||||
|
||||
/**
|
||||
* 修改评论管理
|
||||
*
|
||||
* @param cmsComment 评论管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCmsComment(CmsComment cmsComment);
|
||||
|
||||
/**
|
||||
* 批量删除评论管理
|
||||
*
|
||||
* @param ids 需要删除的评论管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsCommentByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除评论管理信息
|
||||
*
|
||||
* @param id 评论管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsCommentById(Long id);
|
||||
}
|
|
@ -0,0 +1,275 @@
|
|||
package com.ruoyi.cms.comment.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.cms.comment.domain.CmsCommentLike;
|
||||
import com.ruoyi.cms.comment.mapper.CmsCommentLikeMapper;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.cms.comment.mapper.CmsCommentMapper;
|
||||
import com.ruoyi.cms.comment.domain.CmsComment;
|
||||
import com.ruoyi.cms.comment.service.ICmsCommentService;
|
||||
|
||||
/**
|
||||
* 评论管理Service业务层处理
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-21
|
||||
*/
|
||||
@Service
|
||||
public class CmsCommentServiceImpl implements ICmsCommentService
|
||||
{
|
||||
@Autowired
|
||||
private CmsCommentMapper cmsCommentMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Autowired
|
||||
private CmsCommentLikeMapper cmsCommentLikeMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 首页查询评论列表
|
||||
*/
|
||||
@Override
|
||||
public List<CmsComment> selectCommentList(CmsComment cmsComment) {
|
||||
//判断是否登录
|
||||
Long logUserUserId = null;
|
||||
String createBy = cmsComment.getCreateBy();
|
||||
if (createBy!=null&&!"".equals(createBy)){
|
||||
SysUser logUser = sysUserMapper.selectUserByUserName(createBy);
|
||||
logUserUserId = logUser.getUserId();
|
||||
}
|
||||
cmsComment.setCreateBy(null);
|
||||
cmsComment.setType("0");
|
||||
cmsComment.setDelFlag("0");
|
||||
List<CmsComment> cmsCommentList = cmsCommentMapper.selectCmsCommentList(cmsComment);
|
||||
for (CmsComment comment : cmsCommentList) {
|
||||
//添加头像
|
||||
Long userId = comment.getUserId();
|
||||
if (userId!=null){
|
||||
SysUser user = sysUserMapper.selectUserById(userId);
|
||||
comment.setAvatar(user.getAvatar());
|
||||
}
|
||||
//添加是否被点赞
|
||||
if (logUserUserId!=null){
|
||||
CmsCommentLike commentLike = new CmsCommentLike();
|
||||
commentLike.setCommentId(comment.getId());
|
||||
commentLike.setUserId(logUserUserId);
|
||||
List<CmsCommentLike> likeList = cmsCommentLikeMapper.selectCmsCommentLikeList(commentLike);
|
||||
if (likeList.size()>0){
|
||||
comment.setIsLike(true);
|
||||
}else {
|
||||
comment.setIsLike(false);
|
||||
}
|
||||
}
|
||||
//添加子评论(回复)
|
||||
CmsComment childComment = new CmsComment();
|
||||
childComment.setType("1");
|
||||
childComment.setMainId(comment.getId());
|
||||
List<CmsComment> childCommentList = cmsCommentMapper.selectChildCommentList(childComment);
|
||||
if (childCommentList.size()>0){
|
||||
for (CmsComment childListComment : childCommentList) {
|
||||
//添加头像
|
||||
Long childUserId = childListComment.getUserId();
|
||||
if (childUserId!=null){
|
||||
SysUser user = sysUserMapper.selectUserById(childUserId);
|
||||
childListComment.setAvatar(user.getAvatar());
|
||||
}
|
||||
//添加是否被点赞
|
||||
if (logUserUserId!=null){
|
||||
CmsCommentLike commentLike = new CmsCommentLike();
|
||||
commentLike.setCommentId(comment.getId());
|
||||
commentLike.setUserId(logUserUserId);
|
||||
List<CmsCommentLike> likeList = cmsCommentLikeMapper.selectCmsCommentLikeList(commentLike);
|
||||
if (likeList.size()>0){
|
||||
comment.setIsLike(true);
|
||||
}else {
|
||||
comment.setIsLike(false);
|
||||
}
|
||||
}
|
||||
//添加父评论信息
|
||||
CmsComment byId = cmsCommentMapper.selectCmsCommentById(childListComment.getParentId());
|
||||
childListComment.setPCreateBy(byId.getCreateBy());
|
||||
}
|
||||
comment.setChildren(childCommentList);
|
||||
}
|
||||
}
|
||||
return cmsCommentList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addCmsCommentLike(CmsCommentLike cmsCommentLike) {
|
||||
int result = -1;
|
||||
String createBy = cmsCommentLike.getCreateBy();
|
||||
if (!"".equals(createBy)&&createBy!=null){
|
||||
SysUser user = sysUserMapper.selectUserByUserName(createBy);
|
||||
if (user!=null){
|
||||
cmsCommentLike.setUserId(user.getUserId());
|
||||
cmsCommentLikeMapper.addCmsCommentLike(cmsCommentLike);
|
||||
}
|
||||
}
|
||||
//修改点赞数量
|
||||
CmsComment cmsComment = new CmsComment();
|
||||
cmsComment.setId(cmsCommentLike.getCommentId());
|
||||
cmsComment.setLikeNum(cmsCommentLike.getLikeNum());
|
||||
result = cmsCommentMapper.updateCmsComment(cmsComment);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delCmsCommentLike(CmsCommentLike cmsCommentLike) {
|
||||
int result = -1;
|
||||
String createBy = cmsCommentLike.getCreateBy();
|
||||
if (!"".equals(createBy)&&createBy!=null){
|
||||
SysUser user = sysUserMapper.selectUserByUserName(createBy);
|
||||
if (user!=null){
|
||||
cmsCommentLike.setUserId(user.getUserId());
|
||||
cmsCommentLikeMapper.deleteCmsCommentLike(cmsCommentLike);
|
||||
}
|
||||
}
|
||||
//修改点赞数量
|
||||
CmsComment cmsComment = new CmsComment();
|
||||
cmsComment.setId(cmsCommentLike.getCommentId());
|
||||
cmsComment.setLikeNum(cmsCommentLike.getLikeNum());
|
||||
result = cmsCommentMapper.updateCmsComment(cmsComment);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询评论管理
|
||||
*
|
||||
* @param id 评论管理主键
|
||||
* @return 评论管理
|
||||
*/
|
||||
@Override
|
||||
public CmsComment selectCmsCommentById(Long id)
|
||||
{
|
||||
return cmsCommentMapper.selectCmsCommentById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询评论管理列表
|
||||
*
|
||||
* @param cmsComment 评论管理
|
||||
* @return 评论管理
|
||||
*/
|
||||
@Override
|
||||
public List<CmsComment> selectCmsCommentList(CmsComment cmsComment)
|
||||
{
|
||||
List<CmsComment> cmsCommentList = new ArrayList<>();
|
||||
//判断用户权限
|
||||
String createBy = cmsComment.getCreateBy();
|
||||
if (createBy!=null&&!"".equals(createBy)){
|
||||
SysUser user = sysUserMapper.selectUserByUserName(createBy);
|
||||
if (user!=null){
|
||||
List<CmsComment> CommentList = cmsCommentMapper.selectCmsCommentList(cmsComment);
|
||||
for (CmsComment comment : CommentList) {
|
||||
//查询子评论(回复)
|
||||
CmsComment childComment = new CmsComment();
|
||||
childComment.setType("1");
|
||||
childComment.setParentId(comment.getId());
|
||||
List<CmsComment> childCommentList = cmsCommentMapper.selectCmsCommentList(childComment);
|
||||
if (childCommentList.size()>0){
|
||||
cmsCommentList.addAll(childCommentList);
|
||||
}
|
||||
}
|
||||
cmsCommentList.addAll(CommentList);
|
||||
}
|
||||
}else {
|
||||
cmsCommentList = cmsCommentMapper.selectCmsCommentList(cmsComment);
|
||||
}
|
||||
for (CmsComment comment : cmsCommentList) {
|
||||
//添加头像
|
||||
Long userId = comment.getUserId();
|
||||
if (userId!=null){
|
||||
SysUser user = sysUserMapper.selectUserById(userId);
|
||||
comment.setAvatar(user.getAvatar());
|
||||
}
|
||||
//添加父评论信息
|
||||
Long parentId = comment.getParentId();
|
||||
if (parentId!=null){
|
||||
CmsComment parentComment = cmsCommentMapper.selectCmsCommentById(parentId);
|
||||
comment.setPCreateBy(parentComment.getCreateBy());
|
||||
}
|
||||
}
|
||||
//排序
|
||||
// String[] sortNameArr1 = {"createTime"};
|
||||
// //true升序,false降序
|
||||
// boolean[] isAscArr1 = {false};
|
||||
// ListSortUtils.sort(cmsMessageList, sortNameArr1, isAscArr1);
|
||||
// cmsMessageList.sort((a,b)->a.getCreateBy().compareTo(b.getCreateBy()));
|
||||
// Collections.sort(cmsMessageList, new Comparator<CmsMessage>() {
|
||||
// @Override
|
||||
// public int compare(CmsMessage o1, CmsMessage o2) {
|
||||
// //升序
|
||||
// //return o1.getCreateBy().compareTo(o2.getCreateBy());
|
||||
// //降序
|
||||
// return o2.getCreateBy().compareTo(o1.getCreateBy());
|
||||
// }
|
||||
// });
|
||||
return cmsCommentList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增评论管理
|
||||
*
|
||||
* @param cmsComment 评论管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCmsComment(CmsComment cmsComment)
|
||||
{
|
||||
String createBy = cmsComment.getCreateBy();
|
||||
if (createBy!=null&&!"".equals(createBy)){
|
||||
SysUser user = sysUserMapper.selectUserByUserName(createBy);
|
||||
if (user!=null){
|
||||
cmsComment.setUserId(user.getUserId());
|
||||
}
|
||||
}
|
||||
cmsComment.setCreateTime(DateUtils.getNowDate());
|
||||
return cmsCommentMapper.insertCmsComment(cmsComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改评论管理
|
||||
*
|
||||
* @param cmsComment 评论管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCmsComment(CmsComment cmsComment)
|
||||
{
|
||||
cmsComment.setUpdateTime(DateUtils.getNowDate());
|
||||
return cmsCommentMapper.updateCmsComment(cmsComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除评论管理
|
||||
*
|
||||
* @param ids 需要删除的评论管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCmsCommentByIds(Long[] ids)
|
||||
{
|
||||
return cmsCommentMapper.updateDelFlagByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评论管理信息
|
||||
*
|
||||
* @param id 评论管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCmsCommentById(Long id)
|
||||
{
|
||||
return cmsCommentMapper.updateDelFlagById(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.ruoyi.cms.fileInfo.controller;
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈〉
|
||||
* @Date: 2022/1/2 1:05
|
||||
*/
|
||||
|
||||
import com.ruoyi.cms.fileInfo.domain.FileBlogInfo;
|
||||
import com.ruoyi.cms.fileInfo.domain.SysFileInfo;
|
||||
import com.ruoyi.cms.fileInfo.service.IFileBlogInfoService;
|
||||
import com.ruoyi.cms.fileInfo.service.ISysFileInfoService;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: WangNing
|
||||
* @Description:〈〉
|
||||
* @Date: 2022/1/2 1:05
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/fileBlogInfo")
|
||||
public class FileBlogInfoController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IFileBlogInfoService fileBlogInfoService;
|
||||
|
||||
@Autowired
|
||||
private ISysFileInfoService fileInfoService;
|
||||
|
||||
/**
|
||||
* 新增blog文件关联
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:blog:add')")
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody FileBlogInfo fileBlogInfo)
|
||||
{
|
||||
List<FileBlogInfo> fileBlogList = new ArrayList<>();
|
||||
Long blogId = fileBlogInfo.getBlogId();
|
||||
Long[] fileIds = fileBlogInfo.getFileIds();
|
||||
for (Long fileId : fileIds) {
|
||||
FileBlogInfo info = new FileBlogInfo();
|
||||
info.setFileId(fileId);
|
||||
info.setBlogId(blogId);
|
||||
fileBlogList.add(info);
|
||||
}
|
||||
fileBlogInfoService.batchFileBlog(fileBlogList);
|
||||
return toAjax(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除blog文件关联
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:blog:remove')")
|
||||
@DeleteMapping("/{blogIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] blogIds)
|
||||
{
|
||||
for (Long id : blogIds) {
|
||||
List<FileBlogInfo> fileBlogInfos = fileBlogInfoService.selectFileBlogList(id);
|
||||
fileBlogInfos.forEach((FileBlogInfo fileBlogInfo)->{
|
||||
Long fileId = fileBlogInfo.getFileId();
|
||||
fileInfoService.deleteSysFileInfoByFileId(fileId);
|
||||
});
|
||||
}
|
||||
fileBlogInfoService.deleteFileBlog(blogIds);
|
||||
return toAjax(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据blogId获取文件列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:blog:query')")
|
||||
@GetMapping(value = "/{blogId}")
|
||||
public AjaxResult getInfo(@PathVariable Long blogId)
|
||||
{
|
||||
List<SysFileInfo> sysFileInfoList = new ArrayList<>();
|
||||
List<FileBlogInfo> fileBlogInfos = fileBlogInfoService.selectFileBlogList(blogId);
|
||||
fileBlogInfos.forEach((FileBlogInfo fileBlogInfo)->{
|
||||
Long fileId = fileBlogInfo.getFileId();
|
||||
SysFileInfo sysFileInfo = fileInfoService.selectSysFileInfoByFileId(fileId);
|
||||
if (sysFileInfo!=null){
|
||||
sysFileInfoList.add(sysFileInfo);
|
||||
}
|
||||
});
|
||||
return AjaxResult.success(sysFileInfoList);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.ruoyi.cms.fileInfo.controller;
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈〉
|
||||
* @Date: 2022/1/1 0:36
|
||||
*/
|
||||
|
||||
import com.ruoyi.cms.fileInfo.domain.FileNoticeInfo;
|
||||
import com.ruoyi.cms.fileInfo.domain.SysFileInfo;
|
||||
import com.ruoyi.cms.fileInfo.service.IFileNoticeInfoService;
|
||||
import com.ruoyi.cms.fileInfo.service.ISysFileInfoService;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: WangNing
|
||||
* @Description:〈〉
|
||||
* @Date: 2022/1/1 0:36
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/fileNoticeInfo")
|
||||
public class FileNoticeInfoController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IFileNoticeInfoService fileNoticeInfoService;
|
||||
|
||||
@Autowired
|
||||
private ISysFileInfoService fileInfoService;
|
||||
|
||||
/**
|
||||
* 新增通知公告文件
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:add')")
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody FileNoticeInfo fileNoticeInfo)
|
||||
{
|
||||
List<FileNoticeInfo> fileNoticeList = new ArrayList<>();
|
||||
Long noticeId = fileNoticeInfo.getNoticeId();
|
||||
Long[] fileIds = fileNoticeInfo.getFileIds();
|
||||
for (Long fileId : fileIds) {
|
||||
FileNoticeInfo info = new FileNoticeInfo();
|
||||
info.setFileId(fileId);
|
||||
info.setNoticeId(noticeId);
|
||||
fileNoticeList.add(info);
|
||||
}
|
||||
fileNoticeInfoService.batchFileNotice(fileNoticeList);
|
||||
return toAjax(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除通知公告文件
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
||||
@DeleteMapping("/{noticeIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] noticeIds)
|
||||
{
|
||||
for (Long id : noticeIds) {
|
||||
List<FileNoticeInfo> fileNoticeInfos = fileNoticeInfoService.selectFileNoticeList(id);
|
||||
fileNoticeInfos.forEach((FileNoticeInfo fileNoticeInfo)->{
|
||||
Long fileId = fileNoticeInfo.getFileId();
|
||||
fileInfoService.deleteSysFileInfoByFileId(fileId);
|
||||
});
|
||||
}
|
||||
fileNoticeInfoService.deleteFileNotice(noticeIds);
|
||||
return toAjax(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据通知公告编号获取文件列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:query')")
|
||||
@GetMapping(value = "/{noticeId}")
|
||||
public AjaxResult getInfo(@PathVariable Long noticeId)
|
||||
{
|
||||
List<SysFileInfo> sysFileInfoList = new ArrayList<>();
|
||||
List<FileNoticeInfo> fileNoticeInfos = fileNoticeInfoService.selectFileNoticeList(noticeId);
|
||||
fileNoticeInfos.forEach((FileNoticeInfo fileNoticeInfo)->{
|
||||
Long fileId = fileNoticeInfo.getFileId();
|
||||
SysFileInfo sysFileInfo = fileInfoService.selectSysFileInfoByFileId(fileId);
|
||||
if (sysFileInfo!=null){
|
||||
sysFileInfoList.add(sysFileInfo);
|
||||
}
|
||||
});
|
||||
return AjaxResult.success(sysFileInfoList);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package com.ruoyi.cms.fileInfo.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.cms.fileInfo.domain.SysFileInfo;
|
||||
import com.ruoyi.cms.fileInfo.service.ISysFileInfoService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 文件管理Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2021-12-29
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/fileInfo")
|
||||
public class SysFileInfoController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysFileInfoService sysFileInfoService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 查询文件管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:fileInfo:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysFileInfo sysFileInfo)
|
||||
{
|
||||
startPage();
|
||||
//判断用户权限
|
||||
String createBy = sysFileInfo.getCreateBy();
|
||||
if (createBy==null&&"".equals(createBy)){
|
||||
throw new ServiceException("获取列表createBy参数为空");
|
||||
}
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(getLoginUser().getUser());
|
||||
if (SecurityUtils.isAdmin(getUserId())||roles.contains("admin")||roles.contains("cms")){
|
||||
sysFileInfo.setCreateBy("");
|
||||
}
|
||||
List<SysFileInfo> list = sysFileInfoService.selectSysFileInfoList(sysFileInfo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出文件管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:fileInfo:export')")
|
||||
@Log(title = "文件管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysFileInfo sysFileInfo)
|
||||
{
|
||||
List<SysFileInfo> list = sysFileInfoService.selectSysFileInfoList(sysFileInfo);
|
||||
ExcelUtil<SysFileInfo> util = new ExcelUtil<SysFileInfo>(SysFileInfo.class);
|
||||
util.exportExcel(response, list, "文件管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件管理详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:fileInfo:query')")
|
||||
@GetMapping(value = "/{fileId}")
|
||||
public AjaxResult getInfo(@PathVariable("fileId") Long fileId)
|
||||
{
|
||||
return AjaxResult.success(sysFileInfoService.selectSysFileInfoByFileId(fileId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增文件管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:fileInfo:add')")
|
||||
@Log(title = "文件管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysFileInfo sysFileInfo)
|
||||
{
|
||||
return toAjax(sysFileInfoService.insertSysFileInfo(sysFileInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文件管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:fileInfo:edit')")
|
||||
@Log(title = "文件管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysFileInfo sysFileInfo)
|
||||
{
|
||||
return toAjax(sysFileInfoService.updateSysFileInfo(sysFileInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:fileInfo:remove')")
|
||||
@Log(title = "文件管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{fileIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] fileIds)
|
||||
{
|
||||
return toAjax(sysFileInfoService.deleteSysFileInfoByFileIds(fileIds));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.ruoyi.cms.fileInfo.domain;
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈blog文件关联 cms_blog_file〉
|
||||
* @Date: 2022/1/2 0:41
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* @Author: WangNing
|
||||
* @Description:〈blog文件关联 cms_blog_file〉
|
||||
* @Date: 2022/1/2 0:41
|
||||
**/
|
||||
public class FileBlogInfo {
|
||||
private Long fileId;
|
||||
private Long blogId;
|
||||
private Long[] fileIds;
|
||||
|
||||
public Long getFileId() {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
public void setFileId(Long fileId) {
|
||||
this.fileId = fileId;
|
||||
}
|
||||
|
||||
public Long getBlogId() {
|
||||
return blogId;
|
||||
}
|
||||
|
||||
public void setBlogId(Long blogId) {
|
||||
this.blogId = blogId;
|
||||
}
|
||||
|
||||
public Long[] getFileIds() {
|
||||
return fileIds;
|
||||
}
|
||||
|
||||
public void setFileIds(Long[] fileIds) {
|
||||
this.fileIds = fileIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("fileId", getFileId())
|
||||
.append("blogId", getBlogId())
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.ruoyi.cms.fileInfo.domain;
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈通知公告和文件关联 sys_notice_file〉
|
||||
* @Date: 2021/12/31 21:49
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* @Author: WangNing
|
||||
* @Description:〈通知公告和文件关联 sys_notice_file〉
|
||||
* @Date: 2021/12/31 21:49
|
||||
**/
|
||||
public class FileNoticeInfo {
|
||||
private Long fileId;
|
||||
private Long noticeId;
|
||||
private Long[] fileIds;
|
||||
|
||||
public Long getFileId() {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
public void setFileId(Long fileId) {
|
||||
this.fileId = fileId;
|
||||
}
|
||||
|
||||
public Long getNoticeId() {
|
||||
return noticeId;
|
||||
}
|
||||
|
||||
public void setNoticeId(Long noticeId) {
|
||||
this.noticeId = noticeId;
|
||||
}
|
||||
|
||||
public Long[] getFileIds() {
|
||||
return fileIds;
|
||||
}
|
||||
|
||||
public void setFileIds(Long[] fileIds) {
|
||||
this.fileIds = fileIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("fileId", getFileId())
|
||||
.append("roleId", getNoticeId())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package com.ruoyi.cms.fileInfo.domain;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 文件管理对象 sys_file_info
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2021-12-29
|
||||
*/
|
||||
public class SysFileInfo extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 文件主键id */
|
||||
private Long fileId;
|
||||
|
||||
/** 文件名称 */
|
||||
@Excel(name = "文件名称")
|
||||
private String fileOriginName;
|
||||
|
||||
/** 文件类型,例如txt */
|
||||
@Excel(name = "文件类型,例如txt")
|
||||
private String fileSuffix;
|
||||
|
||||
/** 文件大小 */
|
||||
@Excel(name = "文件大小")
|
||||
private String fileSizeInfo;
|
||||
|
||||
/** 存储文件名称 */
|
||||
@Excel(name = "存储文件名称")
|
||||
private String fileObjectName;
|
||||
|
||||
/** 存储路径 */
|
||||
@Excel(name = "存储路径")
|
||||
private String filePath;
|
||||
|
||||
/** 是否删除:Y-被删除,N-未删除 */
|
||||
private String delFlag;
|
||||
|
||||
public void setFileId(Long fileId)
|
||||
{
|
||||
this.fileId = fileId;
|
||||
}
|
||||
|
||||
public Long getFileId()
|
||||
{
|
||||
return fileId;
|
||||
}
|
||||
public void setFileOriginName(String fileOriginName)
|
||||
{
|
||||
this.fileOriginName = fileOriginName;
|
||||
}
|
||||
|
||||
public String getFileOriginName()
|
||||
{
|
||||
return fileOriginName;
|
||||
}
|
||||
public void setFileSuffix(String fileSuffix)
|
||||
{
|
||||
this.fileSuffix = fileSuffix;
|
||||
}
|
||||
|
||||
public String getFileSuffix()
|
||||
{
|
||||
return fileSuffix;
|
||||
}
|
||||
public void setFileSizeInfo(String fileSizeInfo)
|
||||
{
|
||||
this.fileSizeInfo = fileSizeInfo;
|
||||
}
|
||||
|
||||
public String getFileSizeInfo()
|
||||
{
|
||||
return fileSizeInfo;
|
||||
}
|
||||
public void setFileObjectName(String fileObjectName)
|
||||
{
|
||||
this.fileObjectName = fileObjectName;
|
||||
}
|
||||
|
||||
public String getFileObjectName()
|
||||
{
|
||||
return fileObjectName;
|
||||
}
|
||||
public void setFilePath(String filePath)
|
||||
{
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public String getFilePath()
|
||||
{
|
||||
return filePath;
|
||||
}
|
||||
public void setDelFlag(String delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("fileId", getFileId())
|
||||
.append("fileOriginName", getFileOriginName())
|
||||
.append("fileSuffix", getFileSuffix())
|
||||
.append("fileSizeInfo", getFileSizeInfo())
|
||||
.append("fileObjectName", getFileObjectName())
|
||||
.append("filePath", getFilePath())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.ruoyi.cms.fileInfo.mapper;
|
||||
|
||||
import com.ruoyi.cms.fileInfo.domain.FileBlogInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈blog文件关联 数据层〉
|
||||
* @Date: 2022/1/2 0:48
|
||||
*/
|
||||
public interface FileBlogInfoMapper {
|
||||
/**
|
||||
* 批量新增
|
||||
*/
|
||||
public int batchFileBlog(List<FileBlogInfo> fileBlogList);
|
||||
/**
|
||||
* 通过blogID删除blog文件关联
|
||||
*/
|
||||
public int deleteFileBlogByBlogId(Long blogId);
|
||||
/**
|
||||
* 批量删除blog文件关联
|
||||
*/
|
||||
public int deleteFileBlog(Long[] ids);
|
||||
/**
|
||||
* 查询文件列表
|
||||
*/
|
||||
public List<FileBlogInfo> selectFileBlogList(Long blogId);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.ruoyi.cms.fileInfo.mapper;
|
||||
|
||||
import com.ruoyi.cms.fileInfo.domain.FileNoticeInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈通知公告和文件关联 数据层〉
|
||||
* @Date: 2021/12/31 22:24
|
||||
*/
|
||||
public interface FileNoticeInfoMapper {
|
||||
/**
|
||||
* 批量新增
|
||||
*/
|
||||
public int batchFileNotice(List<FileNoticeInfo> userRoleList);
|
||||
/**
|
||||
* 通过通知公告ID删除通知公告和文件关联
|
||||
*/
|
||||
public int deleteFileNoticeByNoticeId(Long noticeId);
|
||||
/**
|
||||
* 批量删除通知公告和文件关联
|
||||
*/
|
||||
public int deleteFileNotice(Long[] ids);
|
||||
/**
|
||||
* 查询文件列表
|
||||
*/
|
||||
public List<FileNoticeInfo> selectFileNoticeList(Long noticeId);
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.ruoyi.cms.fileInfo.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.cms.fileInfo.domain.SysFileInfo;
|
||||
|
||||
/**
|
||||
* 文件管理Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2021-12-29
|
||||
*/
|
||||
public interface SysFileInfoMapper
|
||||
{
|
||||
/**
|
||||
* 查询文件管理
|
||||
*
|
||||
* @param fileObjectName
|
||||
* @return 文件管理
|
||||
*/
|
||||
public SysFileInfo selectSysFileInfoByFileObjectName(String fileObjectName);
|
||||
|
||||
/**
|
||||
* 查询文件管理
|
||||
*
|
||||
* @param fileId 文件管理主键
|
||||
* @return 文件管理
|
||||
*/
|
||||
public SysFileInfo selectSysFileInfoByFileId(Long fileId);
|
||||
|
||||
/**
|
||||
* 查询文件管理列表
|
||||
*
|
||||
* @param sysFileInfo 文件管理
|
||||
* @return 文件管理集合
|
||||
*/
|
||||
public List<SysFileInfo> selectSysFileInfoList(SysFileInfo sysFileInfo);
|
||||
|
||||
/**
|
||||
* 新增文件管理
|
||||
*
|
||||
* @param sysFileInfo 文件管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysFileInfo(SysFileInfo sysFileInfo);
|
||||
|
||||
/**
|
||||
* 修改文件管理
|
||||
*
|
||||
* @param sysFileInfo 文件管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysFileInfo(SysFileInfo sysFileInfo);
|
||||
|
||||
/**
|
||||
* 删除文件管理
|
||||
*
|
||||
* @param fileId 文件管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysFileInfoByFileId(Long fileId);
|
||||
|
||||
/**
|
||||
* 批量删除文件管理
|
||||
*
|
||||
* @param fileIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysFileInfoByFileIds(Long[] fileIds);
|
||||
|
||||
/**
|
||||
* 删除文件管理信息
|
||||
*
|
||||
* @param fileObjectName
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysFileInfoByFileObjectName(String fileObjectName);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.ruoyi.cms.fileInfo.service;
|
||||
|
||||
import com.ruoyi.cms.fileInfo.domain.FileBlogInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈${DESCRIPTION}〉
|
||||
* @Date: 2022/1/2 0:58
|
||||
*/
|
||||
public interface IFileBlogInfoService {
|
||||
/**
|
||||
* 批量新增
|
||||
*/
|
||||
public int batchFileBlog(List<FileBlogInfo> fileBlogList);
|
||||
/**
|
||||
* 通过通知公告ID删除通知公告和文件关联
|
||||
*/
|
||||
public int deleteFileBlogByBlogId(Long blogId);
|
||||
/**
|
||||
* 批量删除通知公告和文件关联
|
||||
*/
|
||||
public int deleteFileBlog(Long[] ids);
|
||||
/**
|
||||
* 查询文件列表
|
||||
*/
|
||||
public List<FileBlogInfo> selectFileBlogList(Long blogId);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.ruoyi.cms.fileInfo.service;
|
||||
|
||||
import com.ruoyi.cms.fileInfo.domain.FileNoticeInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈Service接口〉
|
||||
* @Date: 2021/12/31 23:24
|
||||
*/
|
||||
public interface IFileNoticeInfoService {
|
||||
/**
|
||||
* 批量新增
|
||||
*/
|
||||
public int batchFileNotice(List<FileNoticeInfo> fileNoticeList);
|
||||
/**
|
||||
* 通过通知公告ID删除通知公告和文件关联
|
||||
*/
|
||||
public int deleteFileNoticeByNoticeId(Long noticeId);
|
||||
/**
|
||||
* 批量删除通知公告和文件关联
|
||||
*/
|
||||
public int deleteFileNotice(Long[] ids);
|
||||
/**
|
||||
* 查询文件列表
|
||||
*/
|
||||
public List<FileNoticeInfo> selectFileNoticeList(Long noticeId);
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.ruoyi.cms.fileInfo.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.cms.fileInfo.domain.SysFileInfo;
|
||||
|
||||
/**
|
||||
* 文件管理Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2021-12-29
|
||||
*/
|
||||
public interface ISysFileInfoService
|
||||
{
|
||||
/**
|
||||
* 查询文件管理
|
||||
*
|
||||
* @param fileObjectName
|
||||
* @return 文件管理
|
||||
*/
|
||||
public SysFileInfo selectSysFileInfoByFileObjectName(String fileObjectName);
|
||||
/**
|
||||
* 查询文件管理
|
||||
*
|
||||
* @param fileId 文件管理主键
|
||||
* @return 文件管理
|
||||
*/
|
||||
public SysFileInfo selectSysFileInfoByFileId(Long fileId);
|
||||
|
||||
/**
|
||||
* 查询文件管理列表
|
||||
*
|
||||
* @param sysFileInfo 文件管理
|
||||
* @return 文件管理集合
|
||||
*/
|
||||
public List<SysFileInfo> selectSysFileInfoList(SysFileInfo sysFileInfo);
|
||||
|
||||
/**
|
||||
* 新增文件管理
|
||||
*
|
||||
* @param sysFileInfo 文件管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysFileInfo(SysFileInfo sysFileInfo);
|
||||
|
||||
/**
|
||||
* 修改文件管理
|
||||
*
|
||||
* @param sysFileInfo 文件管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysFileInfo(SysFileInfo sysFileInfo);
|
||||
|
||||
/**
|
||||
* 批量删除文件管理
|
||||
*
|
||||
* @param fileIds 需要删除的文件管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysFileInfoByFileIds(Long[] fileIds);
|
||||
|
||||
/**
|
||||
* 删除文件管理信息
|
||||
*
|
||||
* @param fileId 文件管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysFileInfoByFileId(Long fileId);
|
||||
|
||||
/**
|
||||
* 删除文件管理信息
|
||||
*
|
||||
* @param fileObjectName
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysFileInfoByFileObjectName(String fileObjectName);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.ruoyi.cms.fileInfo.service.impl;
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈〉
|
||||
* @Date: 2022/1/2 1:00
|
||||
*/
|
||||
|
||||
import com.ruoyi.cms.fileInfo.domain.FileBlogInfo;
|
||||
import com.ruoyi.cms.fileInfo.mapper.FileBlogInfoMapper;
|
||||
import com.ruoyi.cms.fileInfo.service.IFileBlogInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: WangNing
|
||||
* @Description:〈〉
|
||||
* @Date: 2022/1/2 1:00
|
||||
**/
|
||||
@Service
|
||||
public class FileBlogInfoServiceImpl implements IFileBlogInfoService {
|
||||
|
||||
@Autowired
|
||||
private FileBlogInfoMapper fileBlogInfoMapper;
|
||||
|
||||
@Override
|
||||
public int batchFileBlog(List<FileBlogInfo> fileBlogList) {
|
||||
return fileBlogInfoMapper.batchFileBlog(fileBlogList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteFileBlogByBlogId(Long blogId) {
|
||||
return fileBlogInfoMapper.deleteFileBlogByBlogId(blogId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteFileBlog(Long[] ids) {
|
||||
return fileBlogInfoMapper.deleteFileBlog(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileBlogInfo> selectFileBlogList(Long blogId) {
|
||||
return fileBlogInfoMapper.selectFileBlogList(blogId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.ruoyi.cms.fileInfo.service.impl;
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈〉
|
||||
* @Date: 2021/12/31 23:33
|
||||
*/
|
||||
|
||||
import com.ruoyi.cms.fileInfo.domain.FileNoticeInfo;
|
||||
import com.ruoyi.cms.fileInfo.domain.SysFileInfo;
|
||||
import com.ruoyi.cms.fileInfo.mapper.FileNoticeInfoMapper;
|
||||
import com.ruoyi.cms.fileInfo.mapper.SysFileInfoMapper;
|
||||
import com.ruoyi.cms.fileInfo.service.IFileNoticeInfoService;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: WangNing
|
||||
* @Description:〈〉
|
||||
* @Date: 2021/12/31 23:33
|
||||
**/
|
||||
@Service
|
||||
public class FileNoticeInfoServiceImpl implements IFileNoticeInfoService {
|
||||
|
||||
@Autowired
|
||||
private FileNoticeInfoMapper fileNoticeInfoMapper;
|
||||
|
||||
@Override
|
||||
public int batchFileNotice(List<FileNoticeInfo> fileNoticeList) {
|
||||
return fileNoticeInfoMapper.batchFileNotice(fileNoticeList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteFileNoticeByNoticeId(Long noticeId) {
|
||||
return fileNoticeInfoMapper.deleteFileNoticeByNoticeId(noticeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteFileNotice(Long[] ids) {
|
||||
return fileNoticeInfoMapper.deleteFileNotice(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileNoticeInfo> selectFileNoticeList(Long noticeId) {
|
||||
return fileNoticeInfoMapper.selectFileNoticeList(noticeId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package com.ruoyi.cms.fileInfo.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.cms.fileInfo.mapper.SysFileInfoMapper;
|
||||
import com.ruoyi.cms.fileInfo.domain.SysFileInfo;
|
||||
import com.ruoyi.cms.fileInfo.service.ISysFileInfoService;
|
||||
|
||||
/**
|
||||
* 文件管理Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2021-12-29
|
||||
*/
|
||||
@Service
|
||||
public class SysFileInfoServiceImpl implements ISysFileInfoService
|
||||
{
|
||||
@Autowired
|
||||
private SysFileInfoMapper sysFileInfoMapper;
|
||||
|
||||
@Override
|
||||
public SysFileInfo selectSysFileInfoByFileObjectName(String fileObjectName) {
|
||||
return sysFileInfoMapper.selectSysFileInfoByFileObjectName(fileObjectName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文件管理
|
||||
*
|
||||
* @param fileId 文件管理主键
|
||||
* @return 文件管理
|
||||
*/
|
||||
@Override
|
||||
public SysFileInfo selectSysFileInfoByFileId(Long fileId)
|
||||
{
|
||||
return sysFileInfoMapper.selectSysFileInfoByFileId(fileId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文件管理列表
|
||||
*
|
||||
* @param sysFileInfo 文件管理
|
||||
* @return 文件管理
|
||||
*/
|
||||
@Override
|
||||
public List<SysFileInfo> selectSysFileInfoList(SysFileInfo sysFileInfo)
|
||||
{
|
||||
return sysFileInfoMapper.selectSysFileInfoList(sysFileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增文件管理
|
||||
*
|
||||
* @param sysFileInfo 文件管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysFileInfo(SysFileInfo sysFileInfo)
|
||||
{
|
||||
sysFileInfo.setCreateTime(DateUtils.getNowDate());
|
||||
return sysFileInfoMapper.insertSysFileInfo(sysFileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文件管理
|
||||
*
|
||||
* @param sysFileInfo 文件管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysFileInfo(SysFileInfo sysFileInfo)
|
||||
{
|
||||
sysFileInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
return sysFileInfoMapper.updateSysFileInfo(sysFileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除文件管理
|
||||
*
|
||||
* @param fileIds 需要删除的文件管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysFileInfoByFileIds(Long[] fileIds)
|
||||
{
|
||||
for (int i = 0; i<fileIds.length; i++){
|
||||
Long fileId = fileIds[i];
|
||||
SysFileInfo sysFileInfo = sysFileInfoMapper.selectSysFileInfoByFileId(fileId);
|
||||
String filePath = RuoYiConfig.getProfile() + StringUtils.substringAfter(sysFileInfo.getFilePath(), Constants.RESOURCE_PREFIX);
|
||||
FileUtils.deleteFile(filePath);
|
||||
}
|
||||
return sysFileInfoMapper.deleteSysFileInfoByFileIds(fileIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件管理信息
|
||||
*
|
||||
* @param fileId 文件管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysFileInfoByFileId(Long fileId)
|
||||
{
|
||||
SysFileInfo sysFileInfo = sysFileInfoMapper.selectSysFileInfoByFileId(fileId);
|
||||
String filePath = RuoYiConfig.getProfile() + StringUtils.substringAfter(sysFileInfo.getFilePath(), Constants.RESOURCE_PREFIX);
|
||||
FileUtils.deleteFile(filePath);
|
||||
return sysFileInfoMapper.deleteSysFileInfoByFileId(fileId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteSysFileInfoByFileObjectName(String fileObjectName) {
|
||||
SysFileInfo sysFileInfo = sysFileInfoMapper.selectSysFileInfoByFileObjectName(fileObjectName);
|
||||
String filePath = RuoYiConfig.getProfile() + StringUtils.substringAfter(sysFileInfo.getFilePath(), Constants.RESOURCE_PREFIX);
|
||||
FileUtils.deleteFile(filePath);
|
||||
return sysFileInfoMapper.deleteSysFileInfoByFileObjectName(fileObjectName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
package com.ruoyi.cms.message.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.cms.message.domain.CmsMessageLike;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.cms.message.domain.CmsMessage;
|
||||
import com.ruoyi.cms.message.service.ICmsMessageService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 留言管理Controller
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/cms/message")
|
||||
public class CmsMessageController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICmsMessageService cmsMessageService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 首页查询留言列表
|
||||
*/
|
||||
@GetMapping("/cms/list")
|
||||
public TableDataInfo cmsList(CmsMessage cmsMessage)
|
||||
{
|
||||
startPage();
|
||||
List<CmsMessage> list = cmsMessageService.selectMessageList(cmsMessage);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页新增留言
|
||||
*/
|
||||
@PostMapping("/cms/addMessage")
|
||||
public AjaxResult addMessage(@RequestBody CmsMessage cmsMessage)
|
||||
{
|
||||
Long parentId = cmsMessage.getParentId();
|
||||
if (parentId!=null){
|
||||
CmsMessage message = cmsMessageService.selectCmsMessageById(parentId);
|
||||
if (message.getMainId()!=null){
|
||||
cmsMessage.setMainId(message.getMainId());
|
||||
}else {
|
||||
cmsMessage.setMainId(parentId);
|
||||
}
|
||||
}
|
||||
return toAjax(cmsMessageService.insertCmsMessage(cmsMessage));
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页新增点赞
|
||||
*/
|
||||
@PostMapping("/cms/addCmsMessageLike")
|
||||
public AjaxResult addCmsMessageLike(@RequestBody CmsMessageLike cmsMessageLike)
|
||||
{
|
||||
return toAjax(cmsMessageService.addCmsMessageLike(cmsMessageLike));
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页删除点赞
|
||||
*/
|
||||
@Log(title = "删除留言点赞", businessType = BusinessType.DELETE)
|
||||
@PostMapping("/cms/delCmsMessageLike")
|
||||
public AjaxResult delCmsMessageLike(@RequestBody CmsMessageLike cmsMessageLike)
|
||||
{
|
||||
return toAjax(cmsMessageService.delCmsMessageLike(cmsMessageLike));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询留言管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:message:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CmsMessage cmsMessage)
|
||||
{
|
||||
startPage();
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(getLoginUser().getUser());
|
||||
if (!SecurityUtils.isAdmin(getUserId())&&!roles.contains("admin")&&!roles.contains("cms")){
|
||||
cmsMessage.setCreateBy(getUsername());
|
||||
}
|
||||
cmsMessage.setDelFlag("0");
|
||||
List<CmsMessage> list = cmsMessageService.selectCmsMessageList(cmsMessage);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出留言管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:message:export')")
|
||||
@Log(title = "留言管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CmsMessage cmsMessage)
|
||||
{
|
||||
List<CmsMessage> list = cmsMessageService.selectCmsMessageList(cmsMessage);
|
||||
ExcelUtil<CmsMessage> util = new ExcelUtil<CmsMessage>(CmsMessage.class);
|
||||
util.exportExcel(response, list, "留言管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取留言管理详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:message:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(cmsMessageService.selectCmsMessageById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增留言管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:message:add')")
|
||||
@Log(title = "留言管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CmsMessage cmsMessage)
|
||||
{
|
||||
return toAjax(cmsMessageService.insertCmsMessage(cmsMessage));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改留言管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:message:edit')")
|
||||
@Log(title = "留言管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CmsMessage cmsMessage)
|
||||
{
|
||||
return toAjax(cmsMessageService.updateCmsMessage(cmsMessage));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除留言管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:message:remove')")
|
||||
@Log(title = "留言管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(cmsMessageService.deleteCmsMessageByIds(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
package com.ruoyi.cms.message.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 留言管理对象 cms_message
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-15
|
||||
*/
|
||||
public class CmsMessage extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
|
||||
/** 父留言id */
|
||||
@Excel(name = "父留言id")
|
||||
private Long parentId;
|
||||
|
||||
/** 主留言id(第一级留言) */
|
||||
@Excel(name = "主留言id(第一级留言)")
|
||||
private Long mainId;
|
||||
|
||||
/** 点赞数量 */
|
||||
@Excel(name = "点赞数量")
|
||||
private Long likeNum;
|
||||
|
||||
/** 内容 */
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
/** 留言类型:(0代表留言 1代表回复) */
|
||||
@Excel(name = "留言类型:(0代表留言 1代表回复)")
|
||||
private String type;
|
||||
|
||||
/** 被留言者id,可以是人、项目、资源 */
|
||||
@Excel(name = "被留言者id,可以是人、项目、资源")
|
||||
private Long blogId;
|
||||
|
||||
/** 留言者id */
|
||||
@Excel(name = "留言者id")
|
||||
private Long userId;
|
||||
|
||||
/** 删除标志(0代表存在 1代表删除) */
|
||||
@Excel(name = "删除标志(0代表存在 1代表删除)")
|
||||
private String delFlag;
|
||||
|
||||
/** 头像 */
|
||||
private String avatar;
|
||||
|
||||
/** 回复 */
|
||||
private List<CmsMessage> children;
|
||||
|
||||
/** 父留言者 */
|
||||
private String pCreateBy;
|
||||
|
||||
/** 点赞 */
|
||||
private boolean isLike;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setParentId(Long parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Long getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
public void setLikeNum(Long likeNum)
|
||||
{
|
||||
this.likeNum = likeNum;
|
||||
}
|
||||
|
||||
public Long getMainId() {
|
||||
return mainId;
|
||||
}
|
||||
|
||||
public void setMainId(Long mainId) {
|
||||
this.mainId = mainId;
|
||||
}
|
||||
|
||||
public Long getLikeNum()
|
||||
{
|
||||
return likeNum;
|
||||
}
|
||||
public void setContent(String content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
public void setBlogId(Long blogId)
|
||||
{
|
||||
this.blogId = blogId;
|
||||
}
|
||||
|
||||
public Long getBlogId()
|
||||
{
|
||||
return blogId;
|
||||
}
|
||||
public void setUserId(Long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
|
||||
public String getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public List<CmsMessage> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<CmsMessage> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public String getPCreateBy() {
|
||||
return pCreateBy;
|
||||
}
|
||||
|
||||
public void setPCreateBy(String pCreateBy) {
|
||||
this.pCreateBy = pCreateBy;
|
||||
}
|
||||
|
||||
public boolean getIsLike() {
|
||||
return isLike;
|
||||
}
|
||||
|
||||
public void setIsLike(boolean isLike) {
|
||||
this.isLike = isLike;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("parentId", getParentId())
|
||||
.append("mainId", getMainId())
|
||||
.append("likeNum", getLikeNum())
|
||||
.append("content", getContent())
|
||||
.append("type", getType())
|
||||
.append("blogId", getBlogId())
|
||||
.append("userId", getUserId())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("avatar",getAvatar())
|
||||
.append("children",getChildren())
|
||||
.append("pCreateBy",getPCreateBy())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("isLike", getIsLike())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.ruoyi.cms.message.domain;
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈留言点赞实体类〉
|
||||
* @Date: 2022/1/19 8:38
|
||||
*/
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* @Author: WangNing
|
||||
* @Description:〈留言点赞实体类〉
|
||||
* @Date: 2022/1/19 8:38
|
||||
**/
|
||||
public class CmsMessageLike extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long messageId;
|
||||
private Long userId;
|
||||
|
||||
/** 点赞数量 */
|
||||
private Long likeNum;
|
||||
|
||||
public Long getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public void setMessageId(Long messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getLikeNum() {
|
||||
return likeNum;
|
||||
}
|
||||
|
||||
public void setLikeNum(Long likeNum) {
|
||||
this.likeNum = likeNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("messageId", getMessageId())
|
||||
.append("userId", getUserId())
|
||||
.append("likeNum", getLikeNum())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.ruoyi.cms.message.mapper;
|
||||
|
||||
import com.ruoyi.cms.message.domain.CmsMessageLike;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈数据层〉
|
||||
* @Date: 2022/1/19 8:42
|
||||
*/
|
||||
public interface CmsMessageLikeMapper {
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
public List<CmsMessageLike> selectCmsMessageLikeList(CmsMessageLike cmsMessageLike);
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
public int addCmsMessageLike(CmsMessageLike cmsMessageLike);
|
||||
/**
|
||||
* 删除关联
|
||||
*/
|
||||
public int deleteCmsMessageLike(CmsMessageLike cmsMessageLike);
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.ruoyi.cms.message.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.cms.message.domain.CmsMessage;
|
||||
|
||||
/**
|
||||
* 留言管理Mapper接口
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-15
|
||||
*/
|
||||
public interface CmsMessageMapper
|
||||
{
|
||||
/**
|
||||
* 查询留言管理
|
||||
*
|
||||
* @param id 留言管理主键
|
||||
* @return 留言管理
|
||||
*/
|
||||
public CmsMessage selectCmsMessageById(Long id);
|
||||
|
||||
/**
|
||||
* 查询留言管理列表
|
||||
*
|
||||
* @param cmsMessage 留言管理
|
||||
* @return 留言管理集合
|
||||
*/
|
||||
public List<CmsMessage> selectCmsMessageList(CmsMessage cmsMessage);
|
||||
|
||||
/**
|
||||
* 查询子留言列表
|
||||
*/
|
||||
public List<CmsMessage> selectChildMessageList(CmsMessage cmsMessage);
|
||||
|
||||
/**
|
||||
* 新增留言管理
|
||||
*
|
||||
* @param cmsMessage 留言管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCmsMessage(CmsMessage cmsMessage);
|
||||
|
||||
/**
|
||||
* 修改留言管理
|
||||
*
|
||||
* @param cmsMessage 留言管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCmsMessage(CmsMessage cmsMessage);
|
||||
|
||||
/**
|
||||
* 删除留言管理
|
||||
*
|
||||
* @param id 留言管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsMessageById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除留言管理
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsMessageByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除留言管理
|
||||
*
|
||||
* @param id 留言管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDelFlagById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除留言管理
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDelFlagByIds(Long[] ids);
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.ruoyi.cms.message.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.cms.message.domain.CmsMessage;
|
||||
import com.ruoyi.cms.message.domain.CmsMessageLike;
|
||||
|
||||
/**
|
||||
* 留言管理Service接口
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-15
|
||||
*/
|
||||
public interface ICmsMessageService
|
||||
{
|
||||
/**
|
||||
* 首页查询留言列表
|
||||
*/
|
||||
public List<CmsMessage> selectMessageList(CmsMessage cmsMessage);
|
||||
|
||||
/**
|
||||
* 首页新增点赞
|
||||
*/
|
||||
public int addCmsMessageLike(CmsMessageLike cmsMessageLike);
|
||||
|
||||
/**
|
||||
* 首页删除点赞
|
||||
*/
|
||||
public int delCmsMessageLike(CmsMessageLike cmsMessageLike);
|
||||
|
||||
/**
|
||||
* 查询留言管理
|
||||
*
|
||||
* @param id 留言管理主键
|
||||
* @return 留言管理
|
||||
*/
|
||||
public CmsMessage selectCmsMessageById(Long id);
|
||||
|
||||
/**
|
||||
* 查询留言管理列表
|
||||
*
|
||||
* @param cmsMessage 留言管理
|
||||
* @return 留言管理集合
|
||||
*/
|
||||
public List<CmsMessage> selectCmsMessageList(CmsMessage cmsMessage);
|
||||
|
||||
/**
|
||||
* 新增留言管理
|
||||
*
|
||||
* @param cmsMessage 留言管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCmsMessage(CmsMessage cmsMessage);
|
||||
|
||||
/**
|
||||
* 修改留言管理
|
||||
*
|
||||
* @param cmsMessage 留言管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCmsMessage(CmsMessage cmsMessage);
|
||||
|
||||
/**
|
||||
* 批量删除留言管理
|
||||
*
|
||||
* @param ids 需要删除的留言管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsMessageByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除留言管理信息
|
||||
*
|
||||
* @param id 留言管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsMessageById(Long id);
|
||||
}
|
|
@ -0,0 +1,274 @@
|
|||
package com.ruoyi.cms.message.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.cms.message.domain.CmsMessageLike;
|
||||
import com.ruoyi.cms.message.mapper.CmsMessageLikeMapper;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.cms.message.mapper.CmsMessageMapper;
|
||||
import com.ruoyi.cms.message.domain.CmsMessage;
|
||||
import com.ruoyi.cms.message.service.ICmsMessageService;
|
||||
|
||||
/**
|
||||
* 留言管理Service业务层处理
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-15
|
||||
*/
|
||||
@Service
|
||||
public class CmsMessageServiceImpl implements ICmsMessageService
|
||||
{
|
||||
@Autowired
|
||||
private CmsMessageMapper cmsMessageMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Autowired
|
||||
private CmsMessageLikeMapper cmsMessageLikeMapper;
|
||||
|
||||
/**
|
||||
* 首页查询留言列表
|
||||
*/
|
||||
@Override
|
||||
public List<CmsMessage> selectMessageList(CmsMessage cmsMessage) {
|
||||
//判断是否登录
|
||||
Long logUserUserId = null;
|
||||
String createBy = cmsMessage.getCreateBy();
|
||||
if (createBy!=null&&!"".equals(createBy)){
|
||||
SysUser logUser = sysUserMapper.selectUserByUserName(createBy);
|
||||
logUserUserId = logUser.getUserId();
|
||||
}
|
||||
cmsMessage.setCreateBy(null);
|
||||
cmsMessage.setType("0");
|
||||
cmsMessage.setDelFlag("0");
|
||||
List<CmsMessage> cmsMessageList = cmsMessageMapper.selectCmsMessageList(cmsMessage);
|
||||
for (CmsMessage message : cmsMessageList) {
|
||||
//添加头像
|
||||
Long userId = message.getUserId();
|
||||
if (userId!=null){
|
||||
SysUser user = sysUserMapper.selectUserById(userId);
|
||||
message.setAvatar(user.getAvatar());
|
||||
}
|
||||
//添加是否被点赞
|
||||
if (logUserUserId!=null){
|
||||
CmsMessageLike messageLike = new CmsMessageLike();
|
||||
messageLike.setMessageId(message.getId());
|
||||
messageLike.setUserId(logUserUserId);
|
||||
List<CmsMessageLike> likeList = cmsMessageLikeMapper.selectCmsMessageLikeList(messageLike);
|
||||
if (likeList.size()>0){
|
||||
message.setIsLike(true);
|
||||
}else {
|
||||
message.setIsLike(false);
|
||||
}
|
||||
}
|
||||
//添加子评论(回复)
|
||||
CmsMessage childMessage = new CmsMessage();
|
||||
childMessage.setType("1");
|
||||
childMessage.setMainId(message.getId());
|
||||
List<CmsMessage> childMessageList = cmsMessageMapper.selectChildMessageList(childMessage);
|
||||
if (childMessageList.size()>0){
|
||||
for (CmsMessage childListMessage : childMessageList) {
|
||||
//添加头像
|
||||
Long childUserId = childListMessage.getUserId();
|
||||
if (childUserId!=null){
|
||||
SysUser user = sysUserMapper.selectUserById(childUserId);
|
||||
childListMessage.setAvatar(user.getAvatar());
|
||||
}
|
||||
//添加是否被点赞
|
||||
if (logUserUserId!=null){
|
||||
CmsMessageLike messageLike = new CmsMessageLike();
|
||||
messageLike.setMessageId(message.getId());
|
||||
messageLike.setUserId(logUserUserId);
|
||||
List<CmsMessageLike> likeList = cmsMessageLikeMapper.selectCmsMessageLikeList(messageLike);
|
||||
if (likeList.size()>0){
|
||||
message.setIsLike(true);
|
||||
}else {
|
||||
message.setIsLike(false);
|
||||
}
|
||||
}
|
||||
//添加父留言信息
|
||||
CmsMessage byId = cmsMessageMapper.selectCmsMessageById(childListMessage.getParentId());
|
||||
childListMessage.setPCreateBy(byId.getCreateBy());
|
||||
}
|
||||
message.setChildren(childMessageList);
|
||||
}
|
||||
}
|
||||
return cmsMessageList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addCmsMessageLike(CmsMessageLike cmsMessageLike) {
|
||||
int result = -1;
|
||||
String createBy = cmsMessageLike.getCreateBy();
|
||||
if (!"".equals(createBy)&&createBy!=null){
|
||||
SysUser user = sysUserMapper.selectUserByUserName(createBy);
|
||||
if (user!=null){
|
||||
cmsMessageLike.setUserId(user.getUserId());
|
||||
cmsMessageLikeMapper.addCmsMessageLike(cmsMessageLike);
|
||||
}
|
||||
}
|
||||
//修改点赞数量
|
||||
CmsMessage cmsMessage = new CmsMessage();
|
||||
cmsMessage.setId(cmsMessageLike.getMessageId());
|
||||
cmsMessage.setLikeNum(cmsMessageLike.getLikeNum());
|
||||
result = cmsMessageMapper.updateCmsMessage(cmsMessage);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delCmsMessageLike(CmsMessageLike cmsMessageLike) {
|
||||
int result = -1;
|
||||
String createBy = cmsMessageLike.getCreateBy();
|
||||
if (!"".equals(createBy)&&createBy!=null){
|
||||
SysUser user = sysUserMapper.selectUserByUserName(createBy);
|
||||
if (user!=null){
|
||||
cmsMessageLike.setUserId(user.getUserId());
|
||||
cmsMessageLikeMapper.deleteCmsMessageLike(cmsMessageLike);
|
||||
}
|
||||
}
|
||||
//修改点赞数量
|
||||
CmsMessage cmsMessage = new CmsMessage();
|
||||
cmsMessage.setId(cmsMessageLike.getMessageId());
|
||||
cmsMessage.setLikeNum(cmsMessageLike.getLikeNum());
|
||||
result = cmsMessageMapper.updateCmsMessage(cmsMessage);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询留言管理
|
||||
*
|
||||
* @param id 留言管理主键
|
||||
* @return 留言管理
|
||||
*/
|
||||
@Override
|
||||
public CmsMessage selectCmsMessageById(Long id)
|
||||
{
|
||||
return cmsMessageMapper.selectCmsMessageById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询留言管理列表
|
||||
*
|
||||
* @param cmsMessage 留言管理
|
||||
* @return 留言管理
|
||||
*/
|
||||
@Override
|
||||
public List<CmsMessage> selectCmsMessageList(CmsMessage cmsMessage)
|
||||
{
|
||||
List<CmsMessage> cmsMessageList = new ArrayList<>();
|
||||
//判断用户权限
|
||||
String createBy = cmsMessage.getCreateBy();
|
||||
if (createBy!=null&&!"".equals(createBy)){
|
||||
SysUser user = sysUserMapper.selectUserByUserName(createBy);
|
||||
if (user!=null){
|
||||
List<CmsMessage> MessageList = cmsMessageMapper.selectCmsMessageList(cmsMessage);
|
||||
for (CmsMessage message : MessageList) {
|
||||
//查询子评论(回复)
|
||||
CmsMessage childMessage = new CmsMessage();
|
||||
childMessage.setType("1");
|
||||
childMessage.setParentId(message.getId());
|
||||
List<CmsMessage> childMessageList = cmsMessageMapper.selectCmsMessageList(childMessage);
|
||||
if (childMessageList.size()>0){
|
||||
cmsMessageList.addAll(childMessageList);
|
||||
}
|
||||
}
|
||||
cmsMessageList.addAll(MessageList);
|
||||
}
|
||||
}else {
|
||||
cmsMessageList = cmsMessageMapper.selectCmsMessageList(cmsMessage);
|
||||
}
|
||||
for (CmsMessage message : cmsMessageList) {
|
||||
//添加头像
|
||||
Long userId = message.getUserId();
|
||||
if (userId!=null){
|
||||
SysUser user = sysUserMapper.selectUserById(userId);
|
||||
message.setAvatar(user.getAvatar());
|
||||
}
|
||||
//添加父留言信息
|
||||
Long parentId = message.getParentId();
|
||||
if (parentId!=null){
|
||||
CmsMessage parentMessage = cmsMessageMapper.selectCmsMessageById(parentId);
|
||||
message.setPCreateBy(parentMessage.getCreateBy());
|
||||
}
|
||||
}
|
||||
//排序
|
||||
// String[] sortNameArr1 = {"createTime"};
|
||||
// //true升序,false降序
|
||||
// boolean[] isAscArr1 = {false};
|
||||
// ListSortUtils.sort(cmsMessageList, sortNameArr1, isAscArr1);
|
||||
// cmsMessageList.sort((a,b)->a.getCreateBy().compareTo(b.getCreateBy()));
|
||||
// Collections.sort(cmsMessageList, new Comparator<CmsMessage>() {
|
||||
// @Override
|
||||
// public int compare(CmsMessage o1, CmsMessage o2) {
|
||||
// //升序
|
||||
// //return o1.getCreateBy().compareTo(o2.getCreateBy());
|
||||
// //降序
|
||||
// return o2.getCreateBy().compareTo(o1.getCreateBy());
|
||||
// }
|
||||
// });
|
||||
return cmsMessageList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增留言管理
|
||||
*
|
||||
* @param cmsMessage 留言管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCmsMessage(CmsMessage cmsMessage)
|
||||
{
|
||||
String createBy = cmsMessage.getCreateBy();
|
||||
if (createBy!=null&&!"".equals(createBy)){
|
||||
SysUser user = sysUserMapper.selectUserByUserName(createBy);
|
||||
if (user!=null){
|
||||
cmsMessage.setUserId(user.getUserId());
|
||||
}
|
||||
}
|
||||
cmsMessage.setCreateTime(DateUtils.getNowDate());
|
||||
return cmsMessageMapper.insertCmsMessage(cmsMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改留言管理
|
||||
*
|
||||
* @param cmsMessage 留言管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCmsMessage(CmsMessage cmsMessage)
|
||||
{
|
||||
cmsMessage.setUpdateTime(DateUtils.getNowDate());
|
||||
return cmsMessageMapper.updateCmsMessage(cmsMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除留言管理
|
||||
*
|
||||
* @param ids 需要删除的留言管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCmsMessageByIds(Long[] ids)
|
||||
{
|
||||
return cmsMessageMapper.updateDelFlagByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除留言管理信息
|
||||
*
|
||||
* @param id 留言管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCmsMessageById(Long id)
|
||||
{
|
||||
return cmsMessageMapper.updateDelFlagById(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
package com.ruoyi.cms.tag.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.cms.tag.domain.CmsTag;
|
||||
import com.ruoyi.cms.tag.service.ICmsTagService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 标签管理Controller
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-02
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/cms/tag")
|
||||
public class CmsTagController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICmsTagService cmsTagService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 查询标签管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:tag:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CmsTag cmsTag)
|
||||
{
|
||||
startPage();
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(getLoginUser().getUser());
|
||||
if (!SecurityUtils.isAdmin(getUserId())&&!roles.contains("admin")&&!roles.contains("cms")){
|
||||
cmsTag.setCreateBy(getUsername());
|
||||
}
|
||||
List<CmsTag> list = cmsTagService.selectCmsTagList(cmsTag);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出标签管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:tag:export')")
|
||||
@Log(title = "标签管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CmsTag cmsTag)
|
||||
{
|
||||
List<CmsTag> list = cmsTagService.selectCmsTagList(cmsTag);
|
||||
ExcelUtil<CmsTag> util = new ExcelUtil<CmsTag>(CmsTag.class);
|
||||
util.exportExcel(response, list, "标签管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标签管理详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:tag:query')")
|
||||
@GetMapping(value = "/{tagId}")
|
||||
public AjaxResult getInfo(@PathVariable("tagId") Long tagId)
|
||||
{
|
||||
return AjaxResult.success(cmsTagService.selectCmsTagByTagId(tagId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增标签管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:tag:add')")
|
||||
@Log(title = "标签管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CmsTag cmsTag)
|
||||
{
|
||||
cmsTag.setCreateBy(getUsername());
|
||||
return toAjax(cmsTagService.insertCmsTag(cmsTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改标签管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:tag:edit')")
|
||||
@Log(title = "标签管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CmsTag cmsTag)
|
||||
{
|
||||
cmsTag.setUpdateBy(getUsername());
|
||||
return toAjax(cmsTagService.updateCmsTag(cmsTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:tag:remove')")
|
||||
@Log(title = "标签管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{tagIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] tagIds)
|
||||
{
|
||||
return toAjax(cmsTagService.deleteCmsTagByTagIds(tagIds));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.ruoyi.cms.tag.domain;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 标签管理对象 cms_tag
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-02
|
||||
*/
|
||||
public class CmsTag extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 标签ID */
|
||||
private Long tagId;
|
||||
|
||||
/** 标签名称 */
|
||||
@Excel(name = "标签名称")
|
||||
private String tagName;
|
||||
|
||||
/** 博客数量 */
|
||||
private int blogNum;
|
||||
|
||||
public void setTagId(Long tagId)
|
||||
{
|
||||
this.tagId = tagId;
|
||||
}
|
||||
|
||||
public Long getTagId()
|
||||
{
|
||||
return tagId;
|
||||
}
|
||||
public void setTagName(String tagName)
|
||||
{
|
||||
this.tagName = tagName;
|
||||
}
|
||||
|
||||
public String getTagName()
|
||||
{
|
||||
return tagName;
|
||||
}
|
||||
|
||||
public int getBlogNum() {
|
||||
return blogNum;
|
||||
}
|
||||
|
||||
public void setBlogNum(int blogNum) {
|
||||
this.blogNum = blogNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("tagId", getTagId())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("tagName", getTagName())
|
||||
.append("blogNum", getBlogNum())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.ruoyi.cms.tag.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.cms.tag.domain.CmsTag;
|
||||
|
||||
/**
|
||||
* 标签管理Mapper接口
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-02
|
||||
*/
|
||||
public interface CmsTagMapper
|
||||
{
|
||||
/**
|
||||
* 查询标签管理
|
||||
*
|
||||
* @param tagId 标签管理主键
|
||||
* @return 标签管理
|
||||
*/
|
||||
public CmsTag selectCmsTagByTagId(Long tagId);
|
||||
|
||||
/**
|
||||
* 查询标签管理列表
|
||||
*
|
||||
* @param cmsTag 标签管理
|
||||
* @return 标签管理集合
|
||||
*/
|
||||
public List<CmsTag> selectCmsTagList(CmsTag cmsTag);
|
||||
|
||||
/**
|
||||
* 通过tagName查询标签管理列表
|
||||
*
|
||||
* @param tagName
|
||||
* @return 标签管理集合
|
||||
*/
|
||||
public List<CmsTag> selectCmsTagListByTagName(String tagName);
|
||||
|
||||
/**
|
||||
* 新增标签管理
|
||||
*
|
||||
* @param cmsTag 标签管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCmsTag(CmsTag cmsTag);
|
||||
|
||||
/**
|
||||
* 修改标签管理
|
||||
*
|
||||
* @param cmsTag 标签管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCmsTag(CmsTag cmsTag);
|
||||
|
||||
/**
|
||||
* 删除标签管理
|
||||
*
|
||||
* @param tagId 标签管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsTagByTagId(Long tagId);
|
||||
|
||||
/**
|
||||
* 批量删除标签管理
|
||||
*
|
||||
* @param tagIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsTagByTagIds(Long[] tagIds);
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.ruoyi.cms.tag.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.cms.tag.domain.CmsTag;
|
||||
|
||||
/**
|
||||
* 标签管理Service接口
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-02
|
||||
*/
|
||||
public interface ICmsTagService
|
||||
{
|
||||
/**
|
||||
* 查询标签管理
|
||||
*
|
||||
* @param tagId 标签管理主键
|
||||
* @return 标签管理
|
||||
*/
|
||||
public CmsTag selectCmsTagByTagId(Long tagId);
|
||||
|
||||
/**
|
||||
* 查询标签管理列表
|
||||
*
|
||||
* @param cmsTag 标签管理
|
||||
* @return 标签管理集合
|
||||
*/
|
||||
public List<CmsTag> selectCmsTagList(CmsTag cmsTag);
|
||||
|
||||
/**
|
||||
* 新增标签管理
|
||||
*
|
||||
* @param cmsTag 标签管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCmsTag(CmsTag cmsTag);
|
||||
|
||||
/**
|
||||
* 修改标签管理
|
||||
*
|
||||
* @param cmsTag 标签管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCmsTag(CmsTag cmsTag);
|
||||
|
||||
/**
|
||||
* 批量删除标签管理
|
||||
*
|
||||
* @param tagIds 需要删除的标签管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsTagByTagIds(Long[] tagIds);
|
||||
|
||||
/**
|
||||
* 删除标签管理信息
|
||||
*
|
||||
* @param tagId 标签管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsTagByTagId(Long tagId);
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package com.ruoyi.cms.tag.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.cms.blog.mapper.CmsBlogTagMapper;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.cms.tag.mapper.CmsTagMapper;
|
||||
import com.ruoyi.cms.tag.domain.CmsTag;
|
||||
import com.ruoyi.cms.tag.service.ICmsTagService;
|
||||
|
||||
/**
|
||||
* 标签管理Service业务层处理
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-02
|
||||
*/
|
||||
@Service
|
||||
public class CmsTagServiceImpl implements ICmsTagService
|
||||
{
|
||||
@Autowired
|
||||
private CmsTagMapper cmsTagMapper;
|
||||
|
||||
@Autowired
|
||||
private CmsBlogTagMapper cmsBlogTagMapper;
|
||||
|
||||
/**
|
||||
* 查询标签管理
|
||||
*
|
||||
* @param tagId 标签管理主键
|
||||
* @return 标签管理
|
||||
*/
|
||||
@Override
|
||||
public CmsTag selectCmsTagByTagId(Long tagId)
|
||||
{
|
||||
return cmsTagMapper.selectCmsTagByTagId(tagId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询标签管理列表
|
||||
*
|
||||
* @param cmsTag 标签管理
|
||||
* @return 标签管理
|
||||
*/
|
||||
@Override
|
||||
public List<CmsTag> selectCmsTagList(CmsTag cmsTag)
|
||||
{
|
||||
List<CmsTag> cmsTagList = cmsTagMapper.selectCmsTagList(cmsTag);
|
||||
for (CmsTag tag : cmsTagList) {
|
||||
int blogNum = cmsBlogTagMapper.countBlogByTagId(tag.getTagId());
|
||||
tag.setBlogNum(blogNum);
|
||||
}
|
||||
return cmsTagList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增标签管理
|
||||
*
|
||||
* @param cmsTag 标签管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCmsTag(CmsTag cmsTag)
|
||||
{
|
||||
List<CmsTag> cmsTagList = cmsTagMapper.selectCmsTagListByTagName(cmsTag.getTagName());
|
||||
if (cmsTagList.size()>0){
|
||||
throw new ServiceException("标签名称已存在");
|
||||
}
|
||||
cmsTag.setCreateTime(DateUtils.getNowDate());
|
||||
return cmsTagMapper.insertCmsTag(cmsTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改标签管理
|
||||
*
|
||||
* @param cmsTag 标签管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCmsTag(CmsTag cmsTag)
|
||||
{
|
||||
List<CmsTag> cmsTagList = cmsTagMapper.selectCmsTagListByTagName(cmsTag.getTagName());
|
||||
if (cmsTagList.size()>0){
|
||||
for (CmsTag tag : cmsTagList) {
|
||||
if (!cmsTag.getTagId().equals(tag.getTagId())){
|
||||
throw new ServiceException("标签名称已存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
cmsTag.setUpdateTime(DateUtils.getNowDate());
|
||||
return cmsTagMapper.updateCmsTag(cmsTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除标签管理
|
||||
*
|
||||
* @param tagIds 需要删除的标签管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCmsTagByTagIds(Long[] tagIds)
|
||||
{
|
||||
for (Long tagId : tagIds) {
|
||||
//删除标签文章关联表信息
|
||||
cmsBlogTagMapper.deleteBlogTagByTagId(tagId);
|
||||
}
|
||||
return cmsTagMapper.deleteCmsTagByTagIds(tagIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签管理信息
|
||||
*
|
||||
* @param tagId 标签管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCmsTagByTagId(Long tagId)
|
||||
{
|
||||
//删除标签文章关联表信息
|
||||
cmsBlogTagMapper.deleteBlogTagByTagId(tagId);
|
||||
return cmsTagMapper.deleteCmsTagByTagId(tagId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package com.ruoyi.cms.type.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.cms.type.domain.CmsType;
|
||||
import com.ruoyi.cms.type.service.ICmsTypeService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 分类管理Controller
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-02
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/cms/type")
|
||||
public class CmsTypeController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICmsTypeService cmsTypeService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 查询分类管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:type:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CmsType cmsType)
|
||||
{
|
||||
startPage();
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(getLoginUser().getUser());
|
||||
if (!SecurityUtils.isAdmin(getUserId())&&!roles.contains("admin")&&!roles.contains("cms")){
|
||||
cmsType.setCreateBy(getUsername());
|
||||
}
|
||||
List<CmsType> list = cmsTypeService.selectCmsTypeList(cmsType);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出分类管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:type:export')")
|
||||
@Log(title = "分类管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CmsType cmsType)
|
||||
{
|
||||
List<CmsType> list = cmsTypeService.selectCmsTypeList(cmsType);
|
||||
ExcelUtil<CmsType> util = new ExcelUtil<CmsType>(CmsType.class);
|
||||
util.exportExcel(response, list, "分类管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类管理详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:type:query')")
|
||||
@GetMapping(value = "/{typeId}")
|
||||
public AjaxResult getInfo(@PathVariable("typeId") Long typeId)
|
||||
{
|
||||
return AjaxResult.success(cmsTypeService.selectCmsTypeByTypeId(typeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增分类管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:type:add')")
|
||||
@Log(title = "分类管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CmsType cmsType)
|
||||
{
|
||||
cmsType.setCreateBy(getUsername());
|
||||
return toAjax(cmsTypeService.insertCmsType(cmsType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分类管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:type:edit')")
|
||||
@Log(title = "分类管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CmsType cmsType)
|
||||
{
|
||||
cmsType.setUpdateBy(getUsername());
|
||||
return toAjax(cmsTypeService.updateCmsType(cmsType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分类管理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:type:remove')")
|
||||
@Log(title = "分类管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{typeIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] typeIds)
|
||||
{
|
||||
return toAjax(cmsTypeService.deleteCmsTypeByTypeIds(typeIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮-删除分类图片
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('cms:type:edit')")
|
||||
@PostMapping("/cancel")
|
||||
public AjaxResult cancel(@RequestBody CmsType cmsType)
|
||||
{
|
||||
return toAjax(cmsTypeService.cancel(cmsType));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.ruoyi.cms.type.domain;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 分类管理对象 cms_type
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-02
|
||||
*/
|
||||
public class CmsType extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 分类ID */
|
||||
private Long typeId;
|
||||
|
||||
/** 分类名称 */
|
||||
@Excel(name = "分类名称")
|
||||
private String typeName;
|
||||
|
||||
/** 分类图像 */
|
||||
@Excel(name = "分类图像")
|
||||
private String typePic;
|
||||
|
||||
/** 博客数量 */
|
||||
private int blogNum;
|
||||
|
||||
public void setTypeId(Long typeId)
|
||||
{
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public Long getTypeId()
|
||||
{
|
||||
return typeId;
|
||||
}
|
||||
public void setTypeName(String typeName)
|
||||
{
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public String getTypeName()
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
public void setTypePic(String typePic)
|
||||
{
|
||||
this.typePic = typePic;
|
||||
}
|
||||
|
||||
public String getTypePic()
|
||||
{
|
||||
return typePic;
|
||||
}
|
||||
|
||||
public int getBlogNum() {
|
||||
return blogNum;
|
||||
}
|
||||
|
||||
public void setBlogNum(int blogNum) {
|
||||
this.blogNum = blogNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("typeId", getTypeId())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("typeName", getTypeName())
|
||||
.append("typePic", getTypePic())
|
||||
.append("blogNum", getBlogNum())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.ruoyi.cms.type.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.cms.tag.domain.CmsTag;
|
||||
import com.ruoyi.cms.type.domain.CmsType;
|
||||
|
||||
/**
|
||||
* 分类管理Mapper接口
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-02
|
||||
*/
|
||||
public interface CmsTypeMapper
|
||||
{
|
||||
/**
|
||||
* 查询分类管理
|
||||
*
|
||||
* @param typeId 分类管理主键
|
||||
* @return 分类管理
|
||||
*/
|
||||
public CmsType selectCmsTypeByTypeId(Long typeId);
|
||||
|
||||
/**
|
||||
* 查询分类管理列表
|
||||
*
|
||||
* @param cmsType 分类管理
|
||||
* @return 分类管理集合
|
||||
*/
|
||||
public List<CmsType> selectCmsTypeList(CmsType cmsType);
|
||||
|
||||
/**
|
||||
* 通过typeName查询标签管理列表
|
||||
*
|
||||
* @param typeName
|
||||
* @return 标签管理集合
|
||||
*/
|
||||
public List<CmsType> selectCmsTypeListByTypeName(String typeName);
|
||||
|
||||
/**
|
||||
* 新增分类管理
|
||||
*
|
||||
* @param cmsType 分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCmsType(CmsType cmsType);
|
||||
|
||||
/**
|
||||
* 修改分类管理
|
||||
*
|
||||
* @param cmsType 分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCmsType(CmsType cmsType);
|
||||
|
||||
/**
|
||||
* 删除分类管理
|
||||
*
|
||||
* @param typeId 分类管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsTypeByTypeId(Long typeId);
|
||||
|
||||
/**
|
||||
* 批量删除分类管理
|
||||
*
|
||||
* @param typeIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsTypeByTypeIds(Long[] typeIds);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.ruoyi.cms.type.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.cms.type.domain.CmsType;
|
||||
|
||||
/**
|
||||
* 分类管理Service接口
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-02
|
||||
*/
|
||||
public interface ICmsTypeService
|
||||
{
|
||||
/**
|
||||
* 查询分类管理
|
||||
*
|
||||
* @param typeId 分类管理主键
|
||||
* @return 分类管理
|
||||
*/
|
||||
public CmsType selectCmsTypeByTypeId(Long typeId);
|
||||
|
||||
/**
|
||||
* 查询分类管理列表
|
||||
*
|
||||
* @param cmsType 分类管理
|
||||
* @return 分类管理集合
|
||||
*/
|
||||
public List<CmsType> selectCmsTypeList(CmsType cmsType);
|
||||
|
||||
/**
|
||||
* 新增分类管理
|
||||
*
|
||||
* @param cmsType 分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCmsType(CmsType cmsType);
|
||||
|
||||
/**
|
||||
* 修改分类管理
|
||||
*
|
||||
* @param cmsType 分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCmsType(CmsType cmsType);
|
||||
|
||||
/**
|
||||
* 批量删除分类管理
|
||||
*
|
||||
* @param typeIds 需要删除的分类管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsTypeByTypeIds(Long[] typeIds);
|
||||
|
||||
/**
|
||||
* 删除分类管理信息
|
||||
*
|
||||
* @param typeId 分类管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCmsTypeByTypeId(Long typeId);
|
||||
|
||||
/**
|
||||
* 取消按钮-删除分类图片
|
||||
*
|
||||
* @param cmsType 分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int cancel(CmsType cmsType);
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
package com.ruoyi.cms.type.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.cms.blog.mapper.CmsBlogTypeMapper;
|
||||
import com.ruoyi.cms.fileInfo.service.ISysFileInfoService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.cms.type.mapper.CmsTypeMapper;
|
||||
import com.ruoyi.cms.type.domain.CmsType;
|
||||
import com.ruoyi.cms.type.service.ICmsTypeService;
|
||||
|
||||
/**
|
||||
* 分类管理Service业务层处理
|
||||
*
|
||||
* @author ning
|
||||
* @date 2022-01-02
|
||||
*/
|
||||
@Service
|
||||
public class CmsTypeServiceImpl implements ICmsTypeService
|
||||
{
|
||||
@Autowired
|
||||
private CmsTypeMapper cmsTypeMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysFileInfoService sysFileInfoService;
|
||||
|
||||
@Autowired
|
||||
private CmsBlogTypeMapper cmsBlogTypeMapper;
|
||||
|
||||
/**
|
||||
* 查询分类管理
|
||||
*
|
||||
* @param typeId 分类管理主键
|
||||
* @return 分类管理
|
||||
*/
|
||||
@Override
|
||||
public CmsType selectCmsTypeByTypeId(Long typeId)
|
||||
{
|
||||
return cmsTypeMapper.selectCmsTypeByTypeId(typeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分类管理列表
|
||||
*
|
||||
* @param cmsType 分类管理
|
||||
* @return 分类管理
|
||||
*/
|
||||
@Override
|
||||
public List<CmsType> selectCmsTypeList(CmsType cmsType)
|
||||
{
|
||||
List<CmsType> cmsTypeList = cmsTypeMapper.selectCmsTypeList(cmsType);
|
||||
for (CmsType type : cmsTypeList) {
|
||||
int blogNum = cmsBlogTypeMapper.countBlogByTypeId(type.getTypeId());
|
||||
type.setBlogNum(blogNum);
|
||||
}
|
||||
return cmsTypeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增分类管理
|
||||
*
|
||||
* @param cmsType 分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCmsType(CmsType cmsType)
|
||||
{
|
||||
List<CmsType> cmsTypeList = cmsTypeMapper.selectCmsTypeListByTypeName(cmsType.getTypeName());
|
||||
if (cmsTypeList.size()>0){
|
||||
throw new ServiceException("分类名称已存在");
|
||||
}
|
||||
cmsType.setCreateTime(DateUtils.getNowDate());
|
||||
return cmsTypeMapper.insertCmsType(cmsType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分类管理
|
||||
*
|
||||
* @param cmsType 分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCmsType(CmsType cmsType)
|
||||
{
|
||||
List<CmsType> cmsTypeList = cmsTypeMapper.selectCmsTypeListByTypeName(cmsType.getTypeName());
|
||||
if (cmsTypeList.size()>0){
|
||||
for (CmsType type : cmsTypeList) {
|
||||
if (!type.getTypeId().equals(cmsType.getTypeId())){
|
||||
throw new ServiceException("分类名称已存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
String typePic = cmsTypeMapper.selectCmsTypeByTypeId(cmsType.getTypeId()).getTypePic();
|
||||
if (typePic!=null&&!"".equals(typePic)&&!typePic.equals(cmsType.getTypePic())){
|
||||
int newFileNameSeparatorIndex = typePic.lastIndexOf("/");
|
||||
String FileName = typePic.substring(newFileNameSeparatorIndex + 1).toLowerCase();
|
||||
sysFileInfoService.deleteSysFileInfoByFileObjectName(FileName);
|
||||
}
|
||||
cmsType.setUpdateTime(DateUtils.getNowDate());
|
||||
return cmsTypeMapper.updateCmsType(cmsType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除分类管理
|
||||
*
|
||||
* @param typeIds 需要删除的分类管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCmsTypeByTypeIds(Long[] typeIds)
|
||||
{
|
||||
for (Long typeId : typeIds) {
|
||||
String typePic = cmsTypeMapper.selectCmsTypeByTypeId(typeId).getTypePic();
|
||||
if (typePic!=null&&!"".equals(typePic)){
|
||||
int newFileNameSeparatorIndex = typePic.lastIndexOf("/");
|
||||
String FileName = typePic.substring(newFileNameSeparatorIndex + 1).toLowerCase();
|
||||
sysFileInfoService.deleteSysFileInfoByFileObjectName(FileName);
|
||||
}
|
||||
//删除分类文章关联表信息
|
||||
cmsBlogTypeMapper.deleteBlogTypeByTypeId(typeId);
|
||||
}
|
||||
return cmsTypeMapper.deleteCmsTypeByTypeIds(typeIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分类管理信息
|
||||
*
|
||||
* @param typeId 分类管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCmsTypeByTypeId(Long typeId)
|
||||
{
|
||||
String typePic = cmsTypeMapper.selectCmsTypeByTypeId(typeId).getTypePic();
|
||||
if (typePic!=null&&!"".equals(typePic)){
|
||||
int newFileNameSeparatorIndex = typePic.lastIndexOf("/");
|
||||
String FileName = typePic.substring(newFileNameSeparatorIndex + 1).toLowerCase();
|
||||
sysFileInfoService.deleteSysFileInfoByFileObjectName(FileName);
|
||||
}
|
||||
//删除分类文章关联表信息
|
||||
cmsBlogTypeMapper.deleteBlogTypeByTypeId(typeId);
|
||||
return cmsTypeMapper.deleteCmsTypeByTypeId(typeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮-删除分类图片
|
||||
*
|
||||
* @param cmsType 分类管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int cancel(CmsType cmsType) {
|
||||
String typePic = cmsType.getTypePic();
|
||||
if (typePic!=null&&!"".equals(typePic)){
|
||||
Long typeId = cmsType.getTypeId();
|
||||
if (typeId==null){
|
||||
int newFileNameSeparatorIndex = typePic.lastIndexOf("/");
|
||||
String FileName = typePic.substring(newFileNameSeparatorIndex + 1).toLowerCase();
|
||||
sysFileInfoService.deleteSysFileInfoByFileObjectName(FileName);
|
||||
}else {
|
||||
String Pic = cmsTypeMapper.selectCmsTypeByTypeId(typeId).getTypePic();
|
||||
if (!typePic.equals(Pic)){
|
||||
int newFileNameSeparatorIndex = typePic.lastIndexOf("/");
|
||||
String FileName = typePic.substring(newFileNameSeparatorIndex + 1).toLowerCase();
|
||||
sysFileInfoService.deleteSysFileInfoByFileObjectName(FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
package com.ruoyi.cms.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @program: RuoYi-Vue
|
||||
* @Author: WangNing
|
||||
* @Description: 〈list多属性排序〉
|
||||
* @Date: 2022/1/20 10:25
|
||||
*/
|
||||
public class ListSortUtils {
|
||||
/**
|
||||
* 对list的元素按照多个属性名称排序,
|
||||
* list元素的属性可以是数字(byte、short、int、long、float、double等,支持正数、负数、0)、char、String、java.util.Date
|
||||
*
|
||||
*
|
||||
* list元素的属性名称
|
||||
* @param isAsc
|
||||
* true升序,false降序
|
||||
*/
|
||||
public static <E> void sort(List<E> list, final boolean isAsc, final String... sortnameArr) {
|
||||
Collections.sort(list, new Comparator<E>() {
|
||||
|
||||
@Override
|
||||
public int compare(E a, E b) {
|
||||
|
||||
int ret = 0;
|
||||
try {
|
||||
for (int i = 0; i < sortnameArr.length; i++) {
|
||||
ret = ListSortUtils.compareObject(sortnameArr[i], isAsc, a, b);
|
||||
if (0 != ret) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 给list的每个属性都指定是升序还是降序
|
||||
*
|
||||
* @param list
|
||||
* @param sortnameArr 参数数组
|
||||
* @param typeArr 每个属性对应的升降序数组, true升序,false降序
|
||||
*/
|
||||
|
||||
public static <E> void sort(List<E> list, final String[] sortnameArr, final boolean[] typeArr) {
|
||||
if (sortnameArr.length != typeArr.length) {
|
||||
throw new RuntimeException("属性数组元素个数和升降序数组元素个数不相等");
|
||||
}
|
||||
Collections.sort(list, new Comparator<E>() {
|
||||
@Override
|
||||
public int compare(E a, E b) {
|
||||
int ret = 0;
|
||||
try {
|
||||
for (int i = 0; i < sortnameArr.length; i++) {
|
||||
ret = ListSortUtils.compareObject(sortnameArr[i], typeArr[i], a, b);
|
||||
if (0 != ret) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 对2个对象按照指定属性名称进行排序
|
||||
*
|
||||
* @param sortname
|
||||
* 属性名称
|
||||
* @param isAsc
|
||||
* true升序,false降序
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static <E> int compareObject(final String sortname, final boolean isAsc, E a, E b) throws Exception {
|
||||
int ret;
|
||||
Object value1 = ListSortUtils.forceGetFieldValue(a, sortname);
|
||||
Object value2 = ListSortUtils.forceGetFieldValue(b, sortname);
|
||||
String str1 = value1.toString();
|
||||
String str2 = value2.toString();
|
||||
if (value1 instanceof Number && value2 instanceof Number) {
|
||||
int maxlen = Math.max(str1.length(), str2.length());
|
||||
str1 = ListSortUtils.addZero2Str((Number) value1, maxlen);
|
||||
str2 = ListSortUtils.addZero2Str((Number) value2, maxlen);
|
||||
} else if (value1 instanceof Date && value2 instanceof Date) {
|
||||
long time1 = ((Date) value1).getTime();
|
||||
long time2 = ((Date) value2).getTime();
|
||||
int maxlen = Long.toString(Math.max(time1, time2)).length();
|
||||
str1 = ListSortUtils.addZero2Str(time1, maxlen);
|
||||
str2 = ListSortUtils.addZero2Str(time2, maxlen);
|
||||
}
|
||||
if (isAsc) {
|
||||
ret = str1.compareTo(str2);
|
||||
} else {
|
||||
ret = str2.compareTo(str1);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 给数字对象按照指定长度在左侧补0.
|
||||
*
|
||||
* 使用案例: addZero2Str(11,4) 返回 "0011", addZero2Str(-18,6)返回 "-000018"
|
||||
*
|
||||
* @param numObj
|
||||
* 数字对象
|
||||
* @param length
|
||||
* 指定的长度
|
||||
* @return
|
||||
*/
|
||||
public static String addZero2Str(Number numObj, int length) {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
// 设置是否使用分组
|
||||
nf.setGroupingUsed(false);
|
||||
// 设置最大整数位数
|
||||
nf.setMaximumIntegerDigits(length);
|
||||
// 设置最小整数位数
|
||||
nf.setMinimumIntegerDigits(length);
|
||||
return nf.format(numObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定对象的指定属性值(去除private,protected的限制)
|
||||
*
|
||||
* @param obj
|
||||
* 属性名称所在的对象
|
||||
* @param fieldName
|
||||
* 属性名称
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Object forceGetFieldValue(Object obj, String fieldName) throws Exception {
|
||||
Field field = obj.getClass().getField(fieldName);
|
||||
Object object = null;
|
||||
boolean accessible = field.isAccessible();
|
||||
if (!accessible) {
|
||||
// 如果是private,protected修饰的属性,需要修改为可以访问的
|
||||
field.setAccessible(true);
|
||||
object = field.get(obj);
|
||||
// 还原private,protected属性的访问性质
|
||||
field.setAccessible(accessible);
|
||||
return object;
|
||||
}
|
||||
object = field.get(obj);
|
||||
return object;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.cms.blog.mapper.CmsBlogMapper">
|
||||
|
||||
<resultMap type="CmsBlog" id="CmsBlogResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="title" column="title" />
|
||||
<result property="type" column="type" />
|
||||
<result property="content" column="content" />
|
||||
<result property="top" column="Top" />
|
||||
<result property="views" column="views" />
|
||||
<result property="status" column="status" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCmsBlogVo">
|
||||
select id, create_by, create_time, update_by, update_time, title, type, content, Top, views, status from cms_blog
|
||||
</sql>
|
||||
|
||||
<select id="selectCmsBlogList" parameterType="CmsBlog" resultMap="CmsBlogResult">
|
||||
<include refid="selectCmsBlogVo"/>
|
||||
<where>
|
||||
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
<if test="content != null and content != ''"> and content = #{content}</if>
|
||||
<if test="top != null and top != ''"> and Top = #{top}</if>
|
||||
<if test="views != null "> and views = #{views}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
|
||||
</where>
|
||||
ORDER BY Top DESC, create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectCmsBlogById" parameterType="Long" resultMap="CmsBlogResult">
|
||||
<include refid="selectCmsBlogVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectCmsBlogListByTypeId" parameterType="Long" resultMap="CmsBlogResult">
|
||||
<include refid="selectCmsBlogVo"/>
|
||||
<where>
|
||||
<if test="id != null and id != ''"> and id in (SELECT blog_id FROM cms_blog_type WHERE type_id = #{id})</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectCmsBlogListByTagId" parameterType="Long" resultMap="CmsBlogResult">
|
||||
<include refid="selectCmsBlogVo"/>
|
||||
<where>
|
||||
<if test="id != null and id != ''"> and id in (SELECT blog_id FROM cms_blog_tag WHERE tag_id = #{id})</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectCmsBlogListRecommend" parameterType="CmsBlog" resultMap="CmsBlogResult">
|
||||
<include refid="selectCmsBlogVo"/>
|
||||
<where>
|
||||
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
<if test="content != null and content != ''"> and content = #{content}</if>
|
||||
<if test="top != null and top != ''"> and Top = #{top}</if>
|
||||
<if test="views != null "> and views = #{views}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
|
||||
</where>
|
||||
ORDER BY views DESC, create_time DESC
|
||||
</select>
|
||||
|
||||
<insert id="insertCmsBlog" parameterType="CmsBlog" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into cms_blog
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="title != null and title != ''">title,</if>
|
||||
<if test="type != null and type != ''">type,</if>
|
||||
<if test="content != null">content,</if>
|
||||
<if test="top != null">Top,</if>
|
||||
<if test="views != null">views,</if>
|
||||
<if test="status != null">status,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="title != null and title != ''">#{title},</if>
|
||||
<if test="type != null and type != ''">#{type},</if>
|
||||
<if test="content != null">#{content},</if>
|
||||
<if test="top != null">#{top},</if>
|
||||
<if test="views != null">#{views},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateCmsBlog" parameterType="CmsBlog">
|
||||
update cms_blog
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="title != null and title != ''">title = #{title},</if>
|
||||
<if test="type != null and type != ''">type = #{type},</if>
|
||||
<if test="content != null">content = #{content},</if>
|
||||
<if test="top != null">Top = #{top},</if>
|
||||
<if test="views != null">views = #{views},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteCmsBlogById" parameterType="Long">
|
||||
delete from cms_blog where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteCmsBlogByIds" parameterType="String">
|
||||
delete from cms_blog where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.ruoyi.cms.blog.mapper.CmsBlogTagMapper">
|
||||
<resultMap type="cmsBlogTag" id="blogTagResult">
|
||||
<result property="tagId" column="tag_id" />
|
||||
<result property="blogId" column="blog_id" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchBlogTag">
|
||||
insert into cms_blog_tag(tag_id, blog_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.tagId},#{item.blogId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteBlogTagByBlogId" parameterType="Long">
|
||||
delete from cms_blog_tag where blog_id=#{blogId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBlogTag" parameterType="Long">
|
||||
delete from cms_blog_tag where blog_id in
|
||||
<foreach collection="array" item="blogId" open="(" separator="," close=")">
|
||||
#{blogId}
|
||||
</foreach>
|
||||
</delete>
|
||||
<delete id="deleteBlogTagByTagId" parameterType="Long">
|
||||
delete from cms_blog_tag where tag_id=#{tagId}
|
||||
</delete>
|
||||
|
||||
<select id="selectBlogTagList" parameterType="Long" resultMap="blogTagResult">
|
||||
select tag_id, blog_id from cms_blog_tag where blog_id = #{blogId}
|
||||
</select>
|
||||
<select id="countBlogByTagId" parameterType="Long" resultType="java.lang.Integer">
|
||||
select count(*) from cms_blog_tag where tag_id=#{tagId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.ruoyi.cms.blog.mapper.CmsBlogTypeMapper">
|
||||
<resultMap type="CmsBlogType" id="blogTypeResult">
|
||||
<result property="typeId" column="type_id" />
|
||||
<result property="blogId" column="blog_id" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchBlogType">
|
||||
insert into cms_blog_type(type_id, blog_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.typeId},#{item.blogId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteBlogTypeByBlogId" parameterType="Long">
|
||||
delete from cms_blog_type where blog_id=#{blogId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBlogType" parameterType="Long">
|
||||
delete from cms_blog_type where blog_id in
|
||||
<foreach collection="array" item="blogId" open="(" separator="," close=")">
|
||||
#{blogId}
|
||||
</foreach>
|
||||
</delete>
|
||||
<delete id="deleteBlogTypeByTypeId" parameterType="Long">
|
||||
delete from cms_blog_type where type_id=#{typeId}
|
||||
</delete>
|
||||
|
||||
<select id="selectBlogTypeList" parameterType="Long" resultMap="blogTypeResult">
|
||||
select type_id, blog_id from cms_blog_type where blog_id = #{blogId}
|
||||
</select>
|
||||
<select id="countBlogByTypeId" parameterType="Long" resultType="java.lang.Integer">
|
||||
select count(*) from cms_blog_type where type_id=#{typeId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.ruoyi.cms.comment.mapper.CmsCommentLikeMapper">
|
||||
<resultMap type="CmsCommentLike" id="commentLikeResult">
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="commentId" column="comment_id" />
|
||||
<result property="userId" column="user_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCmsMessageLikeVo">
|
||||
select create_by, create_time, update_by, update_time, comment_id, user_id from cms_comment_like
|
||||
</sql>
|
||||
|
||||
<select id="selectCmsCommentLikeList" parameterType="CmsCommentLike" resultMap="commentLikeResult">
|
||||
<include refid="selectCmsMessageLikeVo"/>
|
||||
<where>
|
||||
<if test="commentId != null"> and comment_id = #{commentId}</if>
|
||||
<if test="userId != null"> and user_id = #{userId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="addCmsCommentLike" parameterType="CmsCommentLike">
|
||||
insert into cms_comment_like
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="commentId != null">comment_id,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="commentId != null">#{commentId},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteCmsCommentLike" parameterType="CmsCommentLike">
|
||||
delete from cms_comment_like
|
||||
<where>
|
||||
<if test="commentId != null"> and comment_id = #{commentId}</if>
|
||||
<if test="userId != null"> and user_id = #{userId}</if>
|
||||
</where>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,133 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.cms.comment.mapper.CmsCommentMapper">
|
||||
|
||||
<resultMap type="CmsComment" id="CmsCommentResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="mainId" column="main_id" />
|
||||
<result property="likeNum" column="like_num" />
|
||||
<result property="content" column="content" />
|
||||
<result property="type" column="type" />
|
||||
<result property="blogId" column="blog_id" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCmsCommentVo">
|
||||
select id, parent_id, main_id, like_num, content, type, blog_id, del_flag, user_id, create_by, create_time, update_by, update_time from cms_comment
|
||||
</sql>
|
||||
|
||||
<select id="selectCmsCommentList" parameterType="CmsComment" resultMap="CmsCommentResult">
|
||||
<include refid="selectCmsCommentVo"/>
|
||||
<where>
|
||||
<if test="parentId != null "> and parent_id = #{parentId}</if>
|
||||
<if test="mainId != null "> and main_id = #{mainId}</if>
|
||||
<if test="likeNum != null "> and like_num = #{likeNum}</if>
|
||||
<if test="content != null and content != ''"> and content like concat('%', #{content}, '%')</if>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
<if test="blogId != null "> and blog_id = #{blogId}</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="delFlag != null and delFlag != ''"> and del_flag = #{delFlag}</if>
|
||||
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
|
||||
</where>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectCmsCommentById" parameterType="Long" resultMap="CmsCommentResult">
|
||||
<include refid="selectCmsCommentVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectChildCommentList" parameterType="CmsComment" resultMap="CmsCommentResult">
|
||||
<include refid="selectCmsCommentVo"/>
|
||||
<where>
|
||||
<if test="parentId != null "> and parent_id = #{parentId}</if>
|
||||
<if test="mainId != null "> and main_id = #{mainId}</if>
|
||||
<if test="likeNum != null "> and like_num = #{likeNum}</if>
|
||||
<if test="content != null and content != ''"> and content like concat('%', #{content}, '%')</if>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
<if test="blogId != null "> and blog_id = #{blogId}</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="delFlag != null and delFlag != ''"> and del_flag = #{delFlag}</if>
|
||||
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
|
||||
</where>
|
||||
ORDER BY create_time ASC
|
||||
</select>
|
||||
|
||||
<insert id="insertCmsComment" parameterType="CmsComment" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into cms_comment
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="mainId != null">main_id,</if>
|
||||
<if test="likeNum != null">like_num,</if>
|
||||
<if test="content != null">content,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="blogId != null">blog_id,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="mainId != null">#{mainId},</if>
|
||||
<if test="likeNum != null">#{likeNum},</if>
|
||||
<if test="content != null">#{content},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="blogId != null">#{blogId},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateCmsComment" parameterType="CmsComment">
|
||||
update cms_comment
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="mainId != null">main_id = #{mainId},</if>
|
||||
<if test="likeNum != null">like_num = #{likeNum},</if>
|
||||
<if test="content != null">content = #{content},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="blogId != null">blog_id = #{blogId},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updateDelFlagById" parameterType="Long">
|
||||
Update cms_comment Set del_flag = '1' where id = #{id}
|
||||
</update>
|
||||
<update id="updateDelFlagByIds" parameterType="Long">
|
||||
Update cms_comment Set del_flag = '1' where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteCmsCommentById" parameterType="Long">
|
||||
delete from cms_comment where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteCmsCommentByIds" parameterType="String">
|
||||
delete from cms_comment where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.ruoyi.cms.message.mapper.CmsMessageLikeMapper">
|
||||
<resultMap type="CmsMessageLike" id="messageLikeResult">
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="messageId" column="message_id" />
|
||||
<result property="userId" column="user_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCmsMessageLikeVo">
|
||||
select create_by, create_time, update_by, update_time, message_id, user_id from cms_message_like
|
||||
</sql>
|
||||
|
||||
<select id="selectCmsMessageLikeList" parameterType="CmsMessageLike" resultMap="messageLikeResult">
|
||||
<include refid="selectCmsMessageLikeVo"/>
|
||||
<where>
|
||||
<if test="messageId != null"> and message_id = #{messageId}</if>
|
||||
<if test="userId != null"> and user_id = #{userId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="addCmsMessageLike" parameterType="CmsMessageLike">
|
||||
insert into cms_message_like
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="messageId != null">message_id,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="messageId != null">#{messageId},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteCmsMessageLike" parameterType="CmsMessageLike">
|
||||
delete from cms_message_like
|
||||
<where>
|
||||
<if test="messageId != null"> and message_id = #{messageId}</if>
|
||||
<if test="userId != null"> and user_id = #{userId}</if>
|
||||
</where>
|
||||
</delete>
|
||||
</mapper>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue