部署方式由war转为jar包;使用gitee图床作为图片服务

master
Bosen 2021-12-06 21:59:28 +08:00
parent a2a0320b9b
commit 31f2b1e91a
47 changed files with 560 additions and 437 deletions

View File

@ -129,17 +129,17 @@
![](https://img-blog.csdnimg.cn/1281208680ff4461a48202f71629a285.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_20,color_FFFFFF,t_70,g_se,x_16) ![](https://img-blog.csdnimg.cn/1281208680ff4461a48202f71629a285.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_20,color_FFFFFF,t_70,g_se,x_16)
![](https://img-blog.csdnimg.cn/0c0547bf787c4877b62557cd2d17e729.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_20,color_FFFFFF,t_70,g_se,x_16) ![](https://img-blog.csdnimg.cn/0c0547bf787c4877b62557cd2d17e729.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_20,color_FFFFFF,t_70,g_se,x_16)
### 3.打包项目 ### 3.打包项目
填写好项目配置信息后,就可以开始打包项目了:依次点击 **Build -> Build Artifacts -> jieyue.war -> Build**,项目将会开始打包~ 填写好项目配置信息后,就可以开始打包项目了:按照下图所示的步骤依次执行,最后打包好的 **`jieyue.jar`** 将会存放在 **`target`** 目录中。
![](https://img-blog.csdnimg.cn/bf5814bfd67344dba8ece2211c32f5b9.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_20,color_FFFFFF,t_70,g_se,x_16) ![](https://img-blog.csdnimg.cn/11e170bd1863418d99b38caebcb12c10.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_20,color_FFFFFF,t_70,g_se,x_16)
等待项目打包完后相应的war包会存放在target目录下名称为 **`ROOT.war`** (如下)
![](https://img-blog.csdnimg.cn/2c9057e8e6924c39a2b81154db104876.png)
### 4.安装Docker ### 4.安装Docker
docker的安装流程可参考下面这篇文章笔者在这里就不再赘述了**[https://www.runoob.com/docker/centos-docker-install.html](https://www.runoob.com/docker/centos-docker-install.html)** docker的安装流程可参考下面这篇文章笔者在这里就不再赘述了**[https://www.runoob.com/docker/centos-docker-install.html](https://www.runoob.com/docker/centos-docker-install.html)**
<br/> <br/>
### 5.安装MySQL ### 5.安装MySQL
5.1执行如下命令拉取MySQL的docker镜像 5.1执行如下命令拉取MySQL的Docker镜像
```bash ```bash
docker pull hub.c.163.com/library/mysql:latest docker pull hub.c.163.com/library/mysql:latest
``` ```
@ -149,10 +149,10 @@ docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d hub.c.163.
``` ```
5.3MySQL运行成功后需要对MySQL的数据进行初始化这里笔者推荐使用可视化工具Navicat填入对应的信息即可成功连接 5.3MySQL运行成功后需要对MySQL的数据进行初始化这里笔者推荐使用可视化工具Navicat填入对应的信息即可成功连接
![](https://img-blog.csdnimg.cn/3bc392ebdbf249dd93a765bcf8d41733.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_20,color_FFFFFF,t_70,g_se,x_16) ![](https://img-blog.csdnimg.cn/3bc392ebdbf249dd93a765bcf8d41733.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_20,color_FFFFFF,t_70,g_se,x_16)
5.4新建一个名为jieyue的数据库创建成功后双击该数据库创立连接接着右击选择**运行SQL文件**,运行项目根目录下的`jieyue.sql`文件即可。 5.4新建一个名为jieyue的数据库创建成功后双击该数据库创立连接接着右击选择**运行SQL文件**,运行项目根目录下的 **`jieyue.sql`** 文件即可。
![](https://img-blog.csdnimg.cn/be8eccc8a0084db8a087d8287034cfc3.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_19,color_FFFFFF,t_70,g_se,x_16) ![](https://img-blog.csdnimg.cn/be8eccc8a0084db8a087d8287034cfc3.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_19,color_FFFFFF,t_70,g_se,x_16)
### 6.安装Redis ### 6.安装Redis
6.1执行如下命令拉取Redis的docker镜像 6.1执行如下命令拉取Redis的Docker镜像
```bash ```bash
docker pull hub.c.163.com/library/redis:latest docker pull hub.c.163.com/library/redis:latest
``` ```
@ -162,24 +162,39 @@ docker run -d -p 6379:6379 --name redis hub.c.163.com/library/redis:latest
``` ```
<br/> <br/>
### 7.安装Tomcat ### 7.安装OpenJDK
7.1执行如下命令拉取Tomcat的docker镜像注意tomcat的版本需要是`8.5`的) 7.1执行如下命令拉取OpenJDK的Docker镜像
```bash ```bash
docker pull hub.c.163.com/library/tomcat:8.5 docker pull hub.c.163.com/cloudndp/library/openjdk:8-jessie
``` ```
7.2执行如下命令运行Tomcat 7.2:在 **`jieyue.jar`** 包同一目录下创建 **`Dockerfile`** 文件,具体内容如下
```bash ```bash
docker run -d -p 80:8080 --name tomcat hub.c.163.com/library/tomcat:8.5 FROM hub.c.163.com/cloudndp/library/openjdk:8-jessie
COPY jieyue.jar /jieyue.jar
CMD java -jar /jieyue.jar
EXPOSE 80
``` ```
7.3将前面我们打包好的war包放入到启动好的tomcat容器中执行下面的命令前请确认war包在当前目录下 7.3:在 **`jieyue.jar`** 包同一目录下执行如下命令,创建镜像
```bash ```bash
docker cp ROOT.war tomcat:/usr/local/tomcat/webapps docker build -t jieyue-image .
``` ```
7.4重启tomcat容器 7.4最后运行容器即可
```bash ```bash
docker restart tomcat docker run -d -p 80:80 --name jieyue jieyue-image
``` ```
7.5重启tomcat后访问配置文件中填写的服务器ip地址即可笔者这里填写的是199.91.222.184,访问[http://119.91.222.184/](http://119.91.222.184/),就可以看到网站的主页)至此,捷阅网已成功部署~~ 7.5:使用如下命令可查看项目运行日志(若有如下字眼出现,则表明容器运行成功)
```bash
docker logs jieyue
```
![](https://img-blog.csdnimg.cn/1be4eb72a24a449d893a9d973310b073.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_20,color_FFFFFF,t_70,g_se,x_16)
7.6成功运行后访问配置文件中填写的服务器ip地址即可笔者这里填写的是199.91.222.184,访问[http://119.91.222.184/](http://119.91.222.184/),就可以看到网站的主页)至此,捷阅网已成功部署~~
<br/> <br/>

View File

@ -11,7 +11,7 @@
Target Server Version : 50716 Target Server Version : 50716
File Encoding : 65001 File Encoding : 65001
Date: 07/08/2021 19:03:46 Date: 06/12/2021 21:17:08
*/ */
SET NAMES utf8mb4; SET NAMES utf8mb4;
@ -201,17 +201,17 @@ INSERT INTO `sys_goods` VALUES (39, '棒球帽 ARCHIVE', 'PUMA彪马官方 杨
INSERT INTO `sys_goods` VALUES (40, '条纹棒球帽 ARCHIVE', 'PUMA彪马官方 新款条纹棒球帽 ARCHIVE LOGO 022554 粗呢蓝-条纹-09 均码', '/data/goods/9/20201112192208777150.jpg', 0.01, 0, 9, 0); INSERT INTO `sys_goods` VALUES (40, '条纹棒球帽 ARCHIVE', 'PUMA彪马官方 新款条纹棒球帽 ARCHIVE LOGO 022554 粗呢蓝-条纹-09 均码', '/data/goods/9/20201112192208777150.jpg', 0.01, 0, 9, 0);
INSERT INTO `sys_goods` VALUES (41, '运动休闲手提包', 'PUMA彪马官方娜扎同款新款女子运动休闲手提包 PRIME PUFFA 078192 银色 02 OSFA/均码', '/data/goods/9/20201112192355215509.jpg', 0.01, 0, 9, 0); INSERT INTO `sys_goods` VALUES (41, '运动休闲手提包', 'PUMA彪马官方娜扎同款新款女子运动休闲手提包 PRIME PUFFA 078192 银色 02 OSFA/均码', '/data/goods/9/20201112192355215509.jpg', 0.01, 0, 9, 0);
INSERT INTO `sys_goods` VALUES (44, '测试商品(勿拍)', '测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍)测试商品(勿拍)', '/data/goods/8/20210109201101998677.jpg', 0.01, 0, 8, 82); INSERT INTO `sys_goods` VALUES (44, '测试商品(勿拍)', '测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍);测试商品(勿拍)测试商品(勿拍)', '/data/goods/8/20210109201101998677.jpg', 0.01, 0, 8, 82);
INSERT INTO `sys_goods` VALUES (45, '国潮手绘皮卡丘帆布鞋', '回力官方旗舰 国潮手绘皮卡丘帆布鞋高帮男鞋联名爆改涂鸦鞋子2021新款春季潮流板鞋 黄色闪电(五天内发货) 42', '/data/goods/13/20210330212031740396.jpg', 0.01, 1, 13, 10); INSERT INTO `sys_goods` VALUES (45, '国潮手绘皮卡丘帆布鞋', '回力官方旗舰 国潮手绘皮卡丘帆布鞋高帮男鞋联名爆改涂鸦鞋子2021新款春季潮流板鞋 黄色闪电(五天内发货) 42', '/data/goods/13/20210330212031740396.jpg', 0.01, 1, 13, 9);
INSERT INTO `sys_goods` VALUES (46, ' 国潮手绘高帮帆布鞋', '回力官方旗舰 国潮手绘高帮帆布鞋女士2021新款春季樱花鞋爆改休闲鞋男 缤纷樱花473SH五天内发货 42', '/data/goods/13/20210330212214866150.jpg', 0.01, 1, 13, 9); INSERT INTO `sys_goods` VALUES (46, ' 国潮手绘高帮帆布鞋', '回力官方旗舰 国潮手绘高帮帆布鞋女士2021新款春季樱花鞋爆改休闲鞋男 缤纷樱花473SH五天内发货 42', '/data/goods/13/20210330212214866150.jpg', 0.01, 1, 13, 8);
INSERT INTO `sys_goods` VALUES (47, '本命年高帮帆布鞋', '回力官方旗舰 本命年高帮帆布鞋男鞋嘻哈透气男女休闲鞋潮流百搭学生情侣鞋子【国潮系列】 花布WXY-A363T 39', '/data/goods/13/20210330212245424549.jpg', 0.01, 1, 13, 9); INSERT INTO `sys_goods` VALUES (47, '本命年高帮帆布鞋', '回力官方旗舰 本命年高帮帆布鞋男鞋嘻哈透气男女休闲鞋潮流百搭学生情侣鞋子【国潮系列】 花布WXY-A363T 39', '/data/goods/13/20210330212245424549.jpg', 0.01, 1, 13, 8);
INSERT INTO `sys_goods` VALUES (48, '板鞋女鞋2021秋冬季新', '回力官方旗舰 板鞋女鞋2021秋冬季新款马卡龙撞色低帮透气百搭休闲运动小白鞋子女 白糖果WXYA562C 35', '/data/goods/13/20210330212317794584.jpg', 0.01, 1, 13, 9); INSERT INTO `sys_goods` VALUES (48, '板鞋女鞋2021秋冬季新', '回力官方旗舰 板鞋女鞋2021秋冬季新款马卡龙撞色低帮透气百搭休闲运动小白鞋子女 白糖果WXYA562C 35', '/data/goods/13/20210330212317794584.jpg', 0.01, 1, 13, 8);
INSERT INTO `sys_goods` VALUES (49, '国潮手绘星球宇航员帆布鞋', '回力官方旗舰 国潮手绘星球宇航员帆布鞋情侣2021春夏季新款爆改NASA高帮女士板鞋男鞋子潮鞋子 星球宇航员(下单后五天内发货) 39', '/data/goods/13/20210330212343230193.jpg', 0.01, 1, 13, 10); INSERT INTO `sys_goods` VALUES (49, '国潮手绘星球宇航员帆布鞋', '回力官方旗舰 国潮手绘星球宇航员帆布鞋情侣2021春夏季新款爆改NASA高帮女士板鞋男鞋子潮鞋子 星球宇航员(下单后五天内发货) 39', '/data/goods/13/20210330212343230193.jpg', 0.01, 1, 13, 9);
INSERT INTO `sys_goods` VALUES (50, '国潮手绘彩虹天使马帆布鞋', '回力官方旗舰 国潮手绘彩虹天使马帆布鞋男鞋子2021春夏季女士新款爆改手绘独角兽高帮板鞋潮鞋布鞋 彩虹天使马(下单后五天内发货) 37', '/data/goods/13/20210330212408614514.jpg', 0.01, 1, 13, 10); INSERT INTO `sys_goods` VALUES (50, '国潮手绘彩虹天使马帆布鞋', '回力官方旗舰 国潮手绘彩虹天使马帆布鞋男鞋子2021春夏季女士新款爆改手绘独角兽高帮板鞋潮鞋布鞋 彩虹天使马(下单后五天内发货) 37', '/data/goods/13/20210330212408614514.jpg', 0.01, 1, 13, 9);
INSERT INTO `sys_goods` VALUES (51, 'ins潮复古老爹鞋', '回力官方旗舰 跑步鞋男鞋2021秋季新款ins潮复古老爹鞋学生透气网面减震休闲运动鞋子男 军绿WXY0170 42', '/data/goods/13/20210330212444207204.jpg', 0.01, 1, 13, 10); INSERT INTO `sys_goods` VALUES (51, 'ins潮复古老爹鞋', '回力官方旗舰 跑步鞋男鞋2021秋季新款ins潮复古老爹鞋学生透气网面减震休闲运动鞋子男 军绿WXY0170 42', '/data/goods/13/20210330212444207204.jpg', 0.01, 1, 13, 9);
INSERT INTO `sys_goods` VALUES (52, '荧光手绘帆布鞋星际宇航员高帮鞋', '回力官方旗舰 荧光手绘帆布鞋星际宇航员高帮鞋2021新款春季男女鞋潮流休闲鞋国潮板鞋子男 夜光黑色星球宇航员 42', '/data/goods/13/20210330212516740293.jpg', 0.01, 1, 13, 10); INSERT INTO `sys_goods` VALUES (52, '荧光手绘帆布鞋星际宇航员高帮鞋', '回力官方旗舰 荧光手绘帆布鞋星际宇航员高帮鞋2021新款春季男女鞋潮流休闲鞋国潮板鞋子男 夜光黑色星球宇航员 42', '/data/goods/13/20210330212516740293.jpg', 0.01, 1, 13, 9);
INSERT INTO `sys_goods` VALUES (53, '国潮手绘恶魔小丑高帮帆布鞋', '【手绘】回力官方旗舰 国潮手绘恶魔小丑高帮帆布鞋樱花爆改恶魔系情侣休闲鞋男女鞋涂鸦潮鞋子 恶魔小丑(下单后五天内发货) 42', '/data/goods/13/20210330212538705519.jpg', 0.01, 1, 13, 10); INSERT INTO `sys_goods` VALUES (53, '国潮手绘恶魔小丑高帮帆布鞋', '【手绘】回力官方旗舰 国潮手绘恶魔小丑高帮帆布鞋樱花爆改恶魔系情侣休闲鞋男女鞋涂鸦潮鞋子 恶魔小丑(下单后五天内发货) 42', '/data/goods/13/20210330212538705519.jpg', 0.01, 1, 13, 9);
INSERT INTO `sys_goods` VALUES (54, '国潮手绘浮世绘仙鹤鲸鱼帆布鞋', '【手绘】回力官方旗舰 国潮手绘浮世绘仙鹤鲸鱼帆布鞋男鞋手绘2021春夏季女爆改涂鸦中国风布鞋子 浮世绘仙鹤鲸鱼(下单后五天内发货) 42', '/data/goods/13/20210330212601581309.jpg', 0.01, 1, 13, 10); INSERT INTO `sys_goods` VALUES (54, '国潮手绘浮世绘仙鹤鲸鱼帆布鞋', '【手绘】回力官方旗舰 国潮手绘浮世绘仙鹤鲸鱼帆布鞋男鞋手绘2021春夏季女爆改涂鸦中国风布鞋子 浮世绘仙鹤鲸鱼(下单后五天内发货) 42', '/data/goods/13/20210330212601581309.jpg', 0.01, 1, 13, 9);
INSERT INTO `sys_goods` VALUES (55, '小雏菊经典情侣高帮', '回力官方旗舰 小雏菊经典情侣高帮帆布休闲鞋男正品板鞋手绘印刷新款女高帮鞋子 黑色花(女生建议选小一码) 35', '/data/goods/13/20210330212628919032.jpg', 0.01, 1, 13, 10); INSERT INTO `sys_goods` VALUES (55, '小雏菊经典情侣高帮', '回力官方旗舰 小雏菊经典情侣高帮帆布休闲鞋男正品板鞋手绘印刷新款女高帮鞋子 黑色花(女生建议选小一码) 35', '/data/goods/13/20210330212628919032.jpg', 0.01, 1, 13, 9);
INSERT INTO `sys_goods` VALUES (56, '国潮蓝手绘经典款帆布鞋', '回力官方旗舰 国潮蓝手绘经典款帆布鞋高帮男女2021春季新款情侣国潮红百搭休闲爆改涂鸦鞋子 国潮蓝(下单后五天内发货) 41', '/data/goods/13/20210330212653590038.jpg', 0.01, 1, 13, 10); INSERT INTO `sys_goods` VALUES (56, '国潮蓝手绘经典款帆布鞋', '回力官方旗舰 国潮蓝手绘经典款帆布鞋高帮男女2021春季新款情侣国潮红百搭休闲爆改涂鸦鞋子 国潮蓝(下单后五天内发货) 41', '/data/goods/13/20210330212653590038.jpg', 0.01, 1, 13, 10);
INSERT INTO `sys_goods` VALUES (57, '运动裤卫裤', '李宁运动裤卫裤女官方旗舰网运动时尚系列女子收口卫裤休闲长裤时尚 黑色A-5 M', '/data/goods/12/20210330213038709716.jpg', 0.01, 1, 12, 10); INSERT INTO `sys_goods` VALUES (57, '运动裤卫裤', '李宁运动裤卫裤女官方旗舰网运动时尚系列女子收口卫裤休闲长裤时尚 黑色A-5 M', '/data/goods/12/20210330213038709716.jpg', 0.01, 1, 12, 10);
INSERT INTO `sys_goods` VALUES (59, 'T恤短袖女夏季新品', '李宁T恤短袖女夏季新品女子休闲运动短袖T恤青年薄款休闲跑步健身服圆领休闲上衣短袖官方旗舰网 浅桃粉-3 M', '/data/goods/12/20210330213112628569.jpg', 0.01, 1, 12, 10); INSERT INTO `sys_goods` VALUES (59, 'T恤短袖女夏季新品', '李宁T恤短袖女夏季新品女子休闲运动短袖T恤青年薄款休闲跑步健身服圆领休闲上衣短袖官方旗舰网 浅桃粉-3 M', '/data/goods/12/20210330213112628569.jpg', 0.01, 1, 12, 10);
@ -359,7 +359,7 @@ CREATE TABLE `sys_order` (
`merchant_ratio` float(11, 1) NOT NULL DEFAULT 1.0 COMMENT '订单创建时商户的费率', `merchant_ratio` float(11, 1) NOT NULL DEFAULT 1.0 COMMENT '订单创建时商户的费率',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `order_id`(`order_id`) USING BTREE COMMENT '订单号唯一' UNIQUE INDEX `order_id`(`order_id`) USING BTREE COMMENT '订单号唯一'
) ENGINE = InnoDB AUTO_INCREMENT = 94 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 112 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ---------------------------- -- ----------------------------
-- Records of sys_order -- Records of sys_order
@ -375,6 +375,17 @@ INSERT INTO `sys_order` VALUES (90, 'WVW202012341002151359796', 1607185311336, 1
INSERT INTO `sys_order` VALUES (91, 'QAK202012341002151746672', 1607185311336, 1607185323819, 1, 1, 'SDW202012341002151596097', 1, 5, 0.01, 19, '', '测试', '测试', '测试', '', 0, '/data/pay/SDW202012341002151596097.jpg', '1', 0.1); INSERT INTO `sys_order` VALUES (91, 'QAK202012341002151746672', 1607185311336, 1607185323819, 1, 1, 'SDW202012341002151596097', 1, 5, 0.01, 19, '', '测试', '测试', '测试', '', 0, '/data/pay/SDW202012341002151596097.jpg', '1', 0.1);
INSERT INTO `sys_order` VALUES (92, 'YYT202012341004300490850', 1607186580573, 1607186595850, 1, 1, 'NFF202012341004300926613', 1, 8, 0.01, 34, '', '测试', '测试', '测试', '', 0, '/data/pay/NFF202012341004300926613.jpg', '13', 0.1); INSERT INTO `sys_order` VALUES (92, 'YYT202012341004300490850', 1607186580573, 1607186595850, 1, 1, 'NFF202012341004300926613', 1, 8, 0.01, 34, '', '测试', '测试', '测试', '', 0, '/data/pay/NFF202012341004300926613.jpg', '13', 0.1);
INSERT INTO `sys_order` VALUES (93, 'LID202012341004300509122', 1607186580573, 1607186595850, 1, 1, 'NFF202012341004300926613', 1, 5, 0.01, 19, '', '测试', '测试', '测试', '', 0, '/data/pay/NFF202012341004300926613.jpg', '10', 0.1); INSERT INTO `sys_order` VALUES (93, 'LID202012341004300509122', 1607186580573, 1607186595850, 1, 1, 'NFF202012341004300926613', 1, 5, 0.01, 19, '', '测试', '测试', '测试', '', 0, '/data/pay/NFF202012341004300926613.jpg', '10', 0.1);
INSERT INTO `sys_order` VALUES (101, 'GKJ202112340211010176213', 1638796210886, 1638796384928, 1, 1, 'GAU202112340211010908695', 1, 13, 0.01, 45, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/11f3333f-6d68-4adb-9cf6-035a39a4a551.jpg', NULL, 0.0);
INSERT INTO `sys_order` VALUES (102, 'ZSS202112340211024283551', 1638796224161, 1638796384928, 1, 1, 'ELN202112340211024324951', 1, 13, 0.01, 46, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/147fb8b1-18ac-480a-8d57-2c21635d9519.jpg', NULL, 0.0);
INSERT INTO `sys_order` VALUES (103, 'ZDK202112340211037495045', 1638796237222, 1638796384928, 1, 1, 'IJD202112340211037974203', 1, 13, 0.01, 47, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/4801e190-5640-4f14-a593-66029aa2d0ea.jpg', NULL, 0.0);
INSERT INTO `sys_order` VALUES (104, 'UWU202112340211051689881', 1638796251864, 1638796384928, 1, 1, 'NTP202112340211051560839', 1, 13, 0.01, 48, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/896bd6fa-e609-405c-b601-caa56d71659f.jpg', NULL, 0.0);
INSERT INTO `sys_order` VALUES (105, 'LAW202112340211111244316', 1638796271424, 1638796384928, 1, 1, 'EVM202112340211111457150', 1, 13, 0.01, 49, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/814b7cf6-3e81-4356-aa27-023bf2eb0609.jpg', NULL, 0.0);
INSERT INTO `sys_order` VALUES (106, 'QZG202112340211127932176', 1638796287661, 1638796384928, 1, 1, 'CKX202112340211127838508', 1, 13, 0.01, 50, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/2a3ecc4c-62e4-4964-aa75-1c2a3d082ba1.jpg', NULL, 0.0);
INSERT INTO `sys_order` VALUES (107, 'MVF202112340211155962656', 1638796315927, 1638796384928, 1, 1, 'GXI202112340211155762974', 1, 13, 0.01, 51, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/175a4dc6-1077-46ef-b64e-0e2a9ae66ee0.jpg', NULL, 0.0);
INSERT INTO `sys_order` VALUES (108, 'GYV202112340211210918392', 1638796330108, 1638796384928, 1, 1, 'NJY202112340211210411460', 1, 13, 0.01, 52, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/b7e61e0a-fea6-4022-b9bb-a3949220c085.jpg', NULL, 0.0);
INSERT INTO `sys_order` VALUES (109, 'XAB202112340211229316121', 1638796349401, 1638796384928, 1, 1, 'BGA202112340211229992111', 1, 13, 0.01, 53, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/9d358e5a-638e-4437-8a00-d9f942e5f58f.jpg', NULL, 0.0);
INSERT INTO `sys_order` VALUES (110, 'YUL202112340211250396901', 1638796370482, 1638796384928, 1, 1, 'OAX202112340211250369042', 1, 13, 0.01, 54, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/3db2f150-1b6d-41fa-8b6d-eca59c5f39cc.jpg', NULL, 0.0);
INSERT INTO `sys_order` VALUES (111, 'BHY202112340211304317807', 1638796384928, 1638796384928, 1, 1, 'ETZ202112340211304214293', 1, 13, 0.01, 55, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/87b2e60d-464c-499a-90be-b93e1ea58911.jpg', NULL, 0.0);
-- ---------------------------- -- ----------------------------
-- Table structure for sys_role -- Table structure for sys_role
@ -499,7 +510,7 @@ CREATE TABLE `sys_user` (
-- ---------------------------- -- ----------------------------
-- Records of sys_user -- Records of sys_user
-- ---------------------------- -- ----------------------------
INSERT INTO `sys_user` VALUES (1, 'test', 'e10adc3949ba59abbe56e057f20f883e', 'bosen_once@163.com', 1, '/data/header/user/1.jpg'); INSERT INTO `sys_user` VALUES (1, 'Bosen', 'e10adc3949ba59abbe56e057f20f883e', 'bosen_once@163.com', 1, '/data/header/user/1.jpg');
INSERT INTO `sys_user` VALUES (3, 'bosen_once@qq.com', 'e10adc3949ba59abbe56e057f20f883e', 'bosen_once@qq.com', 1, '/data/header/user/default.jpg'); INSERT INTO `sys_user` VALUES (3, 'bosen_once@qq.com', 'e10adc3949ba59abbe56e057f20f883e', 'bosen_once@qq.com', 1, '/data/header/user/default.jpg');
INSERT INTO `sys_user` VALUES (4, 'test111', 'e10adc3949ba59abbe56e057f20f883e', '806317173@qq.com', 0, '/data/header/user/default.jpg'); INSERT INTO `sys_user` VALUES (4, 'test111', 'e10adc3949ba59abbe56e057f20f883e', '806317173@qq.com', 0, '/data/header/user/default.jpg');
INSERT INTO `sys_user` VALUES (5, 'lalalal', 'e10adc3949ba59abbe56e057f20f883e', '2390025288@qq.com', 0, '/data/header/user/default.jpg'); INSERT INTO `sys_user` VALUES (5, 'lalalal', 'e10adc3949ba59abbe56e057f20f883e', '2390025288@qq.com', 0, '/data/header/user/default.jpg');

35
pom.xml
View File

@ -11,7 +11,7 @@
<groupId>com.example</groupId> <groupId>com.example</groupId>
<artifactId>jieyue</artifactId> <artifactId>jieyue</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging> <packaging>jar</packaging>
<name>jieyue</name> <name>jieyue</name>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
@ -19,7 +19,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<tomcat.version>8.5.29</tomcat.version>
</properties> </properties>
<dependencies> <dependencies>
@ -60,34 +59,32 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<!-- 移除嵌入式tomcat插件 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!-- devtool -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId> <artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- mysql -->
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<!-- mybatis -->
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.3</version> <version>2.1.3</version>
</dependency> </dependency>
<!-- lombok -->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- test -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
@ -127,11 +124,13 @@
<artifactId>qrgen</artifactId> <artifactId>qrgen</artifactId>
<version>1.4</version> <version>1.4</version>
</dependency> </dependency>
<!-- json -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.47</version> <version>1.2.47</version>
</dependency> </dependency>
<!-- redis -->
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId> <artifactId>spring-data-redis</artifactId>
@ -158,15 +157,27 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId> <artifactId>spring-boot-starter-amqp</artifactId>
</dependency> </dependency>
<!-- hutool -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.5.8</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.12</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>ROOT</finalName> <finalName>jieyue</finalName>
<plugins> <plugins>
<!--<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>--> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>

View File

@ -1,15 +1,9 @@
package com.example.jieyue; package com.example.jieyue;
import org.apache.catalina.connector.Connector;
import org.apache.coyote.http11.AbstractHttp11Protocol;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
/** /**
@ -21,35 +15,10 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication @SpringBootApplication
@ServletComponentScan @ServletComponentScan
@EnableScheduling @EnableScheduling
public class JieyueApplication extends SpringBootServletInitializer { public class JieyueApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(JieyueApplication.class, args); SpringApplication.run(JieyueApplication.class, args);
} }
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(JieyueApplication.class);
}
/**
* <p></p>
*/
@Bean
public TomcatServletWebServerFactory containerFactory() {
return new TomcatServletWebServerFactory() {
protected void customizeConnector(Connector connector) {
int maxSize = 50000000;
super.customizeConnector(connector);
connector.setMaxPostSize(maxSize);
connector.setMaxSavePostSize(maxSize);
if (connector.getProtocolHandler() instanceof AbstractHttp11Protocol) {
((AbstractHttp11Protocol <?>) connector.getProtocolHandler()).setMaxSwallowSize(maxSize);
logger.info("Set MaxSwallowSize "+ maxSize);
}
}
};
}
} }

View File

@ -4,6 +4,7 @@ import com.example.jieyue.admin.service.AdminUiService;
import com.example.jieyue.common.entity.SysUi; import com.example.jieyue.common.entity.SysUi;
import com.example.jieyue.user.service.UserHomeService; import com.example.jieyue.user.service.UserHomeService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -12,6 +13,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* <p>UI</p> * <p>UI</p>
@ -24,6 +26,8 @@ public class AdminUiController {
AdminUiService adminUiService; AdminUiService adminUiService;
@Autowired @Autowired
UserHomeService userHomeService; UserHomeService userHomeService;
@Autowired
RedisTemplate redisTemplate;
@RequestMapping("/admin/ui") @RequestMapping("/admin/ui")
public ModelAndView index(ModelAndView modelAndView){ public ModelAndView index(ModelAndView modelAndView){
@ -46,7 +50,7 @@ public class AdminUiController {
modelAndView.addObject("msg","文件上传失败"); modelAndView.addObject("msg","文件上传失败");
}else{ }else{
modelAndView.addObject("msg","文件上传成功"); modelAndView.addObject("msg","文件上传成功");
clearCache();
} }
} }
modelAndView.setViewName("redirect:ui"); modelAndView.setViewName("redirect:ui");
@ -61,9 +65,18 @@ public class AdminUiController {
modelAndView.setViewName("redirect:ui"); modelAndView.setViewName("redirect:ui");
if (adminUiService.delImg(width,height)){ if (adminUiService.delImg(width,height)){
modelAndView.addObject("msg","删除成功"); modelAndView.addObject("msg","删除成功");
clearCache();
}else{ }else{
modelAndView.addObject("msg","删除失败"); modelAndView.addObject("msg","删除失败");
} }
return modelAndView; return modelAndView;
} }
/**
* <p></p>
*/
public void clearCache() {
Set<String> keys = redisTemplate.keys("*");
redisTemplate.delete(keys);
}
} }

View File

@ -2,6 +2,7 @@ package com.example.jieyue.admin.service;
import com.example.jieyue.common.entity.SysMt; import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.mapper.SysMtMapper; import com.example.jieyue.common.mapper.SysMtMapper;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -19,7 +20,11 @@ public class AdminMerchantService {
*/ */
public List<SysMt> getMtInfo(int curPage,int pageSize){ public List<SysMt> getMtInfo(int curPage,int pageSize){
int curRow = (curPage-1)*pageSize; int curRow = (curPage-1)*pageSize;
return mtMapper.findPage(curRow,pageSize); List<SysMt> list = mtMapper.findPage(curRow,pageSize);
for (SysMt sysMt : list) {
sysMt.setHeader(GiteeImgBedUtils.PRE + sysMt.getHeader());
}
return list;
} }
/** /**

View File

@ -1,22 +1,16 @@
package com.example.jieyue.admin.service; package com.example.jieyue.admin.service;
import com.example.jieyue.common.mapper.SysUiMapper; import com.example.jieyue.common.mapper.SysUiMapper;
import com.example.jieyue.common.utils.DateUtil; import com.example.jieyue.common.utils.GiteeImgBedUtils;
import com.example.jieyue.common.utils.FileUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.thymeleaf.util.StringUtils;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@Service @Service
public class AdminUiService { public class AdminUiService {
@Autowired
FileUtil fileUtil;
@Autowired
DateUtil dateUtil;
@Autowired @Autowired
SysUiMapper uiMapper; SysUiMapper uiMapper;
@ -28,32 +22,30 @@ public class AdminUiService {
*/ */
public String upImage(MultipartFile file, RedirectAttributes redirectAttributes, public String upImage(MultipartFile file, RedirectAttributes redirectAttributes,
HttpServletRequest request, String url,int weight,int height) { HttpServletRequest request, String url,int weight,int height) {
// 设置filename 文件名由年月日时分秒以及六位随机数组成
String filename = dateUtil.getNMDHIS()+Math.round(Math.random()*(999999-100000)+100000);
// 接收文件工具类返回的文件位置 // 接收文件工具类返回的文件位置
String result = fileUtil.upFile(file,redirectAttributes,request,url,filename); String result = GiteeImgBedUtils.upload(url, file);
if (result==null){ if (result == null){
return null; return null;
}else{ }else{
if (uiMapper.findByMark(weight,height) == null) { if (uiMapper.findByMark(weight,height) == null) {
int insertRes = uiMapper.insert(result, weight, height); int insertRes = uiMapper.insert(result, weight, height);
if (insertRes == 1) { if (insertRes == 1) {
return filename; return result;
} else { } else {
// sql语句执行失败将已上传的图片移除 // sql语句执行失败将已上传的图片移除
fileUtil.deleteFile(result); GiteeImgBedUtils.delete(result);
return null; return null;
} }
}else{ }else{
// 删除旧图片 // 删除旧图片
fileUtil.deleteFile(uiMapper.findByMark(weight,height).getUrl()); GiteeImgBedUtils.delete(uiMapper.findByMark(weight,height).getUrl());
// 更改图片 // 更改图片
int updateRes = uiMapper.updateUrl(result,weight,height); int updateRes = uiMapper.updateUrl(result,weight,height);
if (updateRes == 1) { if (updateRes == 1) {
return filename; return result;
} else { } else {
// sql语句执行失败将已上传的图片移除 // sql语句执行失败将已上传的图片移除
fileUtil.deleteFile(result); GiteeImgBedUtils.delete(result);
return null; return null;
} }
} }
@ -64,11 +56,11 @@ public class AdminUiService {
* <p></p> * <p></p>
*/ */
public boolean delImg(int width,int height){ public boolean delImg(int width,int height){
if (uiMapper.findByMark(width,height)==null){ if (uiMapper.findByMark(width,height) == null){
return false; return false;
}else{ }else{
fileUtil.deleteFile(uiMapper.findByMark(width,height).getUrl()); GiteeImgBedUtils.delete(uiMapper.findByMark(width, height).getUrl());
int delResult = uiMapper.deleteByMark(width,height); int delResult = uiMapper.deleteByMark(width, height);
if (delResult == 1) { if (delResult == 1) {
return true; return true;
} }

View File

@ -2,6 +2,7 @@ package com.example.jieyue.admin.service;
import com.example.jieyue.common.entity.SysUser; import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.common.mapper.SysUserMapper; import com.example.jieyue.common.mapper.SysUserMapper;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -16,7 +17,11 @@ public class AdminUserService {
* <p></p> * <p></p>
*/ */
public List<SysUser> getUserList(int page, int num){ public List<SysUser> getUserList(int page, int num){
return userMapper.findLimit((page-1)*num,num); List<SysUser> list = userMapper.findLimit((page-1)*num,num);
for (SysUser user : list) {
user.setHeader(GiteeImgBedUtils.PRE + user.getHeader());
}
return list;
} }
/** /**

View File

@ -5,7 +5,7 @@ import com.example.jieyue.common.mapper.SysGoodsMapper;
import com.example.jieyue.common.mapper.SysNoticeMapper; import com.example.jieyue.common.mapper.SysNoticeMapper;
import com.example.jieyue.common.mapper.SysOrderMapper; import com.example.jieyue.common.mapper.SysOrderMapper;
import com.example.jieyue.common.service.MailService; import com.example.jieyue.common.service.MailService;
import com.example.jieyue.common.utils.FileUtil; import com.example.jieyue.common.utils.GiteeImgBedUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -13,7 +13,6 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -29,8 +28,6 @@ public class SchedulerTask {
@Autowired @Autowired
SysGoodsMapper goodsMapper; SysGoodsMapper goodsMapper;
@Autowired @Autowired
FileUtil fileUtil;
@Autowired
RedisTemplate redisTemplate; RedisTemplate redisTemplate;
@Autowired @Autowired
SysNoticeMapper noticeMapper; SysNoticeMapper noticeMapper;
@ -43,15 +40,15 @@ public class SchedulerTask {
@Scheduled(cron="0 0/1 * * * ?") @Scheduled(cron="0 0/1 * * * ?")
@Transactional @Transactional
public void delOverOrder(){ public void delOverOrder(){
long time = 2*60*60*1000;// 订单过期时间,两小时 // 订单过期时间,两小时
long time = 2*60*60*1000;
List<SysOrder> list = orderMapper.findByState(0); List<SysOrder> list = orderMapper.findByState(0);
for (SysOrder sysOrder : list) { for (SysOrder sysOrder : list) {
if (System.currentTimeMillis() > sysOrder.getCreateTime()+time){ if (System.currentTimeMillis() > sysOrder.getCreateTime() + time
if (orderMapper.deleteById(sysOrder.getId())!=1 || && sysOrder.getOrderState() == 0){
if (orderMapper.deleteById(sysOrder.getId()) != 1 ||
goodsMapper.addStock(sysOrder.getGoodsId(),sysOrder.getGoodsNum()) != 1){ goodsMapper.addStock(sysOrder.getGoodsId(),sysOrder.getGoodsNum()) != 1){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}else{
fileUtil.deleteFile(sysOrder.getPayCodeUrl());
} }
} }
} }
@ -62,11 +59,13 @@ public class SchedulerTask {
*/ */
@Scheduled(cron="0 0/1 * * * ?") @Scheduled(cron="0 0/1 * * * ?")
public void delQRCode(){ public void delQRCode(){
long time = 2*60*60*1000;// 订单过期时间,两小时 // 订单过期时间,两小时
long time = 2*60*60*1000;
List<SysOrder> list = orderMapper.findAll(); List<SysOrder> list = orderMapper.findAll();
for (SysOrder sysOrder : list) { for (SysOrder sysOrder : list) {
if (System.currentTimeMillis() > sysOrder.getCreateTime()+time){ if (System.currentTimeMillis() > sysOrder.getCreateTime() + time
fileUtil.deleteFile(sysOrder.getPayCodeUrl()); && sysOrder.getOrderState() == 0){
GiteeImgBedUtils.delete(sysOrder.getPayCodeUrl());
} }
} }
} }
@ -83,19 +82,8 @@ public class SchedulerTask {
int type = Integer.valueOf(map.get("type")); int type = Integer.valueOf(map.get("type"));
int receive = Integer.valueOf(map.get("receive")); int receive = Integer.valueOf(map.get("receive"));
long createTime = Long.valueOf(map.get("createTime")); long createTime = Long.valueOf(map.get("createTime"));
switch (type){
case 0:
noticeMapper.insert(title,context,type,receive,createTime); noticeMapper.insert(title,context,type,receive,createTime);
break;
case 1:
noticeMapper.insert(title,context,type,receive,createTime);
break;
case 2:
noticeMapper.insert(title,context,type,receive,createTime);
break;
default:
break;
}
} }
} }

View File

@ -1,22 +0,0 @@
package com.example.jieyue.common.utils;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* <p></p>
* @author Bosen
* 2020/11/6 10:36
*/
@Component
public class DateUtil {
/**
* <p></p>
*/
public String getNMDHIS(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
return sdf.format(new Date());
}
}

View File

@ -1,78 +0,0 @@
package com.example.jieyue.common.utils;
import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
* <p></p>
* @author Bosen
* 2020/11/5 22:55
*/
@Component
public class FileUtil {
String classpath;
public FileUtil() throws FileNotFoundException {
this.classpath = ResourceUtils.getFile("classpath:/static").getPath()+"\\";
}
/**
* <p></p>
* @return
* null
*
*/
public String upFile(MultipartFile file, RedirectAttributes redirectAttributes,
HttpServletRequest request,String url,String filename) {
// MultipartFile是对当前上传的文件的封装当要同时上传多个文件时可以给定多个MultipartFile参数(数组)
if (file.isEmpty()) {
redirectAttributes.addFlashAttribute("message", "Please select a file to upload");
return null;
}
// 取文件格式后缀名
// String type = file.getOriginalFilename().substring(file.getOriginalFilename().indexOf("."));
File savefile1 = new File(classpath+url);
//判断上传文件的保存目录是否存在
if (!savefile1.exists() && !savefile1.isDirectory()) {
System.out.println(classpath+"目录不存在,需要创建");
//创建目录
savefile1.mkdir();
}
String suffix = this.getSuffixName(file.getOriginalFilename());
try {
// FileUtils.copyInputStreamToFile()这个方法里对IO进行了自动操作不需要额外的再去关闭IO流
// 加入原工程static目录
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(savefile1+"/"+filename+"."+suffix));// 复制临时文件到指定目录下
} catch (IOException e) {
e.printStackTrace();
}
return url+filename+"."+suffix;
}
/**
* <p></p>
*/
public String getSuffixName(String filename){
String[] strArray = filename.split("\\.");
int suffixIndex = strArray.length -1;
return strArray[suffixIndex];
}
/**
* <p></p>
*/
public void deleteFile(String url){
File file1 = new File(classpath+url);
file1.delete();
}
}

View File

@ -0,0 +1,183 @@
package com.example.jieyue.common.utils;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class GiteeImgBedUtils {
/**
*
*/
private static final String ACCESS_TOKEN = "98016b93bd85d836c5158bf340c32d35";
/**
*
*/
private static final String OWNER = "bosen-once";
/**
*
*/
private static final String REPO = "cloud-disk";
/**
* 访
*/
public static final String PRE =
"https://gitee.com/" + OWNER + "/" + REPO + "/raw/master/";
/**
* (POST)(GET)(DELETE)()使
* %s =>(path) (owner)
* %s => (repo)
* %s => (path)
*/
private static final String API_CREATE_POST =
"https://gitee.com/api/v5/repos/%s/%s/contents/%s";
/**
*
*/
private static final String ADD_MESSAGE = "add file";
private static final String DEL_MESSAGE = "del file";
/**
* <p></p>
* @param multipartFile
* @return
*/
public static String upload(String path, MultipartFile multipartFile) {
String originalFilename = multipartFile.getOriginalFilename();
if(originalFilename == null){
return null;
}
String targetUrl = GiteeImgBedUtils.createUploadFileUrl(path, originalFilename);
// 请求体封装
Map<String, Object> map = null;
try {
map = GiteeImgBedUtils.getUploadBodyMap(multipartFile.getBytes());
} catch (IOException e) {
return null;
}
// 借助HttpUtil工具类发送POST请求
String jsonResult = HttpUtil.post(targetUrl, map);
// 解析响应JSON字符串
JSONObject jsonObj = JSONUtil.parseObj(jsonResult);
// 请求失败
if(jsonObj.getObj("commit") == null){
return null;
}
//请求成功:返回下载地址
JSONObject content = JSONUtil.parseObj(jsonObj.getObj("content"));
return content.getObj("path").toString();
}
/**
* <p></p>
*/
public static boolean delete(String path) {
try {
String targetUrl = GiteeImgBedUtils.deleteFileUrl(path);
Map<String, Object> map = getDeleteBodyMap(path);
// 发送delete请求
String jsonResult = HttpRequest.delete(targetUrl).form(map).execute().body();
// 解析响应JSON字符串
JSONObject jsonObj = JSONUtil.parseObj(jsonResult);
return jsonObj.getObj("commit") != null;
} catch (Exception e) {
return false;
}
}
/**
* <p>sha</p>
*/
private static String getShaInfo(String path) {
String targetUrl = GiteeImgBedUtils.deleteFileUrl(path);
Map<String, Object> map = getFileInfoBodyMap();
// 借助HttpUtil工具类发送get请求
String jsonResult = HttpUtil.get(targetUrl, map);
// 解析响应JSON字符串
JSONObject jsonObj = JSONUtil.parseObj(jsonResult);
if (jsonObj.getObj("sha") == null) {
return null;
}
return jsonObj.getObj("sha").toString();
}
/**
* ()
*/
private static String createUploadFileUrl(String path, String originalFilename){
//获取文件后缀
String suffix = getFileSuffix(originalFilename);
//拼接存储的图片名称
String fileName = UUID.randomUUID().toString() + suffix;
//填充请求路径
return String.format(GiteeImgBedUtils.API_CREATE_POST,
GiteeImgBedUtils.OWNER,
GiteeImgBedUtils.REPO,
path + "/" + fileName);
}
/**
* <p></p>
*/
private static String deleteFileUrl(String path) {
return String.format(GiteeImgBedUtils.API_CREATE_POST,
GiteeImgBedUtils.OWNER,
GiteeImgBedUtils.REPO,
path);
}
/**
* mapaccess_tokenmessagecontent
* @param multipartFile
* @return map
*/
private static Map<String,Object> getUploadBodyMap(byte[] multipartFile){
HashMap<String, Object> bodyMap = new HashMap<>(3);
bodyMap.put("access_token", GiteeImgBedUtils.ACCESS_TOKEN);
bodyMap.put("message", GiteeImgBedUtils.ADD_MESSAGE);
bodyMap.put("content", Base64.encode(multipartFile));
return bodyMap;
}
/**
* mapaccess_tokenpathshamessage
* @return map
*/
private static Map<String,Object> getDeleteBodyMap(String path){
HashMap<String, Object> bodyMap = new HashMap<>(3);
bodyMap.put("access_token", GiteeImgBedUtils.ACCESS_TOKEN);
bodyMap.put("message", GiteeImgBedUtils.DEL_MESSAGE);
bodyMap.put("sha", getShaInfo(path));
return bodyMap;
}
/**
* shamapaccess_token
* @return map
*/
private static Map<String,Object> getFileInfoBodyMap(){
HashMap<String, Object> bodyMap = new HashMap<>(3);
bodyMap.put("access_token", GiteeImgBedUtils.ACCESS_TOKEN);
return bodyMap;
}
/**
* changlu.jpg => .jpg
* @return
*/
private static String getFileSuffix(String fileName) {
return fileName.contains(".") ? fileName.substring(fileName.indexOf('.')) : null;
}
}

View File

@ -26,7 +26,7 @@ public class IsEmptyUtil {
*/ */
public boolean strings(String ... strings){ public boolean strings(String ... strings){
for (String string : strings) { for (String string : strings) {
if (string==null || string.equals("")){ if (string==null || "".equals(string)){
return true; return true;
} }
} }
@ -37,7 +37,7 @@ public class IsEmptyUtil {
* <p></p> * <p></p>
*/ */
public boolean string(String string){ public boolean string(String string){
if (string==null || string.equals("")){ if (string==null || "".equals(string)){
return true; return true;
}else{ }else{
return false; return false;

View File

@ -1,21 +0,0 @@
package com.example.jieyue.common.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import org.springframework.stereotype.Component;
@Component
public class JsonUtil {
/**
*
*/
public int[] jsonToIntArray(String json){
JSONArray jsonArray = JSON.parseArray(json);
int[] array = new int[jsonArray.size()];
for (int i = 0;i < jsonArray.size();i++){
array[i] = (Integer) jsonArray.get(i);
}
return array;
}
}

View File

@ -4,8 +4,7 @@ import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.*;
import java.io.IOException;
import java.util.*; import java.util.*;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
@ -22,6 +21,8 @@ import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer; import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;
/** /**
* *
@ -51,27 +52,27 @@ public class QRCodeUtil {
* *
* @param content * @param content
* @param path * @param path
* @param filename
* @param size 250 * @param size 250
* @param logoPath logo * @param logoPath logo
*/ */
public static boolean zxingCodeCreate(String content, String path, String filename,Integer size, String logoPath) { public static String zxingCodeCreate(String content, String path, Integer size, String logoPath) {
try { try {
//图片类型 //图片类型
String imageType = "jpg"; String imageType = "jpg";
//获取二维码流的形式,写入到目录文件中 //获取二维码流的形式,写入到目录文件中
BufferedImage image = getBufferedImage(content, size, logoPath); BufferedImage image = getBufferedImage(content, size, logoPath);
//创建一个ByteArrayOutputStream
//生成二维码存放文件 ByteArrayOutputStream os = new ByteArrayOutputStream();
File file = new File(path+filename+".jpg"); //把BufferedImage写入ByteArrayOutputStream
if (!file.exists()) { ImageIO.write(image, imageType, os);
file.mkdirs(); //ByteArrayOutputStream转成InputStream
} InputStream input = new ByteArrayInputStream(os.toByteArray());
ImageIO.write(image, imageType, file); //InputStream转成MultipartFile
return true; MultipartFile multipartFile = new MockMultipartFile("file", "file.jpg", "text/plain", input);
return GiteeImgBedUtils.upload(path, multipartFile);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return false; return null;
} }
} }

View File

@ -1,20 +0,0 @@
package com.example.jieyue.common.utils;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class StringUtil {
public static String GetMapToXML(Map<String,String> param){
StringBuffer sb = new StringBuffer();
sb.append("<xml>");
for (Map.Entry<String,String> entry : param.entrySet()) {
sb.append("<"+ entry.getKey() +">");
sb.append(entry.getValue());
sb.append("</"+ entry.getKey() +">");
}
sb.append("</xml>");
return sb.toString();
}
}

View File

@ -4,6 +4,7 @@ import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.entity.SysMt; import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.merchant.service.MerchantGoodsService; import com.example.jieyue.merchant.service.MerchantGoodsService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -15,6 +16,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* <p></p> * <p></p>
@ -25,6 +27,8 @@ import java.util.List;
public class MerchantGoodsController { public class MerchantGoodsController {
@Autowired @Autowired
MerchantGoodsService goodsService; MerchantGoodsService goodsService;
@Autowired
RedisTemplate redisTemplate;
/** /**
* <p></p> * <p></p>
@ -77,6 +81,7 @@ public class MerchantGoodsController {
break; break;
case 1: case 1:
modelAndView.addObject("msg","添加商品成功"); modelAndView.addObject("msg","添加商品成功");
clearCache();
break; break;
case 2: case 2:
modelAndView.addObject("msg","必填信息不能为空"); modelAndView.addObject("msg","必填信息不能为空");
@ -96,6 +101,7 @@ public class MerchantGoodsController {
int res = goodsService.delGoods(id); int res = goodsService.delGoods(id);
if (res == 1){ if (res == 1){
modelAndView.addObject("msg","删除成功"); modelAndView.addObject("msg","删除成功");
clearCache();
}else{ }else{
modelAndView.addObject("msg","删除失败"); modelAndView.addObject("msg","删除失败");
} }
@ -110,8 +116,9 @@ public class MerchantGoodsController {
public ModelAndView putGoods(ModelAndView modelAndView,int id){ public ModelAndView putGoods(ModelAndView modelAndView,int id){
if (goodsService.putGoods(id)){ if (goodsService.putGoods(id)){
modelAndView.addObject("msg","上架商品成功"); modelAndView.addObject("msg","上架商品成功");
clearCache();
}else{ }else{
modelAndView.addObject("msg","上架商品成功"); modelAndView.addObject("msg","上架商品失败");
} }
modelAndView.setViewName("redirect:goods"); modelAndView.setViewName("redirect:goods");
return modelAndView; return modelAndView;
@ -124,8 +131,9 @@ public class MerchantGoodsController {
public ModelAndView OffGoods(ModelAndView modelAndView,int id){ public ModelAndView OffGoods(ModelAndView modelAndView,int id){
if (goodsService.OffGoods(id)){ if (goodsService.OffGoods(id)){
modelAndView.addObject("msg","下架商品成功"); modelAndView.addObject("msg","下架商品成功");
clearCache();
}else{ }else{
modelAndView.addObject("msg","下架商品成功"); modelAndView.addObject("msg","下架商品失败");
} }
modelAndView.setViewName("redirect:goods"); modelAndView.setViewName("redirect:goods");
return modelAndView; return modelAndView;
@ -164,6 +172,7 @@ public class MerchantGoodsController {
break; break;
case 1: case 1:
modelAndView.addObject("msg","修改商品成功"); modelAndView.addObject("msg","修改商品成功");
clearCache();
break; break;
case 2: case 2:
modelAndView.addObject("msg","必填信息不能为空"); modelAndView.addObject("msg","必填信息不能为空");
@ -174,4 +183,12 @@ public class MerchantGoodsController {
modelAndView.setViewName("redirect:goods"); modelAndView.setViewName("redirect:goods");
return modelAndView; return modelAndView;
} }
/**
* <p></p>
*/
public void clearCache() {
Set<String> keys = redisTemplate.keys("*");
redisTemplate.delete(keys);
}
} }

View File

@ -1,6 +1,7 @@
package com.example.jieyue.merchant.controller; package com.example.jieyue.merchant.controller;
import com.example.jieyue.common.entity.SysMt; import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import com.example.jieyue.merchant.service.MerchantLoginService; import com.example.jieyue.merchant.service.MerchantLoginService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -50,7 +51,8 @@ public class MerchantLoginController {
modelAndView.addObject("msg","您的账号处于停用状态,请等待管理员处理"); modelAndView.addObject("msg","您的账号处于停用状态,请等待管理员处理");
break; break;
} }
session.setAttribute("merchant",merchant); merchant.setHeader(GiteeImgBedUtils.PRE + merchant.getHeader());
session.setAttribute("merchant", merchant);
break; break;
default: default:
break; break;

View File

@ -3,6 +3,7 @@ package com.example.jieyue.merchant.controller;
import com.example.jieyue.common.entity.SysMtUi; import com.example.jieyue.common.entity.SysMtUi;
import com.example.jieyue.merchant.service.MerchantUiService; import com.example.jieyue.merchant.service.MerchantUiService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -10,6 +11,7 @@ import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Set;
/** /**
* <p></p> * <p></p>
@ -20,6 +22,8 @@ import javax.servlet.http.HttpServletRequest;
public class MerchantUiController { public class MerchantUiController {
@Autowired @Autowired
MerchantUiService uiService; MerchantUiService uiService;
@Autowired
RedisTemplate redisTemplate;
@RequestMapping("/merchant/ui") @RequestMapping("/merchant/ui")
public ModelAndView index(ModelAndView modelAndView, HttpServletRequest request){ public ModelAndView index(ModelAndView modelAndView, HttpServletRequest request){
@ -42,6 +46,7 @@ public class MerchantUiController {
switch (res){ switch (res){
case 1: case 1:
modelAndView.addObject("msg","图片删除成功"); modelAndView.addObject("msg","图片删除成功");
clearCache();
break; break;
case 0: case 0:
modelAndView.addObject("msg","图片删除失败"); modelAndView.addObject("msg","图片删除失败");
@ -63,6 +68,7 @@ public class MerchantUiController {
switch (res){ switch (res){
case 1: case 1:
modelAndView.addObject("msg","图片修改成功"); modelAndView.addObject("msg","图片修改成功");
clearCache();
break; break;
case 0: case 0:
modelAndView.addObject("msg","图片修改失败"); modelAndView.addObject("msg","图片修改失败");
@ -85,6 +91,7 @@ public class MerchantUiController {
int result = uiService.updateHeard(redirectAttributes,request,img); int result = uiService.updateHeard(redirectAttributes,request,img);
if (result==1){ if (result==1){
modelAndView.addObject("msg","修改logo成功"); modelAndView.addObject("msg","修改logo成功");
clearCache();
}else{ }else{
modelAndView.addObject("msg","修改logo失败"); modelAndView.addObject("msg","修改logo失败");
} }
@ -92,4 +99,12 @@ public class MerchantUiController {
modelAndView.setViewName("redirect:/merchant/ui"); modelAndView.setViewName("redirect:/merchant/ui");
return modelAndView; return modelAndView;
} }
/**
* <p></p>
*/
public void clearCache() {
Set<String> keys = redisTemplate.keys("*");
redisTemplate.delete(keys);
}
} }

View File

@ -3,15 +3,11 @@ package com.example.jieyue.merchant.service;
import com.example.jieyue.common.entity.SysGoods; import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.entity.SysMt; import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.mapper.SysGoodsMapper; import com.example.jieyue.common.mapper.SysGoodsMapper;
import com.example.jieyue.common.utils.DateUtil; import com.example.jieyue.common.utils.GiteeImgBedUtils;
import com.example.jieyue.common.utils.FileUtil;
import com.example.jieyue.common.utils.IsEmptyUtil; import com.example.jieyue.common.utils.IsEmptyUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -24,10 +20,6 @@ public class MerchantGoodsService {
@Autowired @Autowired
SysGoodsMapper goodsMapper; SysGoodsMapper goodsMapper;
@Autowired @Autowired
FileUtil fileUtil;
@Autowired
DateUtil dateUtil;
@Autowired
IsEmptyUtil isEmptyUtil = new IsEmptyUtil(); IsEmptyUtil isEmptyUtil = new IsEmptyUtil();
/** /**
@ -49,7 +41,11 @@ public class MerchantGoodsService {
*/ */
public List<SysGoods> getMtGoods(HttpSession session,int page,int num){ public List<SysGoods> getMtGoods(HttpSession session,int page,int num){
SysMt sysMt = (SysMt) session.getAttribute("merchant"); SysMt sysMt = (SysMt) session.getAttribute("merchant");
return goodsMapper.findByMtLimit(sysMt.getId(),(page-1)*num,num); List<SysGoods> list = goodsMapper.findByMtLimit(sysMt.getId(),(page-1)*num,num);
for (SysGoods sysGoods : list) {
sysGoods.setImg(GiteeImgBedUtils.PRE + sysGoods.getImg());
}
return list;
} }
/** /**
@ -74,20 +70,17 @@ public class MerchantGoodsService {
SysMt sysMt = (SysMt)request.getSession().getAttribute("merchant"); SysMt sysMt = (SysMt)request.getSession().getAttribute("merchant");
int merchant = sysMt.getId(); int merchant = sysMt.getId();
if (img.getOriginalFilename().equals("")){ if ("".equals(img.getOriginalFilename())){
// 执行插入 // 执行插入
goodsMapperResult = goodsMapper.insert1(name,describe,price,merchant,stock); goodsMapperResult = goodsMapper.insert1(name,describe,price,merchant,stock);
if(goodsMapperResult != 1){ if(goodsMapperResult != 1){
return 0; return 0;
} }
}else{ }else{
// 设置filename 文件名由年月日时分秒以及六位随机数组成
String filename = dateUtil.getNMDHIS()+Math.round(Math.random()*(999999-100000)+100000);
// 获取商户id一个商户对应一个文件夹 // 获取商户id一个商户对应一个文件夹
int id = ((SysMt) request.getSession().getAttribute("merchant")).getId(); int id = ((SysMt) request.getSession().getAttribute("merchant")).getId();
// 接收文件工具类返回的文件位置 // 接收文件工具类返回的文件位置
String imgUrl = fileUtil.upFile(img,redirectAttributes,request, String imgUrl = GiteeImgBedUtils.upload("/data/goods/" + id, img);
"/data/goods/"+id+"/",filename);
// 文件上传失败 // 文件上传失败
if (imgUrl == null){ if (imgUrl == null){
return -1; return -1;
@ -96,7 +89,7 @@ public class MerchantGoodsService {
goodsMapperResult = goodsMapper.insert2(name,describe,price,merchant,stock,imgUrl); goodsMapperResult = goodsMapper.insert2(name,describe,price,merchant,stock,imgUrl);
if (goodsMapperResult != 1){ if (goodsMapperResult != 1){
// sql语句执行失败将已上传的图片移除 // sql语句执行失败将已上传的图片移除
fileUtil.deleteFile(imgUrl); GiteeImgBedUtils.delete(imgUrl);
return 0; return 0;
} }
} }
@ -117,11 +110,8 @@ public class MerchantGoodsService {
if (sql!=1){ if (sql!=1){
return -1; return -1;
}else{ }else{
// 当文件路径在/data下时才执行文件的删除
if (imgUrl.indexOf("/data") == 0){
// 删除源文件与编译文件中对应的goods图片信息 // 删除源文件与编译文件中对应的goods图片信息
fileUtil.deleteFile(imgUrl); GiteeImgBedUtils.delete(imgUrl);
}
return 1; return 1;
} }
} }
@ -176,13 +166,10 @@ public class MerchantGoodsService {
return 0; return 0;
} }
}else{ }else{
// 设置filename 文件名由年月日时分秒以及六位随机数组成
String filename = dateUtil.getNMDHIS()+Math.round(Math.random()*(999999-100000)+100000);
// 获取商户id一个商户对应一个文件夹 // 获取商户id一个商户对应一个文件夹
int id = ((SysMt) request.getSession().getAttribute("merchant")).getId(); int id = ((SysMt) request.getSession().getAttribute("merchant")).getId();
// 接收文件工具类返回的文件位置 // 接收文件工具类返回的文件位置
String imgUrl = fileUtil.upFile(img,redirectAttributes,request, String imgUrl = GiteeImgBedUtils.upload("/data/goods/" + id, img);
"/data/goods/"+id+"/",filename);
// 文件上传失败 // 文件上传失败
if (imgUrl == null){ if (imgUrl == null){
return -1; return -1;
@ -192,11 +179,11 @@ public class MerchantGoodsService {
goodsMapperResult = goodsMapper.updateGoods2(name,describe,price,merchant,stock,goodsId,imgUrl); goodsMapperResult = goodsMapper.updateGoods2(name,describe,price,merchant,stock,goodsId,imgUrl);
if (goodsMapperResult != 1){ if (goodsMapperResult != 1){
// sql语句执行失败将已上传的图片移除 // sql语句执行失败将已上传的图片移除
fileUtil.deleteFile(imgUrl); GiteeImgBedUtils.delete(imgUrl);
return 0; return 0;
}else{ }else{
// 新图片已插入,将旧图删除 // 新图片已插入,将旧图删除
fileUtil.deleteFile(tempGoods.getImg()); GiteeImgBedUtils.delete(tempGoods.getImg());
} }
} }
return 1; return 1;

View File

@ -18,12 +18,17 @@ public class MerchantOrderService {
*/ */
public List<SysOrder> getOrderList(int merchantId,int page, int num, int flag){ public List<SysOrder> getOrderList(int merchantId,int page, int num, int flag){
switch (flag){ switch (flag){
case 0:// 未支付 // 未支付
case 0:
return orderMapper.findNotPayLimitByMt(merchantId,(page-1)*num,num); return orderMapper.findNotPayLimitByMt(merchantId,(page-1)*num,num);
case 1:// 已支付 // 已支付
case 1:
return orderMapper.findPayLimitByMt(merchantId,(page-1)*num,num); return orderMapper.findPayLimitByMt(merchantId,(page-1)*num,num);
case 2:// 全部订单 // 全部订单
case 2:
return orderMapper.findLimitByMt(merchantId,(page-1)*num,num); return orderMapper.findLimitByMt(merchantId,(page-1)*num,num);
default:
break;
} }
return null; return null;
} }
@ -33,12 +38,17 @@ public class MerchantOrderService {
*/ */
public int getAllPage(int merchantId,int flag,int num){ public int getAllPage(int merchantId,int flag,int num){
switch (flag){ switch (flag){
case 0:// 未支付 // 未支付
case 0:
return (int)Math.ceil((double)orderMapper.notPayCountByMt(merchantId)/(double)num); return (int)Math.ceil((double)orderMapper.notPayCountByMt(merchantId)/(double)num);
case 1:// 已支付 // 已支付
case 1:
return (int)Math.ceil((double)orderMapper.payCountByMt(merchantId)/(double)num); return (int)Math.ceil((double)orderMapper.payCountByMt(merchantId)/(double)num);
case 2:// 全部订单 // 全部订单
case 2:
return (int)Math.ceil((double)orderMapper.orderCountByMt(merchantId)/(double)num); return (int)Math.ceil((double)orderMapper.orderCountByMt(merchantId)/(double)num);
default:
break;
} }
return 1; return 1;
} }
@ -49,7 +59,7 @@ public class MerchantOrderService {
public List<SysOrder> getOrderById(String orderId,int merchant){ public List<SysOrder> getOrderById(String orderId,int merchant){
SysOrder order = orderMapper.findByOrderIdAndMt(orderId,merchant); SysOrder order = orderMapper.findByOrderIdAndMt(orderId,merchant);
List<SysOrder> list = new ArrayList<>(); List<SysOrder> list = new ArrayList<>();
if (order!=null){ if (order != null){
list.add(order); list.add(order);
} }
return list; return list;

View File

@ -4,8 +4,7 @@ import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.entity.SysMtUi; import com.example.jieyue.common.entity.SysMtUi;
import com.example.jieyue.common.mapper.SysMtMapper; import com.example.jieyue.common.mapper.SysMtMapper;
import com.example.jieyue.common.mapper.SysMtUiMapper; import com.example.jieyue.common.mapper.SysMtUiMapper;
import com.example.jieyue.common.utils.DateUtil; import com.example.jieyue.common.utils.GiteeImgBedUtils;
import com.example.jieyue.common.utils.FileUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -19,10 +18,6 @@ public class MerchantUiService {
@Autowired @Autowired
SysMtUiMapper mtUiMapper; SysMtUiMapper mtUiMapper;
@Autowired @Autowired
FileUtil fileUtil;
@Autowired
DateUtil dateUtil;
@Autowired
SysMtMapper merchantMapper; SysMtMapper merchantMapper;
/** /**
@ -42,7 +37,11 @@ public class MerchantUiService {
* <p></p> * <p></p>
*/ */
public SysMtUi getHomeImg(int width,int height,HttpSession session){ public SysMtUi getHomeImg(int width,int height,HttpSession session){
return mtUiMapper.findByMark(width,height,getMtId(session)); SysMtUi ui = mtUiMapper.findByMark(width,height,getMtId(session));
if (ui != null) {
ui.setUrl(GiteeImgBedUtils.PRE + ui.getUrl());
}
return ui;
} }
/** /**
@ -51,8 +50,8 @@ public class MerchantUiService {
public int delHomeImg(int id){ public int delHomeImg(int id){
String url = mtUiMapper.findById(id).getUrl(); String url = mtUiMapper.findById(id).getUrl();
int sql = mtUiMapper.deleteById(id); int sql = mtUiMapper.deleteById(id);
if (sql==1){ if (sql == 1){
fileUtil.deleteFile(url); GiteeImgBedUtils.delete(url);
return 1; return 1;
}else{ }else{
return 0; return 0;
@ -68,11 +67,8 @@ public class MerchantUiService {
int id = ((SysMt)request.getSession().getAttribute("merchant")).getId(); int id = ((SysMt)request.getSession().getAttribute("merchant")).getId();
SysMtUi sysMtUi = mtUiMapper.findByMark(width,height,id); SysMtUi sysMtUi = mtUiMapper.findByMark(width,height,id);
// 设置filename 文件名由年月日时分秒以及六位随机数组成
String filename = dateUtil.getNMDHIS()+Math.round(Math.random()*(999999-100000)+100000);
// 接收文件工具类返回的文件位置 // 接收文件工具类返回的文件位置
String imgUrl = fileUtil.upFile(img,redirectAttributes,request, String imgUrl = GiteeImgBedUtils.upload("/data/mtui/" + id, img);
"/data/mtui/"+id+"/",filename);
if (imgUrl==null){ if (imgUrl==null){
// 上传图片失败 // 上传图片失败
return 0; return 0;
@ -83,10 +79,10 @@ public class MerchantUiService {
int sql = mtUiMapper.updateUrl(imgUrl,width,height,id); int sql = mtUiMapper.updateUrl(imgUrl,width,height,id);
if (sql==1){ if (sql==1){
// sql语句执行成功将旧图删除加入新图 // sql语句执行成功将旧图删除加入新图
fileUtil.deleteFile(sysMtUi.getUrl()); GiteeImgBedUtils.delete(sysMtUi.getUrl());
}else{ }else{
// sql语句执行失败将已上传的新图删除 // sql语句执行失败将已上传的新图删除
fileUtil.deleteFile(imgUrl); GiteeImgBedUtils.delete(imgUrl);
} }
return sql; return sql;
} }
@ -105,19 +101,15 @@ public class MerchantUiService {
public int updateHeard(RedirectAttributes redirectAttributes,HttpServletRequest request, MultipartFile img){ public int updateHeard(RedirectAttributes redirectAttributes,HttpServletRequest request, MultipartFile img){
// 获取商户信息 // 获取商户信息
SysMt merchant = (SysMt) request.getSession().getAttribute("merchant"); SysMt merchant = (SysMt) request.getSession().getAttribute("merchant");
// 设置filename 文件名由年月日时分秒以及六位随机数组成 String headerUrl = GiteeImgBedUtils.upload("/data/header/merchant/", img);
String filename = dateUtil.getNMDHIS()+Math.round(Math.random()*(999999-100000)+100000);
String headerUrl = fileUtil.upFile(img,redirectAttributes,request,"/data/header/merchant/",filename);
int sql = merchantMapper.updateHeader(merchant.getId(),headerUrl); int sql = merchantMapper.updateHeader(merchant.getId(),headerUrl);
if (sql!=1){ if (sql != 1){
fileUtil.deleteFile(headerUrl); GiteeImgBedUtils.delete(headerUrl);
return -1; return -1;
}else{ }else{
if (!merchant.getHeader().equals("/lib/merchant/images/2.png")){ GiteeImgBedUtils.delete(merchant.getHeader());
fileUtil.deleteFile(merchant.getHeader());
}
// 修改会话信息 // 修改会话信息
merchant.setHeader(headerUrl); merchant.setHeader(GiteeImgBedUtils.PRE + headerUrl);
request.getSession().setAttribute("merchant",merchant); request.getSession().setAttribute("merchant",merchant);
} }
return 1; return 1;

View File

@ -2,6 +2,7 @@ package com.example.jieyue.merchant.service;
import com.example.jieyue.common.entity.SysUser; import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.common.mapper.SysUserMapper; import com.example.jieyue.common.mapper.SysUserMapper;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -16,7 +17,11 @@ public class MerchantUserService {
* <p></p> * <p></p>
*/ */
public List<SysUser> getUserList(int page, int num){ public List<SysUser> getUserList(int page, int num){
return userMapper.findLimit((page-1)*num,num); List<SysUser> list = userMapper.findLimit((page-1)*num,num);
for (SysUser user : list) {
user.setHeader(GiteeImgBedUtils.PRE + user.getHeader());
}
return list;
} }
/** /**

View File

@ -25,7 +25,7 @@ public class UserCheckOutController {
@RequestMapping("/user/checkout") @RequestMapping("/user/checkout")
public ModelAndView index(ModelAndView modelAndView,String ids,@RequestParam(defaultValue = "-1")int num){ public ModelAndView index(ModelAndView modelAndView,String ids,@RequestParam(defaultValue = "-1")int num){
if(ids == null || ids.equals("")){ if(ids == null || "".equals(ids)){
modelAndView.addObject("msg","请选择您要结算的商品"); modelAndView.addObject("msg","请选择您要结算的商品");
modelAndView.setViewName("redirect:/user/cart"); modelAndView.setViewName("redirect:/user/cart");
}else{ }else{

View File

@ -38,9 +38,7 @@ public class UserHomeController{
Map<String, SysMtUi> lowImg = null; Map<String, SysMtUi> lowImg = null;
if (redisTemplate.opsForHash().entries("homePageCache").size() != 0){ if (redisTemplate.opsForHash().entries("homePageCache").size() != 0){
Map map = redisTemplate.opsForHash().entries("homePageCache"); Map map = redisTemplate.opsForHash().entries("homePageCache");
// 商城主页宣传海报 // 商城主页宣传海报
imgMap = (Map<String, SysUi>) map.get("imgMap"); imgMap = (Map<String, SysUi>) map.get("imgMap");
// 获取热卖商品列表 // 获取热卖商品列表
@ -52,9 +50,7 @@ public class UserHomeController{
// 获取商户宣传店铺的海报 // 获取商户宣传店铺的海报
homeImg = (Map<String, SysMtUi>) map.get("homeImg"); homeImg = (Map<String, SysMtUi>) map.get("homeImg");
lowImg = (Map<String, SysMtUi>) map.get("lowImg"); lowImg = (Map<String, SysMtUi>) map.get("lowImg");
}else{ }else{
// 商城主页宣传海报 // 商城主页宣传海报
imgMap = homeService.getImage(); imgMap = homeService.getImage();
// 获取热卖商品列表 // 获取热卖商品列表
@ -67,19 +63,17 @@ public class UserHomeController{
homeImg = homeService.getMtImg(400,320,3); homeImg = homeService.getMtImg(400,320,3);
lowImg = homeService.getMtImg(600,310,3); lowImg = homeService.getMtImg(600,310,3);
} }
modelAndView.addObject("imgMap", imgMap);
modelAndView.addObject("imgMap",imgMap); modelAndView.addObject("escGoodsMap", escGoodsMap);
modelAndView.addObject("escGoodsMap",escGoodsMap); modelAndView.addObject("descGoodsMap", descGoodsMap);
modelAndView.addObject("descGoodsMap",descGoodsMap); modelAndView.addObject("randGoodsMap", randGoodsMap);
modelAndView.addObject("randGoodsMap",randGoodsMap); modelAndView.addObject("homeImg", homeImg);
modelAndView.addObject("homeImg",homeImg); modelAndView.addObject("lowImg", lowImg);
modelAndView.addObject("lowImg",lowImg);
if (redisTemplate.opsForHash().entries("homePageCache").size() == 0){ if (redisTemplate.opsForHash().entries("homePageCache").size() == 0){
// 设置缓存 十分钟内有效 // 设置缓存 十分钟内有效
homeService.setHomeCache(modelAndView); homeService.setHomeCache(modelAndView);
} }
modelAndView.setViewName("user/home/index"); modelAndView.setViewName("user/home/index");
return modelAndView; return modelAndView;
} }

View File

@ -24,7 +24,7 @@ public class UserInfoController {
@RequestMapping("/user/info") @RequestMapping("/user/info")
public ModelAndView index(ModelAndView modelAndView, HttpServletRequest request){ public ModelAndView index(ModelAndView modelAndView, HttpServletRequest request){
SysUser user = (SysUser) request.getSession().getAttribute("user"); SysUser user = (SysUser) request.getSession().getAttribute("user");
modelAndView.addObject("user",user); modelAndView.addObject("user", user);
modelAndView.setViewName("user/info/index"); modelAndView.setViewName("user/info/index");
return modelAndView; return modelAndView;
} }

View File

@ -1,6 +1,7 @@
package com.example.jieyue.user.controller; package com.example.jieyue.user.controller;
import com.example.jieyue.common.entity.SysUser; import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import com.example.jieyue.user.service.UserLoginService; import com.example.jieyue.user.service.UserLoginService;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -51,6 +52,7 @@ public class UserLoginController {
if (result==1){ if (result==1){
// 登陆成功 // 登陆成功
SysUser user = service.userInfo(email); SysUser user = service.userInfo(email);
user.setHeader(GiteeImgBedUtils.PRE + user.getHeader());
session.setAttribute("user",user); session.setAttribute("user",user);
modelAndView.setViewName("redirect:/"); modelAndView.setViewName("redirect:/");
}else if (result==-1){ }else if (result==-1){

View File

@ -6,6 +6,7 @@ import com.example.jieyue.common.entity.SysOrder;
import com.example.jieyue.common.mapper.SysGoodsMapper; import com.example.jieyue.common.mapper.SysGoodsMapper;
import com.example.jieyue.common.mapper.SysMtMapper; import com.example.jieyue.common.mapper.SysMtMapper;
import com.example.jieyue.common.mapper.SysOrderMapper; import com.example.jieyue.common.mapper.SysOrderMapper;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import com.example.jieyue.user.service.WxPayService; import com.example.jieyue.user.service.WxPayService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -34,8 +35,8 @@ public class UserPayController {
String orderMark = wxPayService.getOrderId(); String orderMark = wxPayService.getOrderId();
// 添加订单 // 添加订单
String res = wxPayService.addOrder(nums,orderMark,users,merchants,prices,notes,goods,address,name,phone,code,0,carts); String res = wxPayService.addOrder(nums,orderMark,users,merchants,prices,notes,goods,address,name,phone,code,0,carts);
if(!res.equals("-1") && !res.equals("0") && !res.equals("")){ if(!"-1".equals(res) && !"0".equals(res) && !"".equals(res)){
modelAndView.addObject("orderMark",orderMark); modelAndView.addObject("orderMark", orderMark);
modelAndView.setViewName("redirect:/user/wxpay/index?mark="+orderMark); modelAndView.setViewName("redirect:/user/wxpay/index?mark="+orderMark);
} }
return modelAndView; return modelAndView;
@ -74,10 +75,10 @@ public class UserPayController {
*/ */
@RequestMapping("/user/wxpay/index") @RequestMapping("/user/wxpay/index")
public ModelAndView wxNotify(ModelAndView modelAndView,String mark) { public ModelAndView wxNotify(ModelAndView modelAndView,String mark) {
String codeUrl = orderMapper.findByOrderMark(mark).get(0).getPayCodeUrl(); String codeUrl = GiteeImgBedUtils.PRE + orderMapper.findByOrderMark(mark).get(0).getPayCodeUrl();
modelAndView.addObject("codeUrl",codeUrl); modelAndView.addObject("codeUrl", codeUrl);
modelAndView.addObject("orderMark",mark); modelAndView.addObject("orderMark", mark);
modelAndView.setViewName("user/pay/wx"); modelAndView.setViewName("user/pay/wx");
return modelAndView; return modelAndView;

View File

@ -54,7 +54,7 @@ public class UserProductController {
*/ */
@RequestMapping("/user/product/add-comment") @RequestMapping("/user/product/add-comment")
public ModelAndView addComment(ModelAndView modelAndView,int goods,int merchant,String context,HttpServletRequest request){ public ModelAndView addComment(ModelAndView modelAndView,int goods,int merchant,String context,HttpServletRequest request){
if (context.equals("")){ if ("".equals(context)){
modelAndView.addObject("msg","评论内容不能为空"); modelAndView.addObject("msg","评论内容不能为空");
}else{ }else{
int result = productService.addComment(goods,merchant,context,request); int result = productService.addComment(goods,merchant,context,request);

View File

@ -7,6 +7,7 @@ import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.common.mapper.SysCartMapper; import com.example.jieyue.common.mapper.SysCartMapper;
import com.example.jieyue.common.mapper.SysGoodsMapper; import com.example.jieyue.common.mapper.SysGoodsMapper;
import com.example.jieyue.common.mapper.SysMtMapper; import com.example.jieyue.common.mapper.SysMtMapper;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -63,7 +64,7 @@ public class UserCartService {
SysGoods goods = goodsMapper.findById(cart.getGoodsId()); SysGoods goods = goodsMapper.findById(cart.getGoodsId());
SysMt merchant = merchantMapper.findById(goods.getMerchant()); SysMt merchant = merchantMapper.findById(goods.getMerchant());
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("goodsImg",goods.getImg()); map.put("goodsImg", GiteeImgBedUtils.PRE + goods.getImg());
map.put("cartId",cart.getId()+""); map.put("cartId",cart.getId()+"");
map.put("goodsId",goods.getId()+""); map.put("goodsId",goods.getId()+"");
map.put("goodsPrice",goods.getPrice().toPlainString()); map.put("goodsPrice",goods.getPrice().toPlainString());

View File

@ -6,6 +6,7 @@ import com.example.jieyue.common.entity.SysUi;
import com.example.jieyue.common.mapper.SysGoodsMapper; import com.example.jieyue.common.mapper.SysGoodsMapper;
import com.example.jieyue.common.mapper.SysMtUiMapper; import com.example.jieyue.common.mapper.SysMtUiMapper;
import com.example.jieyue.common.mapper.SysUiMapper; import com.example.jieyue.common.mapper.SysUiMapper;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -42,7 +43,7 @@ public class UserHomeService {
redisTemplate.expire("homePageCache",10, TimeUnit.MINUTES); redisTemplate.expire("homePageCache",10, TimeUnit.MINUTES);
} }
/* /**
* *
*/ */
public Map<String,SysUi> getImage(){ public Map<String,SysUi> getImage(){
@ -55,6 +56,25 @@ public class UserHomeService {
SysUi img3151 = uiMapper.findByMark(3151,282); SysUi img3151 = uiMapper.findByMark(3151,282);
SysUi img3152 = uiMapper.findByMark(3152,282); SysUi img3152 = uiMapper.findByMark(3152,282);
if(img1920 != null) {
img1920.setUrl(GiteeImgBedUtils.PRE + img1920.getUrl());
}
if(img1230 != null) {
img1230.setUrl(GiteeImgBedUtils.PRE + img1230.getUrl());
}
if(img475 != null) {
img475.setUrl(GiteeImgBedUtils.PRE + img475.getUrl());
}
if(img674 != null) {
img674.setUrl(GiteeImgBedUtils.PRE + img674.getUrl());
}
if(img3151 != null) {
img3151.setUrl(GiteeImgBedUtils.PRE + img3151.getUrl());
}
if(img3152 != null) {
img3152.setUrl(GiteeImgBedUtils.PRE + img3152.getUrl());
}
map.put(1920+"",img1920); map.put(1920+"",img1920);
map.put(1230+"",img1230); map.put(1230+"",img1230);
map.put(475+"",img475); map.put(475+"",img475);
@ -65,50 +85,45 @@ public class UserHomeService {
return map; return map;
} }
/* /**
* *
*/ */
public Map<String, SysGoods> getEsc(int num){ public Map<String, SysGoods> getEsc(int num){
List<SysGoods> list = goodsMapper.findAllEsc(num); return common(goodsMapper.findAllEsc(num));
Map<String, SysGoods> map = new HashMap<>();
for (int i=0;i < list.size();i++) {
map.put(i+"",list.get(i));
}
return map;
} }
/* /**
* *
*/ */
public Map<String, SysGoods> getDesc(int num){ public Map<String, SysGoods> getDesc(int num){
List<SysGoods> list = goodsMapper.findAllDesc(num); return common(goodsMapper.findAllDesc(num));
Map<String, SysGoods> map = new HashMap<>();
for (int i=0;i < list.size();i++) {
map.put(i+"",list.get(i));
}
return map;
} }
/* /**
* *
*/ */
public Map<String, SysGoods> getRand(int num){ public Map<String, SysGoods> getRand(int num){
List<SysGoods> list = goodsMapper.findRand(num); return common(goodsMapper.findRand(num));
}
public Map<String, SysGoods> common(List<SysGoods> list) {
Map<String, SysGoods> map = new HashMap<>(); Map<String, SysGoods> map = new HashMap<>();
for (int i=0;i < list.size();i++) { for (int i=0;i < list.size();i++) {
map.put(i+"",list.get(i)); list.get(i).setImg(GiteeImgBedUtils.PRE + list.get(i).getImg());
map.put(i+"", list.get(i));
} }
return map; return map;
} }
/* /**
* *
*/ */
public Map<String, SysMtUi> getMtImg(int width,int height,int num){ public Map<String, SysMtUi> getMtImg(int width,int height,int num){
Map<String, SysMtUi> map = new HashMap<>(); Map<String, SysMtUi> map = new HashMap<>();
List<SysMtUi> list = mtUiMapper.findLimit(width,height,num); List<SysMtUi> list = mtUiMapper.findLimit(width,height,num);
for (int i=0;i<list.size();i++){ for (int i=0;i<list.size();i++){
map.put(i+"",list.get(i)); list.get(i).setUrl(GiteeImgBedUtils.PRE + list.get(i).getUrl());
map.put(i+"", list.get(i));
} }
return map; return map;
} }

View File

@ -3,9 +3,8 @@ package com.example.jieyue.user.service;
import com.example.jieyue.common.entity.SysUser; import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.common.mapper.SysUserMapper; import com.example.jieyue.common.mapper.SysUserMapper;
import com.example.jieyue.common.service.MailService; import com.example.jieyue.common.service.MailService;
import com.example.jieyue.common.utils.FileUtil; import com.example.jieyue.common.utils.GiteeImgBedUtils;
import com.example.jieyue.common.utils.IsEmptyUtil; import com.example.jieyue.common.utils.IsEmptyUtil;
import com.sun.mail.smtp.DigestMD5;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils; import org.springframework.util.DigestUtils;
@ -23,9 +22,6 @@ public class UserInfoService {
@Autowired @Autowired
SysUserMapper sysUserMapper; SysUserMapper sysUserMapper;
@Autowired
FileUtil fileUtil;
IsEmptyUtil isEmptyUtil = new IsEmptyUtil(); IsEmptyUtil isEmptyUtil = new IsEmptyUtil();
@ -49,7 +45,7 @@ public class UserInfoService {
SysUser user = sysUserMapper.selectById(id); SysUser user = sysUserMapper.selectById(id);
if (!oldPwd.equals("") || !newPwd.equals("") || !rePwd.equals("")){ if (!"".equals(oldPwd) || !"".equals(newPwd) || !"".equals(rePwd)){
oldPwd = DigestUtils.md5DigestAsHex(oldPwd.getBytes()); oldPwd = DigestUtils.md5DigestAsHex(oldPwd.getBytes());
if (!user.getPassword().equals(oldPwd)){ if (!user.getPassword().equals(oldPwd)){
return 3; return 3;
@ -58,7 +54,7 @@ public class UserInfoService {
return 4; return 4;
} }
} }
if (newPwd.equals("")){ if ("".equals(newPwd)){
newPwd = user.getPassword(); newPwd = user.getPassword();
}else{ }else{
newPwd = DigestUtils.md5DigestAsHex(newPwd.getBytes()); newPwd = DigestUtils.md5DigestAsHex(newPwd.getBytes());
@ -66,15 +62,18 @@ public class UserInfoService {
// 更新头像 // 更新头像
String header = user.getHeader(); String header = user.getHeader();
if (!img.isEmpty()){ if (!img.isEmpty()){
if (!user.getHeader().equals("/data/header/user/default.jpg")){ header = GiteeImgBedUtils.upload("/data/header/user/", img);
fileUtil.deleteFile(user.getHeader()); if (!"".equals(header) && null != header &&
!user.getHeader().equals(GiteeImgBedUtils.PRE + "/data/header/user/default.jpg")){
GiteeImgBedUtils.delete(user.getHeader());
} }
header = fileUtil.upFile(img,redirectAttributes,request,"/data/header/user/",""+id);
} }
int sql = sysUserMapper.updateById(username,newPwd,header,email,id); int sql = sysUserMapper.updateById(username, newPwd, header, email, id);
if (sql==1){ if (sql == 1){
// 更新用户信息 // 更新用户信息
request.getSession().setAttribute("user",sysUserMapper.selectById(id)); SysUser newUser = sysUserMapper.selectById(id);
newUser.setHeader(GiteeImgBedUtils.PRE + newUser.getHeader());
request.getSession().setAttribute("user", newUser);
return 1; return 1;
} }
return -1; return -1;

View File

@ -4,6 +4,7 @@ import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.entity.SysOrder; import com.example.jieyue.common.entity.SysOrder;
import com.example.jieyue.common.mapper.SysGoodsMapper; import com.example.jieyue.common.mapper.SysGoodsMapper;
import com.example.jieyue.common.mapper.SysOrderMapper; import com.example.jieyue.common.mapper.SysOrderMapper;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -30,7 +31,9 @@ public class UserOrderService {
public List<SysGoods> getGoodsList(List<SysOrder> orderList){ public List<SysGoods> getGoodsList(List<SysOrder> orderList){
List<SysGoods> list = new ArrayList<>(); List<SysGoods> list = new ArrayList<>();
for (SysOrder order : orderList) { for (SysOrder order : orderList) {
list.add(goodsMapper.findById(order.getGoodsId())); SysGoods goods = goodsMapper.findById(order.getGoodsId());
goods.setImg(GiteeImgBedUtils.PRE + goods.getImg());
list.add(goods);
} }
return list; return list;
} }

View File

@ -4,6 +4,7 @@ import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.index.GoodsIndex; import com.example.jieyue.common.index.GoodsIndex;
import com.example.jieyue.common.mapper.SysGoodsMapper; import com.example.jieyue.common.mapper.SysGoodsMapper;
import com.example.jieyue.common.repository.GoodsIndexRepository; import com.example.jieyue.common.repository.GoodsIndexRepository;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -21,7 +22,11 @@ public class UserSearchService {
* <p>mysql</p> * <p>mysql</p>
*/ */
public List<SysGoods> mysqlSearchGoods(String keyword){ public List<SysGoods> mysqlSearchGoods(String keyword){
return goodsMapper.search(keyword); List<SysGoods> list = goodsMapper.search(keyword);
for (SysGoods goods : list) {
goods.setImg(GiteeImgBedUtils.PRE + goods.getImg());
}
return list;
} }
/** /**

View File

@ -4,6 +4,7 @@ import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.entity.SysMt; import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.mapper.SysGoodsMapper; import com.example.jieyue.common.mapper.SysGoodsMapper;
import com.example.jieyue.common.mapper.SysMtMapper; import com.example.jieyue.common.mapper.SysMtMapper;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -22,28 +23,29 @@ public class UserShopService {
* <p></p> * <p></p>
*/ */
public SysMt getMerchantInfo(int merchantId){ public SysMt getMerchantInfo(int merchantId){
return merchantMapper.findById(merchantId); SysMt merchant = merchantMapper.findById(merchantId);
merchant.setHeader(GiteeImgBedUtils.PRE + merchant.getHeader());
return merchant;
} }
/** /**
* <p></p> * <p></p>
*/ */
public Map<Integer,SysGoods> getGoodsList(int merchantId, int page, int num){ public Map<Integer,SysGoods> getGoodsList(int merchantId, int page, int num){
List<SysGoods> list = goodsMapper.findByMtLimit(merchantId,(page-1)*num,page*num); return common(goodsMapper.findByMtLimit(merchantId,(page-1)*num,page*num));
Map<Integer,SysGoods> map = new HashMap<>();
for (int i = 0;i < list.size();i++){
map.put(i,list.get(i));
}
return map;
} }
/** /**
* <p></p> * <p></p>
*/ */
public Map<Integer,SysGoods> getRandGoodsMap(int merchant,int num){ public Map<Integer,SysGoods> getRandGoodsMap(int merchant,int num){
List<SysGoods> list = goodsMapper.findMerchantRand(merchant,num); return common(goodsMapper.findMerchantRand(merchant,num));
}
public Map<Integer,SysGoods> common(List<SysGoods> list) {
Map<Integer,SysGoods> map = new HashMap<>(); Map<Integer,SysGoods> map = new HashMap<>();
for (int i = 0;i < list.size();i++) { for (int i = 0;i < list.size();i++) {
list.get(i).setImg(GiteeImgBedUtils.PRE + list.get(i).getImg());
map.put(i,list.get(i)); map.put(i,list.get(i));
} }
return map; return map;

View File

@ -8,7 +8,6 @@ import com.example.jieyue.common.mapper.SysMtMapper;
import com.example.jieyue.common.mapper.SysOrderMapper; import com.example.jieyue.common.mapper.SysOrderMapper;
import com.example.jieyue.common.utils.IsEmptyUtil; import com.example.jieyue.common.utils.IsEmptyUtil;
import com.example.jieyue.common.utils.QRCodeUtil; import com.example.jieyue.common.utils.QRCodeUtil;
import com.example.jieyue.common.utils.StringUtil;
import com.example.jieyue.wxpay.config.MyWXPayConfig; import com.example.jieyue.wxpay.config.MyWXPayConfig;
import com.example.jieyue.wxpay.sdk.WXPay; import com.example.jieyue.wxpay.sdk.WXPay;
import com.example.jieyue.wxpay.sdk.WXPayConstants; import com.example.jieyue.wxpay.sdk.WXPayConstants;
@ -28,7 +27,10 @@ import java.io.InputStreamReader;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
/** /**
* <p></p> * <p></p>
@ -37,8 +39,6 @@ import java.util.*;
*/ */
@Service @Service
public class WxPayService { public class WxPayService {
@Autowired
StringUtil stringUtil;
@Autowired @Autowired
SysOrderMapper orderMapper; SysOrderMapper orderMapper;
@Autowired @Autowired
@ -91,7 +91,7 @@ public class WxPayService {
SysMt merchant = merchantMapper.findById(Integer.valueOf(merchantsArr[i])); SysMt merchant = merchantMapper.findById(Integer.valueOf(merchantsArr[i]));
// 执行sql语句 // 执行sql语句
int sql = -1; int sql = -1;
if (cartArr[i].equals("0")){ if ("0".equals(cartArr[i])){
sql = orderMapper.insert1(orderId,createTime,Integer.valueOf(numArr[i]),mark,Integer.valueOf(userArr[i]), sql = orderMapper.insert1(orderId,createTime,Integer.valueOf(numArr[i]),mark,Integer.valueOf(userArr[i]),
Integer.valueOf(merchantsArr[i]),new BigDecimal(dfPrice.format(Double.valueOf(pricesArr[i]))), Integer.valueOf(merchantsArr[i]),new BigDecimal(dfPrice.format(Double.valueOf(pricesArr[i]))),
Integer.valueOf(goodsArr[i]),notes,address,name,phone,code,way,merchant.getRatio()); Integer.valueOf(goodsArr[i]),notes,address,name,phone,code,way,merchant.getRatio());
@ -117,7 +117,6 @@ public class WxPayService {
* <p>js</p> * <p>js</p>
*/ */
public String[] getStringArray(String array){ public String[] getStringArray(String array){
List<String> list = new ArrayList<>();
return array.split(","); return array.split(",");
} }
@ -145,21 +144,20 @@ public class WxPayService {
data.put("body", "捷阅网商品"); data.put("body", "捷阅网商品");
data.put("out_trade_no", orderMark); data.put("out_trade_no", orderMark);
data.put("device_info", orderMark); data.put("device_info", orderMark);
BigDecimal temp = new BigDecimal(100);
data.put("total_fee", price); data.put("total_fee", price);
data.put("spbill_create_ip", "123.12.12.123"); data.put("spbill_create_ip", "123.12.12.123");
data.put("notify_url", siteUrl+"/user/wxpay/notify"); data.put("notify_url", siteUrl + "/user/wxpay/notify");
data.put("trade_type", "NATIVE"); // 此处指定为扫码支付 data.put("trade_type", "NATIVE"); // 此处指定为扫码支付
data.put("product_id", orderMark); data.put("product_id", orderMark);
String codeUrl = "";
try { try {
Map<String, String> resp = wxPay.unifiedOrder(data); Map<String, String> resp = wxPay.unifiedOrder(data);
System.out.println(resp); System.out.println(resp);
QRCodeUtil.zxingCodeCreate(resp.get("code_url"),classPath+"/data/pay/",orderMark,500,""); codeUrl = QRCodeUtil.zxingCodeCreate(resp.get("code_url"), "/data/pay/", 500, "");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
String codeUrl = "/data/pay/"+orderMark+".jpg"; orderMapper.updateCodeUrl(codeUrl, orderMark);
orderMapper.updateCodeUrl(codeUrl,orderMark);
return codeUrl; return codeUrl;
} }

View File

@ -11,6 +11,10 @@ server:
error: error:
include-exception: true include-exception: true
spring: spring:
servlet:
multipart:
max-file-size: 50MB
max-request-size: 100MB
jmx: jmx:
enabled: false enabled: false
application: application:

View File

@ -4,4 +4,4 @@
| |_| | | __/ |_| | |_| | __/ | |_| | | __/ |_| | |_| | __/
\___/|_|\___|\__, |\__,_|\___| \___/|_|\___|\__, |\__,_|\___|
|___/ |___/
@author: Bosen-once 捷阅网购物商城 @author: Bosen

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -78,6 +78,11 @@
</div> </div>
<script th:fragment="alertMsg" th:inline="javascript"> <script th:fragment="alertMsg" th:inline="javascript">
function loading() {
var img = document.getElementById("loading");
img.style.display = "";
}
window.onload = function () { window.onload = function () {
if ("[[${param.msg}]]" != "") { if ("[[${param.msg}]]" != "") {
alert("[[${param.msg}]]"); alert("[[${param.msg}]]");

View File

@ -32,6 +32,7 @@
</head> </head>
<body> <body>
<img id="loading" th:src="@{/loading.gif}" style="position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 999; display: none; opacity: 0.8"/>
<div id="wrapper"> <div id="wrapper">
<div th:include="admin/common/model::nav"></div> <div th:include="admin/common/model::nav"></div>
@ -45,14 +46,14 @@
<h4>推荐尺寸1920x737</h4> <h4>推荐尺寸1920x737</h4>
<form th:action="@{/admin/up-image}" method="post" enctype="multipart/form-data" style="text-align: right"> <form th:action="@{/admin/up-image}" method="post" enctype="multipart/form-data" style="text-align: right">
<input type="file" name="file" style="display: none;" id="input1920" onchange="showImg(this,'img1920')"> <input type="file" name="file" style="display: none;" id="input1920" onchange="showImg(this,'img1920')">
<input type="submit" value="修改"> <input type="submit" value="修改" onclick="loading()">
<input type="number" value="1920" name="width" hidden="hidden"> <input type="number" value="1920" name="width" hidden="hidden">
<input type="number" value="737" name="height" hidden="hidden"> <input type="number" value="737" name="height" hidden="hidden">
</form> </form>
<form th:action="@{/admin/del-image}" method="post" style="text-align: right"> <form th:action="@{/admin/del-image}" method="post" style="text-align: right">
<input type="number" value="1920" name="width" hidden="hidden"> <input type="number" value="1920" name="width" hidden="hidden">
<input type="number" value="737" name="height" hidden="hidden"> <input type="number" value="737" name="height" hidden="hidden">
<input type="submit" value="删除" onclick="if (confirm('确认删除?')==false)return false; "/> <input type="submit" value="删除" onclick="if (confirm('确认删除?') == false) {return false;} else {loading();}"/>
</form> </form>
<div style="width: 100%;text-align: center"> <div style="width: 100%;text-align: center">
<!--1920*737--> <!--1920*737-->
@ -73,12 +74,12 @@
<input type="file" name="file" style="display: none;" id="input1230" onchange="showImg(this,'img1230')"> <input type="file" name="file" style="display: none;" id="input1230" onchange="showImg(this,'img1230')">
<input type="number" value="1230" name="width" hidden="hidden"> <input type="number" value="1230" name="width" hidden="hidden">
<input type="number" value="535" name="height" hidden="hidden"> <input type="number" value="535" name="height" hidden="hidden">
<input type="submit" value="修改"> <input type="submit" value="修改" onclick="loading()">
</form> </form>
<form th:action="@{/admin/del-image}" method="post" style="text-align: right"> <form th:action="@{/admin/del-image}" method="post" style="text-align: right">
<input type="number" value="1230" name="width" hidden="hidden"> <input type="number" value="1230" name="width" hidden="hidden">
<input type="number" value="535" name="height" hidden="hidden"> <input type="number" value="535" name="height" hidden="hidden">
<input type="submit" value="删除" onclick="if (confirm('确认删除?')==false)return false; "/> <input type="submit" value="删除" onclick="if (confirm('确认删除?') == false) {return false;} else {loading();}"/>
</form> </form>
<div style="width: 100%;text-align: center"> <div style="width: 100%;text-align: center">
<!--1230*535--> <!--1230*535-->
@ -99,12 +100,12 @@
<input type="file" name="file" style="display: none;" id="input3151" onchange="showImg(this,'img3151')"> <input type="file" name="file" style="display: none;" id="input3151" onchange="showImg(this,'img3151')">
<input type="number" value="3151" name="width" hidden="hidden"> <input type="number" value="3151" name="width" hidden="hidden">
<input type="number" value="282" name="height" hidden="hidden"> <input type="number" value="282" name="height" hidden="hidden">
<input type="submit" value="修改"> <input type="submit" value="修改" onclick="loading()">
</form> </form>
<form th:action="@{/admin/del-image}" method="post" style="text-align: right"> <form th:action="@{/admin/del-image}" method="post" style="text-align: right">
<input type="number" value="3151" name="width" hidden="hidden"> <input type="number" value="3151" name="width" hidden="hidden">
<input type="number" value="282" name="height" hidden="hidden"> <input type="number" value="282" name="height" hidden="hidden">
<input type="submit" value="删除" onclick="if (confirm('确认删除?')==false)return false; "/> <input type="submit" value="删除" onclick="if (confirm('确认删除?') == false) {return false;} else {loading();}"/>
</form> </form>
<div style="width: 100%;text-align: center"> <div style="width: 100%;text-align: center">
<img th:if="${imgMap.get('3151')} eq null" th:src="@{/image/user/home/banner/3.jpg}" id="img3151" onclick="upImg('input3151')" > <img th:if="${imgMap.get('3151')} eq null" th:src="@{/image/user/home/banner/3.jpg}" id="img3151" onclick="upImg('input3151')" >
@ -124,12 +125,12 @@
<input type="file" name="file" style="display: none;" id="input3152" onchange="showImg(this,'img3152')"> <input type="file" name="file" style="display: none;" id="input3152" onchange="showImg(this,'img3152')">
<input type="number" value="3152" name="width" hidden="hidden"> <input type="number" value="3152" name="width" hidden="hidden">
<input type="number" value="282" name="height" hidden="hidden"> <input type="number" value="282" name="height" hidden="hidden">
<input type="submit" value="修改"> <input type="submit" value="修改" onclick="loading()">
</form> </form>
<form th:action="@{/admin/del-image}" method="post" style="text-align: right"> <form th:action="@{/admin/del-image}" method="post" style="text-align: right">
<input type="number" value="3152" name="width" hidden="hidden"> <input type="number" value="3152" name="width" hidden="hidden">
<input type="number" value="282" name="height" hidden="hidden"> <input type="number" value="282" name="height" hidden="hidden">
<input type="submit" value="删除" onclick="if (confirm('确认删除?')==false)return false; "/> <input type="submit" value="删除" onclick="if (confirm('确认删除?') == false) {return false;} else {loading();}"/>
</form> </form>
<div style="width: 100%;text-align: center"> <div style="width: 100%;text-align: center">
<img th:if="${imgMap.get('3152')} eq null" th:src="@{/image/user/home/banner/3.jpg}" id="img3152" onclick="upImg('input3152')" > <img th:if="${imgMap.get('3152')} eq null" th:src="@{/image/user/home/banner/3.jpg}" id="img3152" onclick="upImg('input3152')" >
@ -149,12 +150,12 @@
<input type="file" name="file" style="display: none;" id="input475" onchange="showImg(this,'img475')"> <input type="file" name="file" style="display: none;" id="input475" onchange="showImg(this,'img475')">
<input type="number" value="475" name="width" hidden="hidden"> <input type="number" value="475" name="width" hidden="hidden">
<input type="number" value="570" name="height" hidden="hidden"> <input type="number" value="570" name="height" hidden="hidden">
<input type="submit" value="修改"> <input type="submit" value="修改" onclick="loading()">
</form> </form>
<form th:action="@{/admin/del-image}" method="post" style="text-align: right"> <form th:action="@{/admin/del-image}" method="post" style="text-align: right">
<input type="number" value="475" name="width" hidden="hidden"> <input type="number" value="475" name="width" hidden="hidden">
<input type="number" value="570" name="height" hidden="hidden"> <input type="number" value="570" name="height" hidden="hidden">
<input type="submit" value="删除" onclick="if (confirm('确认删除?')==false)return false; "/> <input type="submit" value="删除" onclick="if (confirm('确认删除?') == false) {return false;} else {loading();}"/>
</form> </form>
<div style="width: 100%;text-align: center"> <div style="width: 100%;text-align: center">
<img th:if="${imgMap.get('475')} eq null" th:src="@{/image/user/home/banner/1.jpg}" id="img475" onclick="upImg('input475')" > <img th:if="${imgMap.get('475')} eq null" th:src="@{/image/user/home/banner/1.jpg}" id="img475" onclick="upImg('input475')" >
@ -174,12 +175,12 @@
<input type="file" name="file" style="display: none;" id="input674" onchange="showImg(this,'img674')"> <input type="file" name="file" style="display: none;" id="input674" onchange="showImg(this,'img674')">
<input type="number" value="674" name="width" hidden="hidden"> <input type="number" value="674" name="width" hidden="hidden">
<input type="number" value="264" name="height" hidden="hidden"> <input type="number" value="264" name="height" hidden="hidden">
<input type="submit" value="修改"> <input type="submit" value="修改" onclick="loading()">
</form> </form>
<form th:action="@{/admin/del-image}" method="post" style="text-align: right"> <form th:action="@{/admin/del-image}" method="post" style="text-align: right">
<input type="number" value="674" name="width" hidden="hidden"> <input type="number" value="674" name="width" hidden="hidden">
<input type="number" value="264" name="height" hidden="hidden"> <input type="number" value="264" name="height" hidden="hidden">
<input type="submit" value="删除" onclick="if (confirm('确认删除?')==false)return false; "/> <input type="submit" value="删除" onclick="if (confirm('确认删除?') == false) {return false;} else {loading();}"/>
</form> </form>
<div style="width: 100%;text-align: center"> <div style="width: 100%;text-align: center">
<img th:if="${imgMap.get('674')} eq null" th:src="@{/image/user/home/banner/2.jpg}" id="img674" onclick="upImg('input674')" > <img th:if="${imgMap.get('674')} eq null" th:src="@{/image/user/home/banner/2.jpg}" id="img674" onclick="upImg('input674')" >

View File

@ -97,6 +97,11 @@
<!--sidebar end--> <!--sidebar end-->
<script th:fragment="alertMsg" th:inline="javascript"> <script th:fragment="alertMsg" th:inline="javascript">
function loading() {
var img = document.getElementById("loading");
img.style.display = "";
}
window.onload = function () { window.onload = function () {
if ("[[${param.msg}]]" != "") { if ("[[${param.msg}]]" != "") {
alert("[[${param.msg}]]"); alert("[[${param.msg}]]");

View File

@ -61,6 +61,7 @@
</style> </style>
</head> </head>
<body> <body>
<img id="loading" th:src="@{/loading.gif}" style="position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 999; display: none; opacity: 0.8"/>
<section id="container"> <section id="container">
<!--header start--> <!--header start-->
<header class="header fixed-top clearfix" th:include="merchant/common/model::header"></header> <header class="header fixed-top clearfix" th:include="merchant/common/model::header"></header>
@ -90,7 +91,7 @@
</p> </p>
</td> </td>
<td style="text-align: center;"> <td style="text-align: center;">
<img th:src="@{/image/user/home/product/5.jpg}" style="width: 144px;height: 181.8px" <img th:src="@{/image/merchant/default.jpg}" style="width: 144px;height: 181.8px"
id="img0" onclick="upImg('input0')"> id="img0" onclick="upImg('input0')">
<input style="display: none" type="file" name="img" id="input0" <input style="display: none" type="file" name="img" id="input0"
onchange="showImg(this,'img0')"> onchange="showImg(this,'img0')">
@ -112,7 +113,7 @@
style="text-align: center;height: 181.8px"> style="text-align: center;height: 181.8px">
</td> </td>
<td style="text-align: center;font-weight: bold;"> <td style="text-align: center;font-weight: bold;">
<input type="submit" value="添加商品" style="text-align: center;height: 181.8px;color: purple"> <input type="submit" onclick="loading()" value="添加商品" style="text-align: center;height: 181.8px;color: purple">
</td> </td>
</tr> </tr>
</form> </form>
@ -157,7 +158,7 @@
<b>删除</b> <b>删除</b>
</button> </button>
<button type="submit" style="background: deepskyblue;color: white;border-radius: 5px;width: 50px;height: 30px" <button type="submit" style="background: deepskyblue;color: white;border-radius: 5px;width: 50px;height: 30px"
onclick="if (confirm('确认修改该商品的信息?')==false)return false; "> onclick="if (confirm('确认修改该商品的信息?')==false) {return false;} else {loading()} ">
<b>修改</b> <b>修改</b>
</button> </button>
@ -230,6 +231,7 @@
function delGoods(goodsId) { function delGoods(goodsId) {
if (confirm("确认删除此商品?")) { if (confirm("确认删除此商品?")) {
loading();
window.location = "/merchant/del-goods?id=" + goodsId; window.location = "/merchant/del-goods?id=" + goodsId;
} }
} }

View File

@ -42,6 +42,7 @@
</style> </style>
</head> </head>
<body> <body>
<img id="loading" th:src="@{/loading.gif}" style="position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 999; display: none; opacity: 0.8"/>
<section id="container"> <section id="container">
<!--header start--> <!--header start-->
<header class="header fixed-top clearfix" th:include="merchant/common/model::header"></header> <header class="header fixed-top clearfix" th:include="merchant/common/model::header"></header>
@ -61,7 +62,7 @@
<img th:src="@{${session.merchant.getHeader()}}" width="240" height="240" onclick="upImg('headerInput')" id="header" style="border-radius: 100%"> <img th:src="@{${session.merchant.getHeader()}}" width="240" height="240" onclick="upImg('headerInput')" id="header" style="border-radius: 100%">
<input style="display: none;" id="headerInput" type="file" name="img" onchange="showImg(this,'header')"> <input style="display: none;" id="headerInput" type="file" name="img" onchange="showImg(this,'header')">
<br/> <br/>
<input type="submit" value="修改" style="background: purple;border-radius: 5px;color: white"> <input type="submit" value="修改" onclick="loading()" style="background: purple;border-radius: 5px;color: white">
</form> </form>
</td> </td>
</tr> </tr>
@ -76,8 +77,7 @@
<input type="number" name="width" value="400" hidden> <input type="number" name="width" value="400" hidden>
<input type="number" name="height" value="320" hidden> <input type="number" name="height" value="320" hidden>
<br/> <br/>
<input type="submit" value="修改" style="background: purple;border-radius: 5px;color: white"> <input type="submit" onclick="loading()" value="修改" style="background: purple;border-radius: 5px;color: white">
<a style="color: purple" th:if="${homeImg}!=null" th:href="@{/merchant/del-home-img(id=${homeImg.getId()})}">删除</a>
</form> </form>
</td> </td>
<td> <td>
@ -90,8 +90,7 @@
<input type="number" name="width" value="600" hidden> <input type="number" name="width" value="600" hidden>
<input type="number" name="height" value="310" hidden> <input type="number" name="height" value="310" hidden>
<br/> <br/>
<input type="submit" value="修改" style="background: purple;border-radius: 5px;color: white"> <input type="submit" onclick="loading()" value="修改" style="background: purple;border-radius: 5px;color: white">
<a style="color: purple" th:if="${lowImg}!=null" th:href="@{/merchant/del-home-img(id=${lowImg.getId()})}">删除</a>
</form> </form>
</td> </td>
</tr> </tr>

View File

@ -270,6 +270,12 @@
</footer> </footer>
<script th:fragment="alertMsg" th:inline="javascript"> <script th:fragment="alertMsg" th:inline="javascript">
function loading() {
var img = document.getElementById("loading");
img.style.display = "";
}
window.onload = function () { window.onload = function () {
if ("[[${param.msg}]]" != "") { if ("[[${param.msg}]]" != "") {
alert("[[${param.msg}]]"); alert("[[${param.msg}]]");

View File

@ -103,7 +103,7 @@
</div> </div>
</div> </div>
<!-- entry-header-area end --> <!-- entry-header-area end -->
<img id="loading" th:src="@{/loading.gif}" style="position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 999; display: none; opacity: 0.8"/>
<!-- cart-main-area start --> <!-- cart-main-area start -->
<div class="cart-main-area"> <div class="cart-main-area">
<div class="container"> <div class="container">
@ -170,6 +170,7 @@
var form = document.getElementById("form"); var form = document.getElementById("form");
form.action = "/user/update-info"; form.action = "/user/update-info";
form.submit(); form.submit();
loading();
} }
function showImg(input,id) { function showImg(input,id) {