Author SHA1 Message Date
dependabot[bot] bec9f5591e Bump mysql-connector-java from 8.0.11 to 8.0.16 in /ruoyi-api
Bumps [mysql-connector-java](https://github.com/mysql/mysql-connector-j) from 8.0.11 to 8.0.16.
- [Release notes](https://github.com/mysql/mysql-connector-j/releases)
- [Changelog](https://github.com/mysql/mysql-connector-j/blob/release/8.0/CHANGES)
- [Commits](https://github.com/mysql/mysql-connector-j/compare/8.0.11...8.0.16)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-02 00:56:19 +00:00
guchengwuyue 37c39d7b6a Update README.md 2020-06-13 17:36:57 +08:00
guchengwuyue 02ba3af532 Update README.md 2020-06-08 19:49:02 +08:00
guchengwuyue 34b84a053d Update README.md 2020-05-05 14:26:37 +08:00
guchengwuyue b1de865f6a Update README.md 2020-05-04 19:48:38 +08:00
guchengwuyue e345600d9e Update README.md 2020-05-04 19:47:12 +08:00
guchengwuyue 10630d5bfe Update README.md 2020-04-13 17:53:17 +08:00
guchengwuyue 274ad36c70 Update README.md 2020-04-13 17:50:00 +08:00
guchengwuyue ed28897508 Update README.md 2020-04-13 15:49:51 +08:00
guchengwuyue 9381f27d65 Update README.md 2019-12-15 11:35:19 +08:00
guchengwuyue 60086d17a7 Update README.md 2019-11-16 06:37:06 +08:00
guchengwuyue 40f968fbda Update README.md 2019-11-11 19:13:10 +08:00
guchengwuyue 4be0b0ac89 Update README.md 2019-11-07 22:06:58 +08:00
4592 changed files with 167774 additions and 550702 deletions

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
*.js linguist-language=java
*.css linguist-language=java
*.html linguist-language=java
+42 -6
View File
@@ -1,7 +1,43 @@
/.git
/.idea
######################################################################
# 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
*.DS_Store
/yshop-drink-boot3/target/
/yshop-drink-vue3/node_modules
/yshop-drink-uniapp-vue3/node_moduls
*.xml.versionsBackup
!*/build/*.java
!*/build/*.html
!*/build/*.xml
+13 -14
View File
@@ -1,21 +1,20 @@
MIT License
The MIT License (MIT)
Copyright (c) 2023 yshop
Copyright (c) 2018 RuoYi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+195 -152
View File
@@ -1,152 +1,195 @@
## 平台简介
意象点餐(扫码点餐)系统,在线点餐(外卖与自取)小程序模式,支持多门店模式,SaaS多租户模式,基础技术Java17,springboot3、vue3、uniapp(vue3)(支持H5、微信小程序)
采用当前流行技术组合的前后端分离点餐系统: SpringBoot3、Spring Security OAuth2、MybatisPlus、SpringSecurity、jwt、redis、Vue3的前后端分离的系统,
包含外卖与自取、商品管理(多规格sku)、店铺管理、云小票打印、图片素材库、订单管理、积分兑换(积分+金额)、充值、优惠券、充值、多门店、微信公众号、商家中心、提前预约、桌面扫码点餐(单人或者多人协同)、收银台(支持扫码枪与扫码盒子收款)、会员卡、桌台点餐、自定义装修等功能,更适合企业或个人二次开发.
官网地址:[https://www.yixiang.co/](https://www.yixiang.co/)
## 演示地址
| 后台登陆: | https://dc.yixiang.co 账号/密码:admin/admin123 |
|---|---|
| 门店登陆: | https://dc.yixiang.co 账号/密码:yixiang001/123456789 |
| 移动端演示:关注右边公众号点击菜单其他系统体验点餐小程序与点餐H5,其中如果演示使用验证码登陆的点击下验证码默认验证码是9999 | ![输入图片说明](assets/77a93e8c07a913b838a756abadb383b9.png) |
## 视频资料
如果对您有帮助,您可以点右上角 "Star" 支持一下,这样我们才有继续免费下去的动力,谢谢! QQ交流群 (入群前,请在网页右上角点 "Star" ),群里有视频教程与开发文档哦!!
交流QQ群:544263002
## 项目说明
```
yshop-drink. Java工程
yshop-drink-vue 后台前端vue3工程
yshop-drink-uniapp-vue3 移动端uniapp(vue3版本)工程,支持微信小程序、h5
```
## 本地快速启动
##### 1、环境要求
```
jdk17
mysql8
redis6+
node16+
maven3.8+
```
##### 2、开发工具
```
idea
vscode
hbuilder
```
##### 3、后端启动
- 3.1 请使用idea打开Java工程,自动会安装依赖
- 3.2 创建数据库且导入工程目录下sql/yixiang-drink.sql 文件
- 3.3 找到项目下的yshop-server 的yml,修改数据库相关信息和redis相关信息,如图:
![输入图片说明](assets/image.png)
- 3.4 工程下输入
```
mvn clean install package '-Dmaven.test.skip=true
```
- 3.5 启动项目,如图
![输入图片说明](assets/1702544439568.jpg)
##### 4、后台vue启动
- 4.1 vscode 打开vue工程,在目录下输入命令:
```
pnpm install
```
- 4.2 配置api如图
![输入图片说明](assets/1702544756749.jpg)
- 4.3 本地启动:
```
npm run dev
```
##### 5 移动端uniapp启动
- 5.1 hbuilder导入uniapp项目,
- 5.2 配置api
![输入图片说明](assets/WX20231214-171211@2x.png)
- 5.3 配置小程序
![输入图片说明](assets/WX20231214-171416@2x.png)
- 5.4 运行小程序
![输入图片说明](assets/WX20231214-171514@2x.png)
- 5.5 运行h5
![输入图片说明](assets/1702545370856.jpg)
-
## 小程序截图
| ![输入图片说明](assets/1000.jpg)| ![输入图片说明](assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20260309235851_552_6.png) |
|---|---|
| ![输入图片说明](assets/200000.jpg) | ![输入图片说明](assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20260309235857_557_6.png) |
| ![输入图片说明](assets/10003.jpg) | ![输入图片说明](assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20260309235856_556_6.png) |
## 后台截图
| ![输入图片说明](assets/3000.png) |
| ![输入图片说明](assets/1230000.png)|
|---|---|
| ![输入图片说明](assets/3001.png) |
| ![输入图片说明](assets/3002.png) |
| ![输入图片说明](assets/3003.png) | ![输入图片说明](assets/3004.png) |
![输入图片说明](assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20260310000501_559_6.png)
![输入图片说明](assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20260310001028_564_6.png)
![输入图片说明](assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20260310001057_565_6.png)
## 技术栈
- Spring Boot3
- Spring Security oauth2
- MyBatis
- MyBatisPlus
- Redis
- lombok
- hutool
- Vue3
- Element UI
- uniapp(vue3)
## 特别鸣谢
- ruoyi-vue-pro:https://gitee.com/zhijiantianya/ruoyi-vue-pro
- element-plus:https://element-plus.gitee.io/zh-CN/
- vue:https://cn.vuejs.org/
- pay-java-parent:https://gitee.com/egzosn/pay-java-parent
- uvui:https://www.uvui.cn/
- uniapp:https://uniapp.dcloud.net.cn/
## 开源协议
本项目采用比 Apache 2.0 更宽松的 [MIT License](https://gitee.com/guchengwuyue/yshop-drink/blob/master/LICENSE) 开源协议,个人与企业可 100% 免费使用,不用保留类作者、Copyright 信息。
### **供货商城升级版yshop会员电商系统:**
## yshop会员商城系统介绍
yshop会员商城系统功能:在线买单、在线充值、消费记录、会员中心、多规格sku商品管理、
分销、收藏、地址、分类、评价、积分、运费模板、、优惠券、订单管理、
买单管理、物流、短信、微信菜单、微信回复、微信图文、模板消息等等
### 技术栈
mybatisPlus、redis、lombok、mapstruct、jwt、WxJava、Druid、OSS、Vue、Vue-router、Vuex等
* 核心框架:SpringBoot2 + mybatis + jwt
* 消息中间件:Redis
* 前端手脚架:Avue-cli
* 前端框架:Vue2 + vant + Vue-router + Vuex + jquery + thymeleaf
* 持久层框架:MyBatis-plus
* 微信开发Java SDK:WxJava
* 文件管理:阿里oss、七牛云、腾讯cos、本地
* JDK版本:Java8+
* 数据库:mysql5.7
**模块划分:**
```
- yixiang-base 基础模块
- config 配置等
- coupon 优惠券
- handler mybatis handler
- mall
- order 订单
- oss 云存储
- redis 常用配置与订单过期,自动收货监听等
- system
- weixin
- yixiang-common common通用工具
- yixiang-framework 核心
- yixiang-mall 商城
- yixiang-generator 代码生成模块 支持mybatisplus
- yixiang-quartr 定时任务
- yixiang-admin 管理后台
- yixiang-app api模块 jwt+自定义注解验证
- yixiang-weixin 微信模块
```
**`功能特色** ‘
1、spu,多规格sku商品管理
<table>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2020/0504/192604_7db25918_477893.png"/></td>
<td><img src="https://images.gitee.com/uploads/images/2020/0504/192638_a4adcc1b_477893.png"/></td
</tr>
</table>
2、多级商品分类管理、商品评价管理、订单管理、实时物流、运费模板、用户购物车、用户收藏、优惠券、积分、OSS(七牛、腾讯、阿里)、素材管理等
<table>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2020/0504/192708_127ceda5_477893.png"/></td>
<td><img src="https://images.gitee.com/uploads/images/2020/0504/192733_5402d25d_477893.png"/></td>
</tr>
</table>
-
-
-
-
### **下面是供货老版本商城概况:**
本商城系统是一套完整的商城系统,包括小程序+小程序API+后台商城管理!!
**系统基础组合来源:**
程序员就要坚持着不要重复造轮子想法,所有就在码云里找自己合适的轮子::
1、若依管理后台:用它做后台管理
2、Light Security:用它主要来对接小程序API
当然他们本身已经完成了很多功能,这里不多说,大家可以直接去码云搜索即可,后面会放上他们连接。
本系统主要包括三部分:
第一:商城后台,完成完整的商城管理系统,目前基本已经完成,至于有bug大家可以直接issue或者进群交流(后面会打出来的(⊙o⊙)?!!),
功能大概包括:商品管理,商品多规格属性管理,商品分类,商品品牌,商品订单,会员信息等等。
涉及到技术: **springboot+Thymeleaf+mybatis**
大致效果如下:
<table>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0830/180715_7394c4c4_477893.png"/></td>
<td><img src="https://images.gitee.com/uploads/images/2019/0830/180732_b2055281_477893.png"/></td>
</tr>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0830/180740_8cc475d4_477893.png"/></td>
<td><img src="https://images.gitee.com/uploads/images/2019/0830/180752_45e9b4ce_477893.png"/></td>
</tr>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0830/180800_31df8e35_477893.png"/></td>
<td><img src="https://images.gitee.com/uploads/images/2019/0830/180809_4147d2e2_477893.png"/></td>
</tr>
</table>
第二:小程序API,目前API模块已经基本完成,
涉及到技术: **springboot+mybatis-plus+jwt+mapstruct+lombok+redis+swagger**
大致如下效果:
<table>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0914/145813_85d0bdc7_477893.png"/></td>
<td><img src="https://images.gitee.com/uploads/images/2019/0916/164354_34a2cf90_477893.png"/></td>
</tr>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0928/174546_7531f0ca_477893.png"/></td>
<td></td>
</tr>
</table>
第三:mpvue小程序,小程序主要是用 **mpvue** 框架开发,这里就不说它的好处。
mpvue 小程序运行步骤:
1、安装node环境
node 是8版本
2、设置npm淘宝镜像
npm set registry https://registry.npm.taobao.org/
3、npm install
4、npm run dev
大致效果如下:
<table>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0830/181113_1b7f255a_477893.jpeg"/></td>
<td><img src="https://images.gitee.com/uploads/images/2019/0830/181123_0c86c94c_477893.jpeg"/></td>
</tr>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0830/181132_b729a89b_477893.jpeg"/></td>
<td><img src="https://images.gitee.com/uploads/images/2019/0830/181140_08e362ad_477893.jpeg"/></td>
</tr>
<tr>
<td><img src="https://images.gitee.com/uploads/images/2019/0830/181150_b5e0cd3e_477893.jpeg"/></td>
<td></td>
</tr>
</table>
**学习交流**
其他:欢迎star或者提出你们宝贵的建议哦!!!
****Requirement:****
- JDK1.8+,
- mysql5.7+
**特别鸣谢**
若依系统:[ruoyi](https://gitee.com/y_project/RuoYi)
简单jwt权限:[Light Security](https://gitee.com/itmuch/light-security)
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 MiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 385 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 474 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 609 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 595 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 542 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 430 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 642 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 528 KiB

+12
View File
@@ -0,0 +1,12 @@
@echo off
echo.
echo [信息] 清理生成路径。
echo.
%~d0
cd %~dp0
cd ..
call mvn clean
pause
+12
View File
@@ -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
+14
View File
@@ -0,0 +1,14 @@
@echo off
echo.
echo [信息] 运行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.
Binary file not shown.
-6
View File
@@ -1,6 +0,0 @@
{
"name": "yshop-drink",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}
+274
View File
@@ -0,0 +1,274 @@
<?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>4.0.0</version>
<name>ruoyi</name>
<url>http://www.ruoyi.vip</url>
<description>若依管理系统</description>
<properties>
<ruoyi.version>4.0.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>
<shiro.version>1.4.0</shiro.version>
<thymeleaf.extras.shiro.version>2.0.0</thymeleaf.extras.shiro.version>
<mybatis.boot.version>1.3.2</mybatis.boot.version>
<druid.version>1.1.14</druid.version>
<bitwalker.version>1.19</bitwalker.version>
<kaptcha.version>2.3.2</kaptcha.version>
<swagger.version>2.9.2</swagger.version>
<pagehelper.boot.version>1.2.5</pagehelper.boot.version>
<fastjson.version>1.2.47</fastjson.version>
<oshi.version>3.9.1</oshi.version>
<commons.io.version>2.5</commons.io.version>
<commons.fileupload.version>1.3.3</commons.fileupload.version>
<jsoup.version>1.11.3</jsoup.version>
<poi.version>3.17</poi.version>
<velocity.version>1.7</velocity.version>
</properties>
<!-- 依赖声明 -->
<dependencyManagement>
<dependencies>
<!-- SpringBoot的依赖配置-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.1.RELEASE</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>com.github.penggle</groupId>
<artifactId>kaptcha</artifactId>
<version>${kaptcha.version}</version>
</dependency>
<!--Shiro核心框架 -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>${shiro.version}</version>
</dependency>
<!-- Shiro使用Srping框架 -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>${shiro.version}</version>
</dependency>
<!-- Shiro使用EhCache缓存框架 -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>${shiro.version}</version>
</dependency>
<!-- thymeleaf模板引擎和shiro框架的整合 -->
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>${thymeleaf.extras.shiro.version}</version>
</dependency>
<!-- 解析客户端操作系统、浏览器等 -->
<dependency>
<groupId>eu.bitwalker</groupId>
<artifactId>UserAgentUtils</artifactId>
<version>${bitwalker.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>
<!-- swagger2-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- swagger2-UI-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</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>
<!-- HTML解析器 -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>${jsoup.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</artifactId>
<version>${velocity.version}</version>
</dependency>
<!-- 阿里JSON解析器 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.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>
</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-api</module>
</modules>
<packaging>pom</packaging>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<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>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
+107
View File
@@ -0,0 +1,107 @@
<?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>4.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>ruoyi-admin</artifactId>
<description>
web服务入口
</description>
<dependencies>
<!-- SpringBoot集成thymeleaf模板 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency>
<!-- swagger2-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<!--防止进入swagger页面报类型转换错误,排除2.9.2中的引用,手动增加1.5.21版本-->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.21</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.21</version>
</dependency>
<!-- swagger2-UI-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<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.0.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>${artifactId}</warName>
</configuration>
</plugin>
</plugins>
<finalName>${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,91 @@
package com.ruoyi.web.controller.common;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.config.ServerConfig;
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;
/**
* 通用请求处理
*
* @author ruoyi
*/
@Controller
public class CommonController
{
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
@Autowired
private ServerConfig serverConfig;
/**
* 通用下载请求
*
* @param fileName 文件名称
* @param delete 是否删除
*/
@GetMapping("common/download")
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
{
try
{
if (!FileUtils.isValidFilename(fileName))
{
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
}
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
String filePath = Global.getDownloadPath() + fileName;
response.setCharacterEncoding("utf-8");
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition",
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
FileUtils.writeBytes(filePath, response.getOutputStream());
if (delete)
{
FileUtils.deleteFile(filePath);
}
}
catch (Exception e)
{
log.error("下载文件失败", e);
}
}
/**
* 通用上传请求
*/
@PostMapping("/common/upload")
@ResponseBody
public AjaxResult uploadFile(MultipartFile file) throws Exception
{
try
{
// 上传文件路径
String filePath = Global.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("fileName", fileName);
ajax.put("url", url);
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
}
@@ -0,0 +1,80 @@
package com.ruoyi.web.controller.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* 模态窗口
*
* @author ruoyi
*/
@Controller
@RequestMapping("/demo/modal")
public class DemoDialogController
{
private String prefix = "demo/modal";
/**
* 模态窗口
*/
@GetMapping("/dialog")
public String dialog()
{
return prefix + "/dialog";
}
/**
* 弹层组件
*/
@GetMapping("/layer")
public String layer()
{
return prefix + "/layer";
}
/**
* 表单
*/
@GetMapping("/form")
public String form()
{
return prefix + "/form";
}
/**
* 表格
*/
@GetMapping("/table")
public String table()
{
return prefix + "/table";
}
/**
* 表格check
*/
@GetMapping("/check")
public String check()
{
return prefix + "/table/check";
}
/**
* 表格radio
*/
@GetMapping("/radio")
public String radio()
{
return prefix + "/table/radio";
}
/**
* 表格回传父窗体
*/
@GetMapping("/parent")
public String parent()
{
return prefix + "/table/parent";
}
}
@@ -0,0 +1,261 @@
package com.ruoyi.web.controller.demo.controller;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.core.domain.AjaxResult;
/**
* 表单相关
*
* @author ruoyi
*/
@Controller
@RequestMapping("/demo/form")
public class DemoFormController
{
private String prefix = "demo/form";
private final static List<UserFormModel> users = new ArrayList<UserFormModel>();
{
users.add(new UserFormModel(1, "1000001", "测试1", "15888888888"));
users.add(new UserFormModel(2, "1000002", "测试2", "15666666666"));
users.add(new UserFormModel(3, "1000003", "测试3", "15666666666"));
users.add(new UserFormModel(4, "1000004", "测试4", "15666666666"));
users.add(new UserFormModel(5, "1000005", "测试5", "15666666666"));
}
/**
* 按钮页
*/
@GetMapping("/button")
public String button()
{
return prefix + "/button";
}
/**
* 下拉框
*/
@GetMapping("/select")
public String select()
{
return prefix + "/select";
}
/**
* 表单校验
*/
@GetMapping("/validate")
public String validate()
{
return prefix + "/validate";
}
/**
* 功能扩展(包含文件上传)
*/
@GetMapping("/jasny")
public String jasny()
{
return prefix + "/jasny";
}
/**
* 拖动排序
*/
@GetMapping("/sortable")
public String sortable()
{
return prefix + "/sortable";
}
/**
* 选项卡 & 面板
*/
@GetMapping("/tabs_panels")
public String tabs_panels()
{
return prefix + "/tabs_panels";
}
/**
* 栅格
*/
@GetMapping("/grid")
public String grid()
{
return prefix + "/grid";
}
/**
* 表单向导
*/
@GetMapping("/wizard")
public String wizard()
{
return prefix + "/wizard";
}
/**
* 文件上传
*/
@GetMapping("/upload")
public String upload()
{
return prefix + "/upload";
}
/**
* 日期和时间页
*/
@GetMapping("/datetime")
public String datetime()
{
return prefix + "/datetime";
}
/**
* 左右互选组件
*/
@GetMapping("/duallistbox")
public String duallistbox()
{
return prefix + "/duallistbox";
}
/**
* 基本表单
*/
@GetMapping("/basic")
public String basic()
{
return prefix + "/basic";
}
/**
* 卡片列表
*/
@GetMapping("/cards")
public String cards()
{
return prefix + "/cards";
}
/**
* summernote 富文本编辑器
*/
@GetMapping("/summernote")
public String summernote()
{
return prefix + "/summernote";
}
/**
* 搜索自动补全
*/
@GetMapping("/autocomplete")
public String autocomplete()
{
return prefix + "/autocomplete";
}
/**
* 获取用户数据
*/
@GetMapping("/userModel")
@ResponseBody
public AjaxResult userModel()
{
AjaxResult ajax = new AjaxResult();
ajax.put("code", 200);
ajax.put("value", users);
return ajax;
}
/**
* 获取数据集合
*/
@GetMapping("/collection")
@ResponseBody
public AjaxResult collection()
{
String[] array = { "ruoyi 1", "ruoyi 2", "ruoyi 3", "ruoyi 4", "ruoyi 5" };
AjaxResult ajax = new AjaxResult();
ajax.put("value", array);
return ajax;
}
}
class UserFormModel
{
/** 用户ID */
private int userId;
/** 用户编号 */
private String userCode;
/** 用户姓名 */
private String userName;
/** 用户手机 */
private String userPhone;
public UserFormModel()
{
}
public UserFormModel(int userId, String userCode, String userName, String userPhone)
{
this.userId = userId;
this.userCode = userCode;
this.userName = userName;
this.userPhone = userPhone;
}
public int getUserId()
{
return userId;
}
public void setUserId(int userId)
{
this.userId = userId;
}
public String getUserCode()
{
return userCode;
}
public void setUserCode(String userCode)
{
this.userCode = userCode;
}
public String getUserName()
{
return userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getUserPhone()
{
return userPhone;
}
public void setUserPhone(String userPhone)
{
this.userPhone = userPhone;
}
}
@@ -0,0 +1,35 @@
package com.ruoyi.web.controller.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* 图标相关
*
* @author ruoyi
*/
@Controller
@RequestMapping("/demo/icon")
public class DemoIconController
{
private String prefix = "demo/icon";
/**
* FontAwesome图标
*/
@GetMapping("/fontawesome")
public String fontAwesome()
{
return prefix + "/fontawesome";
}
/**
* Glyphicons图标
*/
@GetMapping("/glyphicons")
public String glyphicons()
{
return prefix + "/glyphicons";
}
}
@@ -0,0 +1,303 @@
package com.ruoyi.web.controller.demo.controller;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.demo.domain.UserOperateModel;
/**
* 操作控制
*
* @author ruoyi
*/
@Controller
@RequestMapping("/demo/operate")
public class DemoOperateController extends BaseController
{
private String prefix = "demo/operate";
private final static Map<Integer, UserOperateModel> users = new LinkedHashMap<Integer, UserOperateModel>();
{
users.put(1, new UserOperateModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0"));
users.put(2, new UserOperateModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1"));
users.put(3, new UserOperateModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1"));
users.put(4, new UserOperateModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1"));
users.put(5, new UserOperateModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1"));
users.put(6, new UserOperateModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1"));
users.put(7, new UserOperateModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1"));
users.put(8, new UserOperateModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1"));
users.put(9, new UserOperateModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1"));
users.put(10, new UserOperateModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1"));
users.put(11, new UserOperateModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1"));
users.put(12, new UserOperateModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1"));
users.put(13, new UserOperateModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1"));
users.put(14, new UserOperateModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1"));
users.put(15, new UserOperateModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1"));
users.put(16, new UserOperateModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1"));
users.put(17, new UserOperateModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1"));
users.put(18, new UserOperateModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1"));
users.put(19, new UserOperateModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1"));
users.put(20, new UserOperateModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1"));
users.put(21, new UserOperateModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1"));
users.put(22, new UserOperateModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1"));
users.put(23, new UserOperateModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1"));
users.put(24, new UserOperateModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1"));
users.put(25, new UserOperateModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1"));
users.put(26, new UserOperateModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1"));
}
/**
* 表格
*/
@GetMapping("/table")
public String table()
{
return prefix + "/table";
}
/**
* 其他
*/
@GetMapping("/other")
public String other()
{
return prefix + "/other";
}
/**
* 查询数据
*/
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(UserOperateModel userModel)
{
TableDataInfo rspData = new TableDataInfo();
List<UserOperateModel> userList = new ArrayList<UserOperateModel>(users.values());
// 查询条件过滤
if (StringUtils.isNotEmpty(userModel.getSearchValue()))
{
userList.clear();
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
{
if (entry.getValue().getUserName().equals(userModel.getSearchValue()))
{
userList.add(entry.getValue());
}
}
}
PageDomain pageDomain = TableSupport.buildPageRequest();
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize())
{
rspData.setRows(userList);
rspData.setTotal(userList.size());
return rspData;
}
Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
Integer pageSize = pageDomain.getPageNum() * 10;
if (pageSize > userList.size())
{
pageSize = userList.size();
}
rspData.setRows(userList.subList(pageNum, pageSize));
rspData.setTotal(userList.size());
return rspData;
}
/**
* 新增用户
*/
@GetMapping("/add")
public String add(ModelMap mmap)
{
return prefix + "/add";
}
/**
* 新增保存用户
*/
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(UserOperateModel user)
{
Integer userId = users.size() + 1;
user.setUserId(userId);
return AjaxResult.success(users.put(userId, user));
}
/**
* 修改用户
*/
@GetMapping("/edit/{userId}")
public String edit(@PathVariable("userId") Integer userId, ModelMap mmap)
{
mmap.put("user", users.get(userId));
return prefix + "/edit";
}
/**
* 修改保存用户
*/
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(UserOperateModel user)
{
return AjaxResult.success(users.put(user.getUserId(), user));
}
/**
* 导出
*/
@PostMapping("/export")
@ResponseBody
public AjaxResult export(UserOperateModel user)
{
List<UserOperateModel> list = new ArrayList<UserOperateModel>(users.values());
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
return util.exportExcel(list, "用户数据");
}
/**
* 下载模板
*/
@GetMapping("/importTemplate")
@ResponseBody
public AjaxResult importTemplate()
{
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
return util.importTemplateExcel("用户数据");
}
/**
* 导入数据
*/
@PostMapping("/importData")
@ResponseBody
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
List<UserOperateModel> userList = util.importExcel(file.getInputStream());
String message = importUser(userList, updateSupport);
return AjaxResult.success(message);
}
/**
* 删除用户
*/
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
Integer[] userIds = Convert.toIntArray(ids);
for (Integer userId : userIds)
{
users.remove(userId);
}
return AjaxResult.success();
}
/**
* 查看详细
*/
@GetMapping("/detail/{userId}")
public String detail(@PathVariable("userId") Integer userId, ModelMap mmap)
{
mmap.put("user", users.get(userId));
return prefix + "/detail";
}
@PostMapping("/clean")
@ResponseBody
public AjaxResult clean()
{
users.clear();
return success();
}
/**
* 导入用户数据
*
* @param userList 用户数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @return 结果
*/
public String importUser(List<UserOperateModel> userList, Boolean isUpdateSupport)
{
if (StringUtils.isNull(userList) || userList.size() == 0)
{
throw new BusinessException("导入用户数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (UserOperateModel user : userList)
{
try
{
// 验证是否存在这个用户
boolean userFlag = false;
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
{
if (entry.getValue().getUserName().equals(user.getUserName()))
{
userFlag = true;
break;
}
}
if (!userFlag)
{
Integer userId = users.size() + 1;
user.setUserId(userId);
users.put(userId, user);
successNum++;
successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 导入成功");
}
else if (isUpdateSupport)
{
users.put(user.getUserId(), user);
successNum++;
successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 更新成功");
}
else
{
failureNum++;
failureMsg.append("<br/>" + failureNum + "、用户 " + user.getUserName() + " 已存在");
}
}
catch (Exception e)
{
failureNum++;
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
}
}
if (failureNum > 0)
{
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new BusinessException(failureMsg.toString());
}
else
{
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
}
@@ -0,0 +1,53 @@
package com.ruoyi.web.controller.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* 报表
*
* @author ruoyi
*/
@Controller
@RequestMapping("/demo/report")
public class DemoReportController
{
private String prefix = "demo/report";
/**
* 百度ECharts
*/
@GetMapping("/echarts")
public String echarts()
{
return prefix + "/echarts";
}
/**
* 图表插件
*/
@GetMapping("/peity")
public String peity()
{
return prefix + "/peity";
}
/**
* 线状图插件
*/
@GetMapping("/sparkline")
public String sparkline()
{
return prefix + "/sparkline";
}
/**
* 图表组合
*/
@GetMapping("/metrics")
public String metrics()
{
return prefix + "/metrics";
}
}
@@ -0,0 +1,385 @@
package com.ruoyi.web.controller.demo.controller;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
/**
* 表格相关
*
* @author ruoyi
*/
@Controller
@RequestMapping("/demo/table")
public class DemoTableController extends BaseController
{
private String prefix = "demo/table";
private final static List<UserTableModel> users = new ArrayList<UserTableModel>();
{
users.add(new UserTableModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0"));
users.add(new UserTableModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1"));
users.add(new UserTableModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1"));
users.add(new UserTableModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1"));
users.add(new UserTableModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1"));
users.add(new UserTableModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1"));
users.add(new UserTableModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1"));
users.add(new UserTableModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1"));
users.add(new UserTableModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1"));
users.add(new UserTableModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1"));
users.add(new UserTableModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1"));
users.add(new UserTableModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1"));
users.add(new UserTableModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1"));
users.add(new UserTableModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1"));
users.add(new UserTableModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1"));
users.add(new UserTableModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1"));
users.add(new UserTableModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1"));
users.add(new UserTableModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1"));
users.add(new UserTableModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1"));
users.add(new UserTableModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1"));
users.add(new UserTableModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1"));
users.add(new UserTableModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1"));
users.add(new UserTableModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1"));
users.add(new UserTableModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1"));
users.add(new UserTableModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1"));
users.add(new UserTableModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1"));
}
/**
* 搜索相关
*/
@GetMapping("/search")
public String search()
{
return prefix + "/search";
}
/**
* 数据汇总
*/
@GetMapping("/footer")
public String footer()
{
return prefix + "/footer";
}
/**
* 组合表头
*/
@GetMapping("/groupHeader")
public String groupHeader()
{
return prefix + "/groupHeader";
}
/**
* 表格导出
*/
@GetMapping("/export")
public String export()
{
return prefix + "/export";
}
/**
* 翻页记住选择
*/
@GetMapping("/remember")
public String remember()
{
return prefix + "/remember";
}
/**
* 跳转至指定页
*/
@GetMapping("/pageGo")
public String pageGo()
{
return prefix + "/pageGo";
}
/**
* 自定义查询参数
*/
@GetMapping("/params")
public String params()
{
return prefix + "/params";
}
/**
* 多表格
*/
@GetMapping("/multi")
public String multi()
{
return prefix + "/multi";
}
/**
* 点击按钮加载表格
*/
@GetMapping("/button")
public String button()
{
return prefix + "/button";
}
/**
* 表格冻结列
*/
@GetMapping("/fixedColumns")
public String fixedColumns()
{
return prefix + "/fixedColumns";
}
/**
* 自定义触发事件
*/
@GetMapping("/event")
public String event()
{
return prefix + "/event";
}
/**
* 表格细节视图
*/
@GetMapping("/detail")
public String detail()
{
return prefix + "/detail";
}
/**
* 表格图片预览
*/
@GetMapping("/image")
public String image()
{
return prefix + "/image";
}
/**
* 动态增删改查
*/
@GetMapping("/curd")
public String curd()
{
return prefix + "/curd";
}
/**
* 表格拖拽操作
*/
@GetMapping("/reorder")
public String reorder()
{
return prefix + "/reorder";
}
/**
* 表格其他操作
*/
@GetMapping("/other")
public String other()
{
return prefix + "/other";
}
/**
* 查询数据
*/
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(UserTableModel userModel)
{
TableDataInfo rspData = new TableDataInfo();
List<UserTableModel> userList = new ArrayList<UserTableModel>(Arrays.asList(new UserTableModel[users.size()]));
Collections.copy(userList, users);
// 查询条件过滤
if (StringUtils.isNotEmpty(userModel.getUserName()))
{
userList.clear();
for (UserTableModel user : users)
{
if (user.getUserName().equals(userModel.getUserName()))
{
userList.add(user);
}
}
}
PageDomain pageDomain = TableSupport.buildPageRequest();
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize())
{
rspData.setRows(userList);
rspData.setTotal(userList.size());
return rspData;
}
Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
Integer pageSize = pageDomain.getPageNum() * 10;
if (pageSize > userList.size())
{
pageSize = userList.size();
}
rspData.setRows(userList.subList(pageNum, pageSize));
rspData.setTotal(userList.size());
return rspData;
}
}
class UserTableModel
{
/** 用户ID */
private int userId;
/** 用户编号 */
private String userCode;
/** 用户姓名 */
private String userName;
/** 用户性别 */
private String userSex;
/** 用户手机 */
private String userPhone;
/** 用户邮箱 */
private String userEmail;
/** 用户余额 */
private double userBalance;
/** 用户状态(0正常 1停用) */
private String status;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
public UserTableModel()
{
}
public UserTableModel(int userId, String userCode, String userName, String userSex, String userPhone,
String userEmail, double userBalance, String status)
{
this.userId = userId;
this.userCode = userCode;
this.userName = userName;
this.userSex = userSex;
this.userPhone = userPhone;
this.userEmail = userEmail;
this.userBalance = userBalance;
this.status = status;
this.createTime = DateUtils.getNowDate();
}
public int getUserId()
{
return userId;
}
public void setUserId(int userId)
{
this.userId = userId;
}
public String getUserCode()
{
return userCode;
}
public void setUserCode(String userCode)
{
this.userCode = userCode;
}
public String getUserName()
{
return userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getUserSex()
{
return userSex;
}
public void setUserSex(String userSex)
{
this.userSex = userSex;
}
public String getUserPhone()
{
return userPhone;
}
public void setUserPhone(String userPhone)
{
this.userPhone = userPhone;
}
public String getUserEmail()
{
return userEmail;
}
public void setUserEmail(String userEmail)
{
this.userEmail = userEmail;
}
public double getUserBalance()
{
return userBalance;
}
public void setUserBalance(double userBalance)
{
this.userBalance = userBalance;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
public Date getCreateTime()
{
return createTime;
}
public void setCreateTime(Date createTime)
{
this.createTime = createTime;
}
}
@@ -0,0 +1,147 @@
package com.ruoyi.web.controller.demo.domain;
import java.util.Date;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.DateUtils;
public class UserOperateModel extends BaseEntity
{
private static final long serialVersionUID = 1L;
private int userId;
@Excel(name = "用户编号")
private String userCode;
@Excel(name = "用户姓名")
private String userName;
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
private String userSex;
@Excel(name = "用户手机")
private String userPhone;
@Excel(name = "用户邮箱")
private String userEmail;
@Excel(name = "用户余额")
private double userBalance;
@Excel(name = "用户状态", readConverterExp = "0=正常,1=停用")
private String status;
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
private Date createTime;
public UserOperateModel()
{
}
public UserOperateModel(int userId, String userCode, String userName, String userSex, String userPhone,
String userEmail, double userBalance, String status)
{
this.userId = userId;
this.userCode = userCode;
this.userName = userName;
this.userSex = userSex;
this.userPhone = userPhone;
this.userEmail = userEmail;
this.userBalance = userBalance;
this.status = status;
this.createTime = DateUtils.getNowDate();
}
public int getUserId()
{
return userId;
}
public void setUserId(int userId)
{
this.userId = userId;
}
public String getUserCode()
{
return userCode;
}
public void setUserCode(String userCode)
{
this.userCode = userCode;
}
public String getUserName()
{
return userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getUserSex()
{
return userSex;
}
public void setUserSex(String userSex)
{
this.userSex = userSex;
}
public String getUserPhone()
{
return userPhone;
}
public void setUserPhone(String userPhone)
{
this.userPhone = userPhone;
}
public String getUserEmail()
{
return userEmail;
}
public void setUserEmail(String userEmail)
{
this.userEmail = userEmail;
}
public double getUserBalance()
{
return userBalance;
}
public void setUserBalance(double userBalance)
{
this.userBalance = userBalance;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
public Date getCreateTime()
{
return createTime;
}
public void setCreateTime(Date createTime)
{
this.createTime = createTime;
}
}
@@ -0,0 +1,26 @@
package com.ruoyi.web.controller.monitor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
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;
/**
* druid 监控
*
* @author ruoyi
*/
@Controller
@RequestMapping("/monitor/data")
public class DruidController extends BaseController
{
private String prefix = "/druid";
@RequiresPermissions("monitor:data:view")
@GetMapping()
public String index()
{
return redirect(prefix + "/index");
}
}
@@ -0,0 +1,31 @@
package com.ruoyi.web.controller.monitor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.framework.web.domain.Server;
/**
* 服务器监控
*
* @author ruoyi
*/
@Controller
@RequestMapping("/monitor/server")
public class ServerController extends BaseController
{
private String prefix = "monitor/server";
@RequiresPermissions("monitor:server:view")
@GetMapping()
public String server(ModelMap mmap) throws Exception
{
Server server = new Server();
server.copyTo();
mmap.put("server", server);
return prefix + "/server";
}
}
@@ -0,0 +1,80 @@
package com.ruoyi.web.controller.monitor;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
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
*/
@Controller
@RequestMapping("/monitor/logininfor")
public class SysLogininforController extends BaseController
{
private String prefix = "monitor/logininfor";
@Autowired
private ISysLogininforService logininforService;
@RequiresPermissions("monitor:logininfor:view")
@GetMapping()
public String logininfor()
{
return prefix + "/logininfor";
}
@RequiresPermissions("monitor:logininfor:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysLogininfor logininfor)
{
startPage();
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
return getDataTable(list);
}
@Log(title = "登陆日志", businessType = BusinessType.EXPORT)
@RequiresPermissions("monitor:logininfor:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysLogininfor logininfor)
{
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
return util.exportExcel(list, "登陆日志");
}
@RequiresPermissions("monitor:logininfor:remove")
@Log(title = "登陆日志", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(logininforService.deleteLogininforByIds(ids));
}
@RequiresPermissions("monitor:logininfor:remove")
@Log(title = "登陆日志", businessType = BusinessType.CLEAN)
@PostMapping("/clean")
@ResponseBody
public AjaxResult clean()
{
logininforService.cleanLogininfor();
return success();
}
}
@@ -0,0 +1,89 @@
package com.ruoyi.web.controller.monitor;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ResponseBody;
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
*/
@Controller
@RequestMapping("/monitor/operlog")
public class SysOperlogController extends BaseController
{
private String prefix = "monitor/operlog";
@Autowired
private ISysOperLogService operLogService;
@RequiresPermissions("monitor:operlog:view")
@GetMapping()
public String operlog()
{
return prefix + "/operlog";
}
@RequiresPermissions("monitor:operlog:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysOperLog operLog)
{
startPage();
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
return getDataTable(list);
}
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
@RequiresPermissions("monitor:operlog:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysOperLog operLog)
{
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
return util.exportExcel(list, "操作日志");
}
@RequiresPermissions("monitor:operlog:remove")
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(operLogService.deleteOperLogByIds(ids));
}
@RequiresPermissions("monitor:operlog:detail")
@GetMapping("/detail/{operId}")
public String detail(@PathVariable("operId") Long operId, ModelMap mmap)
{
mmap.put("operLog", operLogService.selectOperLogById(operId));
return prefix + "/detail";
}
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
@RequiresPermissions("monitor:operlog:remove")
@PostMapping("/clean")
@ResponseBody
public AjaxResult clean()
{
operLogService.cleanOperLog();
return success();
}
}
@@ -0,0 +1,114 @@
package com.ruoyi.web.controller.monitor;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
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.enums.OnlineStatus;
import com.ruoyi.framework.shiro.session.OnlineSession;
import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysUserOnline;
import com.ruoyi.system.service.ISysUserOnlineService;
/**
* 在线用户监控
*
* @author ruoyi
*/
@Controller
@RequestMapping("/monitor/online")
public class SysUserOnlineController extends BaseController
{
private String prefix = "monitor/online";
@Autowired
private ISysUserOnlineService userOnlineService;
@Autowired
private OnlineSessionDAO onlineSessionDAO;
@RequiresPermissions("monitor:online:view")
@GetMapping()
public String online()
{
return prefix + "/online";
}
@RequiresPermissions("monitor:online:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysUserOnline userOnline)
{
startPage();
List<SysUserOnline> list = userOnlineService.selectUserOnlineList(userOnline);
return getDataTable(list);
}
@RequiresPermissions("monitor:online:batchForceLogout")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@PostMapping("/batchForceLogout")
@ResponseBody
public AjaxResult batchForceLogout(@RequestParam("ids[]") String[] ids)
{
for (String sessionId : ids)
{
SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
if (online == null)
{
return error("用户已下线");
}
OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
if (onlineSession == null)
{
return error("用户已下线");
}
if (sessionId.equals(ShiroUtils.getSessionId()))
{
return error("当前登陆用户无法强退");
}
onlineSession.setStatus(OnlineStatus.off_line);
onlineSessionDAO.update(onlineSession);
online.setStatus(OnlineStatus.off_line);
userOnlineService.saveOnline(online);
}
return success();
}
@RequiresPermissions("monitor:online:forceLogout")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@PostMapping("/forceLogout")
@ResponseBody
public AjaxResult forceLogout(String sessionId)
{
SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
if (sessionId.equals(ShiroUtils.getSessionId()))
{
return error("当前登陆用户无法强退");
}
if (online == null)
{
return error("用户已下线");
}
OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
if (onlineSession == null)
{
return error("用户已下线");
}
onlineSession.setStatus(OnlineStatus.off_line);
onlineSessionDAO.update(onlineSession);
online.setStatus(OnlineStatus.off_line);
userOnlineService.saveOnline(online);
return success();
}
}
@@ -0,0 +1,125 @@
package com.ruoyi.web.controller.shop;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.StoreCoupon;
import com.ruoyi.shop.service.IStoreCouponService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 优惠券主Controller
*
* @author hupeng
* @date 2019-08-29
*/
@Controller
@RequestMapping("/shop/coupon")
public class StoreCouponController extends BaseController
{
private String prefix = "shop/coupon";
@Autowired
private IStoreCouponService storeCouponService;
@RequiresPermissions("shop:coupon:view")
@GetMapping()
public String coupon()
{
return prefix + "/coupon";
}
/**
* 查询优惠券主列表
*/
@RequiresPermissions("shop:coupon:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(StoreCoupon storeCoupon)
{
startPage();
List<StoreCoupon> list = storeCouponService.selectStoreCouponList(storeCoupon);
return getDataTable(list);
}
/**
* 导出优惠券主列表
*/
@RequiresPermissions("shop:coupon:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(StoreCoupon storeCoupon)
{
List<StoreCoupon> list = storeCouponService.selectStoreCouponList(storeCoupon);
ExcelUtil<StoreCoupon> util = new ExcelUtil<StoreCoupon>(StoreCoupon.class);
return util.exportExcel(list, "coupon");
}
/**
* 新增优惠券主
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存优惠券主
*/
@RequiresPermissions("shop:coupon:add")
@Log(title = "优惠券主", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(StoreCoupon storeCoupon)
{
return toAjax(storeCouponService.insertStoreCoupon(storeCoupon));
}
/**
* 修改优惠券主
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Integer id, ModelMap mmap)
{
StoreCoupon storeCoupon = storeCouponService.selectStoreCouponById(id);
mmap.put("storeCoupon", storeCoupon);
return prefix + "/edit";
}
/**
* 修改保存优惠券主
*/
@RequiresPermissions("shop:coupon:edit")
@Log(title = "优惠券主", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(StoreCoupon storeCoupon)
{
return toAjax(storeCouponService.updateStoreCoupon(storeCoupon));
}
/**
* 删除优惠券主
*/
@RequiresPermissions("shop:coupon:remove")
@Log(title = "优惠券主", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(storeCouponService.deleteStoreCouponByIds(ids));
}
}
@@ -0,0 +1,125 @@
package com.ruoyi.web.controller.shop;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.StoreGoodsAttribute;
import com.ruoyi.shop.service.IStoreGoodsAttributeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 商品的属性(独立)Controller
*
* @author hupeng
* @date 2019-08-24
*/
@Controller
@RequestMapping("/shop/attribute")
public class StoreGoodsAttributeController extends BaseController
{
private String prefix = "shop/attribute";
@Autowired
private IStoreGoodsAttributeService storeGoodsAttributeService;
@RequiresPermissions("shop:attribute:view")
@GetMapping()
public String attribute()
{
return prefix + "/attribute";
}
/**
* 查询商品的属性(独立)列表
*/
@RequiresPermissions("shop:attribute:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(StoreGoodsAttribute storeGoodsAttribute)
{
startPage();
List<StoreGoodsAttribute> list = storeGoodsAttributeService.selectStoreGoodsAttributeList(storeGoodsAttribute);
return getDataTable(list);
}
/**
* 导出商品的属性(独立)列表
*/
@RequiresPermissions("shop:attribute:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(StoreGoodsAttribute storeGoodsAttribute)
{
List<StoreGoodsAttribute> list = storeGoodsAttributeService.selectStoreGoodsAttributeList(storeGoodsAttribute);
ExcelUtil<StoreGoodsAttribute> util = new ExcelUtil<StoreGoodsAttribute>(StoreGoodsAttribute.class);
return util.exportExcel(list, "attribute");
}
/**
* 新增商品的属性(独立)
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存商品的属性(独立)
*/
@RequiresPermissions("shop:attribute:add")
@Log(title = "商品的属性(独立)", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(StoreGoodsAttribute storeGoodsAttribute)
{
return toAjax(storeGoodsAttributeService.insertStoreGoodsAttribute(storeGoodsAttribute));
}
/**
* 修改商品的属性(独立)
*/
@GetMapping("/edit/{attrId}")
public String edit(@PathVariable("attrId") Long attrId, ModelMap mmap)
{
StoreGoodsAttribute storeGoodsAttribute = storeGoodsAttributeService.selectStoreGoodsAttributeById(attrId);
mmap.put("storeGoodsAttribute", storeGoodsAttribute);
return prefix + "/edit";
}
/**
* 修改保存商品的属性(独立)
*/
@RequiresPermissions("shop:attribute:edit")
@Log(title = "商品的属性(独立)", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(StoreGoodsAttribute storeGoodsAttribute)
{
return toAjax(storeGoodsAttributeService.updateStoreGoodsAttribute(storeGoodsAttribute));
}
/**
* 删除商品的属性(独立)
*/
@RequiresPermissions("shop:attribute:remove")
@Log(title = "商品的属性(独立)", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(storeGoodsAttributeService.deleteStoreGoodsAttributeByIds(ids));
}
}
@@ -0,0 +1,125 @@
package com.ruoyi.web.controller.shop;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.StoreGoodsBrand;
import com.ruoyi.shop.service.IStoreGoodsBrandService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 产品品牌Controller
*
* @author hupeng
* @date 2019-08-23
*/
@Controller
@RequestMapping("/shop/brand")
public class StoreGoodsBrandController extends BaseController
{
private String prefix = "shop/brand";
@Autowired
private IStoreGoodsBrandService storeGoodsBrandService;
@RequiresPermissions("shop:brand:view")
@GetMapping()
public String brand()
{
return prefix + "/brand";
}
/**
* 查询产品品牌列表
*/
@RequiresPermissions("shop:brand:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(StoreGoodsBrand storeGoodsBrand)
{
startPage();
List<StoreGoodsBrand> list = storeGoodsBrandService.selectStoreGoodsBrandList(storeGoodsBrand);
return getDataTable(list);
}
/**
* 导出产品品牌列表
*/
@RequiresPermissions("shop:brand:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(StoreGoodsBrand storeGoodsBrand)
{
List<StoreGoodsBrand> list = storeGoodsBrandService.selectStoreGoodsBrandList(storeGoodsBrand);
ExcelUtil<StoreGoodsBrand> util = new ExcelUtil<StoreGoodsBrand>(StoreGoodsBrand.class);
return util.exportExcel(list, "brand");
}
/**
* 新增产品品牌
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存产品品牌
*/
@RequiresPermissions("shop:brand:add")
@Log(title = "产品品牌", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(StoreGoodsBrand storeGoodsBrand)
{
return toAjax(storeGoodsBrandService.insertStoreGoodsBrand(storeGoodsBrand));
}
/**
* 修改产品品牌
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
StoreGoodsBrand storeGoodsBrand = storeGoodsBrandService.selectStoreGoodsBrandById(id);
mmap.put("storeGoodsBrand", storeGoodsBrand);
return prefix + "/edit";
}
/**
* 修改保存产品品牌
*/
@RequiresPermissions("shop:brand:edit")
@Log(title = "产品品牌", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(StoreGoodsBrand storeGoodsBrand)
{
return toAjax(storeGoodsBrandService.updateStoreGoodsBrand(storeGoodsBrand));
}
/**
* 删除产品品牌
*/
@RequiresPermissions("shop:brand:remove")
@Log(title = "产品品牌", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(storeGoodsBrandService.deleteStoreGoodsBrandByIds(ids));
}
}
@@ -0,0 +1,153 @@
package com.ruoyi.web.controller.shop;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.StoreGoodsCate;
import com.ruoyi.shop.service.IStoreGoodsCateService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.core.domain.Ztree;
/**
* 商城商品分类Controller
*
* @author hupeng
* @date 2019-08-22
*/
@Controller
@RequestMapping("/shop/cate")
public class StoreGoodsCateController extends BaseController
{
private String prefix = "shop/cate";
@Autowired
private IStoreGoodsCateService storeGoodsCateService;
@RequiresPermissions("shop:cate:view")
@GetMapping()
public String cate()
{
return prefix + "/cate";
}
/**
* 查询商城商品分类树列表
*/
@RequiresPermissions("shop:cate:list")
@PostMapping("/list")
@ResponseBody
public List<StoreGoodsCate> list(StoreGoodsCate storeGoodsCate)
{
List<StoreGoodsCate> list = storeGoodsCateService.selectStoreGoodsCateList(storeGoodsCate);
return list;
}
/**
* 导出商城商品分类列表
*/
@RequiresPermissions("shop:cate:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(StoreGoodsCate storeGoodsCate)
{
List<StoreGoodsCate> list = storeGoodsCateService.selectStoreGoodsCateList(storeGoodsCate);
ExcelUtil<StoreGoodsCate> util = new ExcelUtil<StoreGoodsCate>(StoreGoodsCate.class);
return util.exportExcel(list, "cate");
}
/**
* 新增商城商品分类
*/
@GetMapping(value = { "/add/{id}", "/add/" })
public String add(@PathVariable(value = "id", required = false) Long id, ModelMap mmap)
{
if (StringUtils.isNotNull(id))
{
mmap.put("storeGoodsCate", storeGoodsCateService.selectStoreGoodsCateById(id));
}
return prefix + "/add";
}
/**
* 新增保存商城商品分类
*/
@RequiresPermissions("shop:cate:add")
@Log(title = "商城商品分类", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(StoreGoodsCate storeGoodsCate)
{
return toAjax(storeGoodsCateService.insertStoreGoodsCate(storeGoodsCate));
}
/**
* 修改商城商品分类
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
StoreGoodsCate storeGoodsCate = storeGoodsCateService.selectStoreGoodsCateById(id);
mmap.put("storeGoodsCate", storeGoodsCate);
return prefix + "/edit";
}
/**
* 修改保存商城商品分类
*/
@RequiresPermissions("shop:cate:edit")
@Log(title = "商城商品分类", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(StoreGoodsCate storeGoodsCate)
{
return toAjax(storeGoodsCateService.updateStoreGoodsCate(storeGoodsCate));
}
/**
* 删除
*/
@RequiresPermissions("shop:cate:remove")
@Log(title = "商城商品分类", businessType = BusinessType.DELETE)
@GetMapping("/remove/{id}")
@ResponseBody
public AjaxResult remove(@PathVariable("id") Long id)
{
return toAjax(storeGoodsCateService.deleteStoreGoodsCateById(id));
}
/**
* 选择商城商品分类树
*/
@GetMapping(value = { "/selectCateTree/{id}", "/selectCateTree/" })
public String selectCateTree(@PathVariable(value = "id", required = false) Long id, ModelMap mmap)
{
if (StringUtils.isNotNull(id))
{
mmap.put("storeGoodsCate", storeGoodsCateService.selectStoreGoodsCateById(id));
}
return prefix + "/tree";
}
/**
* 加载商城商品分类树列表
*/
@GetMapping("/treeData")
@ResponseBody
public List<Ztree> treeData()
{
List<Ztree> ztrees = storeGoodsCateService.selectStoreGoodsCateTree();
return ztrees;
}
}
@@ -0,0 +1,514 @@
package com.ruoyi.web.controller.shop;
import java.text.MessageFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.shop.domain.*;
import com.ruoyi.shop.service.*;
import com.ruoyi.shop.vo.SpecAttrVO;
import com.ruoyi.shop.vo.SpecVO;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.aspectj.weaver.AjAttribute;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import javax.servlet.http.HttpServletRequest;
/**
* 商品主Controller
*
* @author hupeng
* @date 2019-08-25
*/
@Controller
@RequestMapping("/shop/goods")
public class StoreGoodsController extends BaseController
{
private String prefix = "shop/goods";
@Autowired
private IStoreGoodsService storeGoodsService;
@Autowired
private IStoreGoodsTypeService storeGoodsTypeService;
@Autowired
private IStoreSpecService storeSpecService;
@Autowired
private IStoreSpecItemService storeSpecItemService;
@Autowired
private IStoreGoodsAttributeService storeGoodsAttributeService;
@Autowired
protected IStoreGoodsAttrService storeGoodsAttrService;
@Autowired
private IStoreSpecGoodsPriceService storeSpecGoodsPriceService;
@Autowired
private IStoreGoodsCateService storeGoodsCateService;
@RequiresPermissions("shop:goods:view")
@GetMapping()
public String goods()
{
return prefix + "/goods";
}
/**
* 查询商品主列表
*/
@RequiresPermissions("shop:goods:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(StoreGoods storeGoods)
{
startPage();
List<StoreGoods> list = storeGoodsService.selectStoreGoodsList(storeGoods);
return getDataTable(list);
}
/**
* 导出商品主列表
*/
@RequiresPermissions("shop:goods:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(StoreGoods storeGoods)
{
List<StoreGoods> list = storeGoodsService.selectStoreGoodsList(storeGoods);
ExcelUtil<StoreGoods> util = new ExcelUtil<StoreGoods>(StoreGoods.class);
return util.exportExcel(list, "goods");
}
/**
* 新增商品主
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存商品主
*/
@RequiresPermissions("shop:goods:add")
@Log(title = "商品主", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(StoreGoods storeGoods)
{
return toAjax(storeGoodsService.insertStoreGoods(storeGoods));
}
/**
*
* @param goodsId
* @param typeId
* @param mmap
* @return
*/
@GetMapping("/editSpec/{goodsId}/{typeId}")
public String editSpecAttr(@PathVariable("goodsId") Integer goodsId,
@PathVariable("typeId") Integer typeId,
ModelMap mmap){
StoreGoods storeGoods = storeGoodsService.selectStoreGoodsById(goodsId);
//StoreGoodsType goodsType = new StoreGoodsType();
//goodsType.setId(typeId);
List<StoreGoodsType> typeList = storeGoodsTypeService.selectStoreGoodsTypeList(null);
//System.out.println(typeList);
mmap.put("storeGoods", storeGoods);
mmap.put("goodsTypes",typeList);
return prefix + "/spec";
}
/**
*
* @param goodsId
* @param typeId
* @return
*/
@PostMapping("/ajaxSpec")
@ResponseBody
public AjaxResult ajaxSpec(@RequestParam(value = "goods_id",defaultValue = "-1") Integer goodsId,
@RequestParam(value = "type_id",defaultValue = "0") Integer typeId){
//System.out.println("typeId:"+typeId);
if(typeId == 0) return AjaxResult.success("success","");
StoreSpec storeSpec = new StoreSpec();
storeSpec.setTypeId(typeId.longValue());
List<StoreSpec> specs = storeSpecService.selectStoreSpecList(storeSpec);
List<StoreSpecItem> specItems = null;
StoreSpecItem specItem = new StoreSpecItem();
for (StoreSpec spec : specs) {
specItem.setSpecId(spec.getId());
specItems = storeSpecItemService.selectStoreSpecItemList(specItem);
//System.out.println("goodsID:"+goodsId);
if(goodsId > 0){
String itemStr = storeGoodsService.getGoodsItems(goodsId.longValue());
if(StringUtils.isNotEmpty(itemStr)){
String[] strs = itemStr.split("_");
for (StoreSpecItem item : specItems) {
if(Arrays.asList(strs).contains(item.getId().toString())){
item.setSelected(true);
}
}
}
}
spec.setStoreSpecItems(specItems);
}
HashMap<String,Object> map = new HashMap<>();
map.put("data",specs);
//System.out.println(specs);
return AjaxResult.success("success",map);
}
/**
*
* @param goodsId
* @param typeId
* @return
*/
@PostMapping("/ajaxGetAttrInput")
@ResponseBody
public AjaxResult ajaxGetAttrInput(@RequestParam(value = "goods_id",defaultValue = "0") Integer goodsId,
@RequestParam(value = "type_id",defaultValue = "0") Integer typeId){
if(typeId == 0) return AjaxResult.success("success","");
StoreGoodsAttribute attribute = new StoreGoodsAttribute();
attribute.setTypeId(typeId);
List<StoreGoodsAttribute> attributeList = storeGoodsAttributeService
.selectStoreGoodsAttributeList(attribute);
//System.out.println("attributeList:"+attributeList);
String str = "";
StoreGoodsAttr storeGoodsAttr = null;
StoreGoodsAttr goodsAttrOption = new StoreGoodsAttr();
goodsAttrOption.setGoodsId(goodsId);
StringBuilder stringBuilder = new StringBuilder();
for (StoreGoodsAttribute attr : attributeList) {
goodsAttrOption.setAttrId(attr.getAttrId().intValue());
List<StoreGoodsAttr> goodsAttrList = storeGoodsAttrService
.selectStoreGoodsAttrList(goodsAttrOption);
if(goodsAttrList.isEmpty()){
StoreGoodsAttr emptyAttr = new StoreGoodsAttr();
emptyAttr.setGoodsId(0);
emptyAttr.setAttrId(0);
emptyAttr.setGoodsAttrId(0);
emptyAttr.setAttrValue("无");
emptyAttr.setAttrPrice("");
goodsAttrList.add(emptyAttr);
}
for (StoreGoodsAttr goodsAttr : goodsAttrList) {
//str = String.format("<tr class='attr_{}'>",attr.getAttrId());
stringBuilder.append(MessageFormat.format("<tr class=attr_{0}>",attr.getAttrId()));
//System.out.println(attr.getAttrId());
stringBuilder.append(MessageFormat.format("<td>{0}</td> <td>",attr.getAttrName()));
stringBuilder.append(MessageFormat.format("<input class='layui-input' type='text' size='40' value={0} name=attr_{1}[] />",
goodsAttr.getAttrValue(),attr.getAttrId()));
stringBuilder.append("</td></tr>");
}
}
str = stringBuilder.toString();
return AjaxResult.success("success",str);
}
@PostMapping("/ajaxGetSpecInput")
@ResponseBody
public AjaxResult ajaxGetSpecInput(@RequestBody String jsonStr){
SpecVO data=JSON.parseObject(jsonStr,SpecVO.class);
//Map<String,Object> map = (Map<String,Object>)jsonObject;
Map<String,List<Integer>> map2 = new HashMap<>();
//重新组合map有相同键值的组合成list
for (String str : data.getList()) {
Map<String,Object> map = (Map<String,Object>)JSONObject.parseObject(str);
String newKey = map.get("specId").toString();
String newValue = map.get("itemId").toString();
List<Integer> tmpList = new ArrayList<>();
if(map2.containsKey(newKey)){
tmpList = map2.get(newKey);
tmpList.add(Integer.parseInt(newValue));
map2.put(newKey,tmpList);
}else{
tmpList.add(Integer.parseInt(newValue));
map2.put(newKey,tmpList);
}
}
Iterator<Map.Entry<String, List<Integer>>> it = map2.entrySet().iterator();
Map<String, Integer> unsortMap =
new HashMap<String, Integer>();
//迭代map把原来值换成列表大小
while (it.hasNext()){
Map.Entry<String, List<Integer>> entry = it.next();
unsortMap.put(entry.getKey(),entry.getValue().size());
}
//定义一个有序的列表map
Map<String, Integer> sortMap = new LinkedHashMap<>();
//升序排序
Stream<Map.Entry<String, Integer>> st = unsortMap.entrySet().stream();
st.sorted(Comparator.comparing(e -> e.getValue()))
.forEachOrdered(e -> sortMap.put(e.getKey(), e.getValue()));
//根据排序后组合最终的MAP
Map<String, List<Integer>> finalMap = new LinkedHashMap<>();
for(String key : sortMap.keySet()){
finalMap.put(key,map2.get(key));
}
//列表笛卡儿积
ArrayList ls = new ArrayList();
for(List<Integer> value : finalMap.values()){
ls.add(value);
}
if(ls.isEmpty()) return AjaxResult.success("success","");
List Dlist = StringUtils.Dikaerji0(ls);
//todo 组合数据
String str = "<table class='table table-bordered' id='spec_input_tab'><tr>";;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(str);
for(String key : finalMap.keySet()){
StoreSpec storeSpec = storeSpecService
.selectStoreSpecById(Long.valueOf(key));
stringBuilder.append(MessageFormat.format("<td><b>{0}</b></td>",
storeSpec.getName()));
}
stringBuilder.append("<td><b>进货价</b></td><td><b>零售价</b></td><td><b>库存</b></td><td><b>操作</b></td></tr>");
//获取商品规格列表
StoreSpecGoodsPrice storeSpecGoodsPrice = new StoreSpecGoodsPrice();
storeSpecGoodsPrice.setGoodsId(Long.valueOf(data.getGoodsId()));
//开始迭代笛卡儿积
Iterator<ArrayList> iter = Dlist.iterator();
while (iter.hasNext()) {
//System.out.println(iter.next());
List<String> itemName = new ArrayList<>();
stringBuilder.append("<tr>");
List<Integer> iterList = iter.next();
Collections.sort(iterList);
iterList.forEach(item-> {
StoreSpecItem storeSpecItem = storeSpecItemService
.selectStoreSpecItemById(Long.valueOf(item.toString()));
stringBuilder.append(MessageFormat.format("<td>{0}</td>",
storeSpecItem.getItem()));
StoreSpec storeSpec2 = storeSpecService
.selectStoreSpecById(Long.valueOf(storeSpecItem.getSpecId()));
itemName.add(storeSpec2.getName()+":"+storeSpecItem.getItem());
});
String itemKeyStr = org.apache.commons.lang.StringUtils.join(iterList.toArray(), "_");
String itemNameStr = org.apache.commons.lang.StringUtils.join(itemName.toArray(), ",");
//while (iter.next().forEach();)
double keyPrice = 0;
double keyMarketPrice = 0;
int keyStoreCount = 0;
//获取商品规格价格列表
storeSpecGoodsPrice.setKey(itemKeyStr);
List<StoreSpecGoodsPrice> storeSpecGoodsPrices = storeSpecGoodsPriceService
.selectStoreSpecGoodsPriceList(storeSpecGoodsPrice);
//System.out.println(storeSpecGoodsPrices);
if(!storeSpecGoodsPrices.isEmpty()){
StoreSpecGoodsPrice goodsPrice = storeSpecGoodsPrices.get(0);
if(goodsPrice != null){
keyPrice = goodsPrice.getPrice();
keyMarketPrice = goodsPrice.getMarketPrice();
keyStoreCount = goodsPrice.getStoreCount().intValue();
}
}
stringBuilder.append(MessageFormat.format("<td><input name=item[{0}][price] value={1} /></td>",
itemKeyStr,String.valueOf(keyPrice)));
stringBuilder.append(MessageFormat.format("<td><input name=item[{0}][market_price] value={1} /></td>",
itemKeyStr,String.valueOf(keyMarketPrice)));
stringBuilder.append(MessageFormat.format("<td><input name=item[{0}][store_count] value={1} /></td>",
itemKeyStr,String.valueOf(keyStoreCount)));
stringBuilder.append(MessageFormat.format("<td>无<input type='hidden' name=item[{0}][key_name] value={1} /></td>",
itemKeyStr,itemNameStr));
stringBuilder.append("</tr>");
//System.out.println(storeSpecGoodsPrices);
}
stringBuilder.append("</table>");
//str = stringBuilder.toString();
return AjaxResult.success("success",stringBuilder.toString());
//return null;
}
@PostMapping("/saveSpecAttr")
@ResponseBody
public AjaxResult saveSpecAttr(HttpServletRequest request){
//获取所有表单参数
Enumeration<String> paramNames = request.getParameterNames();
Map<String,Map<String,String>> specDataMap = new HashMap<>();
Map<String,String> attrDataMap = new HashMap<>();
Map<String,String> tmpMap = null;
String goodsId = request.getParameter("goodsId");
String goodsType = request.getParameter("type_id");
if(StringUtils.isEmpty(goodsId) || Integer.valueOf(goodsId) == 0){
return AjaxResult.error("参数有误");
}
if(StringUtils.isEmpty(goodsType) || Integer.valueOf(goodsType) == 0){
return AjaxResult.error("请选择模型");
}
//过滤参数
while (paramNames.hasMoreElements()) {
String name = paramNames.nextElement();
String[] values = request.getParameterValues(name);
if(values != null && values.length > 0){
StringBuilder builder = new StringBuilder();
for (int i = 0; i < values.length; i++) {
builder.append(values[i]+" ");
}
//过滤规格组合新的规格数据集合
if(name.contains("item")){
String pattern = "item\\[(\\d+[_\\d+]*)]\\[([a-z]+_?[a-z]+)]";
//String pattern = "item\\[(\\d+_\\d+)]\\[([a-z]+_?[a-z]+)]";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(name);
if (m.find( )) {
String keyOne = m.group(1).trim();
System.out.println("keyOne:"+keyOne);
String keyTwo = m.group(2).trim();
System.out.println("keyTwo:"+keyTwo);
String keyValue = builder.toString().trim();
if(!specDataMap.containsKey(keyOne)){
tmpMap = new HashMap<>();
}
tmpMap.put(keyTwo,keyValue);
specDataMap.put(keyOne,tmpMap);
}
}
//过滤属性组合新的属性集合
if(name.contains("attr_")){
String pattern2= "attr_(\\d+)\\[]";
Pattern r2 = Pattern.compile(pattern2);
Matcher m2 = r2.matcher(name);
//System.out.println(name+" : "+builder.toString());
if (m2.find( )) {
attrDataMap.put(m2.group(1),builder.toString().trim());
}else{
System.out.println("no");
}
}
}
}
if(specDataMap.isEmpty()){
return AjaxResult.error("请选择规格项目");
}
if(attrDataMap.isEmpty()){
return AjaxResult.error("请填写商品属性");
}
storeGoodsService.saveSpecAttr(specDataMap,attrDataMap,goodsId,goodsType);
return AjaxResult.success("操作成功");
}
/**
* 修改商品主
*/
@GetMapping("/edit/{goodsId}")
public String edit(@PathVariable("goodsId") Integer goodsId, ModelMap mmap)
{
StoreGoods storeGoods = storeGoodsService.selectStoreGoodsById(goodsId);
StoreGoodsCate storeGoodsCate = storeGoodsCateService
.selectStoreGoodsCateById(storeGoods.getCateId());
storeGoods.setCateName(storeGoodsCate.getCateTitle());
mmap.put("storeGoods", storeGoods);
return prefix + "/edit";
}
/**
* 修改保存商品主
*/
@RequiresPermissions("shop:goods:edit")
@Log(title = "商品主", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(StoreGoods storeGoods)
{
return toAjax(storeGoodsService.updateStoreGoods(storeGoods));
}
/**
* 删除商品主
*/
@RequiresPermissions("shop:goods:remove")
@Log(title = "商品主", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(storeGoodsService.deleteStoreGoodsByIds(ids));
}
@PostMapping( "/changeStatus")
@ResponseBody
public AjaxResult changeStatus(StoreGoods storeGoods){
return toAjax(storeGoodsService.updateStoreGoods(storeGoods));
}
}
@@ -0,0 +1,125 @@
package com.ruoyi.web.controller.shop;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.StoreGoodsType;
import com.ruoyi.shop.service.IStoreGoodsTypeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 商品类型(商品模型)Controller
*
* @author hupeng
* @date 2019-08-24
*/
@Controller
@RequestMapping("/shop/type")
public class StoreGoodsTypeController extends BaseController
{
private String prefix = "shop/type";
@Autowired
private IStoreGoodsTypeService storeGoodsTypeService;
@RequiresPermissions("shop:type:view")
@GetMapping()
public String type()
{
return prefix + "/type";
}
/**
* 查询商品类型(商品模型)列表
*/
@RequiresPermissions("shop:type:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(StoreGoodsType storeGoodsType)
{
startPage();
List<StoreGoodsType> list = storeGoodsTypeService.selectStoreGoodsTypeList(storeGoodsType);
return getDataTable(list);
}
/**
* 导出商品类型(商品模型)列表
*/
@RequiresPermissions("shop:type:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(StoreGoodsType storeGoodsType)
{
List<StoreGoodsType> list = storeGoodsTypeService.selectStoreGoodsTypeList(storeGoodsType);
ExcelUtil<StoreGoodsType> util = new ExcelUtil<StoreGoodsType>(StoreGoodsType.class);
return util.exportExcel(list, "type");
}
/**
* 新增商品类型(商品模型)
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存商品类型(商品模型)
*/
@RequiresPermissions("shop:type:add")
@Log(title = "商品类型(商品模型)", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(StoreGoodsType storeGoodsType)
{
return toAjax(storeGoodsTypeService.insertStoreGoodsType(storeGoodsType));
}
/**
* 修改商品类型(商品模型)
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Integer id, ModelMap mmap)
{
StoreGoodsType storeGoodsType = storeGoodsTypeService.selectStoreGoodsTypeById(id);
mmap.put("storeGoodsType", storeGoodsType);
return prefix + "/edit";
}
/**
* 修改保存商品类型(商品模型)
*/
@RequiresPermissions("shop:type:edit")
@Log(title = "商品类型(商品模型)", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(StoreGoodsType storeGoodsType)
{
return toAjax(storeGoodsTypeService.updateStoreGoodsType(storeGoodsType));
}
/**
* 删除商品类型(商品模型)
*/
@RequiresPermissions("shop:type:remove")
@Log(title = "商品类型(商品模型)", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(storeGoodsTypeService.deleteStoreGoodsTypeByIds(ids));
}
}
@@ -0,0 +1,125 @@
package com.ruoyi.web.controller.shop;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.StoreMember;
import com.ruoyi.shop.service.IStoreMemberService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 商城会员信息Controller
*
* @author hupeng
* @date 2019-08-30
*/
@Controller
@RequestMapping("/shop/member")
public class StoreMemberController extends BaseController
{
private String prefix = "shop/member";
@Autowired
private IStoreMemberService storeMemberService;
@RequiresPermissions("shop:member:view")
@GetMapping()
public String member()
{
return prefix + "/member";
}
/**
* 查询商城会员信息列表
*/
@RequiresPermissions("shop:member:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(StoreMember storeMember)
{
startPage();
List<StoreMember> list = storeMemberService.selectStoreMemberList(storeMember);
return getDataTable(list);
}
/**
* 导出商城会员信息列表
*/
@RequiresPermissions("shop:member:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(StoreMember storeMember)
{
List<StoreMember> list = storeMemberService.selectStoreMemberList(storeMember);
ExcelUtil<StoreMember> util = new ExcelUtil<StoreMember>(StoreMember.class);
return util.exportExcel(list, "member");
}
/**
* 新增商城会员信息
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存商城会员信息
*/
@RequiresPermissions("shop:member:add")
@Log(title = "商城会员信息", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(StoreMember storeMember)
{
return toAjax(storeMemberService.insertStoreMember(storeMember));
}
/**
* 修改商城会员信息
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
StoreMember storeMember = storeMemberService.selectStoreMemberById(id);
mmap.put("storeMember", storeMember);
return prefix + "/edit";
}
/**
* 修改保存商城会员信息
*/
@RequiresPermissions("shop:member:edit")
@Log(title = "商城会员信息", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(StoreMember storeMember)
{
return toAjax(storeMemberService.updateStoreMember(storeMember));
}
/**
* 删除商城会员信息
*/
@RequiresPermissions("shop:member:remove")
@Log(title = "商城会员信息", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(storeMemberService.deleteStoreMemberByIds(ids));
}
}
@@ -0,0 +1,183 @@
package com.ruoyi.web.controller.shop;
import java.util.List;
import com.ruoyi.common.enums.OrderStatus;
import com.ruoyi.common.enums.UserStatus;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.StoreOrder;
import com.ruoyi.shop.service.IStoreOrderService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 订单主Controller
*
* @author hupeng
* @date 2019-08-29
*/
@Controller
@RequestMapping("/shop/order")
public class StoreOrderController extends BaseController
{
private String prefix = "shop/order";
@Autowired
private IStoreOrderService storeOrderService;
@RequiresPermissions("shop:order:view")
@GetMapping()
public String order()
{
return prefix + "/order";
}
/**
* 查询订单主列表
*/
@RequiresPermissions("shop:order:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(StoreOrder storeOrder)
{
startPage();
if(storeOrder.getOrderStatus() != null){
switch (storeOrder.getOrderStatus()){
case -1:
storeOrder.setDeleted(1);
storeOrder.setOrderStatus(0);
storeOrder.setPayStatus(0);
storeOrder.setShippingStatus(0);
break;
case 0:
storeOrder.setDeleted(0);
storeOrder.setOrderStatus(0);
storeOrder.setPayStatus(0);
storeOrder.setShippingStatus(0);
break;
case 1:
storeOrder.setDeleted(0);
storeOrder.setPayStatus(1);
storeOrder.setOrderStatus(0);
storeOrder.setShippingStatus(0);
break;
case 2:
storeOrder.setDeleted(0);
storeOrder.setPayStatus(1);
storeOrder.setOrderStatus(0);
storeOrder.setShippingStatus(1);
break;
case 3:
storeOrder.setDeleted(0);
storeOrder.setPayStatus(1);
storeOrder.setOrderStatus(0);
storeOrder.setShippingStatus(2);
break;
case 4:
storeOrder.setDeleted(0);
storeOrder.setPayStatus(1);
storeOrder.setOrderStatus(0);
storeOrder.setShippingStatus(3);
break;
case 5:
storeOrder.setDeleted(0);
storeOrder.setPayStatus(1);
storeOrder.setOrderStatus(1);
storeOrder.setShippingStatus(0);
break;
case 6:
storeOrder.setDeleted(0);
storeOrder.setPayStatus(1);
storeOrder.setOrderStatus(2);
storeOrder.setShippingStatus(0);
break;
}
}
//System.out.println(storeOrder);
List<StoreOrder> list = storeOrderService.selectStoreOrderList(storeOrder);
return getDataTable(list);
}
/**
* 导出订单主列表
*/
@RequiresPermissions("shop:order:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(StoreOrder storeOrder)
{
List<StoreOrder> list = storeOrderService.selectStoreOrderList(storeOrder);
ExcelUtil<StoreOrder> util = new ExcelUtil<StoreOrder>(StoreOrder.class);
return util.exportExcel(list, "order");
}
/**
* 新增订单主
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存订单主
*/
@RequiresPermissions("shop:order:add")
@Log(title = "订单主", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(StoreOrder storeOrder)
{
return toAjax(storeOrderService.insertStoreOrder(storeOrder));
}
/**
* 修改订单主
*/
@GetMapping("/edit/{orderId}")
public String edit(@PathVariable("orderId") Integer orderId, ModelMap mmap)
{
StoreOrder storeOrder = storeOrderService.selectStoreOrderById(orderId);
mmap.put("storeOrder", storeOrder);
return prefix + "/edit";
}
/**
* 修改保存订单主
*/
@RequiresPermissions("shop:order:edit")
@Log(title = "订单主", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(StoreOrder storeOrder)
{
return toAjax(storeOrderService.updateStoreOrder(storeOrder));
}
/**
* 删除订单主
*/
@RequiresPermissions("shop:order:remove")
@Log(title = "订单主", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(storeOrderService.deleteStoreOrderByIds(ids));
}
}
@@ -0,0 +1,125 @@
package com.ruoyi.web.controller.shop;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.domain.StoreSpec;
import com.ruoyi.shop.service.IStoreSpecService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 商品规格(独立)Controller
*
* @author hupeng
* @date 2019-08-25
*/
@Controller
@RequestMapping("/shop/spec")
public class StoreSpecController extends BaseController
{
private String prefix = "shop/spec";
@Autowired
private IStoreSpecService storeSpecService;
@RequiresPermissions("shop:spec:view")
@GetMapping()
public String spec()
{
return prefix + "/spec";
}
/**
* 查询商品规格(独立)列表
*/
@RequiresPermissions("shop:spec:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(StoreSpec storeSpec)
{
startPage();
List<StoreSpec> list = storeSpecService.selectStoreSpecList(storeSpec);
return getDataTable(list);
}
/**
* 导出商品规格(独立)列表
*/
@RequiresPermissions("shop:spec:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(StoreSpec storeSpec)
{
List<StoreSpec> list = storeSpecService.selectStoreSpecList(storeSpec);
ExcelUtil<StoreSpec> util = new ExcelUtil<StoreSpec>(StoreSpec.class);
return util.exportExcel(list, "spec");
}
/**
* 新增商品规格(独立)
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存商品规格(独立)
*/
@RequiresPermissions("shop:spec:add")
@Log(title = "商品规格(独立)", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(StoreSpec storeSpec)
{
return toAjax(storeSpecService.insertStoreSpec(storeSpec));
}
/**
* 修改商品规格(独立)
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
StoreSpec storeSpec = storeSpecService.selectStoreSpecById(id);
mmap.put("storeSpec", storeSpec);
return prefix + "/edit";
}
/**
* 修改保存商品规格(独立)
*/
@RequiresPermissions("shop:spec:edit")
@Log(title = "商品规格(独立)", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(StoreSpec storeSpec)
{
return toAjax(storeSpecService.updateStoreSpec(storeSpec));
}
/**
* 删除商品规格(独立)
*/
@RequiresPermissions("shop:spec:remove")
@Log(title = "商品规格(独立)", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(storeSpecService.deleteStoreSpecByIds(ids));
}
}
@@ -0,0 +1,92 @@
package com.ruoyi.web.controller.system;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer;
import com.ruoyi.common.core.controller.BaseController;
/**
* 图片验证码(支持算术形式)
*
* @author ruoyi
*/
@Controller
@RequestMapping("/captcha")
public class SysCaptchaController extends BaseController
{
@Resource(name = "captchaProducer")
private Producer captchaProducer;
@Resource(name = "captchaProducerMath")
private Producer captchaProducerMath;
/**
* 验证码生成
*/
@GetMapping(value = "/captchaImage")
public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response)
{
ServletOutputStream out = null;
try
{
HttpSession session = request.getSession();
response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
response.setHeader("Pragma", "no-cache");
response.setContentType("image/jpeg");
String type = request.getParameter("type");
String capStr = null;
String code = null;
BufferedImage bi = null;
if ("math".equals(type))
{
String capText = captchaProducerMath.createText();
capStr = capText.substring(0, capText.lastIndexOf("@"));
code = capText.substring(capText.lastIndexOf("@") + 1);
bi = captchaProducerMath.createImage(capStr);
}
else if ("char".equals(type))
{
capStr = code = captchaProducer.createText();
bi = captchaProducer.createImage(capStr);
}
session.setAttribute(Constants.KAPTCHA_SESSION_KEY, code);
out = response.getOutputStream();
ImageIO.write(bi, "jpg", out);
out.flush();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if (out != null)
{
out.close();
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
return null;
}
}
@@ -0,0 +1,144 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
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.ResponseBody;
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.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService;
/**
* 参数配置 信息操作处理
*
* @author ruoyi
*/
@Controller
@RequestMapping("/system/config")
public class SysConfigController extends BaseController
{
private String prefix = "system/config";
@Autowired
private ISysConfigService configService;
@RequiresPermissions("system:config:view")
@GetMapping()
public String config()
{
return prefix + "/config";
}
/**
* 查询参数配置列表
*/
@RequiresPermissions("system:config:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysConfig config)
{
startPage();
List<SysConfig> list = configService.selectConfigList(config);
return getDataTable(list);
}
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:config:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysConfig config)
{
List<SysConfig> list = configService.selectConfigList(config);
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
return util.exportExcel(list, "参数数据");
}
/**
* 新增参数配置
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存参数配置
*/
@RequiresPermissions("system:config:add")
@Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysConfig config)
{
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setCreateBy(ShiroUtils.getLoginName());
return toAjax(configService.insertConfig(config));
}
/**
* 修改参数配置
*/
@GetMapping("/edit/{configId}")
public String edit(@PathVariable("configId") Long configId, ModelMap mmap)
{
mmap.put("config", configService.selectConfigById(configId));
return prefix + "/edit";
}
/**
* 修改保存参数配置
*/
@RequiresPermissions("system:config:edit")
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysConfig config)
{
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(configService.updateConfig(config));
}
/**
* 删除参数配置
*/
@RequiresPermissions("system:config:remove")
@Log(title = "参数管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(configService.deleteConfigByIds(ids));
}
/**
* 校验参数键名
*/
@PostMapping("/checkConfigKeyUnique")
@ResponseBody
public String checkConfigKeyUnique(SysConfig config)
{
return configService.checkConfigKeyUnique(config);
}
}
@@ -0,0 +1,180 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
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.ResponseBody;
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.Ztree;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.service.ISysDeptService;
/**
* 部门信息
*
* @author ruoyi
*/
@Controller
@RequestMapping("/system/dept")
public class SysDeptController extends BaseController
{
private String prefix = "system/dept";
@Autowired
private ISysDeptService deptService;
@RequiresPermissions("system:dept:view")
@GetMapping()
public String dept()
{
return prefix + "/dept";
}
@RequiresPermissions("system:dept:list")
@PostMapping("/list")
@ResponseBody
public List<SysDept> list(SysDept dept)
{
List<SysDept> deptList = deptService.selectDeptList(dept);
return deptList;
}
/**
* 新增部门
*/
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
{
mmap.put("dept", deptService.selectDeptById(parentId));
return prefix + "/add";
}
/**
* 新增保存部门
*/
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@RequiresPermissions("system:dept:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysDept dept)
{
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
dept.setCreateBy(ShiroUtils.getLoginName());
return toAjax(deptService.insertDept(dept));
}
/**
* 修改
*/
@GetMapping("/edit/{deptId}")
public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap)
{
SysDept dept = deptService.selectDeptById(deptId);
if (StringUtils.isNotNull(dept) && 100L == deptId)
{
dept.setParentName("无");
}
mmap.put("dept", dept);
return prefix + "/edit";
}
/**
* 保存
*/
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:dept:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysDept dept)
{
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
else if (dept.getParentId().equals(dept.getDeptId()))
{
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
}
dept.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(deptService.updateDept(dept));
}
/**
* 删除
*/
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@RequiresPermissions("system:dept:remove")
@GetMapping("/remove/{deptId}")
@ResponseBody
public AjaxResult remove(@PathVariable("deptId") Long deptId)
{
if (deptService.selectDeptCount(deptId) > 0)
{
return AjaxResult.warn("存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId))
{
return AjaxResult.warn("部门存在用户,不允许删除");
}
return toAjax(deptService.deleteDeptById(deptId));
}
/**
* 校验部门名称
*/
@PostMapping("/checkDeptNameUnique")
@ResponseBody
public String checkDeptNameUnique(SysDept dept)
{
return deptService.checkDeptNameUnique(dept);
}
/**
* 选择部门树
*/
@GetMapping("/selectDeptTree/{deptId}")
public String selectDeptTree(@PathVariable("deptId") Long deptId, ModelMap mmap)
{
mmap.put("dept", deptService.selectDeptById(deptId));
return prefix + "/tree";
}
/**
* 加载部门列表树
*/
@GetMapping("/treeData")
@ResponseBody
public List<Ztree> treeData()
{
List<Ztree> ztrees = deptService.selectDeptTree(new SysDept());
return ztrees;
}
/**
* 加载角色部门(数据权限)列表树
*/
@GetMapping("/roleDeptTreeData")
@ResponseBody
public List<Ztree> deptTreeData(SysRole role)
{
List<Ztree> ztrees = deptService.roleDeptTreeData(role);
return ztrees;
}
}
@@ -0,0 +1,120 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
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.ResponseBody;
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.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysDictData;
import com.ruoyi.system.service.ISysDictDataService;
/**
* 数据字典信息
*
* @author ruoyi
*/
@Controller
@RequestMapping("/system/dict/data")
public class SysDictDataController extends BaseController
{
private String prefix = "system/dict/data";
@Autowired
private ISysDictDataService dictDataService;
@RequiresPermissions("system:dict:view")
@GetMapping()
public String dictData()
{
return prefix + "/data";
}
@PostMapping("/list")
@RequiresPermissions("system:dict:list")
@ResponseBody
public TableDataInfo list(SysDictData dictData)
{
startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list);
}
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:dict:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysDictData dictData)
{
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
return util.exportExcel(list, "字典数据");
}
/**
* 新增字典类型
*/
@GetMapping("/add/{dictType}")
public String add(@PathVariable("dictType") String dictType, ModelMap mmap)
{
mmap.put("dictType", dictType);
return prefix + "/add";
}
/**
* 新增保存字典类型
*/
@Log(title = "字典数据", businessType = BusinessType.INSERT)
@RequiresPermissions("system:dict:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysDictData dict)
{
dict.setCreateBy(ShiroUtils.getLoginName());
return toAjax(dictDataService.insertDictData(dict));
}
/**
* 修改字典类型
*/
@GetMapping("/edit/{dictCode}")
public String edit(@PathVariable("dictCode") Long dictCode, ModelMap mmap)
{
mmap.put("dict", dictDataService.selectDictDataById(dictCode));
return prefix + "/edit";
}
/**
* 修改保存字典类型
*/
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:dict:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysDictData dict)
{
dict.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(dictDataService.updateDictData(dict));
}
@Log(title = "字典数据", businessType = BusinessType.DELETE)
@RequiresPermissions("system:dict:remove")
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(dictDataService.deleteDictDataByIds(ids));
}
}
@@ -0,0 +1,182 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
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.ResponseBody;
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.Ztree;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysDictType;
import com.ruoyi.system.service.ISysDictTypeService;
/**
* 数据字典信息
*
* @author ruoyi
*/
@Controller
@RequestMapping("/system/dict")
public class SysDictTypeController extends BaseController
{
private String prefix = "system/dict/type";
@Autowired
private ISysDictTypeService dictTypeService;
@RequiresPermissions("system:dict:view")
@GetMapping()
public String dictType()
{
return prefix + "/type";
}
@PostMapping("/list")
@RequiresPermissions("system:dict:list")
@ResponseBody
public TableDataInfo list(SysDictType dictType)
{
startPage();
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
return getDataTable(list);
}
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:dict:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysDictType dictType)
{
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
return util.exportExcel(list, "字典类型");
}
/**
* 新增字典类型
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存字典类型
*/
@Log(title = "字典类型", businessType = BusinessType.INSERT)
@RequiresPermissions("system:dict:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysDictType dict)
{
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
{
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setCreateBy(ShiroUtils.getLoginName());
return toAjax(dictTypeService.insertDictType(dict));
}
/**
* 修改字典类型
*/
@GetMapping("/edit/{dictId}")
public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap)
{
mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
return prefix + "/edit";
}
/**
* 修改保存字典类型
*/
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:dict:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysDictType dict)
{
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
{
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(dictTypeService.updateDictType(dict));
}
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@RequiresPermissions("system:dict:remove")
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
try
{
return toAjax(dictTypeService.deleteDictTypeByIds(ids));
}
catch (Exception e)
{
return error(e.getMessage());
}
}
/**
* 查询字典详细
*/
@RequiresPermissions("system:dict:list")
@GetMapping("/detail/{dictId}")
public String detail(@PathVariable("dictId") Long dictId, ModelMap mmap)
{
mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
mmap.put("dictList", dictTypeService.selectDictTypeAll());
return "system/dict/data/data";
}
/**
* 校验字典类型
*/
@PostMapping("/checkDictTypeUnique")
@ResponseBody
public String checkDictTypeUnique(SysDictType dictType)
{
return dictTypeService.checkDictTypeUnique(dictType);
}
/**
* 选择字典树
*/
@GetMapping("/selectDictTree/{columnId}/{dictType}")
public String selectDeptTree(@PathVariable("columnId") Long columnId, @PathVariable("dictType") String dictType,
ModelMap mmap)
{
mmap.put("columnId", columnId);
mmap.put("dict", dictTypeService.selectDictTypeByType(dictType));
return prefix + "/tree";
}
/**
* 加载字典列表树
*/
@GetMapping("/treeData")
@ResponseBody
public List<Ztree> treeData()
{
List<Ztree> ztrees = dictTypeService.selectDictTree(new SysDictType());
return ztrees;
}
}
@@ -0,0 +1,48 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysMenu;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysMenuService;
/**
* 首页 业务处理
*
* @author ruoyi
*/
@Controller
public class SysIndexController extends BaseController
{
@Autowired
private ISysMenuService menuService;
// 系统首页
@GetMapping("/index")
public String index(ModelMap mmap)
{
// 取身份信息
SysUser user = ShiroUtils.getSysUser();
// 根据用户id取出菜单
List<SysMenu> menus = menuService.selectMenusByUser(user);
mmap.put("menus", menus);
mmap.put("user", user);
mmap.put("copyrightYear", Global.getCopyrightYear());
mmap.put("demoEnabled", Global.isDemoEnabled());
return "index";
}
// 系统介绍
@GetMapping("/system/main")
public String main(ModelMap mmap)
{
mmap.put("version", Global.getVersion());
return "main";
}
}
@@ -0,0 +1,65 @@
package com.ruoyi.web.controller.system;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
/**
* 登录验证
*
* @author ruoyi
*/
@Controller
public class SysLoginController extends BaseController
{
@GetMapping("/login")
public String login(HttpServletRequest request, HttpServletResponse response)
{
// 如果是Ajax请求,返回Json字符串。
if (ServletUtils.isAjaxRequest(request))
{
return ServletUtils.renderString(response, "{\"code\":\"1\",\"msg\":\"未登录或登录超时。请重新登录\"}");
}
return "login";
}
@PostMapping("/login")
@ResponseBody
public AjaxResult ajaxLogin(String username, String password, Boolean rememberMe)
{
UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe);
Subject subject = SecurityUtils.getSubject();
try
{
subject.login(token);
return success();
}
catch (AuthenticationException e)
{
String msg = "用户或密码错误";
if (StringUtils.isNotEmpty(e.getMessage()))
{
msg = e.getMessage();
}
return error(msg);
}
}
@GetMapping("/unauth")
public String unauth()
{
return "error/unauth";
}
}
@@ -0,0 +1,196 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
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.ResponseBody;
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.Ztree;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysMenu;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.service.ISysMenuService;
/**
* 菜单信息
*
* @author ruoyi
*/
@Controller
@RequestMapping("/system/menu")
public class SysMenuController extends BaseController
{
private String prefix = "system/menu";
@Autowired
private ISysMenuService menuService;
@RequiresPermissions("system:menu:view")
@GetMapping()
public String menu()
{
return prefix + "/menu";
}
@RequiresPermissions("system:menu:list")
@PostMapping("/list")
@ResponseBody
public List<SysMenu> list(SysMenu menu)
{
Long userId = ShiroUtils.getUserId();
List<SysMenu> menuList = menuService.selectMenuList(menu, userId);
return menuList;
}
/**
* 删除菜单
*/
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
@RequiresPermissions("system:menu:remove")
@GetMapping("/remove/{menuId}")
@ResponseBody
public AjaxResult remove(@PathVariable("menuId") Long menuId)
{
if (menuService.selectCountMenuByParentId(menuId) > 0)
{
return AjaxResult.warn("存在子菜单,不允许删除");
}
if (menuService.selectCountRoleMenuByMenuId(menuId) > 0)
{
return AjaxResult.warn("菜单已分配,不允许删除");
}
ShiroUtils.clearCachedAuthorizationInfo();
return toAjax(menuService.deleteMenuById(menuId));
}
/**
* 新增
*/
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
{
SysMenu menu = null;
if (0L != parentId)
{
menu = menuService.selectMenuById(parentId);
}
else
{
menu = new SysMenu();
menu.setMenuId(0L);
menu.setMenuName("主目录");
}
mmap.put("menu", menu);
return prefix + "/add";
}
/**
* 新增保存菜单
*/
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
@RequiresPermissions("system:menu:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysMenu menu)
{
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
menu.setCreateBy(ShiroUtils.getLoginName());
ShiroUtils.clearCachedAuthorizationInfo();
return toAjax(menuService.insertMenu(menu));
}
/**
* 修改菜单
*/
@GetMapping("/edit/{menuId}")
public String edit(@PathVariable("menuId") Long menuId, ModelMap mmap)
{
mmap.put("menu", menuService.selectMenuById(menuId));
return prefix + "/edit";
}
/**
* 修改保存菜单
*/
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:menu:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysMenu menu)
{
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
menu.setUpdateBy(ShiroUtils.getLoginName());
ShiroUtils.clearCachedAuthorizationInfo();
return toAjax(menuService.updateMenu(menu));
}
/**
* 选择菜单图标
*/
@GetMapping("/icon")
public String icon()
{
return prefix + "/icon";
}
/**
* 校验菜单名称
*/
@PostMapping("/checkMenuNameUnique")
@ResponseBody
public String checkMenuNameUnique(SysMenu menu)
{
return menuService.checkMenuNameUnique(menu);
}
/**
* 加载角色菜单列表树
*/
@GetMapping("/roleMenuTreeData")
@ResponseBody
public List<Ztree> roleMenuTreeData(SysRole role)
{
Long userId = ShiroUtils.getUserId();
List<Ztree> ztrees = menuService.roleMenuTreeData(role, userId);
return ztrees;
}
/**
* 加载所有菜单列表树
*/
@GetMapping("/menuTreeData")
@ResponseBody
public List<Ztree> menuTreeData()
{
Long userId = ShiroUtils.getUserId();
List<Ztree> ztrees = menuService.menuTreeData(userId);
return ztrees;
}
/**
* 选择菜单树
*/
@GetMapping("/selectMenuTree/{menuId}")
public String selectMenuTree(@PathVariable("menuId") Long menuId, ModelMap mmap)
{
mmap.put("menu", menuService.selectMenuById(menuId));
return prefix + "/tree";
}
}
@@ -0,0 +1,112 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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.ResponseBody;
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.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.service.ISysNoticeService;
/**
* 公告 信息操作处理
*
* @author ruoyi
*/
@Controller
@RequestMapping("/system/notice")
public class SysNoticeController extends BaseController
{
private String prefix = "system/notice";
@Autowired
private ISysNoticeService noticeService;
@RequiresPermissions("system:notice:view")
@GetMapping()
public String notice()
{
return prefix + "/notice";
}
/**
* 查询公告列表
*/
@RequiresPermissions("system:notice:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysNotice notice)
{
startPage();
List<SysNotice> list = noticeService.selectNoticeList(notice);
return getDataTable(list);
}
/**
* 新增公告
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存公告
*/
@RequiresPermissions("system:notice:add")
@Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(SysNotice notice)
{
notice.setCreateBy(ShiroUtils.getLoginName());
return toAjax(noticeService.insertNotice(notice));
}
/**
* 修改公告
*/
@GetMapping("/edit/{noticeId}")
public String edit(@PathVariable("noticeId") Long noticeId, ModelMap mmap)
{
mmap.put("notice", noticeService.selectNoticeById(noticeId));
return prefix + "/edit";
}
/**
* 修改保存公告
*/
@RequiresPermissions("system:notice:edit")
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(SysNotice notice)
{
notice.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(noticeService.updateNotice(notice));
}
/**
* 删除公告
*/
@RequiresPermissions("system:notice:remove")
@Log(title = "通知公告", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(noticeService.deleteNoticeByIds(ids));
}
}
@@ -0,0 +1,163 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
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.ResponseBody;
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.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.service.ISysPostService;
/**
* 岗位信息操作处理
*
* @author ruoyi
*/
@Controller
@RequestMapping("/system/post")
public class SysPostController extends BaseController
{
private String prefix = "system/post";
@Autowired
private ISysPostService postService;
@RequiresPermissions("system:post:view")
@GetMapping()
public String operlog()
{
return prefix + "/post";
}
@RequiresPermissions("system:post:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysPost post)
{
startPage();
List<SysPost> list = postService.selectPostList(post);
return getDataTable(list);
}
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:post:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysPost post)
{
List<SysPost> list = postService.selectPostList(post);
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
return util.exportExcel(list, "岗位数据");
}
@RequiresPermissions("system:post:remove")
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
try
{
return toAjax(postService.deletePostByIds(ids));
}
catch (Exception e)
{
return error(e.getMessage());
}
}
/**
* 新增岗位
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存岗位
*/
@RequiresPermissions("system:post:add")
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysPost post)
{
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
{
return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setCreateBy(ShiroUtils.getLoginName());
return toAjax(postService.insertPost(post));
}
/**
* 修改岗位
*/
@GetMapping("/edit/{postId}")
public String edit(@PathVariable("postId") Long postId, ModelMap mmap)
{
mmap.put("post", postService.selectPostById(postId));
return prefix + "/edit";
}
/**
* 修改保存岗位
*/
@RequiresPermissions("system:post:edit")
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysPost post)
{
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
{
return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(postService.updatePost(post));
}
/**
* 校验岗位名称
*/
@PostMapping("/checkPostNameUnique")
@ResponseBody
public String checkPostNameUnique(SysPost post)
{
return postService.checkPostNameUnique(post);
}
/**
* 校验岗位编码
*/
@PostMapping("/checkPostCodeUnique")
@ResponseBody
public String checkPostCodeUnique(SysPost post)
{
return postService.checkPostCodeUnique(post);
}
}
@@ -0,0 +1,173 @@
package com.ruoyi.web.controller.system;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysUserService;
/**
* 个人信息 业务处理
*
* @author ruoyi
*/
@Controller
@RequestMapping("/system/user/profile")
public class SysProfileController extends BaseController
{
private static final Logger log = LoggerFactory.getLogger(SysProfileController.class);
private String prefix = "system/user/profile";
@Autowired
private ISysUserService userService;
@Autowired
private SysPasswordService passwordService;
/**
* 个人信息
*/
@GetMapping()
public String profile(ModelMap mmap)
{
SysUser user = ShiroUtils.getSysUser();
mmap.put("user", user);
mmap.put("roleGroup", userService.selectUserRoleGroup(user.getUserId()));
mmap.put("postGroup", userService.selectUserPostGroup(user.getUserId()));
return prefix + "/profile";
}
@GetMapping("/checkPassword")
@ResponseBody
public boolean checkPassword(String password)
{
SysUser user = ShiroUtils.getSysUser();
if (passwordService.matches(user, password))
{
return true;
}
return false;
}
@GetMapping("/resetPwd")
public String resetPwd(ModelMap mmap)
{
SysUser user = ShiroUtils.getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/resetPwd";
}
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd")
@ResponseBody
public AjaxResult resetPwd(String oldPassword, String newPassword)
{
SysUser user = ShiroUtils.getSysUser();
if (StringUtils.isNotEmpty(newPassword) && passwordService.matches(user, oldPassword))
{
user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
if (userService.resetUserPwd(user) > 0)
{
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
return success();
}
return error();
}
else
{
return error("修改密码失败,旧密码错误");
}
}
/**
* 修改用户
*/
@GetMapping("/edit")
public String edit(ModelMap mmap)
{
SysUser user = ShiroUtils.getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/edit";
}
/**
* 修改头像
*/
@GetMapping("/avatar")
public String avatar(ModelMap mmap)
{
SysUser user = ShiroUtils.getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/avatar";
}
/**
* 修改用户
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PostMapping("/update")
@ResponseBody
public AjaxResult update(SysUser user)
{
SysUser currentUser = ShiroUtils.getSysUser();
currentUser.setUserName(user.getUserName());
currentUser.setEmail(user.getEmail());
currentUser.setPhonenumber(user.getPhonenumber());
currentUser.setSex(user.getSex());
if (userService.updateUserInfo(currentUser) > 0)
{
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
return success();
}
return error();
}
/**
* 保存头像
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PostMapping("/updateAvatar")
@ResponseBody
public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file)
{
SysUser currentUser = ShiroUtils.getSysUser();
try
{
if (!file.isEmpty())
{
String avatar = FileUploadUtils.upload(Global.getAvatarPath(), file);
currentUser.setAvatar(avatar);
if (userService.updateUserInfo(currentUser) > 0)
{
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
return success();
}
}
return error();
}
catch (Exception e)
{
log.error("修改头像失败!", e);
return error(e.getMessage());
}
}
}
@@ -0,0 +1,301 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
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.ResponseBody;
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.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
/**
* 角色信息
*
* @author ruoyi
*/
@Controller
@RequestMapping("/system/role")
public class SysRoleController extends BaseController
{
private String prefix = "system/role";
@Autowired
private ISysRoleService roleService;
@Autowired
private ISysUserService userService;
@RequiresPermissions("system:role:view")
@GetMapping()
public String role()
{
return prefix + "/role";
}
@RequiresPermissions("system:role:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysRole role)
{
startPage();
List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list);
}
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:role:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysRole role)
{
List<SysRole> list = roleService.selectRoleList(role);
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
return util.exportExcel(list, "角色数据");
}
/**
* 新增角色
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存角色
*/
@RequiresPermissions("system:role:add")
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysRole role)
{
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
{
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
}
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
{
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
role.setCreateBy(ShiroUtils.getLoginName());
ShiroUtils.clearCachedAuthorizationInfo();
return toAjax(roleService.insertRole(role));
}
/**
* 修改角色
*/
@GetMapping("/edit/{roleId}")
public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap)
{
mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/edit";
}
/**
* 修改保存角色
*/
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysRole role)
{
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
{
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
}
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
{
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
role.setUpdateBy(ShiroUtils.getLoginName());
ShiroUtils.clearCachedAuthorizationInfo();
return toAjax(roleService.updateRole(role));
}
/**
* 角色分配数据权限
*/
@GetMapping("/authDataScope/{roleId}")
public String authDataScope(@PathVariable("roleId") Long roleId, ModelMap mmap)
{
mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/dataScope";
}
/**
* 保存角色分配数据权限
*/
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/authDataScope")
@ResponseBody
public AjaxResult authDataScopeSave(SysRole role)
{
role.setUpdateBy(ShiroUtils.getLoginName());
if (roleService.authDataScope(role) > 0)
{
ShiroUtils.setSysUser(userService.selectUserById(ShiroUtils.getSysUser().getUserId()));
return success();
}
return error();
}
@RequiresPermissions("system:role:remove")
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
try
{
return toAjax(roleService.deleteRoleByIds(ids));
}
catch (Exception e)
{
return error(e.getMessage());
}
}
/**
* 校验角色名称
*/
@PostMapping("/checkRoleNameUnique")
@ResponseBody
public String checkRoleNameUnique(SysRole role)
{
return roleService.checkRoleNameUnique(role);
}
/**
* 校验角色权限
*/
@PostMapping("/checkRoleKeyUnique")
@ResponseBody
public String checkRoleKeyUnique(SysRole role)
{
return roleService.checkRoleKeyUnique(role);
}
/**
* 选择菜单树
*/
@GetMapping("/selectMenuTree")
public String selectMenuTree()
{
return prefix + "/tree";
}
/**
* 角色状态修改
*/
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:role:edit")
@PostMapping("/changeStatus")
@ResponseBody
public AjaxResult changeStatus(SysRole role)
{
return toAjax(roleService.changeStatus(role));
}
/**
* 分配用户
*/
@RequiresPermissions("system:role:edit")
@GetMapping("/authUser/{roleId}")
public String authUser(@PathVariable("roleId") Long roleId, ModelMap mmap)
{
mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/authUser";
}
/**
* 查询已分配用户角色列表
*/
@RequiresPermissions("system:role:list")
@PostMapping("/authUser/allocatedList")
@ResponseBody
public TableDataInfo allocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list);
}
/**
* 取消授权
*/
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/cancel")
@ResponseBody
public AjaxResult cancelAuthUser(SysUserRole userRole)
{
return toAjax(roleService.deleteAuthUser(userRole));
}
/**
* 批量取消授权
*/
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/cancelAll")
@ResponseBody
public AjaxResult cancelAuthUserAll(Long roleId, String userIds)
{
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
}
/**
* 选择用户
*/
@GetMapping("/authUser/selectUser/{roleId}")
public String selectUser(@PathVariable("roleId") Long roleId, ModelMap mmap)
{
mmap.put("role", roleService.selectRoleById(roleId));
return prefix + "/selectUser";
}
/**
* 查询未分配用户角色列表
*/
@RequiresPermissions("system:role:list")
@PostMapping("/authUser/unallocatedList")
@ResponseBody
public TableDataInfo unallocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list);
}
/**
* 批量选择用户授权
*/
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/selectAll")
@ResponseBody
public AjaxResult selectAuthUserAll(Long roleId, String userIds)
{
return toAjax(roleService.insertAuthUsers(roleId, userIds));
}
}
@@ -0,0 +1,263 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
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.ResponseBody;
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.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.shiro.service.SysPasswordService;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
/**
* 用户信息
*
* @author ruoyi
*/
@Controller
@RequestMapping("/system/user")
public class SysUserController extends BaseController
{
private String prefix = "system/user";
@Autowired
private ISysUserService userService;
@Autowired
private ISysRoleService roleService;
@Autowired
private ISysPostService postService;
@Autowired
private SysPasswordService passwordService;
@RequiresPermissions("system:user:view")
@GetMapping()
public String user()
{
return prefix + "/user";
}
@RequiresPermissions("system:user:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysUser user)
{
startPage();
List<SysUser> list = userService.selectUserList(user);
return getDataTable(list);
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:user:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysUser user)
{
List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
return util.exportExcel(list, "用户数据");
}
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
@RequiresPermissions("system:user:import")
@PostMapping("/importData")
@ResponseBody
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 = ShiroUtils.getSysUser().getLoginName();
String message = userService.importUser(userList, updateSupport, operName);
return AjaxResult.success(message);
}
@RequiresPermissions("system:user:view")
@GetMapping("/importTemplate")
@ResponseBody
public AjaxResult importTemplate()
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
return util.importTemplateExcel("用户数据");
}
/**
* 新增用户
*/
@GetMapping("/add")
public String add(ModelMap mmap)
{
mmap.put("roles", roleService.selectRoleAll());
mmap.put("posts", postService.selectPostAll());
return prefix + "/add";
}
/**
* 新增保存用户
*/
@RequiresPermissions("system:user:add")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysUser user)
{
if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName())))
{
return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在");
}
else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
return error("新增用户'" + user.getLoginName() + "'失败,手机号码已存在");
}
else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
}
user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
user.setCreateBy(ShiroUtils.getLoginName());
return toAjax(userService.insertUser(user));
}
/**
* 修改用户
*/
@GetMapping("/edit/{userId}")
public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
{
mmap.put("user", userService.selectUserById(userId));
mmap.put("roles", roleService.selectRolesByUserId(userId));
mmap.put("posts", postService.selectPostsByUserId(userId));
return prefix + "/edit";
}
/**
* 修改保存用户
*/
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysUser user)
{
if (StringUtils.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId()))
{
return error("不允许修改超级管理员用户");
}
else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在");
}
else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
}
user.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(userService.updateUser(user));
}
@RequiresPermissions("system:user:resetPwd")
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@GetMapping("/resetPwd/{userId}")
public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap)
{
mmap.put("user", userService.selectUserById(userId));
return prefix + "/resetPwd";
}
@RequiresPermissions("system:user:resetPwd")
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd")
@ResponseBody
public AjaxResult resetPwdSave(SysUser user)
{
user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
if (userService.resetUserPwd(user) > 0)
{
if (ShiroUtils.getUserId() == user.getUserId())
{
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
}
return success();
}
return error();
}
@RequiresPermissions("system:user:remove")
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
try
{
return toAjax(userService.deleteUserByIds(ids));
}
catch (Exception e)
{
return error(e.getMessage());
}
}
/**
* 校验用户名
*/
@PostMapping("/checkLoginNameUnique")
@ResponseBody
public String checkLoginNameUnique(SysUser user)
{
return userService.checkLoginNameUnique(user.getLoginName());
}
/**
* 校验手机号码
*/
@PostMapping("/checkPhoneUnique")
@ResponseBody
public String checkPhoneUnique(SysUser user)
{
return userService.checkPhoneUnique(user);
}
/**
* 校验email邮箱
*/
@PostMapping("/checkEmailUnique")
@ResponseBody
public String checkEmailUnique(SysUser user)
{
return userService.checkEmailUnique(user);
}
/**
* 用户状态修改
*/
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:user:edit")
@PostMapping("/changeStatus")
@ResponseBody
public AjaxResult changeStatus(SysUser user)
{
return toAjax(userService.changeStatus(user));
}
}
@@ -0,0 +1,26 @@
package com.ruoyi.web.controller.tool;
import org.apache.shiro.authz.annotation.RequiresPermissions;
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;
/**
* build 表单构建
*
* @author ruoyi
*/
@Controller
@RequestMapping("/tool/build")
public class BuildController extends BaseController
{
private String prefix = "tool/build";
@RequiresPermissions("tool:build:view")
@GetMapping()
public String build()
{
return prefix + "/build";
}
}
@@ -0,0 +1,24 @@
package com.ruoyi.web.controller.tool;
import org.apache.shiro.authz.annotation.RequiresPermissions;
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
{
@RequiresPermissions("tool:swagger:view")
@GetMapping()
public String index()
{
return redirect("/swagger-ui.html");
}
}
Loaded 100 of 4592 files, more files were not shown because too many files have changed in this diff. Show more