更换图床

master
云丶言 2022-05-23 00:48:21 +08:00
parent fae1b66996
commit 743a373edb
32 changed files with 455 additions and 559 deletions

View File

@ -130,92 +130,81 @@
# 如何部署?
---
### 1.下载源码
### 下载源码
将源码下载下来使用Idea选择open的方式打开项目第一次打开需要下载项目对应的第三方依赖需要等待2~3分钟
![](https://img-blog.csdnimg.cn/e5e5f9f23bb24fc286caa56564df7857.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_20,color_FFFFFF,t_70,g_se,x_16)
### 2.配置文件
### 配置文件
修改项目配置文件application.yml主要将服务器ip地址、MySQL、Redis连接信息按照自己的需求进行修改即可。
![](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)
### 3.打包项目
填写好项目配置信息后,就可以开始打包项目了:按照下图所示的步骤依次执行,最后打包好的 **`jieyue.jar`** 将会存放在 **`target`** 目录中。
![](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)
### 打包项目
填写好项目配置信息后,就可以开始打包项目了:按照下图所示的步骤依次执行,最后打包好的 **`ROOT.war`** 将会存放在 **`target`** 目录中。
![在这里插入图片描述](https://img-blog.csdnimg.cn/12fa198275c14466804d553efd8b17a7.png)
### 4.安装Docker
### 安装Docker
docker的安装流程可参考下面这篇文章笔者在这里就不再赘述了**[https://www.runoob.com/docker/centos-docker-install.html](https://www.runoob.com/docker/centos-docker-install.html)**
<br/>
### 5.安装MySQL
5.1执行如下命令拉取MySQL的Docker镜像
### 安装MySQL
1执行如下命令拉取MySQL的Docker镜像
```bash
docker pull hub.c.163.com/library/mysql:latest
```
5.2镜像拉取后执行如下命令运行MySQL注意MYSQL_ROOT_PASSWORD中的密码需要与项目配置文件中的MySQL密码保持一致
2镜像拉取后执行如下命令运行MySQL注意MYSQL_ROOT_PASSWORD中的密码需要与项目配置文件中的MySQL密码保持一致
```bash
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d hub.c.163.com/library/mysql:latest
```
5.3MySQL运行成功后需要对MySQL的数据进行初始化这里笔者推荐使用可视化工具Navicat填入对应的信息即可成功连接
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)
5.4新建一个名为jieyue的数据库创建成功后双击该数据库创立连接接着右击选择**运行SQL文件**,运行项目根目录下的 **`jieyue.sql`** 文件即可。
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)
### 6.安装Redis
6.1执行如下命令拉取Redis的Docker镜像
### 安装Redis
1执行如下命令拉取Redis的Docker镜像
```bash
docker pull hub.c.163.com/library/redis:latest
```
6.2执行如下命令运行Redis
2执行如下命令运行Redis
```bash
docker run -d -p 6379:6379 --name redis hub.c.163.com/library/redis:latest
```
<br/>
### 7.安装OpenJDK
7.1执行如下命令拉取OpenJDK的Docker镜像
### 安装Tomcat
1执行如下命令拉取Tomcat的Docker镜像
```bash
docker pull hub.c.163.com/cloudndp/library/openjdk:8-jessie
docker pull hub.c.163.com/library/tomcat:8.5
```
7.2:在 **`jieyue.jar`** 包同一目录下创建 **`Dockerfile`** 文件,具体内容如下
2执行如下命令运行Tomcat
```bash
FROM hub.c.163.com/cloudndp/library/openjdk:8-jessie
COPY jieyue.jar /jieyue.jar
CMD java -jar /jieyue.jar
EXPOSE 80
docker run -d -p 80:8080 -e LANG=C.UTF-8 -e TZ="Asia/Shanghai" --name tomcat hub.c.163.com/library/tomcat:8.5
```
7.3:在 **`jieyue.jar`** 包同一目录下执行如下命令,创建镜像
3使用如下命令进入tomcat容器内将`/usr/local/tomcat/webapps`路径下的`ROOT`文件夹删除
```bash
docker build -t jieyue-image .
docker exec -it tomcat bash
```
7.4:最后运行容器即可
4退出容器来到存放 **`ROOT.war`** 的目录执行如下命令将项目文件拷贝进容器tomcat容器中
```bash
docker run -d -p 80:80 -e LANG=C.UTF-8 -e TZ="Asia/Shanghai" --name jieyue jieyue-image
docker cp ROOT.war tomcat:/usr/local/tomcat/webapps
```
7.5:使用如下命令可查看项目运行日志(若有如下字眼出现,则表明容器运行成功)
4最后重启Tomcat
```bash
docker logs jieyue
docker restart tomcat
```
![](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/),就可以看到网站的主页)至此,捷阅网已成功部署~~
5成功运行后访问配置文件中填写的服务器ip地址即可笔者这里填写的是199.91.222.184,访问 **[http://119.91.222.184/](http://119.91.222.184/)**,就可以看到网站的主页)至此,捷阅网已成功部署~~
<br/>
# 有关网站制作者
---
**个 人 主 页: [云丶言](https://bosen-once.gitee.io/)**
![](https://img-blog.csdnimg.cn/c3f49c6533dc401b9d00bb3655f7e5fb.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_15,color_FFFFFF,t_70,g_se,x_16#pic_center)
---
**CSDN博客[云丶言](https://blog.csdn.net/weixin_47600880)**
![](https://img-blog.csdnimg.cn/45557a1b39054cc6ae793079c8e4f178.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5LqR5Li26KiA,size_15,color_FFFFFF,t_70,g_se,x_16#pic_center)

View File

@ -11,7 +11,7 @@
Target Server Version : 50716
File Encoding : 65001
Date: 28/03/2022 20:07:01
Date: 23/05/2022 00:43:13
*/
SET NAMES utf8mb4;
@ -98,9 +98,9 @@ INSERT INTO `sys_cart` VALUES (10, 70, 1, 1);
INSERT INTO `sys_cart` VALUES (11, 51, 1, 1);
INSERT INTO `sys_cart` VALUES (12, 73, 1, 1);
INSERT INTO `sys_cart` VALUES (13, 47, 1, 1);
INSERT INTO `sys_cart` VALUES (14, 47, 3, 1);
INSERT INTO `sys_cart` VALUES (15, 48, 3, 1);
INSERT INTO `sys_cart` VALUES (16, 46, 3, 1);
INSERT INTO `sys_cart` VALUES (14, 47, 2, 1);
INSERT INTO `sys_cart` VALUES (15, 48, 2, 1);
INSERT INTO `sys_cart` VALUES (16, 46, 2, 1);
INSERT INTO `sys_cart` VALUES (17, 45, 3, 1);
-- ----------------------------
@ -171,7 +171,7 @@ CREATE TABLE `sys_goods` (
`merchant` int(11) NOT NULL COMMENT '商品所属的商户id',
`stock` int(11) NOT NULL DEFAULT 0 COMMENT '商品库存',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 75 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
) ENGINE = InnoDB AUTO_INCREMENT = 76 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_goods
@ -232,6 +232,7 @@ INSERT INTO `sys_goods` VALUES (71, '安踏官方旗舰老爹鞋女鞋', '安踏
INSERT INTO `sys_goods` VALUES (72, '安踏脉冲2代男鞋', '安踏脉冲2代男鞋男2021春季新款男士户外休闲鞋旅游鞋官方旗舰网店912118852 浅米白/墨水蓝-1 8.5(男42)', '/data/goods/14/20210330213810878030.jpg', 0.01, 1, 14, 9);
INSERT INTO `sys_goods` VALUES (73, '安踏女休闲鞋2021春季新款', '安踏女休闲鞋2021春季新款轻便跑步鞋子潮流时尚女鞋老爹鞋女运动鞋子百搭猫爪鞋官方旗舰网店 象牙白/迷雾紫/浅雾灰-5 6.5(女37.5)', '/data/goods/14/20210330213829639750.jpg', 0.01, 1, 14, 10);
INSERT INTO `sys_goods` VALUES (74, '测试商品(勿拍)', '这是一只用于测试的海绵宝宝,勿拍!!!', '/data/goods/11/20210330220346963836.jpg', 0.01, 0, 11, 4);
INSERT INTO `sys_goods` VALUES (75, '1', '1', '/data/goods/13/20220522235640383480.jpg', 1.00, 0, 13, 1);
-- ----------------------------
-- Table structure for sys_mt
@ -309,15 +310,9 @@ CREATE TABLE `sys_notice` (
-- Records of sys_notice
-- ----------------------------
INSERT INTO `sys_notice` VALUES (30, '系统群发消息测试', '系统群发消息测试(无需理会)', '2', 1, 1648468781372);
INSERT INTO `sys_notice` VALUES (31, '系统群发消息测试', '系统群发消息测试(无需理会)', '2', 3, 1648468781375);
INSERT INTO `sys_notice` VALUES (32, '系统群发消息测试', '系统群发消息测试(无需理会)', '2', 4, 1648468781376);
INSERT INTO `sys_notice` VALUES (33, '系统群发消息测试', '系统群发消息测试(无需理会)', '2', 5, 1648468781377);
INSERT INTO `sys_notice` VALUES (34, '系统群发消息测试', '系统群发消息测试(无需理会)', '2', 7, 1648468781378);
INSERT INTO `sys_notice` VALUES (31, '系统群发消息测试', '系统群发消息测试(无需理会)', '2', 2, 1648468781375);
INSERT INTO `sys_notice` VALUES (35, '欢迎访问捷阅网~', '欢迎访问捷阅网~', '2', 1, 1648468890462);
INSERT INTO `sys_notice` VALUES (36, '欢迎访问捷阅网~', '欢迎访问捷阅网~', '2', 3, 1648468890464);
INSERT INTO `sys_notice` VALUES (37, '欢迎访问捷阅网~', '欢迎访问捷阅网~', '2', 4, 1648468890466);
INSERT INTO `sys_notice` VALUES (38, '欢迎访问捷阅网~', '欢迎访问捷阅网~', '2', 5, 1648468890467);
INSERT INTO `sys_notice` VALUES (39, '欢迎访问捷阅网~', '欢迎访问捷阅网~', '2', 7, 1648468890468);
INSERT INTO `sys_notice` VALUES (36, '欢迎访问捷阅网~', '欢迎访问捷阅网~', '2', 2, 1648468890464);
-- ----------------------------
-- Table structure for sys_order
@ -346,7 +341,7 @@ CREATE TABLE `sys_order` (
`merchant_ratio` float(11, 1) NOT NULL DEFAULT 1.0 COMMENT '订单创建时商户的费率',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `order_id`(`order_id`) USING BTREE COMMENT '订单号唯一'
) ENGINE = InnoDB AUTO_INCREMENT = 113 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
@ -362,17 +357,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 (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 (101, 'GKJ202112340211010176213', 1638796210886, 1638796384928, 1, 1, 'GAU202112340211010908695', 3, 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', 3, 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', 3, 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', 3, 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', 3, 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', 3, 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', 3, 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', 3, 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', 3, 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', 3, 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', 3, 13, 0.01, 55, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/87b2e60d-464c-499a-90be-b93e1ea58911.jpg', NULL, 0.0);
INSERT INTO `sys_order` VALUES (101, 'GKJ202112340211010176213', 1638796210886, 1638796384928, 1, 1, 'GAU202112340211010908695', 2, 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', 2, 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', 2, 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', 2, 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', 2, 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', 2, 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', 2, 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', 2, 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', 2, 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', 2, 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', 2, 13, 0.01, 55, '', 'xxxxxxxxxxxxx', 'Bosen', '123456', '', 0, 'data/pay/87b2e60d-464c-499a-90be-b93e1ea58911.jpg', NULL, 0.0);
-- ----------------------------
-- Table structure for sys_role
@ -439,53 +434,9 @@ CREATE TABLE `sys_ui` (
INSERT INTO `sys_ui` VALUES (18, '/data/library/20210328110354280473.jpg', 1230, 535);
INSERT INTO `sys_ui` VALUES (19, '/data/library/20210330181647732986.jpg', 3151, 282);
INSERT INTO `sys_ui` VALUES (20, '/data/library/20210330181628569458.jpeg', 3152, 282);
INSERT INTO `sys_ui` VALUES (21, 'data/library/1f9be131-5b1b-4c29-a172-2f34b757fe77.jpeg', 475, 570);
INSERT INTO `sys_ui` VALUES (21, '/data/library/20210330190628805198.jpeg', 475, 570);
INSERT INTO `sys_ui` VALUES (22, '/data/library/20210330185815215536.jpg', 674, 264);
INSERT INTO `sys_ui` VALUES (23, 'data/library/22f506db-2960-4756-b339-25760fe4dc40.jpg', 1920, 737);
-- ----------------------------
-- Table structure for sys_ui_copy1
-- ----------------------------
DROP TABLE IF EXISTS `sys_ui_copy1`;
CREATE TABLE `sys_ui_copy1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`width` int(7) NOT NULL,
`height` int(7) NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 24 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_ui_copy1
-- ----------------------------
INSERT INTO `sys_ui_copy1` VALUES (18, '/data/library/20210328110354280473.jpg', 1230, 535);
INSERT INTO `sys_ui_copy1` VALUES (19, '/data/library/20210330181647732986.jpg', 3151, 282);
INSERT INTO `sys_ui_copy1` VALUES (20, '/data/library/20210330181628569458.jpeg', 3152, 282);
INSERT INTO `sys_ui_copy1` VALUES (21, '/data/library/20210330190628805198.jpeg', 475, 570);
INSERT INTO `sys_ui_copy1` VALUES (22, '/data/library/20210330185815215536.jpg', 674, 264);
INSERT INTO `sys_ui_copy1` VALUES (23, '/data/library/20210322125308458944.jpg', 1920, 737);
-- ----------------------------
-- Table structure for sys_ui_copy2
-- ----------------------------
DROP TABLE IF EXISTS `sys_ui_copy2`;
CREATE TABLE `sys_ui_copy2` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`width` int(7) NOT NULL,
`height` int(7) NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 24 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_ui_copy2
-- ----------------------------
INSERT INTO `sys_ui_copy2` VALUES (18, '/data/library/20210328110354280473.jpg', 1230, 535);
INSERT INTO `sys_ui_copy2` VALUES (19, '/data/library/20210330181647732986.jpg', 3151, 282);
INSERT INTO `sys_ui_copy2` VALUES (20, '/data/library/20210330181628569458.jpeg', 3152, 282);
INSERT INTO `sys_ui_copy2` VALUES (21, '/data/library/20210330190628805198.jpeg', 475, 570);
INSERT INTO `sys_ui_copy2` VALUES (22, '/data/library/20210330185815215536.jpg', 674, 264);
INSERT INTO `sys_ui_copy2` VALUES (23, '/data/library/20210322125308458944.jpg', 1920, 737);
INSERT INTO `sys_ui` VALUES (23, '/data/library/20210322125308458944.jpg', 1920, 737);
-- ----------------------------
-- Table structure for sys_user
@ -505,10 +456,7 @@ CREATE TABLE `sys_user` (
-- ----------------------------
-- Records of sys_user
-- ----------------------------
INSERT INTO `sys_user` VALUES (1, 'Bosen', 'b9e1115fb6e950878b08e2433b53ed47', 'bosen_once@163.com', 1, 'data/header/user/5123ceb0-7f02-4a03-a6a8-32b70ddcbe08.jpg');
INSERT INTO `sys_user` VALUES (3, 'guest', 'e10adc3949ba59abbe56e057f20f883e', 'guest@qq.com', 1, 'data/header/user/45bd348b-ba84-42ce-80b3-c4f852c943df.itc.cn_images01_20210825_919e1fbb709a4336b52c1cc4f3b8ef17.jpeg&refer=http___p9.itc.jfif');
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 (7, '2390025289@qq.com', 'e10adc3949ba59abbe56e057f20f883e', '2390025289@qq.com', 1, '/data/header/user/default.jpg');
INSERT INTO `sys_user` VALUES (1, 'Bosen', 'b9e1115fb6e950878b08e2433b53ed47', 'bosen_once@163.com', 1, '/data/header/user/1.jpg');
INSERT INTO `sys_user` VALUES (2, 'guest', 'e10adc3949ba59abbe56e057f20f883e', 'guest@qq.com', 1, '/data/header/user/default.jpg');
SET FOREIGN_KEY_CHECKS = 1;

42
pom.xml
View File

@ -11,7 +11,7 @@
<groupId>com.example</groupId>
<artifactId>jieyue</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<packaging>war</packaging>
<name>jieyue</name>
<description>Demo project for Spring Boot</description>
@ -19,6 +19,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<tomcat.version>8.5.29</tomcat.version>
</properties>
<dependencies>
@ -59,32 +60,34 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 移除嵌入式tomcat插件 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- devtool -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.3</version>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
@ -124,13 +127,11 @@
<artifactId>qrgen</artifactId>
<version>1.4</version>
</dependency>
<!-- json -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
<!-- redis -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
@ -139,10 +140,12 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- elasticsearch -->
<dependency>
@ -155,27 +158,15 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</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>
<build>
<finalName>jieyue</finalName>
<finalName>ROOT</finalName>
<plugins>
<plugin>
<!--<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@ -188,11 +179,6 @@
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</build>

View File

@ -1,9 +1,15 @@
package com.example.jieyue;
import org.apache.catalina.connector.Connector;
import org.apache.coyote.http11.AbstractHttp11Protocol;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
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.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
@ -15,10 +21,35 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@ServletComponentScan
@EnableScheduling
public class JieyueApplication {
public class JieyueApplication extends SpringBootServletInitializer {
public static void main(String[] 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

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

View File

@ -1,16 +1,22 @@
package com.example.jieyue.admin.service;
import com.example.jieyue.common.mapper.SysUiMapper;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import com.example.jieyue.common.utils.DateUtil;
import com.example.jieyue.common.utils.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.thymeleaf.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
@Service
public class AdminUiService {
@Autowired
FileUtil fileUtil;
@Autowired
DateUtil dateUtil;
@Autowired
SysUiMapper uiMapper;
@ -21,31 +27,33 @@ public class AdminUiService {
*
*/
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 = GiteeImgBedUtils.upload(url, file);
if (result == null){
String result = fileUtil.upFile(file,redirectAttributes,request,url,filename);
if (result==null){
return null;
}else{
if (uiMapper.findByMark(weight,height) == null) {
int insertRes = uiMapper.insert(result, weight, height);
if (insertRes == 1) {
return result;
return filename;
} else {
// sql语句执行失败将已上传的图片移除
GiteeImgBedUtils.delete(result);
fileUtil.deleteFile(result);
return null;
}
}else{
// 删除旧图片
GiteeImgBedUtils.delete(uiMapper.findByMark(weight,height).getUrl());
fileUtil.deleteFile(uiMapper.findByMark(weight,height).getUrl());
// 更改图片
int updateRes = uiMapper.updateUrl(result,weight,height);
if (updateRes == 1) {
return result;
return filename;
} else {
// sql语句执行失败将已上传的图片移除
GiteeImgBedUtils.delete(result);
fileUtil.deleteFile(result);
return null;
}
}
@ -56,11 +64,11 @@ public class AdminUiService {
* <p></p>
*/
public boolean delImg(int width,int height){
if (uiMapper.findByMark(width,height) == null){
if (uiMapper.findByMark(width,height)==null){
return false;
}else{
GiteeImgBedUtils.delete(uiMapper.findByMark(width, height).getUrl());
int delResult = uiMapper.deleteByMark(width, height);
fileUtil.deleteFile(uiMapper.findByMark(width,height).getUrl());
int delResult = uiMapper.deleteByMark(width,height);
if (delResult == 1) {
return true;
}

View File

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

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

@ -0,0 +1,22 @@
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

@ -0,0 +1,78 @@
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

@ -1,186 +0,0 @@
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 = "24a30786da41fe96ec7ee86daea78ee2";
/**
*
*/
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) {
if(path.contains("default")) {
return true;
}
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

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

View File

@ -0,0 +1,20 @@
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

@ -92,7 +92,7 @@ public class MerchantGoodsController {
modelAndView.setViewName("redirect:goods");
return modelAndView;
}
/**
* <p>id</p>
*/
@ -108,7 +108,7 @@ public class MerchantGoodsController {
modelAndView.setViewName("redirect:goods");
return modelAndView;
}
/**
* <p></p>
*/

View File

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

View File

@ -36,7 +36,7 @@ public class MerchantUiController {
return modelAndView;
}
/**
* <p></p>
*/
@ -57,7 +57,7 @@ public class MerchantUiController {
modelAndView.setViewName("redirect:ui");
return modelAndView;
}
/**
* <p></p>
*/
@ -79,7 +79,7 @@ public class MerchantUiController {
modelAndView.setViewName("redirect:ui");
return modelAndView;
}
/**
* <p></p>
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,6 @@ import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.common.mapper.SysCommentMapper;
import com.example.jieyue.common.mapper.SysGoodsMapper;
import com.example.jieyue.common.mapper.SysUserMapper;
import com.example.jieyue.common.utils.GiteeImgBedUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -22,7 +21,7 @@ public class UserProductService {
SysCommentMapper commentMapper;
@Autowired
SysUserMapper userMapper;
/**
* <p></p>
*/
@ -33,7 +32,7 @@ public class UserProductService {
for (SysComment comment : commentInfo) {
Map<String,String> commentMap = new HashMap<>();
SysUser user = getUserInfo(comment.getUser());
commentMap.put("userHeader",GiteeImgBedUtils.PRE + user.getHeader());
commentMap.put("userHeader",user.getHeader());
commentMap.put("userId",user.getId()+"");
commentMap.put("commentId",comment.getId()+"");
commentMap.put("userName",user.getUsername());
@ -44,7 +43,7 @@ public class UserProductService {
}
return list;
}
/**
* <p></p>
*/
@ -52,14 +51,12 @@ public class UserProductService {
int count = commentMapper.getAllCountByGoods(goods);
return (int)Math.ceil((double)count/(double)num);
}
/**
* <p>id</p>
*/
public SysGoods getGoods(int id){
SysGoods goods = goodsMapper.findById(id);
goods.setImg(GiteeImgBedUtils.PRE + goods.getImg());
return goods;
return goodsMapper.findById(id);
}
/**
@ -71,14 +68,14 @@ public class UserProductService {
public List<SysComment> getCommentInfo(int goods, int page, int num){
return commentMapper.findByGoodsLimit(goods,(page-1)*num,page*num);
}
/**
* <p></p>
*/
public SysUser getUserInfo(int userId){
return userMapper.selectById(userId);
}
/**
* <p></p>
* @return

View File

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

View File

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

View File

@ -8,6 +8,7 @@ import com.example.jieyue.common.mapper.SysMtMapper;
import com.example.jieyue.common.mapper.SysOrderMapper;
import com.example.jieyue.common.utils.IsEmptyUtil;
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.sdk.WXPay;
import com.example.jieyue.wxpay.sdk.WXPayConstants;
@ -27,10 +28,7 @@ import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.*;
/**
* <p></p>
@ -39,6 +37,8 @@ import java.util.Random;
*/
@Service
public class WxPayService {
@Autowired
StringUtil stringUtil;
@Autowired
SysOrderMapper orderMapper;
@Autowired
@ -91,7 +91,7 @@ public class WxPayService {
SysMt merchant = merchantMapper.findById(Integer.valueOf(merchantsArr[i]));
// 执行sql语句
int sql = -1;
if ("0".equals(cartArr[i])){
if (cartArr[i].equals("0")){
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(goodsArr[i]),notes,address,name,phone,code,way,merchant.getRatio());
@ -117,9 +117,10 @@ public class WxPayService {
* <p>js</p>
*/
public String[] getStringArray(String array){
List<String> list = new ArrayList<>();
return array.split(",");
}
/**
* <p></p>
*/
@ -144,20 +145,21 @@ public class WxPayService {
data.put("body", "捷阅网商品");
data.put("out_trade_no", orderMark);
data.put("device_info", orderMark);
BigDecimal temp = new BigDecimal(100);
data.put("total_fee", price);
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("product_id", orderMark);
String codeUrl = "";
try {
Map<String, String> resp = wxPay.unifiedOrder(data);
System.out.println(resp);
codeUrl = QRCodeUtil.zxingCodeCreate(resp.get("code_url"), "/data/pay/", 500, "");
QRCodeUtil.zxingCodeCreate(resp.get("code_url"),classPath+"/data/pay/",orderMark,500,"");
} catch (Exception e) {
e.printStackTrace();
}
orderMapper.updateCodeUrl(codeUrl, orderMark);
String codeUrl = "/data/pay/"+orderMark+".jpg";
orderMapper.updateCodeUrl(codeUrl,orderMark);
return codeUrl;
}
@ -179,7 +181,7 @@ public class WxPayService {
return result;
}
/**
* <p></p>
*/

View File

@ -11,10 +11,6 @@ server:
error:
include-exception: true
spring:
servlet:
multipart:
max-file-size: 50MB
max-request-size: 100MB
jmx:
enabled: false
application:
@ -26,7 +22,7 @@ spring:
url: jdbc:mysql://${site-url}:3306/jieyue?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
data:
elasticsearch:
cluster-nodes: ${site-url}:9200
cluster-nodes: 127.0.0.1:9200
cluster-name: elasticsearch
repositories:
enabled: true

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB