第一次提交

master
Bosen 2021-04-22 15:11:28 +08:00
parent 806fe5f99c
commit 3e1e310358
574 changed files with 124409 additions and 0 deletions

33
.gitignore vendored Normal file
View File

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

118
.mvn/wrapper/MavenWrapperDownloader.java vendored Normal file
View File

@ -0,0 +1,118 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}

BIN
.mvn/wrapper/maven-wrapper.jar vendored Normal file

Binary file not shown.

2
.mvn/wrapper/maven-wrapper.properties vendored Normal file
View File

@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

390
jieyue.sql Normal file
View File

@ -0,0 +1,390 @@
/*
Navicat Premium Data Transfer
Source Server : MySQL
Source Server Type : MySQL
Source Server Version : 50716
Source Host : localhost:3306
Source Schema : jieyue
Target Server Type : MySQL
Target Server Version : 50716
File Encoding : 65001
Date: 22/04/2021 14:57:16
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for sys_access
-- ----------------------------
DROP TABLE IF EXISTS `sys_access`;
CREATE TABLE `sys_access` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '权限名称',
`url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '权限对应的地址',
`status` tinyint(3) NOT NULL DEFAULT 1 COMMENT '1启用 0未启用',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_access
-- ----------------------------
INSERT INTO `sys_access` VALUES (1, '权限管理页面', '/admin/rbac', 1);
INSERT INTO `sys_access` VALUES (2, '后台主页', '/admin/home', 1);
INSERT INTO `sys_access` VALUES (3, '广告设置页面', '/admin/ui', 1);
INSERT INTO `sys_access` VALUES (4, '订单列表页面', '/admin/order', 1);
INSERT INTO `sys_access` VALUES (5, '商户列表页面', '/admin/merchant/', 1);
INSERT INTO `sys_access` VALUES (6, '会员列表页面', '/admin/user', 1);
INSERT INTO `sys_access` VALUES (7, '系统消息页面', '/admin/notice', 1);
-- ----------------------------
-- Table structure for sys_admin
-- ----------------------------
DROP TABLE IF EXISTS `sys_admin`;
CREATE TABLE `sys_admin` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`password` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`email` varchar(75) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`mark` tinyint(3) NOT NULL COMMENT '管理员标记',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `email`(`email`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_admin
-- ----------------------------
INSERT INTO `sys_admin` VALUES (1, 'bosen', 'e10adc3949ba59abbe56e057f20f883e', 'bosen_once@163.com', 1);
-- ----------------------------
-- Table structure for sys_admin_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_admin_role`;
CREATE TABLE `sys_admin_role` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`admin_id` int(11) NOT NULL,
`role_id` int(11) NOT NULL,
`status` tinyint(3) NOT NULL DEFAULT 1 COMMENT '1启用 0未启用',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_admin_role
-- ----------------------------
INSERT INTO `sys_admin_role` VALUES (1, 1, 1, 1);
-- ----------------------------
-- Table structure for sys_cart
-- ----------------------------
DROP TABLE IF EXISTS `sys_cart`;
CREATE TABLE `sys_cart` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`goods_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`goods_num` int(11) NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_cart
-- ----------------------------
INSERT INTO `sys_cart` VALUES (4, 40, 2, 1);
INSERT INTO `sys_cart` VALUES (5, 39, 2, 1);
INSERT INTO `sys_cart` VALUES (7, 18, 2, 1);
INSERT INTO `sys_cart` VALUES (8, 41, 1, 1);
-- ----------------------------
-- Table structure for sys_comment
-- ----------------------------
DROP TABLE IF EXISTS `sys_comment`;
CREATE TABLE `sys_comment` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` int(11) NOT NULL,
`goods` int(11) NOT NULL,
`merchant` int(11) NOT NULL,
`context` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`create_time` bigint(19) NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 23 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_comment
-- ----------------------------
INSERT INTO `sys_comment` VALUES (17, 1, 40, 9, 'PUMA彪马官方 新款条纹棒球帽 ARCHIVE LOGO 022554 粗呢蓝-条纹-09 均码', 1607241751568);
INSERT INTO `sys_comment` VALUES (18, 1, 38, 8, '阿迪达斯官网adidas 三叶草TEE男装短袖上衣 DV1922 DV1925DV1929 粉蓝 XL(参考身高:188~192CM)', 1610197695733);
INSERT INTO `sys_comment` VALUES (19, 1, 44, 8, '测试测试测试测试测试测试测试测试测试测试测试测试测试', 1610247776515);
INSERT INTO `sys_comment` VALUES (20, 1, 44, 8, '测试测试测试测试测试测试测试测试测试测试测试测试测试', 1610247780833);
INSERT INTO `sys_comment` VALUES (21, 1, 44, 8, '测试测试测试测试测试测试测试测试测试测试测试测试测试', 1610247784508);
INSERT INTO `sys_comment` VALUES (22, 1, 44, 8, '测试测试测试测试测试测试测试测试测试测试测试测试测试', 1610247789686);
-- ----------------------------
-- Table structure for sys_goods
-- ----------------------------
DROP TABLE IF EXISTS `sys_goods`;
CREATE TABLE `sys_goods` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`describe` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`img` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '/image/user/home/product/15.jpg',
`price` decimal(10, 2) NOT NULL,
`state` tinyint(3) NOT NULL DEFAULT 1 COMMENT '1已上架 0未上架',
`merchant` int(11) NOT NULL COMMENT '商品所属的商户id',
`stock` int(11) NOT NULL DEFAULT 0 COMMENT '商品库存',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 45 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_goods
-- ----------------------------
INSERT INTO `sys_goods` VALUES (11, '耐克NIKE 男子 板鞋 AJ1', '耐克NIKE 男子 板鞋 AJ1 乔1 AIR JORDAN 1 LOW SE 休闲鞋 CK3022-005黑色44码', '/data/goods/5/20201109204752392935.jpg', 0.01, 1, 5, 1);
INSERT INTO `sys_goods` VALUES (12, '耐克NIKE 男子 板鞋 经典', '耐克NIKE 男子 板鞋 经典 板鞋 COURT VISION MID 休闲鞋 CD5466-101白色42码', '/data/goods/5/20201109205306213001.jpg', 0.01, 1, 5, 1);
INSERT INTO `sys_goods` VALUES (13, '休闲鞋 CD5463-200', '耐克NIKE 男子 板鞋 经典 板鞋 COURT VISION LOW 休闲鞋 CD5463-200亚麻色44码', '/data/goods/5/20201109205751273390.jpg', 0.01, 1, 5, 1);
INSERT INTO `sys_goods` VALUES (14, '板鞋 AO2810-001', '耐克NIKE 女子 简约 百搭 COURT ROYALE AC 板鞋 AO2810-001黑色36码', '/data/goods/5/20201109205945154276.jpg', 0.01, 1, 5, 1);
INSERT INTO `sys_goods` VALUES (15, '休闲鞋 CZ1055-109', '耐克NIKE 女子 板鞋 经典 BLAZER MID \'77 CZ1055-10936.5', '/data/goods/5/20201109210325235653.jpg', 0.01, 1, 5, 1);
INSERT INTO `sys_goods` VALUES (17, '运动鞋 CJ0291-005', '耐克NIKE 男子 气垫 跑步鞋 缓震 ZOOM WINFLO 7 运动鞋 CJ0291-005黑色42码', '/data/goods/5/20201109210622705242.jpg', 0.01, 1, 5, 1);
INSERT INTO `sys_goods` VALUES (18, '运动鞋 AV4789-100', '耐克NIKE 男子 休闲鞋 缓震 M2K TEKNO 运动鞋 AV4789-100顶峰白色42码', '/data/goods/5/20201110142709402793.jpg', 0.01, 1, 5, 1);
INSERT INTO `sys_goods` VALUES (19, '运动鞋 AO0269-101', '耐克NIKE 男子 老爹鞋 气垫 ZOOM 2K 运动鞋 AO0269-101白色42.5码', '/data/goods/5/20201110142841106068.jpg', 0.01, 1, 5, 1);
INSERT INTO `sys_goods` VALUES (20, '运动鞋 CK6467-001', '耐克 NIKE 男子 板鞋/复刻鞋 AIR MAX 90 NRG 运动鞋 CK6467-001 黑色 42码', '/data/goods/5/20201110143028570004.jpg', 0.01, 1, 5, 1);
INSERT INTO `sys_goods` VALUES (21, '拖鞋 JORDAN', '耐克 NIKE 中性大童 拖鞋 JORDAN HYDRO XII RETRO BG 运动鞋 820267-107 白色 37.5码', '/data/goods/5/20201110143155960319.jpg', 0.01, 1, 5, 1);
INSERT INTO `sys_goods` VALUES (22, '休闲鞋 NIKE DROP-TYPE', '耐克 NIKE 男子 休闲鞋 NIKE DROP-TYPE MID 运动鞋 BQ5190-300绿 43码', '/data/goods/5/20201110143316976441.jpg', 0.01, 1, 5, 1);
INSERT INTO `sys_goods` VALUES (23, '运动鞋 CZ8681-167', '耐克NIKE 女子 休闲鞋 复古 DAYBREAK 运动鞋 CZ8681-167帆白色38码', '/data/goods/5/20201110143451872085.jpg', 0.01, 1, 5, 1);
INSERT INTO `sys_goods` VALUES (25, '运动外套GE5175', '阿迪达斯官网 adidas neo W ESNTL 3S WB 女装运动外套GE5175 如图 L', '/data/goods/8/20201110214136520879.jpg', 0.01, 1, 8, 1);
INSERT INTO `sys_goods` VALUES (26, '防风衣ED7539', '阿迪达斯官网 adidas 三叶草LOCK UP TT女装防风衣ED7539 ED7541 淡粉紫灰 32(参考身高:160~165CM)', '/data/goods/8/20201110224214151666.jpg', 0.01, 1, 8, 1);
INSERT INTO `sys_goods` VALUES (28, '防风衣 DV0857', '阿迪达斯官网 adidas 三叶草 女装防风衣 DV0857 DW3890 DX3694 浅粉紫 38(参考身高:169~172CM)', '/data/goods/8/20201110224428269386.jpg', 0.01, 1, 8, 1);
INSERT INTO `sys_goods` VALUES (29, '防风衣 ED7217', '阿迪达斯官网 adidas 三叶草 男装防风衣 ED7217 FL1763 黑色 S(参考身高:173~178CM)', '/data/goods/8/20201110224542348334.jpg', 0.01, 1, 8, 1);
INSERT INTO `sys_goods` VALUES (30, '冬季运动羽绒服FL0036', '阿迪达斯官网 adidas 三叶草 DOWN JACKET 女装冬季运动羽绒服FL0036 黑色 34(参考身高:164~167CM)', '/data/goods/8/20201110224729185763.jpg', 0.01, 1, 8, 1);
INSERT INTO `sys_goods` VALUES (31, '运动棉服FJ6523', '阿迪达斯官网adidas 三叶草 女装冬季运动棉服FJ6523 黑色 34(参考身高:164~167CM)', '/data/goods/8/20201110224846847911.jpg', 0.01, 1, 8, 1);
INSERT INTO `sys_goods` VALUES (32, '运动棉服 ED7601', '阿迪达斯官网 adidas 三叶草 LONG BOMBER 女装冬季运动棉服 ED7601 亮光粉 40(参考身高:170~175CM)', '/data/goods/8/20201110225011851415.jpg', 0.01, 1, 8, 1);
INSERT INTO `sys_goods` VALUES (34, '冬季运动棉服GL6407 ', '阿迪达斯官网 adidas 三叶草 Short Sherpa 女装冬季运动棉服GL6407 森林绿/传奇墨水蓝 40(参考身高:170~175CM)', '/data/goods/8/20201110225219159233.jpg', 0.01, 1, 8, 1);
INSERT INTO `sys_goods` VALUES (35, '连帽外套DN8151', '阿迪达斯官网 adidas 三叶草 3STR ZIP HOODIE女装连帽外套DN8151 如图 34', '/data/goods/8/20201110225330615623.jpg', 0.01, 1, 8, 1);
INSERT INTO `sys_goods` VALUES (36, '连帽外套 DV1935', '阿迪达斯官网 adidas 三叶草 FZ HOODY 男装连帽外套 DV1935 绿 XL(参考身高:188~192CM)', '/data/goods/8/20201110225449776961.jpg', 0.01, 1, 8, 1);
INSERT INTO `sys_goods` VALUES (37, '短袖上衣 CE1666', '阿迪达斯官网 adidas 三叶草 女装短袖上衣 CE1666 CE1667 白 32(参考身高:160~165CM)', '/data/goods/8/20201110225601894276.jpg', 0.01, 1, 8, 1);
INSERT INTO `sys_goods` VALUES (38, '短袖上衣 DV1922', '阿迪达斯官网adidas 三叶草TEE男装短袖上衣 DV1922 DV1925DV1929 粉蓝 XL(参考身高:188~192CM)', '/data/goods/8/20201110225703611247.jpg', 0.01, 1, 8, 1);
INSERT INTO `sys_goods` VALUES (39, '棒球帽 ARCHIVE', 'PUMA彪马官方 杨洋同款新款棒球帽 ARCHIVE LOGO LABEL 022778 粉紫色 06 ADULT', '/data/goods/9/20201112192043550007.jpg', 0.01, 1, 9, 0);
INSERT INTO `sys_goods` VALUES (40, '条纹棒球帽 ARCHIVE', 'PUMA彪马官方 新款条纹棒球帽 ARCHIVE LOGO 022554 粗呢蓝-条纹-09 均码', '/data/goods/9/20201112192208777150.jpg', 0.01, 1, 9, 1);
INSERT INTO `sys_goods` VALUES (41, '运动休闲手提包', 'PUMA彪马官方娜扎同款新款女子运动休闲手提包 PRIME PUFFA 078192 银色 02 OSFA/均码', '/data/goods/9/20201112192355215509.jpg', 0.01, 1, 9, 1);
INSERT INTO `sys_goods` VALUES (44, '测试商品(勿拍)', '测试测试测试测试测试测试测试测试测试测试测试测试测试', '/data/goods/8/20210109201101998677.jpg', 0.01, 1, 8, 20);
-- ----------------------------
-- Table structure for sys_mt
-- ----------------------------
DROP TABLE IF EXISTS `sys_mt`;
CREATE TABLE `sys_mt` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`password` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`ratio` float(11, 1) NOT NULL COMMENT '商户每单收费需要支付的费率',
`state` tinyint(3) NOT NULL COMMENT '1启用 0未启用 2未通过注册',
`header` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '/lib/merchant/images/2.png',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `email`(`email`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_mt
-- ----------------------------
INSERT INTO `sys_mt` VALUES (5, 'Nike耐克', 'nike@qq.com', 'e10adc3949ba59abbe56e057f20f883e', 0.1, 1, '/data/header/merchant/5.jpg');
INSERT INTO `sys_mt` VALUES (8, 'Adidas阿迪达斯', 'adidas@qq.com', 'e10adc3949ba59abbe56e057f20f883e', 0.1, 1, '/data/header/merchant/20201130143514856044.jpg');
INSERT INTO `sys_mt` VALUES (9, 'Puma彪马', 'puma@qq.com', 'e10adc3949ba59abbe56e057f20f883e', 0.1, 0, '/data/header/merchant/20201130144501417757.jpg');
-- ----------------------------
-- Table structure for sys_mt_ui
-- ----------------------------
DROP TABLE IF EXISTS `sys_mt_ui`;
CREATE TABLE `sys_mt_ui` (
`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,
`merchant` int(11) NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_mt_ui
-- ----------------------------
INSERT INTO `sys_mt_ui` VALUES (5, '/data/mtui/5/20201111171430806651.jpg', 400, 320, 5);
INSERT INTO `sys_mt_ui` VALUES (6, '/data/mtui/5/20201111171436443523.jpg', 600, 310, 5);
INSERT INTO `sys_mt_ui` VALUES (8, '/data/mtui/8/20201111172245637416.jpg', 600, 310, 8);
INSERT INTO `sys_mt_ui` VALUES (9, '/data/mtui/9/20201111174106561114.jpg', 400, 320, 9);
INSERT INTO `sys_mt_ui` VALUES (10, '/data/mtui/9/20201111174116118997.jpg', 600, 310, 9);
INSERT INTO `sys_mt_ui` VALUES (12, '/data/mtui/8/20210109201740252613.jpg', 400, 320, 8);
-- ----------------------------
-- Table structure for sys_notice
-- ----------------------------
DROP TABLE IF EXISTS `sys_notice`;
CREATE TABLE `sys_notice` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`context` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '0给管理员发送 1 商户 2用户',
`receive` int(11) NOT NULL COMMENT '接收者的id',
`create_time` bigint(20) NOT NULL COMMENT '通知发送时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 30 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_notice
-- ----------------------------
INSERT INTO `sys_notice` VALUES (1, '测试标题', '测试内容', '0', 1, 1607238236877);
INSERT INTO `sys_notice` VALUES (2, '测试标题', '测试内容', '0', 2, 1607238236897);
INSERT INTO `sys_notice` VALUES (3, '测试标题', '测试内容', '1', 5, 1607238276845);
INSERT INTO `sys_notice` VALUES (4, '测试标题', '测试内容', '1', 8, 1607238276846);
INSERT INTO `sys_notice` VALUES (5, '测试标题', '测试内容', '1', 9, 1607238276847);
INSERT INTO `sys_notice` VALUES (7, '测试标题', '测试内容', '2', 2, 1607238284600);
INSERT INTO `sys_notice` VALUES (8, '测试标题', '测试内容', '2', 3, 1607238284601);
INSERT INTO `sys_notice` VALUES (9, '测试标题', '测试内容', '2', 4, 1607238284601);
INSERT INTO `sys_notice` VALUES (11, '测试标题2', '测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2', '2', 3, 1609926809535);
INSERT INTO `sys_notice` VALUES (12, '测试标题2', '测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2', '2', 4, 1609926809536);
INSERT INTO `sys_notice` VALUES (13, '测试标题2', '测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2测试内容2', '2', 5, 1609926809536);
INSERT INTO `sys_notice` VALUES (14, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息', '2', 1, 1610251470774);
INSERT INTO `sys_notice` VALUES (15, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息', '2', 3, 1610251470775);
INSERT INTO `sys_notice` VALUES (16, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息', '2', 4, 1610251470776);
INSERT INTO `sys_notice` VALUES (17, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息', '2', 5, 1610251470776);
INSERT INTO `sys_notice` VALUES (18, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息', '0', 1, 1610251505029);
INSERT INTO `sys_notice` VALUES (19, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息', '0', 1, 1610251517513);
INSERT INTO `sys_notice` VALUES (20, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息', '0', 1, 1610251532490);
INSERT INTO `sys_notice` VALUES (21, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息', '0', 1, 1610251583253);
INSERT INTO `sys_notice` VALUES (22, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息', '2', 1, 1610251604151);
INSERT INTO `sys_notice` VALUES (23, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息', '2', 3, 1610251604152);
INSERT INTO `sys_notice` VALUES (24, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息', '2', 4, 1610251604153);
INSERT INTO `sys_notice` VALUES (25, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息', '2', 5, 1610251604153);
INSERT INTO `sys_notice` VALUES (26, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息', '2', 1, 1610251616814);
INSERT INTO `sys_notice` VALUES (27, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息', '2', 3, 1610251616814);
INSERT INTO `sys_notice` VALUES (28, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息', '2', 4, 1610251616815);
INSERT INTO `sys_notice` VALUES (29, '测试群发系统消息', '测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息测试群发系统消息', '2', 5, 1610251616815);
-- ----------------------------
-- Table structure for sys_order
-- ----------------------------
DROP TABLE IF EXISTS `sys_order`;
CREATE TABLE `sys_order` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_id` varchar(25) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`create_time` bigint(19) NOT NULL,
`pay_time` bigint(19) NULL DEFAULT NULL,
`goods_num` int(11) NOT NULL COMMENT '商品数量',
`order_state` tinyint(3) NOT NULL DEFAULT 0 COMMENT '1已支付 0未支付',
`order_mark` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '商品标记',
`order_user` int(11) NOT NULL COMMENT '用户id',
`order_merchant` int(11) NOT NULL COMMENT '商户id',
`order_price` decimal(10, 2) NOT NULL COMMENT '订单总金额',
`goods_id` int(11) NOT NULL,
`order_notes` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '订单特殊注释',
`user_address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '地址',
`user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '收件人',
`user_phone` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '电话号码',
`coupon_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '优惠卷代码',
`pay_way` tinyint(3) NOT NULL COMMENT '1支付宝 0微信支付',
`pay_code_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '支付链接',
`cart_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '批量购买的商品',
`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 = 95 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_order
-- ----------------------------
INSERT INTO `sys_order` VALUES (67, 'EGW202012340213807244213', 1607175487598, 1607175743564, 1, 1, 'AXW202012340213807246245', 1, 5, 0.01, 23, '', '测试', '测试', '测试', '', 0, '/data/pay/AXW202012340213807246245.jpg', NULL, 0.1);
INSERT INTO `sys_order` VALUES (68, 'OXH202012340214627915466', 1607175987049, 1607183449712, 1, 1, 'MYV202012340214627324440', 1, 8, 0.01, 36, '', '测试', '测试', '测试', '', 0, '/data/pay/MYV202012340214627324440.jpg', NULL, 0.1);
INSERT INTO `sys_order` VALUES (69, 'RJF202012340215418785117', 1607176458511, 1607183916993, 1, 1, 'BHL202012340215418546511', 1, 5, 0.01, 19, '', '测试', '测试', '测试', '', 0, '/data/pay/BHL202012340215418546511.jpg', NULL, 0.1);
INSERT INTO `sys_order` VALUES (70, 'OHJ202012340215418723349', 1607176458511, 1607183916993, 1, 1, 'BHL202012340215418546511', 1, 8, 0.01, 34, '', '测试', '测试', '测试', '', 0, '/data/pay/BHL202012340215418546511.jpg', NULL, 0.1);
INSERT INTO `sys_order` VALUES (71, 'TCR202012340221129763691', 1607177489871, 1607183147374, 1, 1, 'ZLA202012340221129912783', 1, 8, 0.01, 34, '', '测试', '测试', '测试', '', 0, '/data/pay/ZLA202012340221129912783.jpg', NULL, 0.1);
INSERT INTO `sys_order` VALUES (72, 'PPI202012340221129185744', 1607177489871, 1607183147374, 1, 1, 'ZLA202012340221129912783', 1, 5, 0.01, 19, '', '测试', '测试', '测试', '', 0, '/data/pay/ZLA202012340221129912783.jpg', NULL, 0.1);
INSERT INTO `sys_order` VALUES (89, 'AVZ202012341002051747406', 1607185251976, 1607185263967, 1, 1, 'KQU202012341002051161208', 1, 9, 0.01, 40, '', '测试', '测试', '测试', '', 0, '/data/pay/KQU202012341002051161208.jpg', NULL, 0.1);
INSERT INTO `sys_order` VALUES (90, 'WVW202012341002151359796', 1607185311336, 1607185323819, 1, 1, 'SDW202012341002151596097', 1, 5, 0.01, 13, '', '测试', '测试', '测试', '', 0, '/data/pay/SDW202012341002151596097.jpg', NULL, 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 (93, 'LID202012341004300509122', 1607186580573, 1607186595850, 1, 1, 'NFF202012341004300926613', 1, 5, 0.01, 19, '', '测试', '测试', '测试', '', 0, '/data/pay/NFF202012341004300926613.jpg', '10', 0.1);
-- ----------------------------
-- Table structure for sys_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '角色名',
`status` tinyint(3) NOT NULL DEFAULT 1 COMMENT '1已启用 0未启用',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_role
-- ----------------------------
INSERT INTO `sys_role` VALUES (1, '未定义角色', 1);
INSERT INTO `sys_role` VALUES (2, '超级管理员', 1);
INSERT INTO `sys_role` VALUES (3, '普通管理员', 1);
-- ----------------------------
-- Table structure for sys_role_access
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_access`;
CREATE TABLE `sys_role_access` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`role_id` int(11) NOT NULL,
`access_id` int(11) NOT NULL,
`status` tinyint(3) NOT NULL DEFAULT 1 COMMENT '1启用 0未启用',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_role_access
-- ----------------------------
INSERT INTO `sys_role_access` VALUES (9, 2, 1, 1);
INSERT INTO `sys_role_access` VALUES (10, 2, 2, 1);
INSERT INTO `sys_role_access` VALUES (11, 2, 3, 1);
INSERT INTO `sys_role_access` VALUES (12, 2, 4, 1);
INSERT INTO `sys_role_access` VALUES (13, 2, 5, 1);
-- ----------------------------
-- Table structure for sys_ui
-- ----------------------------
DROP TABLE IF EXISTS `sys_ui`;
CREATE TABLE `sys_ui` (
`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 = 17 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_ui
-- ----------------------------
INSERT INTO `sys_ui` VALUES (2, '/data/library/20201106191900642246.jpg', 1920, 737);
INSERT INTO `sys_ui` VALUES (5, '/data/library/20201106192206806286.jpg', 1230, 535);
INSERT INTO `sys_ui` VALUES (6, '/data/library/20210109210243296422.jpg', 475, 570);
INSERT INTO `sys_ui` VALUES (10, '/data/library/20201130223715934619.jpg', 3151, 282);
INSERT INTO `sys_ui` VALUES (15, '/data/library/20201130222817664532.jpg', 674, 264);
INSERT INTO `sys_ui` VALUES (16, '/data/library/20201201130048784144.jpeg', 3152, 282);
-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`password` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`mark` tinyint(3) NOT NULL COMMENT '0未启用 1已启用',
`header` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '/data/header/user/default.jpg',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `email`(`email`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- 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 (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 (5, 'lalalal', 'e10adc3949ba59abbe56e057f20f883e', '2390025289@qq.com', 0, '/data/header/user/default.jpg');
SET FOREIGN_KEY_CHECKS = 1;

310
mvnw vendored Normal file
View File

@ -0,0 +1,310 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

182
mvnw.cmd vendored Normal file
View File

@ -0,0 +1,182 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%

221
pom.xml Normal file
View File

@ -0,0 +1,221 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>jieyue</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>jieyue</name>
<description>Demo project for Spring Boot</description>
<properties>
<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>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>3.3.4.ALL</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<!--文件上传包-->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>
<!--io操作包-->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<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>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.3.5.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<!-- 二维码支持包 -->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>2.3.4.RELEASE</version>
</dependency>
<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>
</dependencies>
<build>
<finalName>ROOT</finalName>
<plugins>
<!--<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<verbose />
<bootclasspath>${java.home}/lib/rt.jar${path.separator}${java.home}/lib/jce.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>
<licenses>
<license>
<name>The BSD 3-Clause License</name>
<url>https://opensource.org/licenses/BSD-3-Clause</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<name>wxpay</name>
<url>https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=11_1</url>
</developer>
</developers>
<profiles>
<profile>
<id>release</id>
<distributionManagement>
<snapshotRepository>
<id>oss</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>oss</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</profile>
</profiles>
</project>

11
profiles.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<profilesXml xmlns="http://maven.apache.org/PROFILES/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/PROFILES/1.0.0 http://maven.apache.org/xsd/profiles-1.0.0.xsd">
<profiles>
<profile>
<id></id>
</profile>
</profiles>
</profilesXml>

View File

@ -0,0 +1,50 @@
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;
@MapperScan("com.example.jieyue.common.mapper")// mapper扫描
@SpringBootApplication
@ServletComponentScan
@EnableScheduling// 定时任务
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);
}
/*
*
*/
@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

@ -0,0 +1,40 @@
package com.example.jieyue.admin.controller;
import com.example.jieyue.common.mapper.SysGoodsMapper;
import com.example.jieyue.common.mapper.SysOrderMapper;
import com.example.jieyue.common.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
/**
* <p></p>
* @author Bosen
* 2020/11/3 20:38
*/
@RestController
public class AdminHomeController {
@Autowired
SysOrderMapper orderMapper;
@Autowired
SysGoodsMapper goodsMapper;
@Autowired
SysUserMapper userMapper;
@RequestMapping("/admin/home")
public ModelAndView index(ModelAndView modelAndView){
float profit = orderMapper.websiteProfitCount();
int orderCount = orderMapper.payCount();
int goodsCount = goodsMapper.allGoodsCount();
int userCount = userMapper.userCount();
modelAndView.addObject("profit",profit);
modelAndView.addObject("orderCount",orderCount);
modelAndView.addObject("goodsCount",goodsCount);
modelAndView.addObject("userCount",userCount);
modelAndView.setViewName("admin/home/index");
return modelAndView;
}
}

View File

@ -0,0 +1,119 @@
package com.example.jieyue.admin.controller;
import com.example.jieyue.admin.service.AdminLoginService;
import com.example.jieyue.common.entity.SysAdmin;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* <p></p>
* @author Bosen
* 2020/11/3 14:03
*/
@RestController
@RequestMapping("/admin")
public class AdminLoginController {
@Autowired
AdminLoginService service;
/*
*
*/
@RequestMapping({"login",""})
public ModelAndView index(ModelAndView modelAndView){
modelAndView.setViewName("admin/login/index");
return modelAndView;
}
/*
*
*/
@RequestMapping("do-login")
public ModelAndView doLogin(HttpSession session, ModelAndView modelAndView,String email, String password){
int result = service.doLogin(email,password);
if (result==1){
// 登陆成功
SysAdmin admin = service.adminInfo(email);
session.setAttribute("admin",admin);
modelAndView.setViewName("redirect:/admin/home");
}else if (result==-1){
// 用户名或密码错误!
modelAndView.addObject("msg","用户名或密码错误!");
modelAndView.setViewName("redirect:login");
}else if (result==0){
// 必填信息不能为空!
modelAndView.addObject("msg","必填信息不能为空!");
modelAndView.setViewName("redirect:login");
}
return modelAndView;
}
/*
* 退
*/
@RequestMapping("logout")
public ModelAndView logout(ModelAndView modelAndView,HttpSession session){
session.setAttribute("merchant",null);
modelAndView.setViewName("redirect:/admin/login");
return modelAndView;
}
/*
*
*/
@RequestMapping("sign-up")
public ModelAndView signUp(ModelAndView modelAndView,String name,String email,String password){
int result = service.singup(email,email,password);
if (result==0){
// 必填信息不能为空!
modelAndView.addObject("msg","必填信息不能为空!");
}
if (result==4){
// 该邮箱已被注册
modelAndView.addObject("msg","该邮箱已被注册");
}
if (result==3){
// 邮箱格式不正确
modelAndView.addObject("msg","邮箱格式不正确");
}
if (result==2){
// 两次密码输入不一致
modelAndView.addObject("msg","两次密码输入不一致");
}
if (result==1){
// 验证邮件已发送,请留意您的邮箱
modelAndView.addObject("msg","验证邮件已发送,请留意您的邮箱");
}
if (result==-1){
// 验证邮件发送失败,请重试
modelAndView.addObject("msg","注册超时,请重试");
}
modelAndView.setViewName("redirect:login");
return modelAndView;
}
/*
*
*/
@RequestMapping("sign-check")
public ModelAndView singCheck(ModelAndView modelAndView,@Param("email") String email){
int res = service.singCheck(email);
if (res==-1){
modelAndView.setViewName("redirect:/error");
}
if (res==0){
modelAndView.addObject("网络超时请重试");
modelAndView.setViewName("redirect:login");
}
if (res==1){
modelAndView.addObject("msg","注册成功");
modelAndView.setViewName("redirect:login");
}
return modelAndView;
}
}

View File

@ -0,0 +1,122 @@
package com.example.jieyue.admin.controller;
import com.example.jieyue.admin.service.AdminMerchantService;
import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.mapper.SysMtMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* <p></p>
* @author Bosen
* 2020/11/8 10:50
*/
@RestController
@RequestMapping("/admin/merchant")
public class AdminMerchantController {
@Autowired
AdminMerchantService merchantService;
@Autowired
SysMtMapper merchantMapper;
@RequestMapping("")
public ModelAndView index(ModelAndView modelAndView, HttpServletRequest request){
modelAndView.setViewName("/admin/merchant/index");
int pageSize = 10;
int pageCount = merchantService.getMtPage(pageSize);
int num = 1;
int preNum = 1;
int nextNum = 1;
if (request.getParameter("num")!=null){
num = Integer.parseInt(request.getParameter("num"));
}
if (num <= 1){
preNum = 1;
nextNum = 2;
}else{
preNum = num-1;
if (num>=pageCount-1){
nextNum = pageCount;
}else{
nextNum = num+1;
}
}
List<SysMt> mtList = merchantService.getMtInfo(num,pageSize);
if (mtList.size()<=10){
nextNum = num;
}
modelAndView.addObject("mtList",mtList);
modelAndView.addObject("pageCount",pageCount);
modelAndView.addObject("nextNum",nextNum);
modelAndView.addObject("preNum",preNum);
modelAndView.addObject("num",num);
return modelAndView;
}
@RequestMapping("update-ratio")
public ModelAndView updateRatio(ModelAndView modelAndView,String ratio,int id){
try {
float ratioFloat = Float.valueOf(ratio);
if (ratioFloat > 1.0 || ratioFloat < 0.1 || !checkFloat(ratioFloat)){
modelAndView.addObject("msg","费率应在0.1~1.0之间(一位小数)");
}else{
if (merchantMapper.updateRatio(id,ratioFloat)==1){
modelAndView.addObject("msg","修改成功");
}else{
modelAndView.addObject("msg","修改失败");
}
}
}catch (Exception e){
modelAndView.addObject("msg","输入的费率不合法");
}
modelAndView.setViewName("redirect:/admin/merchant");
return modelAndView;
}
/*
*
*/
@RequestMapping("delete-merchant")
public ModelAndView deleteMerchant(ModelAndView modelAndView,int id){
if (merchantService.deleteMerchant(id)==1){
modelAndView.addObject("msg","删除商户成功!");
}else{
modelAndView.addObject("msg","删除商户失败!");
}
modelAndView.setViewName("redirect:/admin/merchant");
return modelAndView;
}
/*
*
*/
@RequestMapping("update-merchant")
public ModelAndView updateMerchant(ModelAndView modelAndView,String email,int state){
if (merchantService.updateMerchantState(email,state)==1){
modelAndView.addObject("msg","操作成功!");
}else{
modelAndView.addObject("msg","操作失败!");
}
modelAndView.setViewName("redirect:/admin/merchant");
return modelAndView;
}
/*
*
*/
public boolean checkFloat(float ratio){
char[] c = String.valueOf(ratio).split(".")[1].toCharArray();
if (c.length > 1){
return true;
}
return false;
}
}

View File

@ -0,0 +1,37 @@
package com.example.jieyue.admin.controller;
import com.example.jieyue.admin.service.AdminNoticeService;
import com.example.jieyue.common.utils.IsEmptyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
@RestController
public class AdminNoticeController {
@Autowired
AdminNoticeService noticeService;
@Autowired
IsEmptyUtil isEmptyUtil;
@RequestMapping("/admin/notice")
public ModelAndView index(ModelAndView modelAndView){
modelAndView.setViewName("admin/notice/index");
return modelAndView;
}
/*
* redis
*/
@RequestMapping("/admin/send-notice")
public ModelAndView sendNotice(ModelAndView modelAndView,String title,String context,int type){
if (isEmptyUtil.strings(title,context)){
modelAndView.addObject("msg","必填信息不能为空");
}else{
noticeService.send(title,context,type);
modelAndView.addObject("msg","系统消息发送成功");
}
modelAndView.setViewName("redirect:/admin/notice");
return modelAndView;
}
}

View File

@ -0,0 +1,53 @@
package com.example.jieyue.admin.controller;
import com.example.jieyue.admin.service.AdminOrderService;
import com.example.jieyue.common.entity.SysOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
/**
* <p></p>
* @author Bosen
* 2020/12/1 13:02
*/
@RestController
public class AdminOrderController {
@Autowired
AdminOrderService orderService;
@RequestMapping("/admin/order")
public ModelAndView index(ModelAndView modelAndView,@RequestParam(defaultValue = "2")int flag, @RequestParam(defaultValue = "1")int page){
// 获取订单信息
List<SysOrder> orderList = orderService.getOrderList(page,18,flag);
modelAndView.addObject("orderList",orderList);
// 获取订单总页数
int allPage = orderService.getAllPage(flag,18);
modelAndView.addObject("page",page);
modelAndView.addObject("flag",flag);
modelAndView.addObject("allPage",allPage);
modelAndView.setViewName("admin/order/index");
return modelAndView;
}
@RequestMapping("/admin/search-order")
public ModelAndView searchOrder(ModelAndView modelAndView,String order){
// 获取订单信息
List<SysOrder> orderList = orderService.getOrderById(order);
modelAndView.addObject("orderList",orderList);
// 获取订单总页数
modelAndView.addObject("page",1);
modelAndView.addObject("flag",2);
modelAndView.addObject("allPage",1);
modelAndView.setViewName("admin/order/index");
return modelAndView;
}
}

View File

@ -0,0 +1,291 @@
package com.example.jieyue.admin.controller;
import com.example.jieyue.admin.service.AdminRbacService;
import com.example.jieyue.common.entity.*;
import com.example.jieyue.common.mapper.*;
import com.example.jieyue.common.utils.IsEmptyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
public class AdminRbacController {
@Autowired
AdminRbacService rbacService;
@Autowired
SysAdminMapper adminMapper;
@Autowired
SysRoleMapper roleMapper;
@Autowired
SysAccessMapper accessMapper;
@Autowired
SysAdminRoleMapper adminRoleMapper;
@Autowired
SysRoleAccessMapper roleAccessMapper;
@Autowired
IsEmptyUtil isEmptyUtil;
@RequestMapping("/admin/rbac")
public ModelAndView index(ModelAndView modelAndView){
// 管理员列表
List<SysAdmin> adminList = adminMapper.findAll();
// 角色列表
List<SysRole> roleList = roleMapper.findAll();
// 权限列表
List<SysAccess> accessList = accessMapper.findAll();
modelAndView.addObject("adminList",adminList);
modelAndView.addObject("roleList",roleList);
modelAndView.addObject("accessList",accessList);
modelAndView.setViewName("admin/rbac/index");
return modelAndView;
}
/*
*
* todo
*/
@RequestMapping("/admin/rbac/update-admin-role")
public ModelAndView updateAdminRole(ModelAndView modelAndView,int adminId){
// 获取管理员角色信息
SysAdminRole adminRole = adminRoleMapper.findByAdminId(adminId);
modelAndView.addObject("adminRole",adminRole);
modelAndView.setViewName("updateRoleAccess");
return modelAndView;
}
/*
*
* todo
*/
@RequestMapping("/admin/rbac/update-admin-role-action")
public ModelAndView updateAdminRoleAction(ModelAndView modelAndView,int adminId,String roles){
modelAndView.setViewName("updateRoleAccess");
return modelAndView;
}
/*
*
*/
@RequestMapping("/admin/add-role")
public ModelAndView addRole(ModelAndView modelAndView,String name){
if (isEmptyUtil.strings(name)){
modelAndView.addObject("msg","请输入角色名");
}
if (roleMapper.countByName(name)!=0){
modelAndView.addObject("msg","此角色已存在");
}
if (roleMapper.insert(name)!=1){
modelAndView.addObject("msg","添加角色失败");
}else{
modelAndView.addObject("msg","添加角色成功");
}
modelAndView.setViewName("redirect:/admin/rbac");
return modelAndView;
}
/*
*
*/
@RequestMapping("/admin/add-access")
public ModelAndView addAccess(ModelAndView modelAndView,String name,String url){
if (isEmptyUtil.strings(name,url)){
modelAndView.addObject("msg","必填信息不能为空");
}
if (accessMapper.countByName(name)!=0){
modelAndView.addObject("msg","此权限已存在");
}
if (accessMapper.insert(name,url)!=1){
modelAndView.addObject("msg","添加权限失败");
}else{
modelAndView.addObject("msg","添加权限成功");
}
modelAndView.setViewName("redirect:/admin/rbac");
return modelAndView;
}
@RequestMapping("/admin/del-admin")
public ModelAndView delAdmin(ModelAndView modelAndView,int id){
modelAndView.setViewName("redirect:/admin/rbac");
if (id==1){
modelAndView.addObject("msg","无法删除此管理员");
return modelAndView;
}
if (adminMapper.deleteById(id)==1){
modelAndView.addObject("msg","删除管理员成功");
}else{
modelAndView.addObject("msg","删除管理员失败");
}
return modelAndView;
}
@RequestMapping("/admin/del-role")
public ModelAndView delRole(ModelAndView modelAndView,int id){
if (roleMapper.deleteById(id)==1){
modelAndView.addObject("msg","删除角色成功");
}else{
modelAndView.addObject("msg","删除角色失败");
}
modelAndView.setViewName("redirect:/admin/rbac");
return modelAndView;
}
@RequestMapping("/admin/del-access")
public ModelAndView delAccess(ModelAndView modelAndView,int id){
if (accessMapper.deleteById(id)==1){
modelAndView.addObject("msg","删除权限成功");
}else{
modelAndView.addObject("msg","删除权限失败");
}
modelAndView.setViewName("redirect:/admin/rbac");
return modelAndView;
}
/*
*
*/
@RequestMapping("/admin/off-admin")
public ModelAndView offAdmin(ModelAndView modelAndView,int id){
modelAndView.setViewName("redirect:/admin/rbac");
if (id==1){
modelAndView.addObject("无法停用此管理员!");
return modelAndView;
}
if (adminMapper.updateMarkById(id,0)==1){
modelAndView.addObject("msg","停用成功!");
}else{
modelAndView.addObject("msg","停用失败!");
}
return modelAndView;
}
/*
*
*/
@RequestMapping("/admin/on-admin")
public ModelAndView onAdmin(ModelAndView modelAndView,int id){
modelAndView.setViewName("redirect:/admin/rbac");
if (adminMapper.updateMarkById(id,1)==1){
modelAndView.addObject("msg","启用成功!");
}else{
modelAndView.addObject("msg","启用失败!");
}
return modelAndView;
}
/*
*
*/
@RequestMapping("/admin/off-role")
public ModelAndView offRole(ModelAndView modelAndView,int id){
modelAndView.setViewName("redirect:/admin/rbac");
if (roleMapper.updateStatus(0,id)==1){
modelAndView.addObject("msg","停用角色成功!");
}else{
modelAndView.addObject("msg","停用角色失败!");
}
return modelAndView;
}
/*
*
*/
@RequestMapping("/admin/on-role")
public ModelAndView onRole(ModelAndView modelAndView,int id){
modelAndView.setViewName("redirect:/admin/rbac");
if (roleMapper.updateStatus(1,id)==1){
modelAndView.addObject("msg","启用角色成功!");
}else{
modelAndView.addObject("msg","启用角色失败!");
}
return modelAndView;
}
/*
*
*/
@RequestMapping("/admin/on-access")
public ModelAndView onAccess(ModelAndView modelAndView,int id){
modelAndView.setViewName("redirect:/admin/rbac");
if (accessMapper.updateStatus(1,id)==1){
modelAndView.addObject("msg","启用权限成功!");
}else{
modelAndView.addObject("msg","启用权限失败!");
}
return modelAndView;
}
/*
*
*/
@RequestMapping("/admin/off-access")
public ModelAndView offAccess(ModelAndView modelAndView,int id){
modelAndView.setViewName("redirect:/admin/rbac");
if (accessMapper.updateStatus(0,id)==1){
modelAndView.addObject("msg","停用权限成功!");
}else{
modelAndView.addObject("msg","停用权限失败!");
}
return modelAndView;
}
/*
*
*/
@RequestMapping("/admin/update-access")
public ModelAndView updateAccess(ModelAndView modelAndView,int id,String name,String url){
modelAndView.setViewName("redirect:/admin/rbac");
if (accessMapper.updateInfo(id,name,url)==1){
modelAndView.addObject("msg","修改权限信息成功!");
}else{
modelAndView.addObject("msg","修改权限信息失败!");
}
return modelAndView;
}
/*
*
*/
@RequestMapping("/admin/role-access")
public ModelAndView roleAccessIndex(ModelAndView modelAndView,int id){
modelAndView.setViewName("/admin/rbac/role-access");
// 获取角色信息
SysRole role = roleMapper.findById(id);
// 获取角色的权限信息
List<SysRoleAccess> roleAccessList = roleAccessMapper.findByRoleId(id);
Map<Integer,SysRoleAccess> roleAccessMap = new HashMap<>();
for (SysRoleAccess sysRoleAccess : roleAccessList) {
roleAccessMap.put(sysRoleAccess.getAccessId(),sysRoleAccess);
}
// 获取全部权限信息
List<SysAccess> allAccessList = accessMapper.findAll();
modelAndView.addObject("role",role);
modelAndView.addObject("allAccessList",allAccessList);
modelAndView.addObject("roleAccessMap",roleAccessMap);
return modelAndView;
}
/*
*
*/
@RequestMapping("/admin/role-access/action")
public ModelAndView action(ModelAndView modelAndView,int role,int ... ids){
modelAndView.setViewName("redirect: /admin/role-access?id="+role);
if (rbacService.setRoleAccess(role,ids)){
modelAndView.addObject("msg","设置成功");
}else{
modelAndView.addObject("msg","设置失败");
}
return modelAndView;
}
}

View File

@ -0,0 +1,71 @@
package com.example.jieyue.admin.controller;
import com.example.jieyue.admin.service.AdminUiService;
import com.example.jieyue.common.entity.SysUi;
import com.example.jieyue.user.service.UserHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
* <p>UI</p>
* @author Bosen
* 2020/11/4 21:00
*/
@RestController
public class AdminUiController {
@Autowired
AdminUiService adminUiService;
@Autowired
UserHomeService userHomeService;
@RequestMapping("/admin/ui")
public ModelAndView index(ModelAndView modelAndView){
modelAndView.setViewName("admin/ui/index");
Map<String, SysUi> imgMap = userHomeService.getImage();
modelAndView.addObject("imgMap",imgMap);
return modelAndView;
}
/**
* <p></p>
* @author Bosen
* 2020/11/5 18:56
*/
@RequestMapping("/admin/up-image")
public ModelAndView upImage(ModelAndView modelAndView, MultipartFile file, RedirectAttributes redirectAttributes, HttpServletRequest request,int width,int height){
if (file.getOriginalFilename().isEmpty()){
modelAndView.addObject("msg","文件上传失败");
}else{
String upFileResult = adminUiService.upImage(file,redirectAttributes,request,"/data/library/",width,height);
if (upFileResult==null){
modelAndView.addObject("msg","文件上传失败");
}else{
modelAndView.addObject("msg","文件上传成功");
}
}
modelAndView.setViewName("redirect:ui");
return modelAndView;
}
/*
*
*/
@RequestMapping("/admin/del-image")
public ModelAndView delImg(ModelAndView modelAndView,int width,int height){
modelAndView.setViewName("redirect:ui");
if (adminUiService.delImg(width,height)){
modelAndView.addObject("msg","删除成功");
}else{
modelAndView.addObject("msg","删除失败");
}
return modelAndView;
}
}

View File

@ -0,0 +1,33 @@
package com.example.jieyue.admin.controller;
import com.example.jieyue.admin.service.AdminUserService;
import com.example.jieyue.common.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
@RestController
public class AdminUserController {
@Autowired
AdminUserService userService;
@RequestMapping("/admin/user")
public ModelAndView index(ModelAndView modelAndView, @RequestParam(defaultValue = "1")int page){
// 获取订单信息
List<SysUser> userList = userService.getUserList(page,10);
modelAndView.addObject("userList",userList);
// 获取订单总页数
int allPage = userService.getAllPage(10);
modelAndView.addObject("page",page);
modelAndView.addObject("allPage",allPage);
modelAndView.setViewName("admin/user/index");
return modelAndView;
}
}

View File

@ -0,0 +1,145 @@
package com.example.jieyue.admin.service;
import com.example.jieyue.common.entity.SysAdmin;
import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.mapper.SysAdminMapper;
import com.example.jieyue.common.mapper.SysAdminRoleMapper;
import com.example.jieyue.common.service.MailService;
import com.example.jieyue.common.service.SysUserService;
import com.example.jieyue.common.utils.IsEmptyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.util.DigestUtils;
/**
* <p></p>
* @author Bosen
* 2020/11/3 19:06
*/
@Service
public class AdminLoginService {
@Autowired
SysAdminMapper adminMapper;
@Autowired
MailService mailService;
@Autowired
SysAdminRoleMapper adminRoleMapper;
@Value("${site-url}")
String sitrUrl;
// 判空工具类
IsEmptyUtil isEmptyUtil = IsEmptyUtil.getInstance();
/**
* <p></p>
* @return int
* 1
* 0
*-1
*/
public int doLogin(String email,String password){
SysAdmin admin = adminMapper.selectByEmail(email);
// 用户名密码不能为空
if (isEmptyUtil.strings(email,password)){
return 0;
}
// 不存在该用户
if (admin==null){
return -1;
}
// 密码验证
password = DigestUtils.md5DigestAsHex(password.getBytes());
// 密码错误
if (!admin.getPassword().equals(password)){
return -1;
}else{
return 1;
}
}
/*
*
*/
public SysAdmin adminInfo(String email){
return adminMapper.getAdminInfo(email);
}
/**
* <p></p>
* @return int
*-1
* 0
* 1
* 2
* 3
* 4
*/
public int singup(String email,String name,String password){
// 必填信息不能为空
if (isEmptyUtil.strings(email,name,password)){
return 0;
}
// 邮箱格式验证
if(!mailService.checkEmail(email)){
System.out.println(email);
return 3;
}
// 该邮箱已被注册
SysAdmin admin = adminMapper.selectByEmail(email);
password = DigestUtils.md5DigestAsHex(password.getBytes());
if (admin!=null){
if (admin.getMark()!=0){
return 4;
}else{
if (adminMapper.update(name,password,email)!=1){
return -1;
}
}
}else{
// 将信息保存状态置为0未启用
// 添加信息未成功返回超时
if (adminMapper.insert(name,password,email,0)!=1){
return -1;
}
}
// 发送注册验证邮件
boolean res = mailService.sendHtmlMail(email,"捷阅网管理员注册验证","<a href='http://"+this.sitrUrl+"admin/sign-check?email="+email+"'>点击此链接完成注册验证</a>");
if (res){
return 1;
}else{
return -1;
}
}
/**
*
* @return int
*-1 404
* 0
* 1
*/
@Transactional
public int singCheck(String email){
SysAdmin admin = adminMapper.selectByEmail(email);
if (admin!=null && admin.getMark()==0){
int res1 = adminMapper.updateMark(1,email);
if (res1==1){
// 设置用户角色,设置失败则回滚
if (adminRoleMapper.updateStatus(1,admin.getId()) != 1){
// 执行回滚
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return 0;
}
return 1;
}else{
return 0;
}
}else{
return -1;
}
}
}

View File

@ -0,0 +1,59 @@
package com.example.jieyue.admin.service;
import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.mapper.SysMtMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class AdminMerchantService {
@Autowired
SysMtMapper mtMapper;
/**
* <p></p>
*
* @param curPage
* @param pageSize
*/
public List<SysMt> getMtInfo(int curPage,int pageSize){
int curRow = (curPage-1)*pageSize;
return mtMapper.findPage(curRow,pageSize);
}
/*
*
*/
public int deleteMerchant(int merchantId){
if (mtMapper.deleteById(merchantId)==1){
return 1;
}
return -1;
}
/*
*
*/
public int updateMerchantState(String email,int state){
if (mtMapper.updateState(email,state)==1){
return 1;
}
return -1;
}
/*
*
*/
public int getMtPage(int pageSize){
if (mtMapper.count()==0){
return 1;
}else{
return (int)Math.ceil((double)mtMapper.count()/pageSize);
}
}
public int updateRatio(float ratio,int id){
return 1;
}
}

View File

@ -0,0 +1,72 @@
package com.example.jieyue.admin.service;
import com.example.jieyue.common.entity.SysAdmin;
import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.common.mapper.SysAdminMapper;
import com.example.jieyue.common.mapper.SysMtMapper;
import com.example.jieyue.common.mapper.SysNoticeMapper;
import com.example.jieyue.common.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class AdminNoticeService {
@Autowired
SysUserMapper userMapper;
@Autowired
SysMtMapper merchantMapper;
@Autowired
SysAdminMapper adminMapper;
@Autowired
SysNoticeMapper noticeMapper;
@Autowired
RedisTemplate redisTemplate;
/*
* redis
*/
public void send(String title,String context,int type){
Map<String,String> map = new HashMap<>();
map.put("title",title);
map.put("context",context);
map.put("type",type+"");
switch (type){
case 0:
// 获取信息
List<SysAdmin> adminList = adminMapper.findAll();
for (SysAdmin sysAdmin : adminList) {
long createTime = System.currentTimeMillis();
map.put("createTime",createTime+"");
map.put("receive",sysAdmin.getId()+"");
redisTemplate.opsForList().leftPush("notice",map);
}
break;
case 1:
// 获取信息
List<SysMt> merchantList = merchantMapper.findAll();
for (SysMt sysMt : merchantList) {
long createTime = System.currentTimeMillis();
map.put("createTime",createTime+"");
map.put("receive",sysMt.getId()+"");
redisTemplate.opsForList().leftPush("notice",map);
}
break;
case 2:
// 获取信息
List<SysUser> userList = userMapper.findAll();
for (SysUser sysUser : userList) {
long createTime = System.currentTimeMillis();
map.put("createTime",createTime+"");
map.put("receive",sysUser.getId()+"");
redisTemplate.opsForList().leftPush("notice",map);
}
break;
}
}
}

View File

@ -0,0 +1,59 @@
package com.example.jieyue.admin.service;
import com.example.jieyue.common.entity.SysOrder;
import com.example.jieyue.common.mapper.SysOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class AdminOrderService {
@Autowired
SysOrderMapper orderMapper;
/*
*
*/
public List<SysOrder> getOrderList(int page,int num,int flag){
switch (flag){
case 0:// 未支付
return orderMapper.findNotPayLimit((page-1)*num,num);
case 1:// 已支付
return orderMapper.findPayLimit((page-1)*num,num);
case 2:// 全部订单
return orderMapper.findLimit((page-1)*num,num);
}
return null;
}
/*
*
*/
public List<SysOrder> getOrderById(String orderId){
SysOrder order = orderMapper.findByOrderId(orderId);
List<SysOrder> list = new ArrayList<>();
if (order!=null){
list.add(order);
}
return list;
}
/*
*
*/
public int getAllPage(int flag,int num){
switch (flag){
case 0:// 未支付
return (int)Math.ceil((double)orderMapper.notPayCount()/(double)num);
case 1:// 已支付
return (int)Math.ceil((double)orderMapper.payCount()/(double)num);
case 2:// 全部订单
return (int)Math.ceil((double)orderMapper.orderCount()/(double)num);
case 3:
return 1;
}
return 1;
}
}

View File

@ -0,0 +1,44 @@
package com.example.jieyue.admin.service;
import com.example.jieyue.common.mapper.SysRoleAccessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
@Service
public class AdminRbacService {
@Autowired
SysRoleAccessMapper roleAccessMapper;
/**
* <p></p>
* @return 1 -1
* @author Bosen
* 2020/12/30 5:19
* TODO TODO TODO TODO
*/
public int updateAdminRoleAction(int adminId,String roles){
// 对使用json封装的js数组进行解析
return -1;
}
/*
*
*/
@Transactional
public boolean setRoleAccess(int role,int[] ids){
// 删除角色原权限
roleAccessMapper.deleteByRoleId(role);
for (int id : ids) {
if (roleAccessMapper.insert(role,id)!=1){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return false;
}
}
return true;
}
}

View File

@ -0,0 +1,80 @@
package com.example.jieyue.admin.service;
import com.example.jieyue.common.mapper.SysUiMapper;
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;
/**
*
*
* @return
* null
*
*/
public String upImage(MultipartFile file,RedirectAttributes redirectAttributes,
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);
if (result==null){
return null;
}else{
if (uiMapper.findByMark(weight,height) == null) {
int insertRes = uiMapper.insert(result, weight, height);
if (insertRes == 1) {
return filename;
} else {
// sql语句执行失败将已上传的图片移除
fileUtil.deleteFile(result);
return null;
}
}else{
// 删除旧图片
fileUtil.deleteFile(uiMapper.findByMark(weight,height).getUrl());
// 更改图片
int updateRes = uiMapper.updateUrl(result,weight,height);
if (updateRes == 1) {
return filename;
} else {
// sql语句执行失败将已上传的图片移除
fileUtil.deleteFile(result);
return null;
}
}
}
}
/*
*
*/
public boolean delImg(int width,int height){
if (uiMapper.findByMark(width,height)==null){
return false;
}else{
fileUtil.deleteFile(uiMapper.findByMark(width,height).getUrl());
int delResult = uiMapper.deleteByMark(width,height);
if (delResult == 1) {
return true;
} else {
// sql语句执行失败
return false;
}
}
}
}

View File

@ -0,0 +1,28 @@
package com.example.jieyue.admin.service;
import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.common.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class AdminUserService {
@Autowired
SysUserMapper userMapper;
/*
*
*/
public List<SysUser> getUserList(int page, int num){
return userMapper.findLimit((page-1)*num,num);
}
/*
*
*/
public int getAllPage(int num){
return (int)Math.ceil((double)userMapper.userCount()/(double)num);
}
}

View File

@ -0,0 +1,96 @@
package com.example.jieyue.alipay.config;
/* *
*AlipayConfig1
*
*
*2017-04-05
*
*便,使
*使
*/
import java.io.FileWriter;
import java.io.IOException;
public class AlipayConfig {
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
// 应用ID,您的APPID收款账号既是您的APPID对应支付宝账号
public static String app_id = "2021002114695818";
// 商户私钥您的PKCS8格式RSA2私钥
public static String merchant_private_key = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC/0lWCv81WoVbU\n" +
"yOTJ7jM9AV6YRmIOUhLqWHGA1wSXAG57NSkK7SifBcit61hdfZaYzDatmQQn5t4D\n" +
"S+gQ4rQwnerKzoTmWY6EKXV3BAawdLG30SRJhX0739l7Ul+X3giTIUG5R4fG9gTN\n" +
"XnmhGX4yTa2yir/IOeWJ0lqXoKRyxRclaMFsF8gW4EBk5S7PVzMhdjh7EV1D+2QB\n" +
"5baNIFaZvfByMr7V+q2+awlBH7ZoDbviyV+vHmZCC/dOLPaWLTkW+t+ih/z9rqaN\n" +
"fZIOTgaLB7g7hca7dnzCM/G1i2UNHWzU2mRfALK/ppvJKe7J7GTOSu92iVF5Yryr\n" +
"CUv6TcjDAgMBAAECggEAQtqStOwWK8A1XBncK0iakQN+LYIyQJ14PDaw8F+AGQSs\n" +
"fMJtWIKJassAQyVH+eWAbCaYU+6FlUaQUAPPkLsCZANVxnMtvH6v/f3ZE67SigNR\n" +
"wSfiBsHAgPKmgKWX7X0T7ftkRafZeY1a5RytNWmGIxARnq1e4/DRwDQRINF7HwhZ\n" +
"Crp/JXZYOYv/0dSRyV5l/S3J13m7NgimG7nejFc7rRhMS9gXQohD9pXcL8N1F+Af\n" +
"zpSf1AFyCvFA41cQO+SNPbpjXHv2k2WuBOFMt08Rxfn4DKiDhhK9eHN0nB9RVeWl\n" +
"DOY/6RiMketWvMqx5TCltE5WtGchEqYHVwNK6Tfe+QKBgQDt50tdoxisr+kj2JAA\n" +
"BQXZmz5isQpeUt3JruNOnw2hVSbMO60iftLTeB+GHX6hGvD5ViFEDgZotgjYL/p+\n" +
"AW7Dm0+D+ecWvVUhySrab/sMso/B33OCqYfPNdj780+fmqVRrRjnK/J4V0n5AoaC\n" +
"Rx0vfXfJUXonPZ+Jn8RSiW8CNwKBgQDOaa9ljnO6mcSr+k/I7Biq0e4ZFvl10M4G\n" +
"aMDE9AyiGUWn0JIERpLCZ0VIgOqtDXuJo5JwPfIHVppobBqaWdlKBuA2rIwynjls\n" +
"+jfplnVlAQKxkdRUM+8nXW24q0qsNFro+KsCE5y6tevxsHyXihmElv9AhRcsXY2g\n" +
"LM7BDzIX1QKBgQDTM2P38+Pi4qRB+28TZWIlJioDKZK/3Ccjdkw7rv5FvLed1ljE\n" +
"5/w4Wkr6IFMbqTRG1kzgAudzrC875ZQmqxTvOIEl9ARQbrMWNGYD2CfyxM7U2Y/N\n" +
"br2vmelQ+1czpPGhCd+y0pQGe8+i7bgGDiX91BA0vE2Kaq2oWxrJ/1J6jwKBgQCh\n" +
"RffRzHRllmEQ0dlmrfkz9iQnHEk6oTNn1I7RE7GPMVm4HYEIsC9YjyGV3Yv+O+uL\n" +
"Be+TnQKucx7feZ9re8oHScoDTduYbQGHQRVQf8snaJu3K66PP6iaxCfHQqZsV9ez\n" +
"8R6D19j8FMnNo8wlBrSbYPL8cUBC3LGcNYYxV3MXJQKBgQDbh5oML1AJ1FYvkMew\n" +
"v/xCNMvrsJDNPty4oZD3lXAqq2/rbHKxDqsB9PkVcd4xdHrYuHU+MbYeb96hHAyv\n" +
"seYiUCWF/XryBGI/7AcHTKpgBA9TXqudCyPUhz0ewC5vKnYdcqXXTjjL1WqILegj\n" +
"cSLF6WzY1X1kw7j9IuP6wyZQZg==";
// 支付宝公钥,查看地址https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuaRqJqDOBRNsIa1MkgyiR6kRUk+M8cbNmGFN0RDy1NJmxyaR/iqIi5k8vQZ+qnVelXTVVEEYKiYaIxj6co8ERKPXlrnk/GiRxn410jX35iLnm/BgwXaiVP1Fx6kusiXiCGWgrvEsbAMFvbZqyqT/z8m+ogQ7JPTkoauzzu16JJxpcSPEf7SPnbuiBjHbUqRGP1pAa1yVun0eVFHaFeqi+cRfGDhwym2xEAMokJh+aFlU3AnCg/f7fBek4UNi6anAadoX3dKcB8cNeIMzg5FaplZP2V0ztLg2Qvw4ezKSWUFB4hFD0d6De61zwpGjgl+ouobyL4prsUA3qlT48E8d8wIDAQAB";
// 服务器异步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数必须外网可以正常访问
public static String notify_url = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp";
// 页面跳转同步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数必须外网可以正常访问
public static String return_url = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp";
// 签名方式
public static String sign_type = "RSA2";
// 字符编码格式
public static String charset = "utf-8";
// 支付宝网关
public static String gatewayUrl = "https://openapi.alipay.com/gateway.do";
// 支付宝网关
public static String log_path = "C:\\";
//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
/**
* 便
* @param sWord
*/
public static void logResult(String sWord) {
FileWriter writer = null;
try {
writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
writer.write(sWord);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}

View File

@ -0,0 +1,42 @@
※运行环境※
Eclipse+JDK1.6及以上+Tomcat6.0及以上
※使用方法※
SDK下载地址
https://doc.open.alipay.com/docs/doc.htm?treeId=193&articleId=103419&docType=1
第一步请下载【JAVA版资源】的SDK。
第二步:下载完毕后,把压缩包解压。
第三步压缩包alipay-sdk-javaXXX.jar、commons-logging-1.1.1.jar架包文件放入工程项目alipay.trade.page.pay-PHP-UTF-8\WebContent\WEB-INF\lib中。
第四步打开AlipayConfig.java文件设置请求参数信息并保存请求参数信息有app_id、merchant_private_key、alipay_public_key、return_url、notify_url。
bizContent的各个请求参数用法与拼接方式见文档https://doc.open.alipay.com/docs/doc.htm?treeId=270&articleId=105899&docType=1
第五步运行index.jsp文件
第六步:体验支付流程,看效果等。
※业务处理注意事项※
请配置notify_url文件、return_url文件其中notify_url文件主要是写入业务处理逻辑代码请结合自身情况谨慎编写。
如何验证异步通知数据?
1、商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号
2、判断total_amount是否确实为该订单的实际金额即商户订单创建时的金额
3、校验通知中的seller_id或者seller_email) 是否为该笔交易对应的操作方一个商户可能有多个seller_id/seller_email
4、验证接口调用方的app_id
※说明※
本demo仅仅为学习参考使用请根据实际情况自行开发把功能嵌入您的项目或平台中。

View File

@ -0,0 +1,91 @@
package com.example.jieyue.common.component;
import com.example.jieyue.common.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* <p>
* 访
*
*
* </p>
* @author Bosen
* 2020/11/2 14:07
*/
@Component
public class LoginHandlerInterceptor implements HandlerInterceptor {
@Autowired
SysAdminMapper adminMapper;
@Autowired
SysRoleMapper roleMapper;
@Autowired
SysAccessMapper accessMapper;
@Autowired
SysAdminRoleMapper adminRoleMapper;
@Autowired
SysRoleAccessMapper roleAccessMapper;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 判断请求
String uri = request.getRequestURI();
String admin = "/admin[\\d\\w\\S]*";
String merchant = "/mer[\\d\\w\\S]*";
Pattern adminPattern = Pattern.compile(admin);
Pattern merchantPattern = Pattern.compile(merchant);
if(adminPattern.matcher(uri).matches()){
// admin
Object user = request.getSession().getAttribute("admin");
if (user == null) {
// 获取request返回页面到登录页
request.getRequestDispatcher("/admin/login").forward(request, response);
return false;
}
}else if (merchantPattern.matcher(uri).matches()){
// merchant
Object user = request.getSession().getAttribute("merchant");
if (user == null) {
// 获取request返回页面到登录页
request.getRequestDispatcher("/merchant/login").forward(request, response);
return false;
}
}else{
// user
Object user = request.getSession().getAttribute("user");
if (user == null) {
// 获取request返回页面到登录页
request.getRequestDispatcher("/user/login").forward(request, response);
return false;
}
}
return true;
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}
/**
* <p></p>
* @author Bosen
* 2020/12/7 7:09
*/
public boolean checkAdminAccess(int adminId,String url){
int roleId = adminRoleMapper.findByAdminId(adminId).getRoleId();
return false;
}
}

View File

@ -0,0 +1,35 @@
package com.example.jieyue.common.config;
import com.example.jieyue.common.component.LoginHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* <p></p>
* @author Bosen
* 2020/11/2 14:08
*/
@Configuration
public class AdminWebMvcConfigurer implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/index.html").setViewName("/admin/login");
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
/*
* 访
*/
registry.addInterceptor(new LoginHandlerInterceptor())
.addPathPatterns("/admin/**")
.excludePathPatterns(
"/admin/login","/admin/do-login","/admin/sign-up","/admin/sign-check",
"/css/**","/js/**","/image/**","/fonts/**","/mapping/**","/data/**",
"/lib/*/*/**"
);
}
}

View File

@ -0,0 +1,34 @@
package com.example.jieyue.common.config;
import com.example.jieyue.common.component.LoginHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* <p></p>
* @author Bosen
* 2020/11/2 14:08
*/
@Configuration
public class MerchantWebMvcConfigurer implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/index.html").setViewName("/merchant/login");
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
/*
* 访
*/
registry.addInterceptor(new LoginHandlerInterceptor())
.addPathPatterns("/mer*/**")
.excludePathPatterns(
"/merchant/login","/merchant/do-login","/merchant/sign-up","/merchant/sign-check",
"/css/**","/js/**","/image/**","/fonts/**","/mapping/**","/data/**",
"/lib/*/*/**"
);
}
}

View File

@ -0,0 +1,48 @@
package com.example.jieyue.common.config;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* <p>redis</p>
* @author Bosen
* 2020/12/6 13:54
*/
@Configuration
@EnableCaching
public class RedisConfigurer extends CachingConfigurerSupport {
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(connectionFactory);
// 使用Jackson2JsonRedisSerializer来序列化/反序列化redis的value值
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(
Object.class);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setVisibility(PropertyAccessor.ALL,
com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY);
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
// value
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
// 使用StringRedisSerializer来序列化/反序列化redis的key值
RedisSerializer<?> redisSerializer = new StringRedisSerializer();
// key
redisTemplate.setKeySerializer(redisSerializer);
redisTemplate.setHashKeySerializer(redisSerializer);
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
}

View File

@ -0,0 +1,20 @@
package com.example.jieyue.common.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.sql.DataSource;
@EnableTransactionManagement
@Configuration
public class TransactionManagerConfiguration {
@Autowired
private DataSource dataSource;
public TransactionManager createTransactionManager(){
return new DataSourceTransactionManager(dataSource);
}
}

View File

@ -0,0 +1,36 @@
package com.example.jieyue.common.config;
import com.example.jieyue.common.component.LoginHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* <p></p>
* @author Bosen
* 2020/11/2 14:08
*/
@Configuration
public class UserWebMvcConfigurer implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/index.html").setViewName("/user/login");
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
/*
* 访
*/
registry.addInterceptor(new LoginHandlerInterceptor())
.addPathPatterns("/user/**")
.excludePathPatterns(
"/","/user/home","/user/login","/user/do-login","/user/sign-up","/user/sign-check",
"/css/**","/js/**","/image/**","/fonts/**","/mapping/**","/data/**","/user/check-order-status",
"/lib/*/*/**","/user/about","/user/product","/user/shop","/user/search","/user/wxpay/notify",
"/user/pay/test"
);
}
}

View File

@ -0,0 +1,22 @@
package com.example.jieyue.common.controller;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.FileNotFoundException;
@RestController
public class TestController {
@RequestMapping("test")
public String test() throws FileNotFoundException {
return ResourceUtils.getFile("classpath:/static").getPath()+"\\";
}
@RequestMapping("/test/check")
public String check(int id){
System.out.println("id="+id);
return "This is test/check";
}
}

View File

@ -0,0 +1,40 @@
package com.example.jieyue.common.entity;
public class SysAccess {
private int id;
private String name;
private String url;
private int status;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}

View File

@ -0,0 +1,60 @@
package com.example.jieyue.common.entity;
public class SysAdmin {
private int id;
private String name;
private String password;
private String email;
private int mark;
@Override
public String toString() {
return "SysAdmin{" +
"id=" + id +
", name='" + name + '\'' +
", password='" + password + '\'' +
", email='" + email + '\'' +
", mark=" + mark +
'}';
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getMark() {
return mark;
}
public void setMark(int mark) {
this.mark = mark;
}
}

View File

@ -0,0 +1,40 @@
package com.example.jieyue.common.entity;
public class SysAdminRole {
private int id;
private int adminId;
private int roleId;
private int status;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getAdminId() {
return adminId;
}
public void setAdminId(int adminId) {
this.adminId = adminId;
}
public int getRoleId() {
return roleId;
}
public void setRoleId(int roleId) {
this.roleId = roleId;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}

View File

@ -0,0 +1,40 @@
package com.example.jieyue.common.entity;
public class SysCart {
private int id;
private int goodsId;
private int userId;
private int goodsNum;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getGoodsId() {
return goodsId;
}
public void setGoodsId(int goodsId) {
this.goodsId = goodsId;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public int getGoodsNum() {
return goodsNum;
}
public void setGoodsNum(int goodsNum) {
this.goodsNum = goodsNum;
}
}

View File

@ -0,0 +1,58 @@
package com.example.jieyue.common.entity;
public class SysComment {
private int id;
private int user;
private int goods;
private int merchant;
private String context;
private long createTime;
public int getMerchant() {
return merchant;
}
public void setMerchant(int merchant) {
this.merchant = merchant;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getUser() {
return user;
}
public void setUser(int user) {
this.user = user;
}
public int getGoods() {
return goods;
}
public void setGoods(int goods) {
this.goods = goods;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public long getCreateTime() {
return createTime;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
}

View File

@ -0,0 +1,91 @@
package com.example.jieyue.common.entity;
import java.math.BigDecimal;
public class SysGoods {
private int id;
private String name;
private String describe;
private String img;
private BigDecimal price;
private int state;
private int merchant;
private int stock;
@Override
public String toString() {
return "SysGoods{" +
"id=" + id +
", name='" + name + '\'' +
", describe='" + describe + '\'' +
", img='" + img + '\'' +
", price=" + price +
", state=" + state +
", merchant=" + merchant +
'}';
}
public int getStock() {
return stock;
}
public void setStock(int stock) {
this.stock = stock;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescribe() {
return describe;
}
public void setDescribe(String describe) {
this.describe = describe;
}
public String getImg() {
return img;
}
public void setImg(String img) {
this.img = img;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public int getMerchant() {
return merchant;
}
public void setMerchant(int merchant) {
this.merchant = merchant;
}
}

View File

@ -0,0 +1,67 @@
package com.example.jieyue.common.entity;
public class SysMt {
private int id;
private String name;
private String email;
private String password;
private float ratio;
private int state;
private String header;
public String getHeader() {
return header;
}
public void setHeader(String header) {
this.header = header;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public float getRatio() {
return ratio;
}
public void setRatio(float ratio) {
this.ratio = ratio;
}
}

View File

@ -0,0 +1,61 @@
package com.example.jieyue.common.entity;
public class SysMtUi {
private int id;
private String url;
private int width;
private int height;
private int merchant;
@Override
public String toString() {
return "SysMtUi{" +
"id=" + id +
", url='" + url + '\'' +
", width=" + width +
", height=" + height +
", merchant=" + merchant +
'}';
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getMerchant() {
return merchant;
}
public void setMerchant(int merchant) {
this.merchant = merchant;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}

View File

@ -0,0 +1,58 @@
package com.example.jieyue.common.entity;
public class SysNotice {
private int id;
private int type;
private String title;
private String context;
private int receive;
private long createTime;
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public int getReceive() {
return receive;
}
public void setReceive(int receive) {
this.receive = receive;
}
public long getCreateTime() {
return createTime;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
}

View File

@ -0,0 +1,187 @@
package com.example.jieyue.common.entity;
import java.math.BigDecimal;
public class SysOrder {
private int id;
private String orderId;
private long createTime;
private long payTime;
private int goodsNum;
private int orderState;
private String orderMark;
private int orderMerchant;
private int orderUser;
private int goodsId;
private BigDecimal orderPrice;
private String orderNotes;
private String userAddress;
private String userName;
private String couponCode;
private int payWay;
private String payCodeUrl;
private int cartId;
private float merchantRatio;
public float getMerchantRatio() {
return merchantRatio;
}
public void setMerchantRatio(float merchantRatio) {
this.merchantRatio = merchantRatio;
}
public int getCartId() {
return cartId;
}
public void setCartId(int cartId) {
this.cartId = cartId;
}
public String getPayCodeUrl() {
return payCodeUrl;
}
public void setPayCodeUrl(String payCodeUrl) {
this.payCodeUrl = payCodeUrl;
}
public int getPayWay() {
return payWay;
}
public void setPayWay(int payWay) {
this.payWay = payWay;
}
public String getCouponCode() {
return couponCode;
}
public void setCouponCode(String couponCode) {
this.couponCode = couponCode;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public long getCreateTime() {
return createTime;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
public long getPayTime() {
return payTime;
}
public void setPayTime(long payTime) {
this.payTime = payTime;
}
public int getGoodsNum() {
return goodsNum;
}
public void setGoodsNum(int goodsNum) {
this.goodsNum = goodsNum;
}
public int getOrderState() {
return orderState;
}
public void setOrderState(int orderState) {
this.orderState = orderState;
}
public String getOrderMark() {
return orderMark;
}
public void setOrderMark(String orderMark) {
this.orderMark = orderMark;
}
public int getOrderMerchant() {
return orderMerchant;
}
public void setOrderMerchant(int orderMerchant) {
this.orderMerchant = orderMerchant;
}
public int getOrderUser() {
return orderUser;
}
public void setOrderUser(int orderUser) {
this.orderUser = orderUser;
}
public int getGoodsId() {
return goodsId;
}
public void setGoodsId(int goodsId) {
this.goodsId = goodsId;
}
public BigDecimal getOrderPrice() {
return orderPrice;
}
public void setOrderPrice(BigDecimal orderPrice) {
this.orderPrice = orderPrice;
}
public String getOrderNotes() {
return orderNotes;
}
public void setOrderNotes(String orderNotes) {
this.orderNotes = orderNotes;
}
public String getUserAddress() {
return userAddress;
}
public void setUserAddress(String userAddress) {
this.userAddress = userAddress;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserPhone() {
return userPhone;
}
public void setUserPhone(String userPhone) {
this.userPhone = userPhone;
}
private String userPhone;
}

View File

@ -0,0 +1,31 @@
package com.example.jieyue.common.entity;
public class SysRole {
private int id;
private String name;
private int status;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}

View File

@ -0,0 +1,40 @@
package com.example.jieyue.common.entity;
public class SysRoleAccess {
private int id;
private int roleId;
private int accessId;
private int status;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getRoleId() {
return roleId;
}
public void setRoleId(int roleId) {
this.roleId = roleId;
}
public int getAccessId() {
return accessId;
}
public void setAccessId(int accessId) {
this.accessId = accessId;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}

View File

@ -0,0 +1,35 @@
package com.example.jieyue.common.entity;
public class SysUi {
private int id;
private String url;
private int width;
private int height;
@Override
public String toString() {
return "SysUi{" +
"id=" + id +
", url='" + url + '\'' +
", width=" + width +
", height=" + height +
'}';
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}

View File

@ -0,0 +1,70 @@
package com.example.jieyue.common.entity;
public class SysUser {
private int id;
private String username;
private String password;
private String email;
private int mark;
private String header;
@Override
public String toString() {
return "SysUser{" +
"id=" + id +
", username='" + username + '\'' +
", password='" + password + '\'' +
", email='" + email + '\'' +
", mark=" + mark +
", header='" + header + '\'' +
'}';
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getMark() {
return mark;
}
public void setMark(int mark) {
this.mark = mark;
}
public String getHeader() {
return header;
}
public void setHeader(String header) {
this.header = header;
}
}

View File

@ -0,0 +1,21 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysAccess;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SysAccessMapper {
List<SysAccess> findAll();
int countByName(String name);
int insert(String name,String url);
int deleteById(int id);
int updateStatus(int status,int id);
int updateInfo(int id,String name,String url);
}

View File

@ -0,0 +1,20 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysAdmin;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SysAdminMapper {
List<SysAdmin> findAll();
int insert(@Param("name") String name, @Param("password") String password,
@Param("email") String email, @Param("mark") int mark);
SysAdmin selectByEmail(String email);
SysAdmin getAdminInfo(String email);
int deleteById(int id);
int updateMark(int mark,String email);
int updateMarkById(int id,int mark);
int update(String name,String password,String email);
}

View File

@ -0,0 +1,23 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysAdminRole;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SysAdminRoleMapper {
List<SysAdminRole> findAll();
SysAdminRole findByAdminId(int adminId);
int insert(int adminId,int roleId);
int deleteById(int id);
int deleteByAdminId(int adminId);
int deleteByRoleId(int roleId);
int updateStatus(int status,int id);
}

View File

@ -0,0 +1,19 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysCart;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SysCartMapper {
List<SysCart> findByUserIdLimit(int userId);
List<SysCart> findAll();
int insert(int userId,int goodsId,int goodsNum);
int deleteById(int id);
int countByUserIdAndGoodsId(int userId,int goodsId);
}

View File

@ -0,0 +1,20 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysComment;
import org.apache.ibatis.annotations.Insert;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SysCommentMapper {
SysComment findById(int id);
int getAllCountByGoods(int id);
int getAllCountByMt(int merchant);
List<SysComment> findByGoodsLimit(int goods,int preNum,int sufNum);
int insert(int user,int goods,int merchant,String context,long createTime);
int deleteById(int id);
}

View File

@ -0,0 +1,32 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysGoods;
import org.springframework.stereotype.Repository;
import java.math.BigDecimal;
import java.util.List;
@Repository
public interface SysGoodsMapper {
SysGoods findById(int id);
List<SysGoods> findByMt(int merchant);
List<SysGoods> findByMtLimit(int merchant,int preNum,int sufNum);
List<SysGoods> findAll();
List<SysGoods> findLimitByMt(int merchant,int preNum,int sufNum);
List<SysGoods> findAllEsc(int num);
List<SysGoods> findRand(int num);
List<SysGoods> findMerchantRand(int merchant,int num);
List<SysGoods> findAllDesc(int num);
List<SysGoods> search(String keyword);
int goodsCount(int merchant);
int allGoodsCount();
int countByMerchant(int merchant);
int deleteById(int id);
int addStock(int id,int stock);
int delStock(int id,int stock);
int updateState(int id,int state);
int updateGoods1(String name,String describe,BigDecimal price,int merchant,int stock,int id);
int updateGoods2(String name,String describe,BigDecimal price,int merchant,int stock,int id,String imgUrl);
int insert1(String name,String describe,BigDecimal price,int merchant,int stock);
int insert2(String name, String describe, BigDecimal price, int merchant,int stock, String img);
}

View File

@ -0,0 +1,31 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysMt;
import com.sun.xml.internal.bind.v2.TODO;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SysMtMapper {
int insert(String name,String email,String password,float ratio,int state);
SysMt findByEmail(String email);
SysMt findById(int id);
int count();
List<SysMt> findPage(int curRow,int pageSize);
List<SysMt> findAll();
int deleteById(int id);
int updateRatio(int id,float ratio);
int updateState(String email,int state);
int updateHeader(int id,String header);
int update(String name,String password,String email);
// todo
int updateName(String name);
}

View File

@ -0,0 +1,17 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysMtUi;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SysMtUiMapper {
SysMtUi findByMark(int width, int height, int merchant);
SysMtUi findById(int id);
List<SysMtUi> findLimit(int width, int height, int num);
int updateUrl(String url, int width, int height,int merchant);
int insert(String url, int width, int height,int merchant);
int deleteByMark(int width, int height,int merchant);
int deleteById(int id);
}

View File

@ -0,0 +1,15 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysNotice;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SysNoticeMapper {
List<SysNotice> findByReceiveTypeLimit(int receive,int type,int preNum,int sufNum);
int deleteById(int id);
int insert(String title,String context,int type,int receive,long createTime);
}

View File

@ -0,0 +1,54 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysOrder;
import org.springframework.stereotype.Repository;
import java.math.BigDecimal;
import java.util.List;
@Repository
public interface SysOrderMapper {
List<SysOrder> findLimit(int preNum,int sufNum);
List<SysOrder> findPayLimit(int preNum,int sufNum);
List<SysOrder> findNotPayLimit(int preNum,int sufNum);
List<SysOrder> findLimitByMt(int merchantId,int preNum,int sufNum);
List<SysOrder> findPayLimitByMt(int merchantId,int preNum,int sufNum);
List<SysOrder> findNotPayLimitByMt(int merchantId,int preNum,int sufNum);
List<SysOrder> findAll();
List<SysOrder> findByUser(int user,int preNum,int sufNum);
List<SysOrder> findByMerchant(int merchant,int num);
List<SysOrder> findByState(int state);
SysOrder findByOrderId(String orderId);
SysOrder findByOrderIdAndMt(String orderId,int merchant);
List<SysOrder> findByOrderMark(String orderMark);
int orderCount();
int payCount();
int notPayCount();
int orderCountByUser(int userId);
int orderCountByMt(int merchantId);
int payCountByMt(int merchantId);
int notPayCountByMt(int merchantId);
// 修改订单状态
int updateState(long pay_time,String orderMark);
int updateCodeUrl(String codeUrl,String orderMark);
int deleteById(int id);
// 添加订单
int insert1(String orderId, long createTime, int goodsNum, String orderMark, int orderUser, int orderMerchant,
BigDecimal orderPrice,int goodsId,String orderNotes,String userAddress,String userName,
String userPhone,String couponCode,int payWay,float merchantRatio);
int insert2(String orderId, long createTime, int goodsNum, String orderMark, int orderUser, int orderMerchant,
BigDecimal orderPrice,int goodsId,String orderNotes,String userAddress,String userName,
String userPhone,String couponCode,int payWay,String cartId,float merchantRatio);
// 收益
float websiteProfitCount();
float merchantProfitCount(int merchantId);
}

View File

@ -0,0 +1,23 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysRoleAccess;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SysRoleAccessMapper {
List<SysRoleAccess> findAll();
List<SysRoleAccess> findByRoleId(int roleId);
int insert(int roleId,int accessId);
int deleteById(int id);
int deleteByRoleId(int roleId);
int deleteByAccessId(int accessId);
int updateStatus(int status,int id);
}

View File

@ -0,0 +1,21 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysRole;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SysRoleMapper {
List<SysRole> findAll();
SysRole findById(int id);
int countByName(String name);
int insert(String name);
int deleteById(int id);
int updateStatus(int status,int id);
}

View File

@ -0,0 +1,12 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysUi;
import org.springframework.stereotype.Repository;
@Repository
public interface SysUiMapper {
SysUi findByMark(int width,int height);
int updateUrl(String url,int width,int height);
int insert(String url,int width,int height);
int deleteByMark(int width,int height);
}

View File

@ -0,0 +1,22 @@
package com.example.jieyue.common.mapper;
import com.example.jieyue.common.entity.SysUser;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SysUserMapper {
SysUser selectById(int id);
List<SysUser> findLimit(int preNum,int sufNum);
int userCount();
List<SysUser> findAll();
int insert(@Param("username") String username,@Param("password") String password,
@Param("email") String email,@Param("mark") int mark);
SysUser selectByEmail(String email);
SysUser getUserInfo(String email);
int updateMark(int mark,String email);
int update(String username,String password,String email);
int updateById(String username,String password,String header,String email,int id);
}

View File

@ -0,0 +1,123 @@
package com.example.jieyue.common.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.FileSystemResource;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Service
public class MailService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* Spring Boot 使使
*/
@Autowired
private JavaMailSender mailSender;
/**
* qq
*/
@Value("${spring.mail.from}")
private String from;
/**
*
* @param to
* @param subject
* @param content
*/
public void sendSimpleMail(String to, String subject, String content) {
//创建SimpleMailMessage对象
SimpleMailMessage message = new SimpleMailMessage();
//邮件发送人
message.setFrom(from);
//邮件接收人
message.setTo(to);
//邮件主题
message.setSubject(subject);
//邮件内容
message.setText(content);
//发送邮件
mailSender.send(message);
}
/**
* html
* @param to
* @param subject
* @param content
*/
public boolean sendHtmlMail(String to, String subject, String content) {
//获取MimeMessage对象
MimeMessage message = mailSender.createMimeMessage();
MimeMessageHelper messageHelper;
try {
messageHelper = new MimeMessageHelper(message, true);
//邮件发送人
messageHelper.setFrom(from);
//邮件接收人
messageHelper.setTo(to);
//邮件主题
message.setSubject(subject);
//邮件内容html格式
messageHelper.setText(content, true);
//发送
mailSender.send(message);
//日志信息
logger.info("邮件已经发送。");
return true;
} catch (MessagingException e) {
logger.error("发送邮件时发生异常!", e);
return false;
}
}
/**
*
* @param to
* @param subject
* @param content
* @param filePath
*/
public void sendAttachmentsMail(String to, String subject, String content, String filePath) {
MimeMessage message = mailSender.createMimeMessage();
try {
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setFrom(from);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(content, true);
FileSystemResource file = new FileSystemResource(new File(filePath));
String fileName = filePath.substring(filePath.lastIndexOf(File.separator));
helper.addAttachment(fileName, file);
mailSender.send(message);
//日志信息
logger.info("邮件已经发送。");
} catch (MessagingException e) {
logger.error("发送邮件时发生异常!", e);
}
}
/*
*
*/
public boolean checkEmail(String email){
String check = "^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$";
Pattern regex = Pattern.compile(check);
Matcher matcher = regex.matcher(email);
return matcher.matches();
}
}

View File

@ -0,0 +1,42 @@
package com.example.jieyue.common.service;
import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.common.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class SysUserService {
@Autowired
SysUserMapper userMapper;
public SysUser selectById(int id){
return userMapper.selectById(id);
}
public SysUser selectByEmail(String email){
return userMapper.selectByEmail(email);
}
public SysUser getUserInfo(String email){
return userMapper.getUserInfo(email);
}
public List<SysUser> findAll(){
return userMapper.findAll();
}
public int insert(String username,String password,String email,int mark){
return userMapper.insert(username,password,email,mark);
}
public int updateMark(int mark,String email){
return userMapper.updateMark(mark,email);
}
public int update(String username,String password,String email){
return userMapper.update(username,password,email);
}
}

View File

@ -0,0 +1,111 @@
package com.example.jieyue.common.task;
import com.example.jieyue.common.entity.SysOrder;
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.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
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;
/**
* <p></p>
* @author Bosen
* 2020/11/13 13:41
*/
@Component
public class SchedulerTask {
@Autowired
SysOrderMapper orderMapper;
@Autowired
SysGoodsMapper goodsMapper;
@Autowired
FileUtil fileUtil;
@Autowired
RedisTemplate redisTemplate;
@Autowired
SysNoticeMapper noticeMapper;
@Autowired
MailService mailService;
/*
*
*/
@Scheduled(cron="* */1 * * * ?")
@Transactional
public void delOverOrder(){
long time = 2*60*60*1000;// 订单过期时间,两小时
List<SysOrder> list = orderMapper.findByState(0);
for (SysOrder sysOrder : list) {
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());
}
}
}
}
/*
*
*/
@Scheduled(cron="* */1 * * * ?")
public void delQRCode(){
long time = 2*60*60*1000;// 订单过期时间,两小时
List<SysOrder> list = orderMapper.findAll();
for (SysOrder sysOrder : list) {
if (System.currentTimeMillis() > sysOrder.getCreateTime()+time){
fileUtil.deleteFile(sysOrder.getPayCodeUrl());
}
}
}
/*
*
*/
@Scheduled(cron="* */1 * * * ?")
public void sendNotice(){
while (redisTemplate.opsForList().size("notice")!=0){
Map<String,String> map = (Map<String,String>)redisTemplate.opsForList().rightPop("notice");
String title = map.get("title");
String context = map.get("context");
int type = Integer.valueOf(map.get("type"));
int receive = Integer.valueOf(map.get("receive"));
long createTime = Long.valueOf(map.get("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;
}
}
}
/*
*
*/
@Scheduled(cron="* */1 * * * ?")
public void sendEmail(){
while (redisTemplate.opsForList().size("email")!=0){
Map<String,String> map = (Map<String,String>)redisTemplate.opsForList().rightPop("email");
mailService.sendHtmlMail(map.get("email"),map.get("title"),map.get("context"));
}
}
}

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 {
/*
*
*/
public String getNMDHIS(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
return sdf.format(new Date());
}
}

View File

@ -0,0 +1,79 @@
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()+"\\";
}
/**
*
*
* @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;
}
/*
*
*/
public String getSuffixName(String filename){
String[] strArray = filename.split("\\.");
int suffixIndex = strArray.length -1;
return strArray[suffixIndex];
}
/*
*
*/
public void deleteFile(String url){
File file1 = new File(classpath+url);
file1.delete();
}
}

View File

@ -0,0 +1,68 @@
package com.example.jieyue.common.utils;
import org.springframework.stereotype.Component;
/**
* <p></p>
* @author Bosen
* 2020/10/31 16:03
*/
@Component
public class IsEmptyUtil {
/*
*
*/
private static class IsEmptyUtilHoler{
private static IsEmptyUtil INSTANCE = new IsEmptyUtil();
}
public static IsEmptyUtil getInstance(){
return IsEmptyUtilHoler.INSTANCE;
}
/*
* ,true
*/
public boolean strings(String ... strings){
for (String string : strings) {
if (string==null || string.equals("")){
return true;
}
}
return false;
}
/*
*
*/
public boolean string(String string){
if (string==null || string.equals("")){
return true;
}else{
return false;
}
}
/*
*
*/
public boolean object(Object object){
if (object==null){
return true;
}else{
return false;
}
}
/*
* ,nulltrue
*/
public boolean objects(Object ... objects){
for (Object object : objects) {
if (object==null){
return true;
}
}
return false;
}
}

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 {
/**
*
* todo
*/
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

@ -0,0 +1,226 @@
package com.example.jieyue.common.utils;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.*;
import javax.imageio.ImageIO;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Binarizer;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.EncodeHintType;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.WriterException;
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;
/**
*
*
* @data 2018-11-2 10:23:14
*/
public class QRCodeUtil {
// 二维码颜色==黑色
private static final int BLACK = 0xFF000000;
// 二维码颜色==白色
private static final int WHITE = 0xFFFFFFFF;
// 二维码图片格式==jpg和png两种
private static final List<String> IMAGE_TYPE = new ArrayList<>();
static {
IMAGE_TYPE.add("jpg");
IMAGE_TYPE.add("png");
}
/**
* zxing
*
* 1,,image,
* 2,,,, logo
* 3,logo20%,
*
* @param content
* @param path
* @param filename
* @param size 250
* @param logoPath logo
*/
public static boolean zxingCodeCreate(String content, String path, String filename,Integer size, String logoPath) {
try {
//图片类型
String imageType = "jpg";
//获取二维码流的形式,写入到目录文件中
BufferedImage image = getBufferedImage(content, size, logoPath);
//生成二维码存放文件
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 false;
}
}
/**
*
*
* @param content
* @param size
* @param logoPath logo
* @return
*/
public static BufferedImage getBufferedImage(String content, Integer size, String logoPath) {
if (size == null || size <= 0) {
size = 250;
}
BufferedImage image = null;
try {
// 设置编码字符集
Map<EncodeHintType, Object> hints = new HashMap<>();
//设置编码
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
//设置容错率最高
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
hints.put(EncodeHintType.MARGIN, 1);
// 1、生成二维码
MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, size, size, hints);
// 2、获取二维码宽高
int codeWidth = bitMatrix.getWidth();
int codeHeight = bitMatrix.getHeight();
// 3、将二维码放入缓冲流
image = new BufferedImage(codeWidth, codeHeight, BufferedImage.TYPE_INT_RGB);
for (int i = 0; i < codeWidth; i++) {
for (int j = 0; j < codeHeight; j++) {
// 4、循环将二维码内容定入图片
image.setRGB(i, j, bitMatrix.get(i, j) ? BLACK : WHITE);
}
}
//判断是否写入logo图片
if (logoPath != null && !"".equals(logoPath)) {
File logoPic = new File(logoPath);
if (logoPic.exists()) {
Graphics2D g = image.createGraphics();
BufferedImage logo = ImageIO.read(logoPic);
int widthLogo = logo.getWidth(null) > image.getWidth() * 2 / 10 ? (image.getWidth() * 2 / 10) : logo.getWidth(null);
int heightLogo = logo.getHeight(null) > image.getHeight() * 2 / 10 ? (image.getHeight() * 2 / 10) : logo.getHeight(null);
int x = (image.getWidth() - widthLogo) / 2;
int y = (image.getHeight() - heightLogo) / 2;
// 开始绘制图片
g.drawImage(logo, x, y, widthLogo, heightLogo, null);
g.drawRoundRect(x, y, widthLogo, heightLogo, 15, 15);
//边框宽度
g.setStroke(new BasicStroke(2));
//边框颜色
g.setColor(Color.WHITE);
g.drawRect(x, y, widthLogo, heightLogo);
g.dispose();
logo.flush();
image.flush();
}
}
} catch (WriterException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return image;
}
/**
* Logo
*
* @param qrPic
* @param logoPic logo
* @param path
*/
public static boolean zxingCodeCreate(File qrPic, File logoPic, String path) {
try {
String imageType = path.substring(path.lastIndexOf(".") + 1).toLowerCase();
if (!IMAGE_TYPE.contains(imageType)) {
return false;
}
if (!qrPic.isFile() && !logoPic.isFile()) {
return false;
}
//读取二维码图片,并构建绘图对象
BufferedImage image = ImageIO.read(qrPic);
Graphics2D g = image.createGraphics();
//读取Logo图片
BufferedImage logo = ImageIO.read(logoPic);
//设置logo的大小,最多20%0
int widthLogo = logo.getWidth(null) > image.getWidth() * 2 / 10 ? (image.getWidth() * 2 / 10) : logo.getWidth(null);
int heightLogo = logo.getHeight(null) > image.getHeight() * 2 / 10 ? (image.getHeight() * 2 / 10) : logo.getHeight(null);
// 计算图片放置位置,默认在中间
int x = (image.getWidth() - widthLogo) / 2;
int y = (image.getHeight() - heightLogo) / 2;
// 开始绘制图片
g.drawImage(logo, x, y, widthLogo, heightLogo, null);
g.drawRoundRect(x, y, widthLogo, heightLogo, 15, 15);
//边框宽度
g.setStroke(new BasicStroke(2));
//边框颜色
g.setColor(Color.WHITE);
g.drawRect(x, y, widthLogo, heightLogo);
g.dispose();
logo.flush();
image.flush();
File newFile = new File(path);
if (!newFile.exists()) {
newFile.mkdirs();
}
ImageIO.write(image, imageType, newFile);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
/**
*
*
* @param path
* @return
*/
public static Result zxingCodeAnalyze(String path) {
try {
MultiFormatReader formatReader = new MultiFormatReader();
File file = new File(path);
if (file.exists()) {
BufferedImage image = ImageIO.read(file);
LuminanceSource source = new BufferedImageLuminanceSource(image);
Binarizer binarizer = new HybridBinarizer(source);
BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer);
Map hints = new HashMap();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
Result result = formatReader.decode(binaryBitmap, hints);
return result;
}
} catch (IOException e) {
e.printStackTrace();
} catch (NotFoundException e) {
e.printStackTrace();
}
return null;
}
}

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

@ -0,0 +1,176 @@
package com.example.jieyue.merchant.controller;
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.merchant.service.MerchantGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.List;
/**
* <p></p>
* @author Bosen
* 2020/11/8 16:27
*/
@RestController
public class MerchantGoodsController {
@Autowired
MerchantGoodsService goodsService;
/*
*
*/
@RequestMapping("/merchant/goods")
public ModelAndView index(ModelAndView modelAndView, HttpSession session, @RequestParam(defaultValue = "1")int page){
List<SysGoods> goodsList = goodsService.getMtGoods(session,page,10);
modelAndView.addObject("goodsList",goodsList);
// 获取订单总页数
int allPage = goodsService.getAllPage(10,(SysMt)session.getAttribute("merchant"));
modelAndView.addObject("page",page);
modelAndView.addObject("allPage",allPage);
modelAndView.setViewName("merchant/goods/index");
return modelAndView;
}
/*
*
*/
@RequestMapping("/merchant/add-goods")
public ModelAndView addGoods(ModelAndView modelAndView, String name, String describe,
String price, MultipartFile img,String stock,
RedirectAttributes redirectAttributes,
HttpServletRequest request){
// 类型转换
BigDecimal priceRes = null;
int stockTemp = 0;
try {
stockTemp = Integer.valueOf(stock);
if (stockTemp==0){
throw new Exception();
}
priceRes = new BigDecimal(price);
}catch (Exception e){
modelAndView.addObject("msg","输入的金额或库存不合法");
modelAndView.setViewName("redirect:goods");
return modelAndView;
}
// 添加商品
int res = goodsService.addGoods(name, describe,priceRes,img,redirectAttributes,stockTemp,request);
switch (res){
case -1:
modelAndView.addObject("msg","图片上传失败");
break;
case 0:
modelAndView.addObject("msg","网络超时");
break;
case 1:
modelAndView.addObject("msg","添加商品成功");
break;
case 2:
modelAndView.addObject("msg","必填信息不能为空");
break;
}
modelAndView.setViewName("redirect:goods");
return modelAndView;
}
/*
* id
*/
@RequestMapping("/merchant/del-goods")
public ModelAndView delGoods(ModelAndView modelAndView,int id){
int res = goodsService.delGoods(id);
if (res == 1){
modelAndView.addObject("msg","删除成功");
}else{
modelAndView.addObject("msg","删除失败");
}
modelAndView.setViewName("redirect:goods");
return modelAndView;
}
/*
*
*/
@RequestMapping("/merchant/put-goods")
public ModelAndView putGoods(ModelAndView modelAndView,int id){
if (goodsService.putGoods(id)){
modelAndView.addObject("msg","上架商品成功");
}else{
modelAndView.addObject("msg","上架商品成功");
}
modelAndView.setViewName("redirect:goods");
return modelAndView;
}
/*
*
*/
@RequestMapping("/merchant/off-goods")
public ModelAndView OffGoods(ModelAndView modelAndView,int id){
if (goodsService.OffGoods(id)){
modelAndView.addObject("msg","下架商品成功");
}else{
modelAndView.addObject("msg","下架商品成功");
}
modelAndView.setViewName("redirect:goods");
return modelAndView;
}
/*
*
*/
@RequestMapping("/merchant/update-goods")
public ModelAndView updateGoods(ModelAndView modelAndView, String name, String describe,
String price, MultipartFile img,String stock,
RedirectAttributes redirectAttributes,
HttpServletRequest request,int id){
// 类型转换
BigDecimal priceRes = null;
int stockTemp = 0;
try {
stockTemp = Integer.valueOf(stock);
if (stockTemp==0){
throw new Exception();
}
priceRes = new BigDecimal(price);
}catch (Exception e){
modelAndView.addObject("msg","输入的金额或库存不合法");
modelAndView.setViewName("redirect:goods");
return modelAndView;
}
// 修改商品信息
int res = goodsService.updateGoods(name, describe,priceRes,img,redirectAttributes,stockTemp,request,id);
switch (res){
case -1:
modelAndView.addObject("msg","图片上传失败");
break;
case 0:
modelAndView.addObject("msg","网络超时");
break;
case 1:
modelAndView.addObject("msg","修改商品成功");
break;
case 2:
modelAndView.addObject("msg","必填信息不能为空");
break;
}
modelAndView.setViewName("redirect:goods");
return modelAndView;
}
}

View File

@ -0,0 +1,42 @@
package com.example.jieyue.merchant.controller;
import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.mapper.SysOrderMapper;
import com.example.jieyue.merchant.service.MerchantHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpSession;
/**
* <p></p>
* @author Bosen
* 2020/11/8 14:27
*/
@RestController
public class MerchantHomeController {
@Autowired
MerchantHomeService homeService;
@Autowired
SysOrderMapper orderMapper;
@RequestMapping({"/merchant/home","/merchant/"})
public ModelAndView index(ModelAndView modelAndView, HttpSession session){
SysMt merchant = (SysMt) session.getAttribute("merchant");
int commentCount = homeService.getCommandCount(merchant.getId());
int userCount = homeService.getUserCount(merchant.getId());
int orderCount = homeService.getOrderCount(merchant.getId());
float profit = orderMapper.merchantProfitCount(merchant.getId());
modelAndView.addObject("commentCount",commentCount);
modelAndView.addObject("profit",profit);
modelAndView.addObject("userCount",userCount);
modelAndView.addObject("orderCount",orderCount);
modelAndView.setViewName("merchant/home/index");
return modelAndView;
}
}

View File

@ -0,0 +1,112 @@
package com.example.jieyue.merchant.controller;
import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.merchant.service.MerchantLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.xml.ws.Service;
/**
* <p></p>
* @author Bosen
* 2020/11/8 12:43
*/
@RestController
@RequestMapping("/merchant")
public class MerchantLoginController {
@Autowired
MerchantLoginService loginService;
@RequestMapping({"login",""})
public ModelAndView index(ModelAndView modelAndView){
modelAndView.setViewName("merchant/login/index");
return modelAndView;
}
/*
*
*/
@RequestMapping("do-login")
public ModelAndView doLogin(ModelAndView modelAndView, String email, String password, HttpSession session){
modelAndView.setViewName("redirect:/merchant/home");
int serviceRes = loginService.doLogin(email,password);
switch (serviceRes){
case 0:
modelAndView.addObject("msg","必填信息不能为空");
break;
case -1:
modelAndView.addObject("msg","邮箱或密码错误");
break;
case 1:
// 登陆成功
SysMt merchant = loginService.getMerchantInfo(email);
session.setAttribute("merchant",merchant);
break;
}
return modelAndView;
}
/*
* 退
*/
@RequestMapping("logout")
public ModelAndView logout(ModelAndView modelAndView,HttpServletRequest request){
request.getSession().setAttribute("merchant",null);
modelAndView.setViewName("redirect:/merchant/login");
return modelAndView;
}
/*
*
*/
@RequestMapping("sign-up")
public ModelAndView signUp(ModelAndView modelAndView,String email,String name,String password){
modelAndView.setViewName("redirect:/merchant/login");
int serviceRes = loginService.signUp(email,name,password);
switch (serviceRes){
case -1:
modelAndView.addObject("msg","验证邮件发送失败,请重试");
break;
case 0:
modelAndView.addObject("msg","必填信息不能为空");
break;
case 1:
modelAndView.addObject("msg","验证信息已发送至邮箱,请留意接收");
break;
case 2:
modelAndView.addObject("msg","该邮箱已被注册");
break;
case 3:
modelAndView.addObject("msg","邮箱格式不正确");
break;
}
return modelAndView;
}
/*
*
*/
@RequestMapping("sign-check")
public ModelAndView singCheck(ModelAndView modelAndView,String email){
int serviceRes = loginService.singCheck(email);
switch (serviceRes){
case -1:
modelAndView.setViewName("redirect:/error");
break;
case 0:
modelAndView.setViewName("redirect:/merchant/login");
modelAndView.addObject("msg","网络超时请重试");
break;
case 1:
modelAndView.setViewName("redirect:/merchant/login");
modelAndView.addObject("msg","注册成功");
break;
}
return modelAndView;
}
}

View File

@ -0,0 +1,54 @@
package com.example.jieyue.merchant.controller;
import com.example.jieyue.admin.service.AdminMerchantService;
import com.example.jieyue.admin.service.AdminOrderService;
import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.entity.SysOrder;
import com.example.jieyue.merchant.service.MerchantOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
public class MerchantOrderController {
@Autowired
MerchantOrderService orderService;
@RequestMapping("/merchant/order")
public ModelAndView index(HttpServletRequest request,ModelAndView modelAndView, @RequestParam(defaultValue = "2")int flag, @RequestParam(defaultValue = "1")int page){
SysMt merchant = (SysMt) request.getSession().getAttribute("merchant");
// 获取订单信息
List<SysOrder> orderList = orderService.getOrderList(merchant.getId(),page,18,flag);
modelAndView.addObject("orderList",orderList);
// 获取订单总页数
int allPage = orderService.getAllPage(merchant.getId(),flag,18);
modelAndView.addObject("page",page);
modelAndView.addObject("flag",flag);
modelAndView.addObject("allPage",allPage);
modelAndView.setViewName("merchant/order/index");
return modelAndView;
}
@RequestMapping("/merchant/search-order")
public ModelAndView searchOrder(HttpServletRequest request,ModelAndView modelAndView,String order){
SysMt merchant = (SysMt) request.getSession().getAttribute("merchant");
// 获取订单信息
List<SysOrder> orderList = orderService.getOrderById(order,merchant.getId());
modelAndView.addObject("orderList",orderList);
// 获取订单总页数
modelAndView.addObject("page",1);
modelAndView.addObject("flag",2);
modelAndView.addObject("allPage",1);
modelAndView.setViewName("merchant/order/index");
return modelAndView;
}
}

View File

@ -0,0 +1,92 @@
package com.example.jieyue.merchant.controller;
import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.entity.SysMtUi;
import com.example.jieyue.merchant.service.MerchantUiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest;
/**
* <p></p>
* @author Bosen
* 2020/11/8 16:29
*/
@RestController
public class MerchantUiController {
@Autowired
MerchantUiService uiService;
@RequestMapping("/merchant/ui")
public ModelAndView index(ModelAndView modelAndView, HttpServletRequest request){
modelAndView.setViewName("merchant/ui/index");
// 商户用于商城首页宣传的海报图片路径
SysMtUi homeImg = uiService.getHomeImg(400,320,request.getSession());
modelAndView.addObject("homeImg",homeImg);
SysMtUi lowImg = uiService.getHomeImg(600,310,request.getSession());
modelAndView.addObject("lowImg",lowImg);
return modelAndView;
}
/*
*
*/
@RequestMapping("/merchant/del-home-img")
public ModelAndView delHomeImg(ModelAndView modelAndView,int id){
int res = uiService.delHomeImg(id);
switch (res){
case 1:
modelAndView.addObject("msg","图片删除成功");
break;
case 0:
modelAndView.addObject("msg","图片删除失败");
break;
}
modelAndView.setViewName("redirect:ui");
return modelAndView;
}
/*
*
*/
@RequestMapping("/merchant/update-home-img")
public ModelAndView updateHomeImg(ModelAndView modelAndView, HttpServletRequest request, MultipartFile img, RedirectAttributes redirectAttributes,int width,int height){
int res = uiService.updateHomeImg(width,height,request.getSession(),img,redirectAttributes,request);
switch (res){
case 1:
modelAndView.addObject("msg","图片修改成功");
break;
case 0:
modelAndView.addObject("msg","图片修改失败");
break;
}
modelAndView.setViewName("redirect:ui");
return modelAndView;
}
/*
*
*/
@RequestMapping("/merchant/update-header")
public ModelAndView updateHeader(RedirectAttributes redirectAttributes,HttpServletRequest request,ModelAndView modelAndView,MultipartFile img){
if (img.isEmpty()){
modelAndView.addObject("msg","未选择要修改的头像");
}else{
int result = uiService.updateHeard(redirectAttributes,request,img);
if (result==1){
modelAndView.addObject("msg","修改logo成功");
}else{
modelAndView.addObject("msg","修改logo失败");
}
}
modelAndView.setViewName("redirect:/merchant/ui");
return modelAndView;
}
}

View File

@ -0,0 +1,32 @@
package com.example.jieyue.merchant.controller;
import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.merchant.service.MerchantUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
@RestController
public class MerchantUserController {
@Autowired
MerchantUserService userService;
@RequestMapping("/merchant/user")
public ModelAndView index(ModelAndView modelAndView, @RequestParam(defaultValue = "1")int page){
// 获取订单信息
List<SysUser> userList = userService.getUserList(page,10);
modelAndView.addObject("userList",userList);
// 获取订单总页数
int allPage = userService.getAllPage(10);
modelAndView.addObject("page",page);
modelAndView.addObject("allPage",allPage);
modelAndView.setViewName("merchant/user/index");
return modelAndView;
}
}

View File

@ -0,0 +1,207 @@
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.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.data.annotation.Id;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.List;
@Service
public class MerchantGoodsService {
@Autowired
SysGoodsMapper goodsMapper;
@Autowired
FileUtil fileUtil;
@Autowired
DateUtil dateUtil;
IsEmptyUtil isEmptyUtil = new IsEmptyUtil();
/*
*
*/
public List<SysGoods> getAllGoods(){
return goodsMapper.findAll();
}
/*
* id
*/
public SysGoods getGoodsById(int id){
return goodsMapper.findById(id);
}
/*
*
*/
public List<SysGoods> getMtGoods(HttpSession session,int page,int num){
SysMt sysMt = (SysMt) session.getAttribute("merchant");
return goodsMapper.findByMtLimit(sysMt.getId(),(page-1)*num,num);
}
/**
* <p></p>
*
* @return
*-1
* 0 sql
* 1
* 2
*/
public int addGoods(String name, String describe, BigDecimal price,MultipartFile img,
RedirectAttributes redirectAttributes,int stock,
HttpServletRequest request){
if (isEmptyUtil.strings(name,describe)){
return 2;
}
if (price == null){
return 2;
}
int goodsMapperResult = 0;
// 获取当前商户id
SysMt sysMt = (SysMt)request.getSession().getAttribute("merchant");
int merchant = sysMt.getId();
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 = fileUtil.upFile(img,redirectAttributes,request,
"/data/goods/"+id+"/",filename);
// 文件上传失败
if (imgUrl == null){
return -1;
}
// 执行插入
goodsMapperResult = goodsMapper.insert2(name,describe,price,merchant,stock,imgUrl);
if (goodsMapperResult != 1){
// sql语句执行失败将已上传的图片移除
fileUtil.deleteFile(imgUrl);
return 0;
}
}
return 1;
}
/**
* <p>id</p>
*
* @return
*-1
* 1
*/
public int delGoods(int id){
// 获取goods示例图片的地址
String imgUrl = goodsMapper.findById(id).getImg();
// 删除数据库中goods的数据
int sql = goodsMapper.deleteById(id);
if (sql!=1){
return -1;
}else{
// 当文件路径在/data下时才执行文件的删除
if (imgUrl.indexOf("/data") == 0){
// 删除源文件与编译文件中对应的goods图片信息
fileUtil.deleteFile(imgUrl);
}
return 1;
}
}
/*
*
*/
public int getAllPage(int num,SysMt merchant){
return (int)Math.ceil((double)goodsMapper.goodsCount(merchant.getId())/(double)num);
}
/*
*
*/
public boolean putGoods(int goodId){
return goodsMapper.updateState(goodId, 1) == 1;
}
/*
*
*/
public boolean OffGoods(int goodId){
return goodsMapper.updateState(goodId, 0) == 1;
}
/**
* <p></p>
*
* @return
*-1
* 0 sql
* 1
* 2
*/
public int updateGoods(String name, String describe, BigDecimal price,MultipartFile img,
RedirectAttributes redirectAttributes,int stock,
HttpServletRequest request,int goodsId){
if (isEmptyUtil.strings(name,describe)){
return 2;
}
if (price == null){
return 2;
}
int goodsMapperResult = 0;
// 获取当前商户id
SysMt sysMt = (SysMt)request.getSession().getAttribute("merchant");
int merchant = sysMt.getId();
if (img.getOriginalFilename().equals("")){
// 执行插入
goodsMapperResult = goodsMapper.updateGoods1(name,describe,price,merchant,stock, goodsId);
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 = fileUtil.upFile(img,redirectAttributes,request,
"/data/goods/"+id+"/",filename);
// 文件上传失败
if (imgUrl == null){
return -1;
}
// 执行插入
SysGoods tempGoods = goodsMapper.findById(goodsId);
goodsMapperResult = goodsMapper.updateGoods2(name,describe,price,merchant,stock,goodsId,imgUrl);
if (goodsMapperResult != 1){
// sql语句执行失败将已上传的图片移除
fileUtil.deleteFile(imgUrl);
return 0;
}else{
// 新图片已插入,将旧图删除
fileUtil.deleteFile(tempGoods.getImg());
}
}
return 1;
}
}

View File

@ -0,0 +1,30 @@
package com.example.jieyue.merchant.service;
import com.example.jieyue.common.mapper.SysCommentMapper;
import com.example.jieyue.common.mapper.SysOrderMapper;
import com.example.jieyue.common.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class MerchantHomeService {
@Autowired
SysCommentMapper commentMapper;
@Autowired
SysUserMapper userMapper;
@Autowired
SysOrderMapper orderMapper;
public int getCommandCount(int merchant){
return commentMapper.getAllCountByMt(merchant);
}
public int getUserCount(int merchant){
return userMapper.userCount();
}
public int getOrderCount(int merchant){
return orderMapper.payCountByMt(merchant);
}
}

View File

@ -0,0 +1,121 @@
package com.example.jieyue.merchant.service;
import com.example.jieyue.common.entity.SysAdmin;
import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.common.mapper.SysMtMapper;
import com.example.jieyue.common.service.MailService;
import com.example.jieyue.common.utils.IsEmptyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
@Service
public class MerchantLoginService {
IsEmptyUtil isEmptyUtil = new IsEmptyUtil();
@Autowired
SysMtMapper mtMapper;
@Autowired
MailService mailService;
@Value("${site-url}")
String sitrUrl;
/**
*
* @return
* 0
*-1
* 1
*/
public int doLogin(String email,String password){
if (isEmptyUtil.strings(email,password)){
return 0;
}
SysMt merchant = mtMapper.findByEmail(email);
if (merchant==null){
return -1;
}else{
password = DigestUtils.md5DigestAsHex(password.getBytes());
if (merchant.getPassword().equals(password)){
return 1;
}else{
return -1;
}
}
}
/**
*
* @return
* 0
*-1
* 1
* 2
* 3
*/
public int signUp(String email,String name,String password){
if (isEmptyUtil.strings(email,name,password)){
return 0;
}
// 邮箱格式验证
if(!mailService.checkEmail(email)){
System.out.println(email);
return 3;
}
// 该邮箱已被注册
SysMt merchant = mtMapper.findByEmail(email);
password = DigestUtils.md5DigestAsHex(password.getBytes());
if (merchant!=null){
if (merchant.getState()!=2){
return 2;
}else{
if (mtMapper.update(name,password,email)!=1){
return -1;
}
}
}else{
// 将信息保存状态置为2未通过注册,ratio=1
// 添加信息未成功返回超时
if (mtMapper.insert(name,email,password,1,2)!=1){
return -1;
}
}
// 发送注册验证邮件
boolean res = mailService.sendHtmlMail(email,"捷阅网商户注册验证","<a href='http://"+this.sitrUrl+"merchant/sign-check?email="+email+"'>点击此链接完成注册验证</a>");
if (res){
return 1;
}else{
return -1;
}
}
/**
*
* @return int
*-1 404
* 0
* 1
*/
public int singCheck(String email){
SysMt merchant = mtMapper.findByEmail(email);
if (merchant!=null && merchant.getState()==2){
int res = mtMapper.updateState(email,0);
if (res==1){
return 1;
}else{
return 0;
}
}else{
return -1;
}
}
/*
*
*/
public SysMt getMerchantInfo(String email){
return mtMapper.findByEmail(email);
}
}

View File

@ -0,0 +1,57 @@
package com.example.jieyue.merchant.service;
import com.example.jieyue.common.entity.SysOrder;
import com.example.jieyue.common.mapper.SysOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class MerchantOrderService {
@Autowired
SysOrderMapper orderMapper;
/*
*
*/
public List<SysOrder> getOrderList(int merchantId,int page, int num, int flag){
switch (flag){
case 0:// 未支付
return orderMapper.findNotPayLimitByMt(merchantId,(page-1)*num,num);
case 1:// 已支付
return orderMapper.findPayLimitByMt(merchantId,(page-1)*num,num);
case 2:// 全部订单
return orderMapper.findLimitByMt(merchantId,(page-1)*num,num);
}
return null;
}
/*
*
*/
public int getAllPage(int merchantId,int flag,int num){
switch (flag){
case 0:// 未支付
return (int)Math.ceil((double)orderMapper.notPayCountByMt(merchantId)/(double)num);
case 1:// 已支付
return (int)Math.ceil((double)orderMapper.payCountByMt(merchantId)/(double)num);
case 2:// 全部订单
return (int)Math.ceil((double)orderMapper.orderCountByMt(merchantId)/(double)num);
}
return 1;
}
/*
*
*/
public List<SysOrder> getOrderById(String orderId,int merchant){
SysOrder order = orderMapper.findByOrderIdAndMt(orderId,merchant);
List<SysOrder> list = new ArrayList<>();
if (order!=null){
list.add(order);
}
return list;
}
}

View File

@ -0,0 +1,126 @@
package com.example.jieyue.merchant.service;
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.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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@Service
public class MerchantUiService {
@Autowired
SysMtUiMapper mtUiMapper;
@Autowired
FileUtil fileUtil;
@Autowired
DateUtil dateUtil;
@Autowired
SysMtMapper merchantMapper;
/**
* <p>id</p>
*
* @return
* -1 session
*/
public int getMtId(HttpSession session){
SysMt mtUi = (SysMt) session.getAttribute("merchant");
if (mtUi == null){
return -1;
}
return mtUi.getId();
}
/*
*
*/
public SysMtUi getHomeImg(int width,int height,HttpSession session){
return mtUiMapper.findByMark(width,height,getMtId(session));
}
/*
*
*/
public int delHomeImg(int id){
String url = mtUiMapper.findById(id).getUrl();
int sql = mtUiMapper.deleteById(id);
if (sql==1){
fileUtil.deleteFile(url);
return 1;
}else{
return 0;
}
}
/*
*
*/
public int updateHomeImg(int width, int height, HttpSession session, MultipartFile img,RedirectAttributes redirectAttributes,
HttpServletRequest request){
// 获取当前商户id
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 = fileUtil.upFile(img,redirectAttributes,request,
"/data/mtui/"+id+"/",filename);
if (imgUrl==null){
// 上传图片失败
return 0;
}
if (sysMtUi==null){
return addHomeImg(imgUrl,width,height,id);
}else{
int sql = mtUiMapper.updateUrl(imgUrl,width,height,id);
if (sql==1){
// sql语句执行成功将旧图删除加入新图
fileUtil.deleteFile(sysMtUi.getUrl());
}else{
// sql语句执行失败将已上传的新图删除
fileUtil.deleteFile(imgUrl);
}
return sql;
}
}
/*
*
*/
public int addHomeImg(String url,int width, int height,int id){
return mtUiMapper.insert(url,width,height,id);
}
/*
*
*/
public int updateHeard(RedirectAttributes redirectAttributes,HttpServletRequest request, MultipartFile img){
// 获取商户信息
SysMt merchant = (SysMt) request.getSession().getAttribute("merchant");
// 设置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){
fileUtil.deleteFile(headerUrl);
return -1;
}else{
if (!merchant.getHeader().equals("/lib/merchant/images/2.png")){
fileUtil.deleteFile(merchant.getHeader());
}
// 修改会话信息
merchant.setHeader(headerUrl);
request.getSession().setAttribute("merchant",merchant);
}
return 1;
}
}

View File

@ -0,0 +1,28 @@
package com.example.jieyue.merchant.service;
import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.common.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class MerchantUserService {
@Autowired
SysUserMapper userMapper;
/*
*
*/
public List<SysUser> getUserList(int page, int num){
return userMapper.findLimit((page-1)*num,num);
}
/*
*
*/
public int getAllPage(int num){
return (int)Math.ceil((double)userMapper.userCount()/(double)num);
}
}

View File

@ -0,0 +1,19 @@
package com.example.jieyue.user.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
/**
* <p></p>
* @author Bosen
* 2020/11/2 21:00
*/
@RestController
public class UserAboutController {
@RequestMapping("/user/about")
public ModelAndView index(ModelAndView modelAndView){
modelAndView.setViewName("user/about/index");
return modelAndView;
}
}

View File

@ -0,0 +1,73 @@
package com.example.jieyue.user.controller;
import com.example.jieyue.common.mapper.SysCartMapper;
import com.example.jieyue.user.service.UserCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* <p></p>
* @author Bosen
* 2020/11/3 13:06
*/
@RestController
public class UserCartController {
@Autowired
UserCartService cartService;
@Autowired
SysCartMapper cartMapper;
@RequestMapping("/user/cart")
public ModelAndView index(ModelAndView modelAndView, HttpServletRequest request){
List<Map> cartList = cartService.getCartList(request);
modelAndView.addObject("cartList",cartList);
modelAndView.setViewName("user/cart/index");
return modelAndView;
}
/*
*
*/
@RequestMapping("/user/add-cart")
public ModelAndView addCart(ModelAndView modelAndView, String id, @RequestParam(defaultValue = "1") int num, HttpServletRequest request){
if (num<=0){
modelAndView.addObject("msg","商品数量不合法");
}else{
int result = cartService.addCart(Integer.valueOf(id),num,request);
if (result == 1){
modelAndView.addObject("msg","已成功添加至购物车");
}
if (result == -1){
modelAndView.addObject("msg","添加至购物车失败");
}
if (result == 2){
modelAndView.addObject("msg","您在此前已将此商品添加至购物车");
}
}
modelAndView.setViewName("redirect:/user/product?id="+id);
return modelAndView;
}
/*
*
*/
@RequestMapping("/user/del-cart")
public ModelAndView delCart(ModelAndView modelAndView,int id){
int sql = cartMapper.deleteById(id);
if (sql == 1){
modelAndView.addObject("msg","移除购物车商品成功");
}else{
modelAndView.addObject("msg","移除购物车商品失败");
}
modelAndView.setViewName("redirect:/user/cart");
return modelAndView;
}
}

View File

@ -0,0 +1,46 @@
package com.example.jieyue.user.controller;
import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.user.service.UserCheckOutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.bind.DefaultValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* <p></p>
* @author Bosen
* 2020/11/3 9:53
*/
@RestController
public class UserCheckOutController {
@Autowired
UserCheckOutService checkOutService;
@RequestMapping("/user/checkout")
public ModelAndView index(ModelAndView modelAndView,String ids,@RequestParam(defaultValue = "-1")int num){
if(ids == null || ids.equals("")){
modelAndView.addObject("msg","请选择您要结算的商品");
modelAndView.setViewName("redirect:/user/cart");
}else{
// 获取商品信息
Map<SysGoods,Integer> goodsMap = checkOutService.getGoodsInfo(ids);
modelAndView.addObject("goodsMap",goodsMap);
// 获取对应的购物车id
List<Integer> carts = checkOutService.getCartIds(ids);
modelAndView.addObject("carts",carts);
// 总金额计算
BigDecimal allPrice = checkOutService.getGoodsNumPrice(goodsMap);
modelAndView.addObject("allPrice",allPrice);
modelAndView.setViewName("/user/checkout/index");
}
return modelAndView;
}
}

View File

@ -0,0 +1,86 @@
package com.example.jieyue.user.controller;
import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.entity.SysMtUi;
import com.example.jieyue.common.entity.SysUi;
import com.example.jieyue.user.service.UserHomeService;
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.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.util.Map;
/**
* <p></p>
* @author Bosen
* 2020/11/2 20:03
*/
@RestController
public class UserHomeController{
@Autowired
UserHomeService homeService;
@Autowired
RedisTemplate redisTemplate;
@RequestMapping({"/user/home","/"})
public ModelAndView home(ModelAndView modelAndView){
Map<String, SysUi> imgMap = null;
// 获取热卖商品列表
Map<String, SysGoods> escGoodsMap = null;
// 获取新出商品列表
Map<String, SysGoods> descGoodsMap = null;
// 随机获取商品列表
Map<String, SysGoods> randGoodsMap = null;
// 获取商户宣传店铺的海报
Map<String, SysMtUi> homeImg = null;
Map<String, SysMtUi> lowImg = null;
if (redisTemplate.opsForHash().entries("homePageCache").size() != 0){
Map map = redisTemplate.opsForHash().entries("homePageCache");
// 商城主页宣传海报
imgMap = (Map<String, SysUi>) map.get("imgMap");
// 获取热卖商品列表
escGoodsMap = (Map<String, SysGoods>) map.get("escGoodsMap");
// 获取新出商品列表
descGoodsMap = (Map<String, SysGoods>) map.get("descGoodsMap");
// 随机获取商品列表
randGoodsMap = (Map<String, SysGoods>) map.get("randGoodsMap");
// 获取商户宣传店铺的海报
homeImg = (Map<String, SysMtUi>) map.get("homeImg");
lowImg = (Map<String, SysMtUi>) map.get("lowImg");
}else{
// 商城主页宣传海报
imgMap = homeService.getImage();
// 获取热卖商品列表
escGoodsMap = homeService.getEsc(13);
// 获取新出商品列表
descGoodsMap = homeService.getDesc(6);
// 随机获取商品列表
randGoodsMap = homeService.getRand(12);
// 获取商户宣传店铺的海报
homeImg = homeService.getMtImg(400,320,3);
lowImg = homeService.getMtImg(600,310,3);
}
modelAndView.addObject("imgMap",imgMap);
modelAndView.addObject("escGoodsMap",escGoodsMap);
modelAndView.addObject("descGoodsMap",descGoodsMap);
modelAndView.addObject("randGoodsMap",randGoodsMap);
modelAndView.addObject("homeImg",homeImg);
modelAndView.addObject("lowImg",lowImg);
if (redisTemplate.opsForHash().entries("homePageCache").size() == 0){
// 设置缓存 十分钟内有效
homeService.setHomeCache(modelAndView);
}
modelAndView.setViewName("user/home/index");
return modelAndView;
}
}

View File

@ -0,0 +1,58 @@
package com.example.jieyue.user.controller;
import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.user.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest;
/**
* <p></p>
* @author Bosen
* 2020/11/24 21:29
*/
@RestController
public class UserInfoController {
@Autowired
UserInfoService userInfoService;
@RequestMapping("/user/info")
public ModelAndView index(ModelAndView modelAndView, HttpServletRequest request){
SysUser user = (SysUser) request.getSession().getAttribute("user");
modelAndView.addObject("user",user);
modelAndView.setViewName("user/info/index");
return modelAndView;
}
@RequestMapping("/user/update-info")
public ModelAndView updateInfo(RedirectAttributes redirectAttributes,HttpServletRequest request,ModelAndView modelAndView, MultipartFile img, int id, String username, String email, String oldPwd, String newPwd, String rePwd){
int result = userInfoService.updateInfo(redirectAttributes,request,img,id,username,email,oldPwd,newPwd,rePwd);
switch (result){
case -1:
modelAndView.addObject("msg","修改信息失败");
break;
case 0:
modelAndView.addObject("msg","必填信息不能为空");
break;
case 1:
modelAndView.addObject("msg","修改信息成功");
break;
case 2:
modelAndView.addObject("msg","邮箱格式不正确");
break;
case 3:
modelAndView.addObject("msg","原密码错误");
break;
case 4:
modelAndView.addObject("msg","两次输入的密码不一致");
break;
}
modelAndView.setViewName("redirect:/user/info");
return modelAndView;
}
}

View File

@ -0,0 +1,122 @@
package com.example.jieyue.user.controller;
import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.user.service.UserLoginService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* <p></p>
* @author Bosen
* 2020/10/30 17:42
*/
@RestController
@RequestMapping("/user")
public class UserLoginController {
@Autowired
private UserLoginService service;
/*
*
*/
@RequestMapping("login")
public ModelAndView index(ModelAndView modelAndView){
modelAndView.setViewName("user/login/index");
return modelAndView;
}
/*
* 退
*/
@RequestMapping("logout")
public ModelAndView logout(ModelAndView modelAndView,HttpServletRequest request){
request.getSession().setAttribute("user",null);
modelAndView.setViewName("redirect:/");
return modelAndView;
}
/*
*
*/
@RequestMapping("do-login")
public ModelAndView doLogin(HttpSession session, ModelAndView modelAndView, String email, String password){
int result = service.dologin(email,password);
if (result==1){
// 登陆成功
SysUser user = service.userInfo(email);
session.setAttribute("user",user);
modelAndView.setViewName("redirect:/");
}else if (result==-1){
// 用户名或密码错误!
modelAndView.addObject("msg","用户名或密码错误!");
modelAndView.setViewName("redirect:login");
}else if (result==0){
// 必填信息不能为空!
modelAndView.addObject("msg","必填信息不能为空!");
modelAndView.setViewName("redirect:login");
}
return modelAndView;
}
/*
*
*/
@RequestMapping("sign-up")
public ModelAndView signUp(ModelAndView modelAndView,String email,String username,String password,String repwd){
int result = service.singup(email,username,password,repwd);
if (result==0){
// 必填信息不能为空!
modelAndView.addObject("msg","必填信息不能为空!");
}
if (result==4){
// 该邮箱已被注册
modelAndView.addObject("msg","该邮箱已被注册");
}
if (result==3){
// 邮箱格式不正确
modelAndView.addObject("msg","邮箱格式不正确");
}
if (result==2){
// 两次密码输入不一致
modelAndView.addObject("msg","两次密码输入不一致");
}
if (result==1){
// 验证邮件已发送,请留意您的邮箱
modelAndView.addObject("msg","验证邮件已发送,请留意您的邮箱");
}
if (result==-1){
// 验证邮件发送失败,请重试
modelAndView.addObject("msg","注册超时,请重试");
}
modelAndView.setViewName("redirect:login");
return modelAndView;
}
/*
*
*/
@RequestMapping("sign-check")
public ModelAndView singCheck(ModelAndView modelAndView,@Param("email") String email){
int res = service.singCheck(email);
if (res==-1){
modelAndView.setViewName("redirect:/error");
}
if (res==0){
modelAndView.addObject("网络超时请重试");
modelAndView.setViewName("redirect:login");
}
if (res==1){
modelAndView.addObject("msg","注册成功");
modelAndView.setViewName("redirect:login");
}
return modelAndView;
}
}

View File

@ -0,0 +1,46 @@
package com.example.jieyue.user.controller;
import com.example.jieyue.common.entity.SysNotice;
import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.common.mapper.SysNoticeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpSession;
import java.util.List;
@RestController
public class UserNoticeController {
@Autowired
SysNoticeMapper noticeMapper;
@RequestMapping("/user/notice")
public ModelAndView index(ModelAndView modelAndView, HttpSession session,@RequestParam(defaultValue = "1") int page){
SysUser user = (SysUser)session.getAttribute("user");
List<SysNotice> noticeList =
noticeMapper.findByReceiveTypeLimit(user.getId(),2,(page-1)*8,8);
modelAndView.addObject("noticeList",noticeList);
modelAndView.setViewName("user/notice/index");
return modelAndView;
}
/*
*
*/
@RequestMapping("/user/del-notice")
public ModelAndView delNotice(ModelAndView modelAndView,int id){
if (noticeMapper.deleteById(id)==1){
modelAndView.addObject("msg","删除通知信息成功");
}else{
modelAndView.addObject("msg","删除通知信息成功失败");
}
modelAndView.setViewName("redirect:/user/notice");
return modelAndView;
}
}

View File

@ -0,0 +1,41 @@
package com.example.jieyue.user.controller;
import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.entity.SysOrder;
import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.user.service.UserOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* <p></p>
* @author Bosen
* 2020/11/3 12:57
*/
@RestController
public class UserOrderController {
@Autowired
UserOrderService orderService;
@RequestMapping("/user/order")
public ModelAndView index(HttpServletRequest request,ModelAndView modelAndView,@RequestParam(defaultValue = "1") int page){
SysUser user = (SysUser) request.getSession().getAttribute("user");
List<SysOrder> orderList = orderService.getOrderList(user.getId(),page,10);
List<SysGoods> goodsList = orderService.getGoodsList(orderList);
int allPage = orderService.getAllPage(user.getId(),10);
modelAndView.addObject("orderList",orderList);
modelAndView.addObject("goodsList",goodsList);
modelAndView.addObject("page",page);
modelAndView.addObject("allPage",allPage);
modelAndView.setViewName("user/order/index");
return modelAndView;
}
}

View File

@ -0,0 +1,124 @@
package com.example.jieyue.user.controller;
import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.entity.SysMt;
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.user.service.WxPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
public class UserPayController {
@Autowired
WxPayService wxPayService;
@Autowired
SysOrderMapper orderMapper;
/*
*
*/
@RequestMapping("/user/pay/wx")
public ModelAndView wx(ModelAndView modelAndView, String nums, String users, String merchants, String goods, String prices,
String notes, String address, String name, String phone, String code,String carts) {
// 生成orderMark
String orderMark = wxPayService.getOrderId();
// 添加订单
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("")){
modelAndView.addObject("orderMark",orderMark);
modelAndView.setViewName("redirect:/user/wxpay/index?mark="+orderMark);
}
return modelAndView;
}
/**
* <p></p>
* @author Bosen
* 2020/12/4 20:58
*/
@RequestMapping("/user/wxpay/notify")
public String wxNotify(HttpServletRequest request) throws Exception {
return wxPayService.wxNotify(request);
}
/*
*
*/
@RequestMapping("/user/check-order-status")
public boolean checkOrderStatus(String orderMark){
List<SysOrder> orderList = orderMapper.findByOrderMark(orderMark);
if (orderList.size()==0){
return false;
}else{
for (SysOrder order : orderList) {
if (order.getOrderState() != 1){
return false;
}
}
return true;
}
}
/*
*
*/
@RequestMapping("/user/wxpay/index")
public ModelAndView wxNotify(ModelAndView modelAndView,String mark) {
String codeUrl = orderMapper.findByOrderMark(mark).get(0).getPayCodeUrl();
modelAndView.addObject("codeUrl",codeUrl);
modelAndView.addObject("orderMark",mark);
modelAndView.setViewName("user/pay/wx");
return modelAndView;
}
/*
*
*/
@Autowired
SysGoodsMapper goodsMapper;
@Autowired
SysMtMapper merchantMapper;
@RequestMapping("/user/pay/test")
@Transactional
public String test() {
// 用于测试商品的id值
int goodsId = 44;
SysGoods goods = goodsMapper.findById(goodsId);
if (goods.getStock() > 0){
// 生成orderMark
String orderMark = wxPayService.getOrderId();
// 生成订单号
String orderId = wxPayService.getOrderId();
// 获取商户信息
SysMt merchant = merchantMapper.findById(goods.getMerchant());
// 执行sql语句
int sql = orderMapper.insert1(orderId, System.currentTimeMillis(), 1, orderMark, 99,
goods.getMerchant(), goods.getPrice(), goodsId, "test", "test",
"test", "123456", "test", 0,merchant.getRatio());
// 将商品库存做相应的减少
int delStock = goodsMapper.delStock(goodsId,1);
// 库存检查,库存少于零时回滚
if (sql != 1 || delStock != 1 || goodsMapper.findById(goodsId).getStock() < 0){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return "SUCCESS This is /user/pay/test";
}
return "ERROR This is /user/pay/test";
}
}

View File

@ -0,0 +1,87 @@
package com.example.jieyue.user.controller;
import com.example.jieyue.common.entity.SysComment;
import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.mapper.SysCommentMapper;
import com.example.jieyue.user.service.UserHomeService;
import com.example.jieyue.user.service.UserProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* <p></p>
* @author Bosen
* 2020/11/2 23:13
*/
@RestController
public class UserProductController {
@Autowired
UserProductService productService;
@Autowired
UserHomeService homeService;
@Autowired
SysCommentMapper commentMapper;
@RequestMapping("/user/product")
public ModelAndView index(ModelAndView modelAndView,int id,@RequestParam(defaultValue = "1") int page){
// 通过id值获取商品对象
SysGoods goods = productService.getGoods(id);
modelAndView.addObject("goods",goods);
// 随机获取商品列表
Map<String, SysGoods> randGoodsMap = homeService.getRand(8);
modelAndView.addObject("randGoodsMap",randGoodsMap);
// 获取商品评论信息
List<Map> commentList = productService.getCommentList(id,page,3);
modelAndView.addObject("commentList",commentList);
// 评论当前页数
modelAndView.addObject("page",page);
// 评论的总页数
int allPage = productService.getAllCountPage(id,3);
modelAndView.addObject("allPage",allPage);
modelAndView.setViewName("user/product/index");
return modelAndView;
}
/*
*
*/
@RequestMapping("/user/product/add-comment")
public ModelAndView addComment(ModelAndView modelAndView,int goods,int merchant,String context,HttpServletRequest request){
if (context.equals("")){
modelAndView.addObject("msg","评论内容不能为空");
}else{
int result = productService.addComment(goods,merchant,context,request);
if (result==1){
modelAndView.addObject("msg","发表评论成功");
}
if (result==-1){
modelAndView.addObject("msg","发表评论失败");
}
}
modelAndView.setViewName("redirect:/user/product?id="+goods);
return modelAndView;
}
/*
*
*/
@RequestMapping("/user/product/del-comment")
public ModelAndView delComment(ModelAndView modelAndView,int id,int goods){
int sql = commentMapper.deleteById(id);
if (sql==1){
modelAndView.addObject("msg","删除评论成功");
}else{
modelAndView.addObject("msg","删除评论失败");
}
modelAndView.setViewName("redirect:/user/product?id="+goods);
return modelAndView;
}
}

View File

@ -0,0 +1,31 @@
package com.example.jieyue.user.controller;
import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.user.service.UserSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
/**
* <p></p>
* @author Bosen
* 2020/11/29 19:48
*/
@RestController
public class UserSearchController {
@Autowired
UserSearchService searchService;
@RequestMapping("/user/search")
public ModelAndView index(ModelAndView modelAndView,String keyword){
// 获取返回的商品列表
List<SysGoods> goodsList = searchService.searchGoods(keyword);
modelAndView.addObject("goodsList",goodsList);
modelAndView.setViewName("user/search/index");
return modelAndView;
}
}

View File

@ -0,0 +1,46 @@
package com.example.jieyue.user.controller;
import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.entity.SysMt;
import com.example.jieyue.user.service.UserShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
import java.util.Map;
/**
* <p></p>
* @author Bosen
* 2020/11/2 20:26
*/
@RestController
public class UserShopController {
@Autowired
UserShopService shopService;
/*
*
*/
@RequestMapping("/user/shop")
public ModelAndView index(ModelAndView modelAndView,int id,@RequestParam(defaultValue = "1") int page){
// 获取商户信息
SysMt merchant = shopService.getMerchantInfo(id);
modelAndView.addObject("merchant",merchant);
// 获取商户商品信息
Map<Integer,SysGoods> goodsMap = shopService.getGoodsList(id,page,12);
modelAndView.addObject("goodsMap",goodsMap);
// 获取随机商品信息
Map<Integer,SysGoods> randGoodsMap = shopService.getRandGoodsMap(id,12);
modelAndView.addObject("randGoodsMap",randGoodsMap);
// 当前页数和总页数
modelAndView.addObject("page",page);
modelAndView.addObject("allPage",shopService.getAllPage(id,12));
modelAndView.setViewName("user/shop/index");
return modelAndView;
}
}

View File

@ -0,0 +1,81 @@
package com.example.jieyue.user.service;
import com.example.jieyue.common.entity.SysCart;
import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.entity.SysMt;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class UserCartService {
@Autowired
SysCartMapper cartMapper;
@Autowired
SysGoodsMapper goodsMapper;
@Autowired
SysMtMapper merchantMapper;
/**
* <p></p>
* @return
*-1
* 1
* 2
* @author Bosen
* 2020/11/29 10:44
*/
public int addCart(int id, int num, HttpServletRequest request){
// 获取用户信息
SysUser user = (SysUser)request.getSession().getAttribute("user");
// 判断用户是否已将此商品添加至购物车
int count = cartMapper.countByUserIdAndGoodsId(user.getId(),id);
if (count == 0){
int sql = cartMapper.insert(user.getId(),id,num);
if (sql == 1){
return 1;
}
}else{
return 2;
}
return -1;
}
/*
*
*/
public List<Map> getCartList(HttpServletRequest request){
// 获取用户信息
SysUser user = (SysUser) request.getSession().getAttribute("user");
List<Map> list = new ArrayList<>();
List<SysCart> cartList = cartMapper.findByUserIdLimit(user.getId());
for (SysCart cart : cartList) {
SysGoods goods = goodsMapper.findById(cart.getGoodsId());
SysMt merchant = merchantMapper.findById(goods.getMerchant());
Map<String,String> map = new HashMap<>();
map.put("goodsImg",goods.getImg());
map.put("cartId",cart.getId()+"");
map.put("goodsId",goods.getId()+"");
map.put("goodsPrice",goods.getPrice().toPlainString());
map.put("goodsName",goods.getName());
map.put("goodsNum",cart.getGoodsNum()+"");
map.put("goodsStock",goods.getStock()+"");
map.put("goodsState",goods.getState()+"");
map.put("goodsMerchant",merchant.getName());
list.add(map);
}
return list;
}
}

View File

@ -0,0 +1,70 @@
package com.example.jieyue.user.service;
import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.mapper.SysGoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class UserCheckOutService {
@Autowired
SysGoodsMapper goodsMapper;
/*
*
*/
public Map<SysGoods,Integer> getGoodsInfo(String ids){
Map<SysGoods,Integer> map = new HashMap<>();
Map<Integer,Integer> idsMap = getIdsMap(ids);
for (Integer id : idsMap.keySet()) {
map.put(goodsMapper.findById(id),idsMap.get(id));
}
return map;
}
/*
*
*/
public BigDecimal getGoodsNumPrice(Map<SysGoods,Integer> goodsMap){
BigDecimal allPrice = new BigDecimal(0.00);
for (SysGoods goods : goodsMap.keySet()) {
allPrice = allPrice.add(goods.getPrice().multiply(new BigDecimal(goodsMap.get(goods))));
}
return allPrice;
}
/*
* ids
*/
public Map<Integer,Integer> getIdsMap(String ids){
String[] idsAndNumArray = ids.split(",");
Map<Integer, Integer> map = new HashMap<>();
for (String idsAndNumA : idsAndNumArray) {
String[] idsAndNum = idsAndNumA.split(":");
int id = Integer.valueOf(idsAndNum[0]);
int num = Integer.valueOf(idsAndNum[1]);
map.put(id,num);
}
return map;
}
/*
* cart id
*/
public List<Integer> getCartIds(String ids){
String[] idsAndNumArray = ids.split(",");
List<Integer> list = new ArrayList<>();
for (int i = 0;i < idsAndNumArray.length;i++) {
String[] idsAndNum = idsAndNumArray[i].split(":");
int cart = Integer.valueOf(idsAndNum[2]);
list.add(cart);
}
return list;
}
}

View File

@ -0,0 +1,115 @@
package com.example.jieyue.user.service;
import com.example.jieyue.common.entity.SysGoods;
import com.example.jieyue.common.entity.SysMtUi;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Service
public class UserHomeService {
@Autowired
RedisTemplate redisTemplate;
@Autowired
SysUiMapper uiMapper;
@Autowired
SysGoodsMapper goodsMapper;
@Autowired
SysMtUiMapper mtUiMapper;
/*
*
*/
public void setHomeCache(ModelAndView modelAndView){
redisTemplate.opsForHash().put("homePageCache","imgMap",modelAndView.getModelMap().get("imgMap"));
redisTemplate.opsForHash().put("homePageCache","escGoodsMap",modelAndView.getModelMap().get("escGoodsMap"));
redisTemplate.opsForHash().put("homePageCache","descGoodsMap",modelAndView.getModelMap().get("descGoodsMap"));
redisTemplate.opsForHash().put("homePageCache","randGoodsMap",modelAndView.getModelMap().get("randGoodsMap"));
redisTemplate.opsForHash().put("homePageCache","homeImg",modelAndView.getModelMap().get("homeImg"));
redisTemplate.opsForHash().put("homePageCache","lowImg",modelAndView.getModelMap().get("lowImg"));
redisTemplate.expire("homePageCache",10, TimeUnit.MINUTES);
}
/*
*
*/
public Map<String,SysUi> getImage(){
Map<String,SysUi> map = new HashMap<>();
SysUi img1920 = uiMapper.findByMark(1920,737);
SysUi img1230 = uiMapper.findByMark(1230,535);
SysUi img475 = uiMapper.findByMark(475,570);
SysUi img674 = uiMapper.findByMark(674,264);
SysUi img3151 = uiMapper.findByMark(3151,282);
SysUi img3152 = uiMapper.findByMark(3152,282);
map.put(1920+"",img1920);
map.put(1230+"",img1230);
map.put(475+"",img475);
map.put(674+"",img674);
map.put(3151+"",img3151);
map.put(3152+"",img3152);
return map;
}
/*
*
*/
public Map<String, SysGoods> getEsc(int num){
List<SysGoods> list = 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){
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++){
map.put(i+"",list.get(i));
}
return map;
}
}

View File

@ -0,0 +1,83 @@
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.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;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletRequest;
@Service
public class UserInfoService {
@Autowired
MailService mailService;
@Autowired
SysUserMapper sysUserMapper;
@Autowired
FileUtil fileUtil;
IsEmptyUtil isEmptyUtil = new IsEmptyUtil();
/**
* <p></p>
*
* @return
*-1
* 1
* 0
* 2
* 3
* 4
*/
public int updateInfo(RedirectAttributes redirectAttributes, HttpServletRequest request,MultipartFile img, int id, String username, String email, String oldPwd, String newPwd, String rePwd){
if (isEmptyUtil.strings(username,email)){
return 0;
}
if (!mailService.checkEmail(email)){
return 2;
}
SysUser user = sysUserMapper.selectById(id);
if (!oldPwd.equals("") || !newPwd.equals("") || !rePwd.equals("")){
oldPwd = DigestUtils.md5DigestAsHex(oldPwd.getBytes());
if (!user.getPassword().equals(oldPwd)){
return 3;
}
if (!newPwd.equals(rePwd)){
return 4;
}
}
if (newPwd.equals("")){
newPwd = oldPwd;
}else{
newPwd = DigestUtils.md5DigestAsHex(newPwd.getBytes());
}
// 更新头像
String header = user.getHeader();
if (!img.isEmpty()){
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){
// 更新用户信息
request.getSession().setAttribute("user",sysUserMapper.selectById(id));
return 1;
}
return -1;
}
}

View File

@ -0,0 +1,137 @@
package com.example.jieyue.user.service;
import com.example.jieyue.common.entity.SysUser;
import com.example.jieyue.common.service.MailService;
import com.example.jieyue.common.service.SysUserService;
import com.example.jieyue.common.utils.IsEmptyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
import java.util.HashMap;
import java.util.Map;
@Service
public class UserLoginService {
@Autowired
SysUserService service;
@Value("${site-url}")
String sitrUrl;
@Autowired
MailService mailService;
@Autowired
RedisTemplate redisTemplate;
// 判空工具类
IsEmptyUtil isEmptyUtil = IsEmptyUtil.getInstance();
/**
* <p></p>
* @return int
* 1
* 0
*-1
*/
public int dologin(String email,String password){
SysUser user = service.selectByEmail(email);
// 用户名密码不能为空
if (isEmptyUtil.strings(email,password)){
return 0;
}
// 不存在该用户
if (user==null){
return -1;
}
// 密码验证
password = DigestUtils.md5DigestAsHex(password.getBytes());
// 密码错误
if (!user.getPassword().equals(password)){
return -1;
}else{
return 1;
}
}
/*
*
*/
public SysUser userInfo(String email){
return service.getUserInfo(email);
}
/**
* <p></p>
* @return int
*-1
* 0
* 1
* 2
* 3
* 4
*/
public int singup(String email,String username,String password,String repwd){
// 必填信息不能为空
if (isEmptyUtil.strings(email,username,password,repwd)){
return 0;
}
// 邮箱格式验证
if(!mailService.checkEmail(email)){
System.out.println(email);
return 3;
}
// 两次密码不一致
if (!password.equals(repwd)){
return 2;
}
// 该邮箱已被注册
SysUser user = service.selectByEmail(email);
password = DigestUtils.md5DigestAsHex(password.getBytes());
if (user!=null){
if (user.getMark()!=0){
return 4;
}else{
if (service.update(username,password,email)!=1){
return -1;
}
}
}else{
// 将信息保存状态置为0未启用
// 添加信息未成功返回超时
if (service.insert(username,password,email,0)!=1){
return -1;
}
}
// 发送注册验证邮件
Map<String,String> map = new HashMap<>();
map.put("email",email);
map.put("title","捷阅网用户注册验证");
map.put("context","<a href='http://" + this.sitrUrl + "/user/sign-check?email=" + email + "'>点击此链接完成注册验证</a>");
redisTemplate.opsForList().leftPush("email",map);
return 1;
}
/**
*
* @return int
*-1 404
* 0
* 1
*/
public int singCheck(String email){
SysUser user = service.selectByEmail(email);
if (user!=null && user.getMark()==0){
int res = service.updateMark(1,email);
if (res==1){
return 1;
}else{
return 0;
}
}else{
return -1;
}
}
}

Some files were not shown because too many files have changed in this diff Show More