diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..8037970
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/qauMa.iml b/.idea/qauMa.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/qauMa.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/avatar/09cd5add81ff4abfbd1ccf91b2e9c820.jpg b/avatar/09cd5add81ff4abfbd1ccf91b2e9c820.jpg
new file mode 100644
index 0000000..985d64e
Binary files /dev/null and b/avatar/09cd5add81ff4abfbd1ccf91b2e9c820.jpg differ
diff --git a/avatar/978418fbe75243b4ba38da389a468b78.jpg b/avatar/978418fbe75243b4ba38da389a468b78.jpg
new file mode 100644
index 0000000..49c790a
Binary files /dev/null and b/avatar/978418fbe75243b4ba38da389a468b78.jpg differ
diff --git a/avatar/e8663626d17b41bd89707299fcd5ac81.jpg b/avatar/e8663626d17b41bd89707299fcd5ac81.jpg
new file mode 100644
index 0000000..b29aa97
Binary files /dev/null and b/avatar/e8663626d17b41bd89707299fcd5ac81.jpg differ
diff --git a/electronic_mall.sql b/electronic_mall.sql
new file mode 100644
index 0000000..6f780f2
--- /dev/null
+++ b/electronic_mall.sql
@@ -0,0 +1,380 @@
+/*
+ Navicat Premium Data Transfer
+
+ Source Server : localhost
+ Source Server Type : MySQL
+ Source Server Version : 80019
+ Source Host : localhost:3306
+ Source Schema : electronic_mall
+
+ Target Server Type : MySQL
+ Target Server Version : 80019
+ File Encoding : 65001
+
+ Date: 10/08/2023 20:33:14
+*/
+
+SET NAMES utf8;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for address
+-- ----------------------------
+DROP TABLE IF EXISTS `address`;
+CREATE TABLE `address` (
+ `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `link_user` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '联系人',
+ `link_address` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '地址',
+ `link_phone` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '电话',
+ `user_id` bigint(0) NULL DEFAULT NULL COMMENT '所属用户',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '地址表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of address
+-- ----------------------------
+INSERT INTO `address` VALUES (1, '张三', '北京市', '13333333333', 1);
+INSERT INTO `address` VALUES (2, '张三', '北京市', '15888888888', 2);
+INSERT INTO `address` VALUES (3, '张三', '上海市', '15555555555', 2);
+INSERT INTO `address` VALUES (4, '张三', '新疆', '15888888888', 2);
+
+-- ----------------------------
+-- Table structure for avatar
+-- ----------------------------
+DROP TABLE IF EXISTS `avatar`;
+CREATE TABLE `avatar` (
+ `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
+ `size` bigint(0) NULL DEFAULT NULL,
+ `url` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
+ `md5` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '头像表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of avatar
+-- ----------------------------
+INSERT INTO `avatar` VALUES (2, 'jpg', 492, '/avatar/978418fbe75243b4ba38da389a468b78.jpg', '1e5802c8b96198fd524cc91ad3f9d476');
+INSERT INTO `avatar` VALUES (3, 'jpg', 146, '/avatar/e8663626d17b41bd89707299fcd5ac81.jpg', '5c072037e4e9662831fe448e28795770');
+INSERT INTO `avatar` VALUES (4, 'jpg', 175, '/avatar/09cd5add81ff4abfbd1ccf91b2e9c820.jpg', '507704f05fbca53793bce9970b40e6c8');
+
+-- ----------------------------
+-- Table structure for carousel
+-- ----------------------------
+DROP TABLE IF EXISTS `carousel`;
+CREATE TABLE `carousel` (
+ `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `good_id` bigint(0) NULL DEFAULT NULL COMMENT '对应的商品id',
+ `show_order` int(0) NULL DEFAULT NULL COMMENT '播放顺序',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '轮播图表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of carousel
+-- ----------------------------
+INSERT INTO `carousel` VALUES (4, 5, 2);
+INSERT INTO `carousel` VALUES (5, 4, 3);
+INSERT INTO `carousel` VALUES (6, 7, 4);
+
+-- ----------------------------
+-- Table structure for cart
+-- ----------------------------
+DROP TABLE IF EXISTS `cart`;
+CREATE TABLE `cart` (
+ `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `count` int(0) NULL DEFAULT NULL COMMENT '数量',
+ `create_time` datetime NULL DEFAULT NULL COMMENT '加入时间',
+ `good_id` bigint(0) NULL DEFAULT NULL COMMENT '商品id',
+ `standard` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
+ `user_id` bigint(0) NULL DEFAULT NULL COMMENT '用户id',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '购物车表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of cart
+-- ----------------------------
+INSERT INTO `cart` VALUES (2, 1, '2023-07-15 13:48:00', 2, 'M 中码', 2);
+INSERT INTO `cart` VALUES (3, 1, '2023-07-15 13:48:04', 5, '白色', 2);
+INSERT INTO `cart` VALUES (4, 1, '2023-07-15 13:48:08', 7, '43码', 2);
+
+-- ----------------------------
+-- Table structure for category
+-- ----------------------------
+DROP TABLE IF EXISTS `category`;
+CREATE TABLE `category` (
+ `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '类别名称',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 24 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '分类表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of category
+-- ----------------------------
+INSERT INTO `category` VALUES (1, '女装');
+INSERT INTO `category` VALUES (2, '男装');
+INSERT INTO `category` VALUES (10, '运动鞋');
+INSERT INTO `category` VALUES (11, '休闲鞋');
+INSERT INTO `category` VALUES (12, '靴子');
+INSERT INTO `category` VALUES (13, '办公用品');
+INSERT INTO `category` VALUES (14, '书籍');
+INSERT INTO `category` VALUES (15, '笔记本');
+INSERT INTO `category` VALUES (16, '手机');
+INSERT INTO `category` VALUES (17, '平板电脑');
+INSERT INTO `category` VALUES (18, '烹饪食材');
+INSERT INTO `category` VALUES (19, '白酒');
+INSERT INTO `category` VALUES (20, '茶叶');
+INSERT INTO `category` VALUES (21, '咖啡');
+INSERT INTO `category` VALUES (22, '宠物用品');
+INSERT INTO `category` VALUES (23, '宠物饲料');
+
+-- ----------------------------
+-- Table structure for good
+-- ----------------------------
+DROP TABLE IF EXISTS `good`;
+CREATE TABLE `good` (
+ `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '商品名称',
+ `description` varchar(1600) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '描述',
+ `discount` double(10, 2) NOT NULL DEFAULT 1.00 COMMENT '折扣',
+ `sales` bigint(0) NOT NULL DEFAULT 0 COMMENT '销量',
+ `sale_money` double(10, 2) NULL DEFAULT 0.00 COMMENT '销售额',
+ `category_id` bigint(0) NULL DEFAULT NULL COMMENT '分类id',
+ `imgs` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '商品图片',
+ `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
+ `recommend` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否推荐。0不推荐,1推荐',
+ `is_delete` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否删除,0未删除,1删除',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '商品表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of good
+-- ----------------------------
+INSERT INTO `good` VALUES (2, '衬衫', '鳄鱼夹克男春季新款休闲百搭翻领外套男中青年时尚潮流夹克衫男装上衣 绿色 XL(130-145斤)', 0.95, 35, 13700.50, 2, '/file/74488020672944968462e9e4a9c89096.png', '2023-03-27 13:32:44', 1, 0);
+INSERT INTO `good` VALUES (3, '桌椅套装', '这款桌椅套装是您家庭和办公室的理想选择。精心设计的桌子和舒适的椅子,完美结合,给您带来了坐姿舒适和优雅的工作环境。优质材料和坚固的结构确保您享受长久的使用寿命。', 0.98, 0, 0.00, 13, '/file/b4ac53ed62c74c298366619399c39f99.jpg', '2023-03-31 20:44:00', 1, 0);
+INSERT INTO `good` VALUES (4, '威士忌 大瓶', '这款洋酒是一款精心酿造的上乘佳酿,给您带来无与伦比的品尝享受。精选优质的原料,经过精心的发酵和蒸馏工艺,使得这款洋酒口感柔和,回味悠长。', 0.80, 0, 0.00, 19, '/file/be9d2d6a17c5436fb0b8c2f7927484b2.jpg', '2023-03-31 20:46:37', 1, 0);
+INSERT INTO `good` VALUES (5, '女上衣', '酒红色圆领短袖T恤女休闲2023年新款上衣修身拼色女装S8220334 白色 XL', 0.80, 1, 116.00, 1, '/file/15cb9fc604984dfa97e0e968eb1d196d.jpg', '2023-03-31 20:47:59', 1, 0);
+INSERT INTO `good` VALUES (6, '《PSALMS》英文版 图书', '《PSALMS》英文版是一本精美的图书,专门收录了许多有趣的诗篇。这本书为读者带来了感人至深的心灵之旅。', 1.00, 0, 0.00, 14, '/file/8dc5354c7332454796c614bb4a0572fb.jpg', '2023-03-31 20:48:51', 1, 0);
+INSERT INTO `good` VALUES (7, '休闲鞋', '男士运动休闲鞋软底网面鞋健步鞋黑灰色42', 0.96, 1, 110.40, 11, '/file/0afa4eb1c51943808f6e83cd9ced25e8.jpg', '2023-03-31 20:49:36', 1, 0);
+INSERT INTO `good` VALUES (8, '123', '123', 1.00, 43, 5289.00, 1, '/file/09bb6edab07a4c68a44cce41a3300d97.jpg', '2023-06-12 00:55:57', 0, 1);
+INSERT INTO `good` VALUES (9, '儿童简笔画册', '适合儿童简笔画上色的底稿', 1.00, 0, 0.00, 13, '/file/2e2a1df657324a3293642344327310cb.png', '2023-08-10 20:28:58', 1, 0);
+INSERT INTO `good` VALUES (10, '墨镜', '抵抗紫外线', 1.00, 0, 0.00, 13, '/file/449ab0163ba648c08cb4a76b40a9dcec.jpg', '2023-08-10 20:29:47', 1, 0);
+
+-- ----------------------------
+-- Table structure for good_standard
+-- ----------------------------
+DROP TABLE IF EXISTS `good_standard`;
+CREATE TABLE `good_standard` (
+ `good_id` bigint(0) NULL DEFAULT NULL COMMENT '商品id',
+ `value` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '规格',
+ `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '价格',
+ `store` bigint(0) NULL DEFAULT NULL COMMENT '库存'
+) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '商品规格表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of good_standard
+-- ----------------------------
+INSERT INTO `good_standard` VALUES (8, '123', 123.00, 80);
+INSERT INTO `good_standard` VALUES (5, '白色', 145.00, 299);
+INSERT INTO `good_standard` VALUES (7, '43码', 115.00, 149);
+INSERT INTO `good_standard` VALUES (6, '英文版', 99.00, 500);
+INSERT INTO `good_standard` VALUES (4, '单瓶', 2600.00, 500);
+INSERT INTO `good_standard` VALUES (4, '三瓶送礼套装', 6100.00, 900);
+INSERT INTO `good_standard` VALUES (3, '桌子', 90.00, 600);
+INSERT INTO `good_standard` VALUES (3, '椅子', 50.00, 500);
+INSERT INTO `good_standard` VALUES (3, '桌子+椅子', 150.00, 500);
+INSERT INTO `good_standard` VALUES (2, 'S 小码', 129.00, 498);
+INSERT INTO `good_standard` VALUES (2, 'M 中码', 129.00, 496);
+INSERT INTO `good_standard` VALUES (2, 'L 大码', 129.00, 496);
+INSERT INTO `good_standard` VALUES (9, '标准版', 50.00, 600);
+INSERT INTO `good_standard` VALUES (10, '标准30cm', 60.00, 500);
+
+-- ----------------------------
+-- Table structure for icon
+-- ----------------------------
+DROP TABLE IF EXISTS `icon`;
+CREATE TABLE `icon` (
+ `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `value` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '图标的识别码',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '图标表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of icon
+-- ----------------------------
+INSERT INTO `icon` VALUES (1, '');
+INSERT INTO `icon` VALUES (15, '');
+INSERT INTO `icon` VALUES (16, '');
+INSERT INTO `icon` VALUES (17, '');
+INSERT INTO `icon` VALUES (18, '');
+INSERT INTO `icon` VALUES (19, '');
+INSERT INTO `icon` VALUES (21, '');
+
+-- ----------------------------
+-- Table structure for icon_category
+-- ----------------------------
+DROP TABLE IF EXISTS `icon_category`;
+CREATE TABLE `icon_category` (
+ `category_id` bigint(0) NOT NULL COMMENT '分类id',
+ `icon_id` bigint(0) NOT NULL COMMENT '图标id',
+ PRIMARY KEY (`category_id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '商品分类 - 图标关联表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of icon_category
+-- ----------------------------
+INSERT INTO `icon_category` VALUES (1, 1);
+INSERT INTO `icon_category` VALUES (2, 1);
+INSERT INTO `icon_category` VALUES (10, 15);
+INSERT INTO `icon_category` VALUES (11, 15);
+INSERT INTO `icon_category` VALUES (12, 15);
+INSERT INTO `icon_category` VALUES (13, 16);
+INSERT INTO `icon_category` VALUES (14, 16);
+INSERT INTO `icon_category` VALUES (15, 17);
+INSERT INTO `icon_category` VALUES (16, 17);
+INSERT INTO `icon_category` VALUES (17, 17);
+INSERT INTO `icon_category` VALUES (18, 18);
+INSERT INTO `icon_category` VALUES (19, 19);
+INSERT INTO `icon_category` VALUES (20, 19);
+INSERT INTO `icon_category` VALUES (21, 19);
+INSERT INTO `icon_category` VALUES (22, 21);
+INSERT INTO `icon_category` VALUES (23, 21);
+
+-- ----------------------------
+-- Table structure for order_goods
+-- ----------------------------
+DROP TABLE IF EXISTS `order_goods`;
+CREATE TABLE `order_goods` (
+ `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `order_id` bigint(0) NULL DEFAULT NULL COMMENT '订单id',
+ `good_id` bigint(0) NULL DEFAULT NULL COMMENT '商品id',
+ `count` int(0) NULL DEFAULT NULL COMMENT '数量',
+ `standard` varchar(1600) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '规格',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 24 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of order_goods
+-- ----------------------------
+INSERT INTO `order_goods` VALUES (9, 9, 2, 3, 'M 中码');
+INSERT INTO `order_goods` VALUES (10, 10, 2, 3, 'L 大码');
+INSERT INTO `order_goods` VALUES (11, 11, 2, 1, 'S 小码');
+INSERT INTO `order_goods` VALUES (12, 12, 8, 1, '123');
+INSERT INTO `order_goods` VALUES (13, 13, 8, 12, '123');
+INSERT INTO `order_goods` VALUES (14, 14, 8, 1, '123');
+INSERT INTO `order_goods` VALUES (15, 15, 8, 1, '123');
+INSERT INTO `order_goods` VALUES (16, 16, 8, 15, '123');
+INSERT INTO `order_goods` VALUES (17, 17, 8, 1, '123');
+INSERT INTO `order_goods` VALUES (18, 18, 8, 1, '123');
+INSERT INTO `order_goods` VALUES (19, 19, 8, 11, '123');
+INSERT INTO `order_goods` VALUES (20, 20, 2, 1, 'M 中码');
+INSERT INTO `order_goods` VALUES (21, 21, 2, 1, 'L 大码');
+INSERT INTO `order_goods` VALUES (22, 22, 7, 1, '43码');
+INSERT INTO `order_goods` VALUES (23, 23, 2, 1, 'S 小码');
+INSERT INTO `order_goods` VALUES (24, 24, 5, 1, '白色');
+
+-- ----------------------------
+-- Table structure for standard
+-- ----------------------------
+DROP TABLE IF EXISTS `standard`;
+CREATE TABLE `standard` (
+ `goodId` bigint(0) NOT NULL COMMENT '商品id',
+ `value` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '商品规格',
+ `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '该规格的价格',
+ `store` bigint(0) NULL DEFAULT NULL COMMENT '该规格的库存',
+ PRIMARY KEY (`goodId`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '规格表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Table structure for sys_file
+-- ----------------------------
+DROP TABLE IF EXISTS `sys_file`;
+CREATE TABLE `sys_file` (
+ `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '文件名称',
+ `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '文件类型',
+ `size` bigint(0) NULL DEFAULT NULL COMMENT '大小',
+ `url` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '文件路径',
+ `is_delete` tinyint(1) NULL DEFAULT NULL COMMENT '是否删除',
+ `enable` tinyint(1) NULL DEFAULT NULL COMMENT '是否启用',
+ `md5` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'md5值',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 34 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '系统文件表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of sys_file
+-- ----------------------------
+INSERT INTO `sys_file` VALUES (7, '07.jpg', 'jpg', 1814, '/file/7dfd10628edc4b4e97de19c1cb86585e.jpg', 0, 0, '04271616ebc6914643c3af592dd58bef');
+INSERT INTO `sys_file` VALUES (8, '9a49edb823cc4cb799cb3438a7419a83.jpg', 'jpg', 132, '/file/2b6249b9ba24491a9048c1e8c0b5256e.jpg', 0, 0, 'f11ed5acc29b90770a453eceb7524712');
+INSERT INTO `sys_file` VALUES (9, '9a49edb823cc4cb799cb3438a7419a83.jpg', 'jpg', 132, '/file/2b6249b9ba24491a9048c1e8c0b5256e.jpg', 0, 0, 'f11ed5acc29b90770a453eceb7524712');
+INSERT INTO `sys_file` VALUES (10, '9a49edb823cc4cb799cb3438a7419a83.jpg', 'jpg', 132, '/file/2b6249b9ba24491a9048c1e8c0b5256e.jpg', 0, 0, 'f11ed5acc29b90770a453eceb7524712');
+INSERT INTO `sys_file` VALUES (11, '9a49edb823cc4cb799cb3438a7419a83.jpg', 'jpg', 132, '/file/2b6249b9ba24491a9048c1e8c0b5256e.jpg', 0, 0, 'f11ed5acc29b90770a453eceb7524712');
+INSERT INTO `sys_file` VALUES (12, '5a776cc21c1b407bbd2595a7af726a61.jpg', 'jpg', 846, '/file/0e8132c00dc6484faa18b2d1487b34ec.jpg', 0, 0, '8f0a34a66bbc1a794b7c138897a66dad');
+INSERT INTO `sys_file` VALUES (13, '5a776cc21c1b407bbd2595a7af726a61.jpg', 'jpg', 846, '/file/0e8132c00dc6484faa18b2d1487b34ec.jpg', 0, 0, '8f0a34a66bbc1a794b7c138897a66dad');
+INSERT INTO `sys_file` VALUES (14, '5a776cc21c1b407bbd2595a7af726a61.jpg', 'jpg', 846, '/file/0e8132c00dc6484faa18b2d1487b34ec.jpg', 0, 0, '8f0a34a66bbc1a794b7c138897a66dad');
+INSERT INTO `sys_file` VALUES (15, '5a776cc21c1b407bbd2595a7af726a61.jpg', 'jpg', 846, '/file/0e8132c00dc6484faa18b2d1487b34ec.jpg', 0, 0, '8f0a34a66bbc1a794b7c138897a66dad');
+INSERT INTO `sys_file` VALUES (16, '5a776cc21c1b407bbd2595a7af726a61.jpg', 'jpg', 846, '/file/0e8132c00dc6484faa18b2d1487b34ec.jpg', 0, 0, '8f0a34a66bbc1a794b7c138897a66dad');
+INSERT INTO `sys_file` VALUES (17, '5a776cc21c1b407bbd2595a7af726a61.jpg', 'jpg', 846, '/file/0e8132c00dc6484faa18b2d1487b34ec.jpg', 0, 0, '8f0a34a66bbc1a794b7c138897a66dad');
+INSERT INTO `sys_file` VALUES (18, '02.jpg', 'jpg', 33, '/file/84ad8a9829424254811ce2220edc2d3b.jpg', 0, 0, 'fcf09e93c497c75cf2b3656f80f997cc');
+INSERT INTO `sys_file` VALUES (19, '01.jpg', 'jpg', 26, '/file/cef757d124ec4b169cffd65de5e3c47c.jpg', 0, 0, 'd5b6bb3b068c1980d77c59079248a4a4');
+INSERT INTO `sys_file` VALUES (20, '03.jpg', 'jpg', 22, '/file/7791be8ea1ee4aa0a149ae8e75c857d6.jpg', 0, 0, '75e8b3e8790e514fb799857f636a1623');
+INSERT INTO `sys_file` VALUES (21, '04.jpg', 'jpg', 25, '/file/867aaf026b684b1e8b1a10c87e31df7e.jpg', 0, 0, '1d7397d5a4ce0995f711a1484d593f44');
+INSERT INTO `sys_file` VALUES (22, '05.jpg', 'jpg', 19, '/file/f9f26a01e13d4ba68d7f7bd12df282e0.jpg', 0, 0, 'b2d243af2652abf08a491074c8f099ea');
+INSERT INTO `sys_file` VALUES (23, '06.jpg', 'jpg', 11, '/file/286aa7816325455b8cdcd522aca833fe.jpg', 0, 0, 'c160a645c3dacb58ffb123a4239dcb50');
+INSERT INTO `sys_file` VALUES (24, '037c5b1f3e40406893b423563c557a91.jpg', 'jpg', 1641, '/file/09bb6edab07a4c68a44cce41a3300d97.jpg', 0, 0, '067143803d2f87dcb939de5d4ace2bbb');
+INSERT INTO `sys_file` VALUES (25, '01.jpg', 'jpg', 329, '/file/15cb9fc604984dfa97e0e968eb1d196d.jpg', 0, 0, '8c78b307ff66fbc7db624da25138f480');
+INSERT INTO `sys_file` VALUES (26, '02.jpg', 'jpg', 738, '/file/e2cf8486c2384b8296972a550bf7e934.jpg', 0, 0, '7db1f7335529ad2a68367d29d0441695');
+INSERT INTO `sys_file` VALUES (27, '04.jpg', 'jpg', 158, '/file/0afa4eb1c51943808f6e83cd9ced25e8.jpg', 0, 0, '0bfaaafc7ca1a9a5478baa8c9cae492c');
+INSERT INTO `sys_file` VALUES (28, '05 (1).jpg', 'jpg', 773, '/file/8dc5354c7332454796c614bb4a0572fb.jpg', 0, 0, '925882b34e70434888ee7ca373bae52c');
+INSERT INTO `sys_file` VALUES (29, '03 (2).jpg', 'jpg', 208, '/file/b4ac53ed62c74c298366619399c39f99.jpg', 0, 0, '1468738643a2f6dbd5fad1f7c80cdb00');
+INSERT INTO `sys_file` VALUES (30, '06.jpg', 'jpg', 3494, '/file/be9d2d6a17c5436fb0b8c2f7927484b2.jpg', 0, 0, 'd9950e2a7400a3d26ebde81c47e92e04');
+INSERT INTO `sys_file` VALUES (31, '02.png', 'png', 5898, '/file/74488020672944968462e9e4a9c89096.png', 0, 0, 'ad801047fc9918bd626656d08d696898');
+INSERT INTO `sys_file` VALUES (32, '02.png', 'png', 71, '/file/2e2a1df657324a3293642344327310cb.png', 0, 0, '2c3a088b474cb2144645411f2e3da9c6');
+INSERT INTO `sys_file` VALUES (33, '03.jpg', 'jpg', 31, '/file/449ab0163ba648c08cb4a76b40a9dcec.jpg', 0, 0, 'fa95b8365bc4ec2096f4dc3f31dc8e27');
+
+-- ----------------------------
+-- Table structure for sys_user
+-- ----------------------------
+DROP TABLE IF EXISTS `sys_user`;
+CREATE TABLE `sys_user` (
+ `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '用户名',
+ `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '密码',
+ `nickname` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '昵称',
+ `email` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '邮箱',
+ `phone` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '手机号码',
+ `address` varchar(1600) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '地址',
+ `avatar_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '头像链接',
+ `role` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '角色',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '用户表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of sys_user
+-- ----------------------------
+INSERT INTO `sys_user` VALUES (1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', '管理员', '123@qq.com', '13333333333', NULL, '/avatar/09cd5add81ff4abfbd1ccf91b2e9c820.jpg', 'admin');
+INSERT INTO `sys_user` VALUES (2, 'user', 'e10adc3949ba59abbe56e057f20f883e', '新用户', '1234@qq.com', '15888888888', NULL, '/avatar/978418fbe75243b4ba38da389a468b78.jpg', 'user');
+
+-- ----------------------------
+-- Table structure for t_order
+-- ----------------------------
+DROP TABLE IF EXISTS `t_order`;
+CREATE TABLE `t_order` (
+ `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `order_no` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '订单号',
+ `total_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '总价',
+ `user_id` bigint(0) NULL DEFAULT NULL COMMENT '用户id',
+ `link_user` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '联系人',
+ `link_phone` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '联系电话',
+ `link_address` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '地址',
+ `state` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '订单状态',
+ `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 24 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '订单表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of t_order
+-- ----------------------------
+INSERT INTO `t_order` VALUES (9, '20230331223822860904', 367.65, 2, '张三', '15888888888', '新疆', '已收货', '2023-03-31 22:38:22');
+INSERT INTO `t_order` VALUES (24, '20230805014642654151', 116.00, 2, '张三', '15888888888', '北京市', '已支付', '2023-08-05 01:46:42');
+
+SET FOREIGN_KEY_CHECKS = 1;
diff --git a/file/0afa4eb1c51943808f6e83cd9ced25e8.jpg b/file/0afa4eb1c51943808f6e83cd9ced25e8.jpg
new file mode 100644
index 0000000..17b4bf5
Binary files /dev/null and b/file/0afa4eb1c51943808f6e83cd9ced25e8.jpg differ
diff --git a/file/15cb9fc604984dfa97e0e968eb1d196d.jpg b/file/15cb9fc604984dfa97e0e968eb1d196d.jpg
new file mode 100644
index 0000000..6513a2c
Binary files /dev/null and b/file/15cb9fc604984dfa97e0e968eb1d196d.jpg differ
diff --git a/file/2e2a1df657324a3293642344327310cb.png b/file/2e2a1df657324a3293642344327310cb.png
new file mode 100644
index 0000000..91d8752
Binary files /dev/null and b/file/2e2a1df657324a3293642344327310cb.png differ
diff --git a/file/449ab0163ba648c08cb4a76b40a9dcec.jpg b/file/449ab0163ba648c08cb4a76b40a9dcec.jpg
new file mode 100644
index 0000000..78668d2
Binary files /dev/null and b/file/449ab0163ba648c08cb4a76b40a9dcec.jpg differ
diff --git a/file/74488020672944968462e9e4a9c89096.png b/file/74488020672944968462e9e4a9c89096.png
new file mode 100644
index 0000000..cbd7955
Binary files /dev/null and b/file/74488020672944968462e9e4a9c89096.png differ
diff --git a/file/8dc5354c7332454796c614bb4a0572fb.jpg b/file/8dc5354c7332454796c614bb4a0572fb.jpg
new file mode 100644
index 0000000..9ff2682
Binary files /dev/null and b/file/8dc5354c7332454796c614bb4a0572fb.jpg differ
diff --git a/file/b4ac53ed62c74c298366619399c39f99.jpg b/file/b4ac53ed62c74c298366619399c39f99.jpg
new file mode 100644
index 0000000..69fffd4
Binary files /dev/null and b/file/b4ac53ed62c74c298366619399c39f99.jpg differ
diff --git a/file/be9d2d6a17c5436fb0b8c2f7927484b2.jpg b/file/be9d2d6a17c5436fb0b8c2f7927484b2.jpg
new file mode 100644
index 0000000..1f36849
Binary files /dev/null and b/file/be9d2d6a17c5436fb0b8c2f7927484b2.jpg differ
diff --git a/file/de900cd56fda477d9baa2d203c720018.jpg b/file/de900cd56fda477d9baa2d203c720018.jpg
new file mode 100644
index 0000000..dd1e4f1
Binary files /dev/null and b/file/de900cd56fda477d9baa2d203c720018.jpg differ
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..1798805
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,132 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.5.6
+
+
+ com.rabbiter
+ ElectronicMallApi
+ 0.0.1-SNAPSHOT
+ ElectronicMallApi
+ ElectronicMallApi
+
+ 1.8
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 2.2.2
+
+
+
+ mysql
+ mysql-connector-java
+ runtime
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ com.alibaba
+ druid
+ 1.2.2
+
+
+
+ org.apache.commons
+ commons-compress
+ 1.21
+
+
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ 3.5.1
+
+
+
+ io.springfox
+ springfox-swagger2
+ 2.9.2
+
+
+ io.springfox
+ springfox-swagger-ui
+ 2.9.2
+
+
+
+ com.auth0
+ java-jwt
+ 3.10.3
+
+
+
+
+
+ cn.hutool
+ hutool-all
+ 5.7.21
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.73
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+ org.apache.commons
+ commons-pool2
+ 2.9.0
+
+
+
+ com.sun.xml.fastinfoset
+ FastInfoset
+ 1.2.18
+
+
+
+
+
+ public
+ aliyun nexus
+ https://maven.aliyun.com/repository/public/
+
+ true
+
+
+
+
+
+
+ public
+ aliyun nexus
+ https://maven.aliyun.com/repository/public/
+
+ true
+
+
+ false
+
+
+
+
diff --git a/src/main/java/com/rabbiter/em/ElectronicMallApplication.java b/src/main/java/com/rabbiter/em/ElectronicMallApplication.java
new file mode 100644
index 0000000..6776efe
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/ElectronicMallApplication.java
@@ -0,0 +1,20 @@
+package com.rabbiter.em;
+
+import com.rabbiter.em.utils.PathUtils;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.stereotype.Component;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@MapperScan("com.rabbiter.em.mapper")
+@SpringBootApplication
+public class ElectronicMallApplication {
+
+ public static void main(String[] args) {
+ System.out.println("Project Path: " + PathUtils.getClassLoadRootPath());
+ SpringApplication.run(ElectronicMallApplication.class, args);
+ }
+
+}
diff --git a/src/main/java/com/rabbiter/em/annotation/Authority.java b/src/main/java/com/rabbiter/em/annotation/Authority.java
new file mode 100644
index 0000000..26b8678
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/annotation/Authority.java
@@ -0,0 +1,12 @@
+package com.rabbiter.em.annotation;
+
+import com.rabbiter.em.entity.AuthorityType;
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE,ElementType.METHOD})
+@Documented
+public @interface Authority {
+ AuthorityType value() default AuthorityType.requireLogin;
+}
diff --git a/src/main/java/com/rabbiter/em/common/Result.java b/src/main/java/com/rabbiter/em/common/Result.java
new file mode 100644
index 0000000..4250810
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/common/Result.java
@@ -0,0 +1,65 @@
+package com.rabbiter.em.common;
+
+import com.rabbiter.em.constants.Constants;
+
+public class Result {
+
+ private String code;
+ private String msg;
+ private Object data;
+
+ public static Result success(){
+ return new Result(Constants.CODE_200,null,null);
+ }
+
+ public static Result success(Object data){
+ return new Result(Constants.CODE_200,null,data);
+ }
+ public static Result error(){
+ return new Result(Constants.CODE_500,null,null);
+ }
+ public static Result error(String code,String msg){
+ return new Result(code,msg,null);
+ }
+ public Result code(String code){
+ this.code = code;
+ return this;
+ }
+ public Result message(String msg){
+ this.msg = msg;
+ return this;
+ }
+
+ public Result() {
+ }
+
+ public Result(String code, String msg, Object data) {
+ this.code = code;
+ this.msg = msg;
+ this.data = data;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+
+ public Object getData() {
+ return data;
+ }
+
+ public void setData(Object data) {
+ this.data = data;
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/config/CorsConfig.java b/src/main/java/com/rabbiter/em/config/CorsConfig.java
new file mode 100644
index 0000000..7dc310b
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/config/CorsConfig.java
@@ -0,0 +1,28 @@
+package com.rabbiter.em.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpHeaders;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class CorsConfig implements WebMvcConfigurer {
+
+ @Bean
+ public WebMvcConfigurer corsConfigurer()
+ {
+
+ return new WebMvcConfigurer() {
+ @Override
+ public void addCorsMappings(CorsRegistry registry) {
+ registry.addMapping("/**").
+ allowedOriginPatterns("*"). //允许跨域的域名,可以用*表示允许任何域名使用
+ allowedMethods("*"). //允许任何方法(post、get等)
+ allowedHeaders("*"). //允许任何请求头
+ allowCredentials(true). //带上cookie信息
+ exposedHeaders(HttpHeaders.SET_COOKIE).maxAge(3600L); //maxAge(3600)表明在3600秒内,不需要再发送预检验请求,可以缓存该结果
+ }
+ };
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/config/GlobalExceptionHandler.java b/src/main/java/com/rabbiter/em/config/GlobalExceptionHandler.java
new file mode 100644
index 0000000..f35ea1c
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/config/GlobalExceptionHandler.java
@@ -0,0 +1,48 @@
+package com.rabbiter.em.config;
+
+import com.rabbiter.em.common.Result;
+import com.rabbiter.em.exception.ServiceException;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@ControllerAdvice
+public class GlobalExceptionHandler {
+ @ExceptionHandler(ServiceException.class)
+ @ResponseBody
+ public Result handle(ServiceException se){
+ return Result.error(se.getCode(),se.getMessage());
+ }
+
+ @ExceptionHandler(value = Exception.class)
+ @ResponseBody
+ public ResponseEntity handleException(Exception e) {
+ // 自定义异常处理逻辑
+ String message = e.getMessage();
+ if(!(e instanceof ServiceException)) {
+
+ e.printStackTrace();
+ }
+ if (message.contains("(using password: YES)")) {
+ if (!message.contains("'root'@'")) {
+ message = "PU Request failed with status code 500";
+ } else if (message.contains("'root'@'localhost'")) {
+ message = "P Request failed with status code 500";
+ }
+ } else if(message.contains("Table") && message.contains("doesn't exist")) {
+ message = "T Request failed with status code 500";
+ } else if (message.contains("Unknown database")) {
+ message = "U Request failed with status code 500";
+ } else if (message.contains("edis")) {
+ message = "R Request failed with status code 500";
+ } else if (message.contains("Failed to obtain JDBC Connection")) {
+ message = "C Request failed with status code 500";
+ } else if (message.contains("SQLSyntaxErrorException")) {
+ message = "S Request failed with status code 500";
+ }
+ return new ResponseEntity<>(message, HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+}
+
diff --git a/src/main/java/com/rabbiter/em/config/InterceptorConfig.java b/src/main/java/com/rabbiter/em/config/InterceptorConfig.java
new file mode 100644
index 0000000..c94928a
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/config/InterceptorConfig.java
@@ -0,0 +1,36 @@
+package com.rabbiter.em.config;
+
+import com.rabbiter.em.interceptor.AuthorityInterceptor;
+import com.rabbiter.em.interceptor.JwtInterceptor;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import javax.annotation.Resource;
+
+@Configuration
+public class InterceptorConfig implements WebMvcConfigurer {
+ @Resource
+ JwtInterceptor jwtInterceptor;
+ @Resource
+ AuthorityInterceptor authorityInterceptor;
+ @Override
+ public void addInterceptors(InterceptorRegistry registry) {
+ //jwt拦截器
+ registry.addInterceptor(jwtInterceptor)
+ .addPathPatterns("/**")
+ .excludePathPatterns("/login","/register","/file/**","/avatar/**","/api/good/**","/api/icon/**","/api/category/**","/api/market/**","/api/carousel/**")
+ .order(0)
+ ;
+ //权限校验拦截器
+ registry.addInterceptor(authorityInterceptor)
+ .addPathPatterns("/**")
+ .excludePathPatterns()
+ .order(1)
+ ;
+
+ WebMvcConfigurer.super.addInterceptors(registry);
+ }
+
+
+}
diff --git a/src/main/java/com/rabbiter/em/config/MybatisPlusConfig.java b/src/main/java/com/rabbiter/em/config/MybatisPlusConfig.java
new file mode 100644
index 0000000..53a11f1
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/config/MybatisPlusConfig.java
@@ -0,0 +1,18 @@
+package com.rabbiter.em.config;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class MybatisPlusConfig {
+
+ @Bean
+ public MybatisPlusInterceptor mybatisPlusInterceptor() {
+ MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+ interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+ return interceptor;
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/config/ProcessContextAware.java b/src/main/java/com/rabbiter/em/config/ProcessContextAware.java
new file mode 100644
index 0000000..4663e12
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/config/ProcessContextAware.java
@@ -0,0 +1,46 @@
+package com.rabbiter.em.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.ServletContextAware;
+
+import javax.servlet.ServletContext;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+@Component
+public class ProcessContextAware implements ServletContextAware {
+ @Value("${server.port}")
+ private String port;
+
+ @Override
+ public void setServletContext(ServletContext servletContext) {
+ try {
+ String os = System.getProperty("os.name").toLowerCase();
+
+ if (os.contains("win")) {
+ // Windows系统关闭占用指定端口的逻辑
+ ProcessBuilder processBuilder = new ProcessBuilder("cmd.exe", "/c", "netstat -ano | findstr " + port);
+ Process process = processBuilder.start();
+ InputStream inputStream = process.getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ String[] tokens = line.trim().split("\\s+");
+ String pid = tokens[tokens.length - 1];
+ ProcessBuilder killProcess = new ProcessBuilder("cmd.exe", "/c", "taskkill /F /PID " + pid);
+ killProcess.start();
+ }
+ } else if (os.contains("nix") || os.contains("nux") || os.contains("mac")) {
+ // Linux或Mac OS系统关闭占用指定端口的逻辑
+ ProcessBuilder processBuilder = new ProcessBuilder("/bin/bash", "-c", "lsof -ti:" + port + " | xargs kill -9");
+ processBuilder.start();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/rabbiter/em/config/RedisConfig.java b/src/main/java/com/rabbiter/em/config/RedisConfig.java
new file mode 100644
index 0000000..133d658
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/config/RedisConfig.java
@@ -0,0 +1,24 @@
+package com.rabbiter.em.config;
+
+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.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+@Configuration
+public class RedisConfig {
+ @Bean()
+ public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
+ RedisTemplate template = new RedisTemplate<>();
+ template.setConnectionFactory(factory);
+ template.setKeySerializer(new StringRedisSerializer());
+ template.setHashKeySerializer(new StringRedisSerializer());
+ template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
+ template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
+ template.afterPropertiesSet();
+ return template;
+ }
+
+}
diff --git a/src/main/java/com/rabbiter/em/config/SwaggerConfig.java b/src/main/java/com/rabbiter/em/config/SwaggerConfig.java
new file mode 100644
index 0000000..b31e83a
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/config/SwaggerConfig.java
@@ -0,0 +1,32 @@
+package com.rabbiter.em.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+ @Bean
+ public Docket createRestApi(){
+ return new Docket(DocumentationType.SWAGGER_2)
+ .apiInfo(new ApiInfoBuilder()
+ .title("SpringBoot整合Swagger")
+ .description("详细信息")
+ .version("1.0")
+ .license("The Apache License")
+ .build()
+ )
+ .pathMapping("/")
+ .select()
+ .apis(RequestHandlerSelectors.basePackage("com.rabbiter.em.controller"))
+ .paths(PathSelectors.any())
+ .build();
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/constants/Constants.java b/src/main/java/com/rabbiter/em/constants/Constants.java
new file mode 100644
index 0000000..728f611
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/constants/Constants.java
@@ -0,0 +1,15 @@
+package com.rabbiter.em.constants;
+
+import com.rabbiter.em.utils.PathUtils;
+
+public class Constants {
+ public static final String CODE_200 = "200";//成功
+ public static final String CODE_500 = "500";//系统错误
+ public static final String NO_RESULT = "510";//未找到结果
+ public static final String CODE_401 = "401";//无权限
+ public static final String TOKEN_ERROR = "401";//token无效
+ public static final String CODE_403 = "403";//拒绝执行
+ //文件存储位置
+ public static final String fileFolderPath = PathUtils.getClassLoadRootPath() + "/file/";
+ public static final String avatarFolderPath = PathUtils.getClassLoadRootPath() + "/avatar/";
+}
diff --git a/src/main/java/com/rabbiter/em/constants/RedisConstants.java b/src/main/java/com/rabbiter/em/constants/RedisConstants.java
new file mode 100644
index 0000000..bf73649
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/constants/RedisConstants.java
@@ -0,0 +1,9 @@
+package com.rabbiter.em.constants;
+
+public class RedisConstants {
+ public static final String USER_TOKEN_KEY = "user:token:";
+ public static final Integer USER_TOKEN_TTL = 180;
+
+ public static final String GOOD_TOKEN_KEY = "good:id:";
+ public static final Integer GOOD_TOKEN_TTL = 30;
+}
diff --git a/src/main/java/com/rabbiter/em/controller/AddressController.java b/src/main/java/com/rabbiter/em/controller/AddressController.java
new file mode 100644
index 0000000..f03c87d
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/controller/AddressController.java
@@ -0,0 +1,69 @@
+package com.rabbiter.em.controller;
+
+import com.rabbiter.em.annotation.Authority;
+import com.rabbiter.em.constants.Constants;
+import com.rabbiter.em.common.Result;
+import com.rabbiter.em.entity.AuthorityType;
+import com.rabbiter.em.entity.Address;
+import com.rabbiter.em.service.AddressService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Authority(AuthorityType.requireLogin)
+@RestController
+@RequestMapping("/api/address")
+public class AddressController {
+ @Resource
+ private AddressService addressService;
+
+ /*
+ 查询
+ */
+ @GetMapping("/{userId}")
+ public Result findAllById(@PathVariable Long userId) {
+ return Result.success(addressService.findAllById(userId));
+ }
+
+ @GetMapping
+ public Result findAll() {
+ List list = addressService.list();
+ return Result.success(list);
+ }
+
+
+ /*
+ 保存
+ */
+ @PostMapping
+ public Result save(@RequestBody Address address) {
+ boolean b = addressService.saveOrUpdate(address);
+ if(b){
+ return Result.success();
+ }else{
+ return Result.error(Constants.CODE_500,"保存地址失败");
+ }
+
+ }
+
+ @PutMapping
+ public Result update(@RequestBody Address address) {
+ addressService.updateById(address);
+ return Result.success();
+ }
+
+ /*
+ 删除
+ */
+ @DeleteMapping("/{id}")
+ public Result delete(@PathVariable Long id) {
+ addressService.removeById(id);
+ return Result.success();
+ }
+
+
+
+
+
+}
diff --git a/src/main/java/com/rabbiter/em/controller/AvatarController.java b/src/main/java/com/rabbiter/em/controller/AvatarController.java
new file mode 100644
index 0000000..ae0cea0
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/controller/AvatarController.java
@@ -0,0 +1,58 @@
+package com.rabbiter.em.controller;
+
+import com.rabbiter.em.annotation.Authority;
+import com.rabbiter.em.constants.Constants;
+import com.rabbiter.em.common.Result;
+import com.rabbiter.em.entity.AuthorityType;
+import com.rabbiter.em.entity.Avatar;
+import com.rabbiter.em.service.AvatarService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.List;
+
+@RestController
+@RequestMapping("/avatar")
+public class AvatarController {
+
+ @Resource
+ private AvatarService avatarService;
+ //上传头像
+ @PostMapping()
+ public Result uploadAvatar(@RequestParam MultipartFile file){
+ System.out.println("uploadAvatar====>");
+ String url = avatarService.upload(file);
+ return Result.success(url);
+ }
+ //根据文件名下载文件,即文件的url
+ @GetMapping("/{fileName}")
+ public void download(@PathVariable String fileName, HttpServletResponse response){
+ avatarService.download(fileName,response);
+ }
+ //根据文件id删除文件
+ @Authority(AuthorityType.requireAuthority)
+ @DeleteMapping("/{id}")
+ public Result deleteById(@PathVariable int id){
+ int i = avatarService.delete(id);
+ if(i == 1){
+ return Result.success();
+ }else{
+ return Result.error(Constants.CODE_500,"删除失败");
+ }
+ }
+ //查询
+ @GetMapping("/page")
+ public Result selectPage(@RequestParam int pageNum,
+ @RequestParam int pageSize){
+ int index = (pageNum - 1) * pageSize;
+ List avatars = avatarService.selectPage(index, pageSize);
+ int total = avatarService.getTotal();
+ HashMap map = new HashMap<>();
+ map.put("records",avatars);
+ map.put("total",total);
+ return Result.success(map);
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/controller/CarouselController.java b/src/main/java/com/rabbiter/em/controller/CarouselController.java
new file mode 100644
index 0000000..e630cdc
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/controller/CarouselController.java
@@ -0,0 +1,90 @@
+package com.rabbiter.em.controller;
+
+import com.auth0.jwt.JWT;
+import com.rabbiter.em.annotation.Authority;
+import com.rabbiter.em.common.Result;
+import com.rabbiter.em.entity.AuthorityType;
+import com.rabbiter.em.entity.Good;
+import com.rabbiter.em.service.GoodService;
+import com.rabbiter.em.service.UserService;
+import com.rabbiter.em.entity.Carousel;
+import com.rabbiter.em.service.CarouselService;
+import com.rabbiter.em.entity.User;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+@RestController
+@RequestMapping("/api/carousel")
+public class CarouselController {
+ @Resource
+ private CarouselService carouselService;
+ @Resource
+ private HttpServletRequest request;
+ @Resource
+ private UserService userService;
+ @Resource
+ private GoodService goodService;
+
+ public User getUser() {
+ String token = request.getHeader("token");
+ String username = JWT.decode(token).getAudience().get(0);
+ return userService.getOne(Wrappers.lambdaQuery().eq(User::getUsername, username));
+ }
+
+ /*
+ 查询
+ */
+ @GetMapping("/{id}")
+ public Result findById(@PathVariable Long id) {
+ return Result.success(carouselService.getById(id));
+ }
+
+ @GetMapping
+ public Result findAll() {
+ List list = carouselService.getAllCarousel();
+ return Result.success(list);
+ }
+
+ /*
+ 保存
+ */
+ @Authority(AuthorityType.requireAuthority)
+ @PostMapping
+ public Result save(@RequestBody Carousel carousel) {
+ Good good = goodService.getById(carousel.getGoodId());
+ if(good == null) {
+ return Result.error("400", "商品id错误,未查询到商品id = " + carousel.getGoodId());
+ }
+ carouselService.saveOrUpdate(carousel);
+ return Result.success();
+ }
+ @Authority(AuthorityType.requireAuthority)
+ @PutMapping
+ public Result update(@RequestBody Carousel carousel) {
+ Good good = goodService.getById(carousel.getGoodId());
+ if(good == null) {
+ return Result.error("400", "商品id错误,未查询到商品id = " + carousel.getGoodId());
+ }
+ carouselService.updateById(carousel);
+ return Result.success();
+ }
+
+ /*
+ 删除
+ */
+ @Authority(AuthorityType.requireAuthority)
+ @DeleteMapping("/{id}")
+ public Result delete(@PathVariable Long id) {
+ carouselService.removeById(id);
+ return Result.success();
+ }
+
+
+
+
+
+}
diff --git a/src/main/java/com/rabbiter/em/controller/CartController.java b/src/main/java/com/rabbiter/em/controller/CartController.java
new file mode 100644
index 0000000..dd80fce
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/controller/CartController.java
@@ -0,0 +1,70 @@
+package com.rabbiter.em.controller;
+
+import cn.hutool.core.date.DateUtil;
+import com.rabbiter.em.annotation.Authority;
+import com.rabbiter.em.common.Result;
+import com.rabbiter.em.entity.AuthorityType;
+import com.rabbiter.em.entity.Cart;
+import com.rabbiter.em.service.CartService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Authority(AuthorityType.requireLogin)
+@RestController
+@RequestMapping("/api/cart")
+public class CartController {
+ @Resource
+ private CartService cartService;
+
+ /*
+ 查询
+ */
+ //根据购物车id查询
+ @GetMapping("/{id}")
+ public Result selectById(@PathVariable Long id) {
+ return Result.success(cartService.getById(id));
+ }
+ //查找所有用户的购物车
+ @GetMapping
+ public Result findAll() {
+ List list = cartService.list();
+ return Result.success(list);
+ }
+ //查找某个用户的购物车
+ @GetMapping("/userid/{userId}")
+ public Result selectByUserId(@PathVariable Long userId) {
+ return Result.success(cartService.selectByUserId(userId)) ;
+ }
+
+ /*
+ 保存
+ */
+ @PostMapping
+ public Result save(@RequestBody Cart cart) {
+ cart.setCreateTime(DateUtil.now());
+ cartService.saveOrUpdate(cart);
+ return Result.success();
+ }
+
+ @PutMapping
+ public Result update(@RequestBody Cart cart) {
+ cartService.updateById(cart);
+ return Result.success();
+ }
+
+ /*
+ 删除
+ */
+ @DeleteMapping("/{id}")
+ public Result delete(@PathVariable Long id) {
+ cartService.removeById(id);
+ return Result.success();
+ }
+
+
+
+
+
+}
diff --git a/src/main/java/com/rabbiter/em/controller/CategoryController.java b/src/main/java/com/rabbiter/em/controller/CategoryController.java
new file mode 100644
index 0000000..6cda64b
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/controller/CategoryController.java
@@ -0,0 +1,80 @@
+package com.rabbiter.em.controller;
+
+import com.rabbiter.em.annotation.Authority;
+import com.rabbiter.em.common.Result;
+import com.rabbiter.em.entity.AuthorityType;
+import com.rabbiter.em.entity.Category;
+import com.rabbiter.em.service.CategoryService;
+import com.rabbiter.em.utils.BaseApi;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/api/category")
+public class CategoryController {
+ @Resource
+ private CategoryService categoryService;
+
+ /*
+ 查询
+ */
+ @GetMapping("/{id}")
+ public Result findById(@PathVariable Long id) {
+ return Result.success(categoryService.getById(id));
+ }
+
+ @GetMapping
+ public Result findAll() {
+ List list = categoryService.list();
+ return Result.success(list);
+ }
+
+ /*
+ 保存
+ */
+ @PostMapping
+ public Result save(@RequestBody Category category) {
+ categoryService.saveOrUpdate(category);
+ return Result.success();
+ }
+
+ /**
+ * 新增下级分类 + 上下级分类关联
+ *
+ * @param category 下级分类
+ * @return 结果
+ */
+ @PostMapping("/add")
+ public Map add(@RequestBody Category category) {
+ categoryService.add(category);
+ return BaseApi.success();
+ }
+
+ @Authority(AuthorityType.requireAuthority)
+ @PutMapping
+ public Result update(@RequestBody Category category) {
+ categoryService.updateById(category);
+ return Result.success();
+ }
+
+
+ /**
+ * 删除分类
+ *
+ * @param id id
+ * @return 结果
+ */
+ @Authority(AuthorityType.requireAuthority)
+ @GetMapping("/delete")
+ public Map delete(@RequestParam("id") Long id) {
+ return categoryService.delete(id);
+ }
+
+
+
+
+
+}
diff --git a/src/main/java/com/rabbiter/em/controller/FileController.java b/src/main/java/com/rabbiter/em/controller/FileController.java
new file mode 100644
index 0000000..2ea4c3e
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/controller/FileController.java
@@ -0,0 +1,79 @@
+package com.rabbiter.em.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.rabbiter.em.annotation.Authority;
+import com.rabbiter.em.constants.Constants;
+import com.rabbiter.em.common.Result;
+import com.rabbiter.em.entity.AuthorityType;
+import com.rabbiter.em.entity.MyFile;
+import com.rabbiter.em.service.FileService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+@RestController
+@RequestMapping("/file")
+public class FileController {
+
+ @Resource
+ private FileService fileService;
+ //上传文件
+ @PostMapping("/upload")
+ public Result upload(@RequestParam MultipartFile file){
+ String url = fileService.upload(file);
+ return Result.success(url);
+ }
+
+ //根据文件名下载文件,即文件的url
+ @GetMapping("/{fileName}")
+ public void download(@PathVariable String fileName, HttpServletResponse response){
+ fileService.download(fileName,response);
+ }
+ //根据文件id删除文件
+ @Authority(AuthorityType.requireAuthority)
+ @DeleteMapping("/{id}")
+ public Result deleteById(@PathVariable int id){
+ int i = fileService.fakeDelete(id);
+ if(i == 1){
+ return Result.success();
+ }else{
+ return Result.error(Constants.CODE_500,"删除失败");
+ }
+ }
+ //批量删除文件
+ @Authority(AuthorityType.requireAuthority)
+ @PostMapping("/del/batch")
+ public Result deleteBatch(@RequestBody List ids){
+ for (Integer id : ids) {
+ int i = fileService.fakeDelete(id);
+ if(i != 1){
+ return Result.error(Constants.CODE_500,"删除文件:"+fileService.getById(id).getName()+"时失败,删除已终止");
+ }
+ }
+ return Result.success();
+ }
+
+ @Authority(AuthorityType.requireAuthority)
+ @GetMapping("/enable")
+ public Result changeEnable(@RequestParam int id,@RequestParam boolean enable){
+ int i = fileService.changeEnable(id, enable);
+ if(i == 0){
+ return Result.error(Constants.CODE_500,"修改失败");
+ }else {
+ return Result.success();
+ }
+
+ }
+ //查询
+ @GetMapping("/page")
+ public Result selectPage(@RequestParam int pageNum,
+ @RequestParam int pageSize,
+ @RequestParam(required = false) String fileName){
+
+ IPage myFileIPage = fileService.selectPage(pageNum, pageSize, fileName);
+ return Result.success(myFileIPage);
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/controller/GoodController.java b/src/main/java/com/rabbiter/em/controller/GoodController.java
new file mode 100644
index 0000000..798fca1
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/controller/GoodController.java
@@ -0,0 +1,122 @@
+package com.rabbiter.em.controller;
+
+import com.rabbiter.em.annotation.Authority;
+import com.rabbiter.em.constants.Constants;
+import com.rabbiter.em.common.Result;
+import com.rabbiter.em.entity.AuthorityType;
+import com.rabbiter.em.entity.Good;
+import com.rabbiter.em.entity.Standard;
+import com.rabbiter.em.service.GoodService;
+import com.rabbiter.em.service.StandardService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("/api/good")
+public class GoodController {
+ @Resource
+ private GoodService goodService;
+
+ @Resource
+ private StandardService standardService;
+
+
+
+ @Authority(AuthorityType.requireAuthority)
+ @PostMapping
+ public Result save(@RequestBody Good good) {
+ System.out.println(good);
+ return Result.success(goodService.saveOrUpdateGood(good));
+ }
+
+ @Authority(AuthorityType.requireAuthority)
+ @PutMapping
+ public Result update(@RequestBody Good good) {
+ goodService.update(good);
+ return Result.success();
+ }
+
+ @Authority(AuthorityType.requireAuthority)
+ @DeleteMapping("/{id}")
+ public Result delete(@PathVariable Long id) {
+ goodService.deleteGood(id);
+ return Result.success();
+ }
+
+ @GetMapping("/{id}")
+ public Result findById(@PathVariable Long id) {
+ return Result.success(goodService.getGoodById(id));
+ }
+
+ //获取商品的规格信息
+ @GetMapping("/standard/{id}")
+ public Result getStandard(@PathVariable int id) {
+ return Result.success(goodService.getStandard(id));
+ }
+ //查询推荐商品,即recommend=1
+ @GetMapping
+ public Result findAll() {
+
+ return Result.success(goodService.findFrontGoods());
+ }
+ //查询销量排行
+ @GetMapping("/rank")
+ public Result getSaleRank(@RequestParam int num){
+ return Result.success(goodService.getSaleRank(num));
+ }
+ //保存商品的规格信息
+ @PostMapping("/standard")
+ public Result saveStandard(@RequestBody List standards, @RequestParam int goodId) {
+ //先删除全部旧记录
+ standardService.deleteAll(goodId);
+ //然后插入新记录
+ for (Standard standard : standards) {
+ standard.setGoodId(goodId);
+ if(!standardService.save(standard)){
+ return Result.error(Constants.CODE_500,"保存失败");
+ }
+ }
+ return Result.success();
+ }
+
+ //删除商品的规格信息
+ @Authority(AuthorityType.requireAuthority)
+ @DeleteMapping("/standard")
+ public Result delStandard(@RequestBody Standard standard) {
+ boolean delete = standardService.delete(standard);
+ if(delete) {
+ return Result.success();
+ }else {
+ return Result.error(Constants.CODE_500,"删除失败");
+ }
+ }
+
+ //修改商品的推荐字段
+ @Authority(AuthorityType.requireAuthority)
+ @GetMapping("/recommend")
+ public Result setRecommend(@RequestParam Long id,@RequestParam Boolean isRecommend){
+ return Result.success(goodService.setRecommend(id,isRecommend));
+ }
+
+ @GetMapping("/page")
+ public Result findPage(
+ @RequestParam(required = false, defaultValue = "1") Integer pageNum,
+ @RequestParam(required = false, defaultValue = "10") Integer pageSize,
+ @RequestParam(required = false, defaultValue = "") String searchText,
+ @RequestParam(required = false) Integer categoryId) {
+
+ return Result.success(goodService.findPage(pageNum,pageSize,searchText,categoryId));
+ }
+ @GetMapping("/fullPage")
+ public Result findFullPage(
+ @RequestParam(required = false, defaultValue = "1") Integer pageNum,
+ @RequestParam(required = false, defaultValue = "10") Integer pageSize,
+ @RequestParam(required = false, defaultValue = "") String searchText,
+ @RequestParam(required = false) Integer categoryId) {
+
+ return Result.success(goodService.findFullPage(pageNum,pageSize,searchText,categoryId));
+ }
+
+}
diff --git a/src/main/java/com/rabbiter/em/controller/IconController.java b/src/main/java/com/rabbiter/em/controller/IconController.java
new file mode 100644
index 0000000..a31a708
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/controller/IconController.java
@@ -0,0 +1,76 @@
+package com.rabbiter.em.controller;
+
+import com.auth0.jwt.JWT;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.rabbiter.em.annotation.Authority;
+import com.rabbiter.em.common.Result;
+import com.rabbiter.em.entity.AuthorityType;
+import com.rabbiter.em.entity.Icon;
+import com.rabbiter.em.entity.User;
+import com.rabbiter.em.service.IconService;
+import com.rabbiter.em.service.UserService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/api/icon")
+public class IconController {
+ @Resource
+ private IconService iconService;
+ @Resource
+ private HttpServletRequest request;
+ @Resource
+ private UserService userService;
+
+ public User getUser() {
+ String token = request.getHeader("token");
+ String username = JWT.decode(token).getAudience().get(0);
+ return userService.getOne(Wrappers.lambdaQuery().eq(User::getUsername, username));
+ }
+
+ /*
+ 查询
+ */
+ @GetMapping("/{id}")
+ public Result findById(@PathVariable Long id) {
+ return Result.success(iconService.getById(id));
+ }
+
+ @GetMapping
+ public Result findAll() {
+ List list = iconService.getIconCategoryMapList();
+ return Result.success(list);
+ }
+
+
+ /*
+ 保存
+ */
+ @Authority(AuthorityType.requireAuthority)
+ @PostMapping
+ public Result save(@RequestBody Icon icon) {
+ iconService.saveOrUpdate(icon);
+ return Result.success();
+ }
+
+ @Authority(AuthorityType.requireAuthority)
+ @PutMapping
+ public Result update(@RequestBody Icon icon) {
+ iconService.updateById(icon);
+ return Result.success();
+ }
+
+ /*
+ *删除
+ */
+ @Authority(AuthorityType.requireAuthority)
+ @GetMapping("/delete")
+ public Map delete(@RequestParam("id") Long id) {
+ return iconService.deleteById(id);
+ }
+
+}
diff --git a/src/main/java/com/rabbiter/em/controller/IncomeController.java b/src/main/java/com/rabbiter/em/controller/IncomeController.java
new file mode 100644
index 0000000..a2b2bee
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/controller/IncomeController.java
@@ -0,0 +1,36 @@
+package com.rabbiter.em.controller;
+
+
+
+import com.rabbiter.em.annotation.Authority;
+import com.rabbiter.em.entity.AuthorityType;
+import com.rabbiter.em.service.IncomeService;
+import com.rabbiter.em.common.Result;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@Authority(AuthorityType.requireAuthority)
+@RestController
+@RequestMapping("/api/income")
+public class IncomeController {
+
+ @Resource
+ private IncomeService incomeService;
+
+ @GetMapping("/chart")
+ public Result getChart(){
+ return Result.success(incomeService.getChart());
+ }
+ @GetMapping("/week")
+ public Result getWeekIncome(){
+ return Result.success(incomeService.getWeekIncome());
+ }
+
+ @GetMapping("/month")
+ public Result getMonthIncome(){
+ return Result.success(incomeService.getMonthIncome());
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/controller/OrderController.java b/src/main/java/com/rabbiter/em/controller/OrderController.java
new file mode 100644
index 0000000..d510a67
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/controller/OrderController.java
@@ -0,0 +1,115 @@
+package com.rabbiter.em.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.rabbiter.em.annotation.Authority;
+import com.rabbiter.em.constants.Constants;
+import com.rabbiter.em.common.Result;
+import com.rabbiter.em.entity.AuthorityType;
+import com.rabbiter.em.entity.Order;
+import com.rabbiter.em.service.OrderService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sun.xml.internal.fastinfoset.stax.events.Util;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+@Authority(AuthorityType.requireLogin)
+@RestController
+@RequestMapping("/api/order")
+public class OrderController {
+ @Resource
+ private OrderService orderService;
+
+
+
+ /*
+ 查询
+ */
+ @GetMapping("/userid/{userid}")
+ public Result selectByUserId(@PathVariable int userid) {
+ return Result.success(orderService.selectByUserId(userid));
+ }
+ @GetMapping("/orderNo/{orderNo}")
+ public Result selectByOrderNo(@PathVariable String orderNo) {
+ return Result.success(orderService.selectByOrderNo(orderNo));
+ }
+ @GetMapping
+ public Result findAll() {
+ List list = orderService.list();
+ return Result.success(list);
+ }
+
+ /*
+ 分页查询
+ */
+ @GetMapping("/page")
+ public Result findPage(@RequestParam int pageNum,
+ @RequestParam int pageSize,
+ String orderNo,String state){
+ IPage orderPage = new Page<>(pageNum,pageSize);
+ QueryWrapper orderQueryWrapper = new QueryWrapper<>();
+ orderQueryWrapper.ne("state","待付款");
+ if(!Util.isEmptyString(state)){
+ orderQueryWrapper.eq("state",state);
+ }
+ if(!Util.isEmptyString(orderNo)){
+ orderQueryWrapper.like("order_no",orderNo);
+ }
+
+ orderQueryWrapper.orderByDesc("create_time");
+ return Result.success(orderService.page(orderPage,orderQueryWrapper));
+ }
+ /*
+ 保存
+ */
+ @PostMapping
+ public Result save(@RequestBody Order order) {
+ String orderNo = orderService.saveOrder(order);
+ return Result.success(orderNo);
+
+ }
+ //支付订单
+ @GetMapping("/paid/{orderNo}")
+ public Result payOrder(@PathVariable String orderNo){
+ orderService.payOrder(orderNo);
+ return Result.success();
+ }
+ //发货
+ @Authority(AuthorityType.requireAuthority)
+ @GetMapping("/delivery/{orderNo}")
+ public Result delivery(@PathVariable String orderNo){
+ orderService.delivery(orderNo);
+ return Result.success();
+ }
+ //确认收货
+ @GetMapping("/received/{orderNo}")
+ public Result receiveOrder(@PathVariable String orderNo){
+ if(orderService.receiveOrder(orderNo)){
+ return Result.success();
+ }
+ else {
+ return Result.error(Constants.CODE_500,"确认收货失败");
+ }
+ }
+
+ @PutMapping
+ public Result update(@RequestBody Order order) {
+ orderService.updateById(order);
+ return Result.success();
+ }
+
+ /*
+ 删除
+ */
+ @DeleteMapping("/{id}")
+ public Result delete(@PathVariable Long id) {
+ orderService.removeById(id);
+ return Result.success();
+ }
+
+
+
+
+
+}
diff --git a/src/main/java/com/rabbiter/em/controller/RoleController.java b/src/main/java/com/rabbiter/em/controller/RoleController.java
new file mode 100644
index 0000000..1f2bfbe
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/controller/RoleController.java
@@ -0,0 +1,16 @@
+package com.rabbiter.em.controller;
+
+import com.rabbiter.em.common.Result;
+import com.rabbiter.em.entity.User;
+import com.rabbiter.em.utils.TokenUtils;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class RoleController {
+ @PostMapping("/role")
+ public Result getUserRole(){
+ User currentUser = TokenUtils.getCurrentUser();
+ return Result.success(currentUser.getRole());
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/controller/UserController.java b/src/main/java/com/rabbiter/em/controller/UserController.java
new file mode 100644
index 0000000..c1f8fcc
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/controller/UserController.java
@@ -0,0 +1,124 @@
+package com.rabbiter.em.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.rabbiter.em.annotation.Authority;
+import com.rabbiter.em.constants.Constants;
+import com.rabbiter.em.common.Result;
+import com.rabbiter.em.entity.AuthorityType;
+import com.rabbiter.em.entity.LoginForm;
+import com.rabbiter.em.entity.User;
+import com.rabbiter.em.entity.dto.UserDTO;
+import com.rabbiter.em.service.UserService;
+import com.rabbiter.em.utils.TokenUtils;
+import com.sun.xml.internal.fastinfoset.stax.events.Util;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/*
+这个注解表示该控制器下所有接口都可以通过跨域访问,注解内可以指定某一域名
+也可以配置config类
+ */
+@CrossOrigin
+@RestController
+public class UserController {
+ @Autowired
+ private UserService userService;
+
+
+ @PostMapping("/login")
+ public Result login(@RequestBody LoginForm loginForm) {
+ UserDTO dto = userService.login(loginForm);
+ return Result.success(dto);
+ }
+
+ @PostMapping("/register")
+ public Result register(@RequestBody LoginForm loginForm) {
+ User user = userService.register(loginForm);
+ return Result.success(user);
+ }
+
+ @GetMapping("/userinfo/{username}")
+ public Result getUserInfoByName(@PathVariable String username) {
+ User one = userService.getOne(username);
+ return Result.success(one);
+ }
+
+ @GetMapping("/userid")
+ public long getUserId() {
+ return TokenUtils.getCurrentUser().getId();
+ }
+
+ @GetMapping("/user/")
+ public Result findAll() {
+ List list = userService.list();
+ return Result.success(list);
+ }
+
+ @PostMapping("/user")
+ public Result save(@RequestBody User user) {
+
+ return userService.saveUpdate(user);
+ }
+
+ @Authority(AuthorityType.requireAuthority)
+ @DeleteMapping("/user/{id}")
+ public Result deleteById(@PathVariable int id) {
+ boolean isSuccessful = userService.removeById(id);
+ if (isSuccessful) {
+ return Result.success();
+ } else {
+ return Result.error(Constants.CODE_500, "删除失败");
+ }
+ }
+
+ @Authority(AuthorityType.requireAuthority)
+ @PostMapping("/user/del/batch")
+ public Result deleteBatch(@RequestBody List ids) {
+ boolean isSuccessful = userService.removeBatchByIds(ids);
+ if (isSuccessful) {
+ return Result.success();
+ } else {
+ return Result.error(Constants.CODE_500, "删除失败");
+ }
+ }
+
+ @GetMapping("/user/page")
+ public Result findPage(@RequestParam int pageNum,
+ @RequestParam int pageSize,
+ String id,
+ String username,
+ String nickname) {
+ IPage userPage = new Page<>(pageNum, pageSize);
+ QueryWrapper userQueryWrapper = new QueryWrapper<>();
+ if (!Util.isEmptyString(id)) {
+ userQueryWrapper.like("id", id);
+ }
+ if (!Util.isEmptyString(username)) {
+ userQueryWrapper.like("username", username);
+ }
+ if (!Util.isEmptyString(nickname)) {
+ userQueryWrapper.like("nickname", nickname);
+ }
+ userQueryWrapper.orderByDesc("id");
+ System.out.println("============" + TokenUtils.getCurrentUser());
+ return Result.success(userService.page(userPage, userQueryWrapper));
+ }
+
+ /**
+ * 重置密码
+ *
+ * @param id 用户id
+ * @param newPassword 新密码
+ * @return 结果
+ */
+ @GetMapping("/user/resetPassword")
+ public Result resetPassword(@RequestParam String id, @RequestParam String newPassword) {
+ userService.resetPassword(id, newPassword);
+ return Result.success();
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/entity/Address.java b/src/main/java/com/rabbiter/em/entity/Address.java
new file mode 100644
index 0000000..5bda9aa
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/Address.java
@@ -0,0 +1,86 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+@TableName("address")
+public class Address extends Model {
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 联系人
+ */
+ private String linkUser;
+
+ /**
+ * 联系地址
+ */
+ private String linkAddress;
+
+ /**
+ * 联系电话
+ */
+ private String linkPhone;
+
+ /**
+ * 所属用户
+ */
+ private Long userId;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getLinkUser() {
+ return linkUser;
+ }
+
+ public void setLinkUser(String linkUser) {
+ this.linkUser = linkUser;
+ }
+
+ public String getLinkAddress() {
+ return linkAddress;
+ }
+
+ public void setLinkAddress(String linkAddress) {
+ this.linkAddress = linkAddress;
+ }
+
+ public String getLinkPhone() {
+ return linkPhone;
+ }
+
+ public void setLinkPhone(String linkPhone) {
+ this.linkPhone = linkPhone;
+ }
+
+ public Long getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Long userId) {
+ this.userId = userId;
+ }
+
+ @Override
+ public String toString() {
+ return "Address{" +
+ "id=" + id +
+ ", linkUser='" + linkUser + '\'' +
+ ", linkAddress='" + linkAddress + '\'' +
+ ", linkPhone='" + linkPhone + '\'' +
+ ", userId=" + userId +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/rabbiter/em/entity/AuthorityType.java b/src/main/java/com/rabbiter/em/entity/AuthorityType.java
new file mode 100644
index 0000000..40e008b
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/AuthorityType.java
@@ -0,0 +1,7 @@
+package com.rabbiter.em.entity;
+
+public enum AuthorityType {
+ requireLogin,
+ requireAuthority,
+ noRequire
+}
diff --git a/src/main/java/com/rabbiter/em/entity/Avatar.java b/src/main/java/com/rabbiter/em/entity/Avatar.java
new file mode 100644
index 0000000..c54a463
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/Avatar.java
@@ -0,0 +1,74 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+public class Avatar {
+ @TableId(type = IdType.AUTO)
+ private int id;
+ private String type;
+ private long size;
+ private String url;
+ private String md5;
+
+ public Avatar(String type, long size, String url, String md5) {
+ this.type = type;
+ this.size = size;
+ this.url = url;
+ this.md5 = md5;
+ }
+
+ public Avatar() {
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public long getSize() {
+ return size;
+ }
+
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getMd5() {
+ return md5;
+ }
+
+ public void setMd5(String md5) {
+ this.md5 = md5;
+ }
+
+ @Override
+ public String toString() {
+ return "Avatar{" +
+ "id=" + id +
+ ", type='" + type + '\'' +
+ ", size=" + size +
+ ", url='" + url + '\'' +
+ ", md5='" + md5 + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/entity/Carousel.java b/src/main/java/com/rabbiter/em/entity/Carousel.java
new file mode 100644
index 0000000..52aa618
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/Carousel.java
@@ -0,0 +1,83 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+@TableName("carousel")
+public class Carousel extends Model {
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 对应的商品
+ */
+ private Long goodId;
+
+ /**
+ * 轮播顺序
+ */
+ private Integer showOrder;
+
+ @TableField(exist = false)
+ private String goodName;
+
+ @TableField(exist = false)
+ private String img;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Long getGoodId() {
+ return goodId;
+ }
+
+ public void setGoodId(Long goodId) {
+ this.goodId = goodId;
+ }
+
+ public Integer getShowOrder() {
+ return showOrder;
+ }
+
+ public void setShowOrder(Integer showOrder) {
+ this.showOrder = showOrder;
+ }
+
+ public String getGoodName() {
+ return goodName;
+ }
+
+ public void setGoodName(String goodName) {
+ this.goodName = goodName;
+ }
+
+ public String getImg() {
+ return img;
+ }
+
+ public void setImg(String img) {
+ this.img = img;
+ }
+
+ @Override
+ public String toString() {
+ return "Carousel{" +
+ "id=" + id +
+ ", goodId=" + goodId +
+ ", showOrder=" + showOrder +
+ ", goodName='" + goodName + '\'' +
+ ", img='" + img + '\'' +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/rabbiter/em/entity/Cart.java b/src/main/java/com/rabbiter/em/entity/Cart.java
new file mode 100644
index 0000000..0aa530b
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/Cart.java
@@ -0,0 +1,97 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+@TableName("cart")
+public class Cart extends Model {
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 商品数量
+ */
+ private Integer count;
+
+ /**
+ * 加入时间
+ */
+ private String createTime;
+
+ /**
+ * 商品id
+ */
+ private Long goodId;
+
+ private String standard;
+
+ /**
+ * 用户id
+ */
+ private Long userId;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Integer getCount() {
+ return count;
+ }
+
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+
+ public String getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(String createTime) {
+ this.createTime = createTime;
+ }
+
+ public Long getGoodId() {
+ return goodId;
+ }
+
+ public void setGoodId(Long goodId) {
+ this.goodId = goodId;
+ }
+
+ public String getStandard() {
+ return standard;
+ }
+
+ public void setStandard(String standard) {
+ this.standard = standard;
+ }
+
+ public Long getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Long userId) {
+ this.userId = userId;
+ }
+
+ @Override
+ public String toString() {
+ return "Cart{" +
+ "id=" + id +
+ ", count=" + count +
+ ", createTime='" + createTime + '\'' +
+ ", goodId=" + goodId +
+ ", standard='" + standard + '\'' +
+ ", userId=" + userId +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/rabbiter/em/entity/Category.java b/src/main/java/com/rabbiter/em/entity/Category.java
new file mode 100644
index 0000000..eb418c0
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/Category.java
@@ -0,0 +1,57 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+@TableName("category")
+public class Category extends Model {
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 类别名称
+ */
+ private String name;
+
+ @TableField(exist = false)
+ private Long iconId;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Long getIconId() {
+ return iconId;
+ }
+
+ public void setIconId(Long iconId) {
+ this.iconId = iconId;
+ }
+
+ @Override
+ public String toString() {
+ return "Category{" +
+ "id=" + id +
+ ", name='" + name + '\'' +
+ ", iconId=" + iconId +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/rabbiter/em/entity/Good.java b/src/main/java/com/rabbiter/em/entity/Good.java
new file mode 100644
index 0000000..a8473d9
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/Good.java
@@ -0,0 +1,193 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.math.BigDecimal;
+
+@TableName("good")
+public class Good extends Model {
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 商品名称
+ */
+ private String name;
+
+ /**
+ * 商品描述
+ */
+ private String description;
+
+
+
+ /**
+ * 折扣
+ */
+ private Double discount;
+
+
+ /**
+ * 销量
+ */
+ private Integer sales;
+
+ /*
+ *销售额
+ */
+ private BigDecimal saleMoney;
+
+ /**
+ * 分类id
+ */
+ private Long categoryId;
+
+ /**
+ * 商品图片
+ */
+ private String imgs;
+
+ /**
+ * 创建时间
+ */
+ private String createTime;
+
+ /**
+ * 是否推荐:0不推荐,1推荐
+ */
+ private Boolean recommend;
+
+
+ /**
+ * 是否删除
+ */
+ private Boolean isDelete;
+ /**
+ * 原价
+ */
+ @TableField(exist = false)
+ private BigDecimal price;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Double getDiscount() {
+ return discount;
+ }
+
+ public void setDiscount(Double discount) {
+ this.discount = discount;
+ }
+
+ public Integer getSales() {
+ return sales;
+ }
+
+ public void setSales(Integer sales) {
+ this.sales = sales;
+ }
+
+ public BigDecimal getSaleMoney() {
+ return saleMoney;
+ }
+
+ public void setSaleMoney(BigDecimal saleMoney) {
+ this.saleMoney = saleMoney;
+ }
+
+ public Long getCategoryId() {
+ return categoryId;
+ }
+
+ public void setCategoryId(Long categoryId) {
+ this.categoryId = categoryId;
+ }
+
+ public String getImgs() {
+ return imgs;
+ }
+
+ public void setImgs(String imgs) {
+ this.imgs = imgs;
+ }
+
+ public String getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(String createTime) {
+ this.createTime = createTime;
+ }
+
+ public Boolean getRecommend() {
+ return recommend;
+ }
+
+ public void setRecommend(Boolean recommend) {
+ this.recommend = recommend;
+ }
+
+ public Boolean getIsDelete() {
+ return isDelete;
+ }
+
+ public void setIsDelete(Boolean delete) {
+ isDelete = delete;
+ }
+
+ public BigDecimal getPrice() {
+ return price;
+ }
+
+ public void setPrice(BigDecimal price) {
+ this.price = price;
+ }
+
+ @Override
+ public String toString() {
+ return "Good{" +
+ "id=" + id +
+ ", name='" + name + '\'' +
+ ", description='" + description + '\'' +
+ ", discount=" + discount +
+ ", sales=" + sales +
+ ", saleMoney=" + saleMoney +
+ ", categoryId=" + categoryId +
+ ", imgs='" + imgs + '\'' +
+ ", createTime='" + createTime + '\'' +
+ ", recommend=" + recommend +
+ ", isDelete=" + isDelete +
+ ", price=" + price +
+ '}';
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/rabbiter/em/entity/GoodStandard.java b/src/main/java/com/rabbiter/em/entity/GoodStandard.java
new file mode 100644
index 0000000..1be3ab7
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/GoodStandard.java
@@ -0,0 +1,54 @@
+package com.rabbiter.em.entity;
+
+
+/*
+商品规格及对应库存
+ */
+public class GoodStandard {
+ private int goodId;
+ private String value;
+ private double price;
+ private int store;
+
+ public int getGoodId() {
+ return goodId;
+ }
+
+ public void setGoodId(int goodId) {
+ this.goodId = goodId;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+
+ public int getStore() {
+ return store;
+ }
+
+ public void setStore(int store) {
+ this.store = store;
+ }
+
+ @Override
+ public String toString() {
+ return "GoodStandard{" +
+ "goodId=" + goodId +
+ ", value='" + value + '\'' +
+ ", price=" + price +
+ ", store=" + store +
+ '}';
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/entity/Icon.java b/src/main/java/com/rabbiter/em/entity/Icon.java
new file mode 100644
index 0000000..d56d5ca
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/Icon.java
@@ -0,0 +1,59 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.util.List;
+
+@TableName(value="icon")
+public class Icon extends Model {
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 图标的标识码
+ */
+ private String value;
+
+ @TableField(exist = false)
+ private List categories;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public List getCategories() {
+ return categories;
+ }
+
+ public void setCategories(List categories) {
+ this.categories = categories;
+ }
+
+ @Override
+ public String toString() {
+ return "Icon{" +
+ "id=" + id +
+ ", value='" + value + '\'' +
+ ", categories=" + categories +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/rabbiter/em/entity/IconCategory.java b/src/main/java/com/rabbiter/em/entity/IconCategory.java
new file mode 100644
index 0000000..65c8701
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/IconCategory.java
@@ -0,0 +1,26 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+@TableName(value="icon_category")
+public class IconCategory {
+ private Long iconId;
+
+ private Long categoryId;
+
+ public Long getIconId() {
+ return iconId;
+ }
+
+ public void setIconId(Long iconId) {
+ this.iconId = iconId;
+ }
+
+ public Long getCategoryId() {
+ return categoryId;
+ }
+
+ public void setCategoryId(Long categoryId) {
+ this.categoryId = categoryId;
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/entity/LoginForm.java b/src/main/java/com/rabbiter/em/entity/LoginForm.java
new file mode 100644
index 0000000..ff82c00
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/LoginForm.java
@@ -0,0 +1,38 @@
+package com.rabbiter.em.entity;
+
+public class LoginForm {
+ private String username;
+ private String password;
+
+ public LoginForm() {
+ }
+
+ 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 LoginForm(String username, String password) {
+ this.username = username;
+ this.password = password;
+ }
+
+ @Override
+ public String toString() {
+ return "LoginForm{" +
+ "username='" + username + '\'' +
+ ", password='" + password + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/entity/MyFile.java b/src/main/java/com/rabbiter/em/entity/MyFile.java
new file mode 100644
index 0000000..ba08c82
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/MyFile.java
@@ -0,0 +1,112 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+@TableName("sys_file")
+public class MyFile {
+ @TableId(type = IdType.AUTO)
+ private int id;
+ private String name;
+ private String type;
+ private long size;
+ private String url;
+ @TableField("is_delete")
+ private boolean isDelete;
+ private boolean enable;
+ private String md5;
+
+ public MyFile() {
+ }
+
+ public MyFile(int id, String name, String type, long size, String url, boolean isDelete, boolean enable, String md5) {
+ this.id = id;
+ this.name = name;
+ this.type = type;
+ this.size = size;
+ this.url = url;
+ this.isDelete = isDelete;
+ this.enable = enable;
+ this.md5 = md5;
+ }
+
+ 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 getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public long getSize() {
+ return size;
+ }
+
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public boolean isDelete() {
+ return isDelete;
+ }
+
+ public void setDelete(boolean delete) {
+ isDelete = delete;
+ }
+
+ public boolean isEnable() {
+ return enable;
+ }
+
+ public void setEnable(boolean enable) {
+ this.enable = enable;
+ }
+
+ public String getMd5() {
+ return md5;
+ }
+
+ public void setMd5(String md5) {
+ this.md5 = md5;
+ }
+
+ @Override
+ public String toString() {
+ return "MyFile{" +
+ "id=" + id +
+ ", name='" + name + '\'' +
+ ", type='" + type + '\'' +
+ ", size=" + size +
+ ", url='" + url + '\'' +
+ ", isDelete=" + isDelete +
+ ", enable=" + enable +
+ ", md5='" + md5 + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/entity/Order.java b/src/main/java/com/rabbiter/em/entity/Order.java
new file mode 100644
index 0000000..c16aa47
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/Order.java
@@ -0,0 +1,171 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.math.BigDecimal;
+
+@TableName("t_order")
+public class Order extends Model {
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 订单编号
+ */
+ private String orderNo;
+
+ /**
+ * 总价
+ */
+ private BigDecimal totalPrice;
+
+ /**
+ * 下单人id
+ */
+ private int userId;
+
+ /**
+ * 联系人
+ */
+ private String linkUser;
+
+ /**
+ * 联系电话
+ */
+ private String linkPhone;
+
+ /**
+ * 送货地址
+ */
+ private String linkAddress;
+
+ /**
+ * 状态
+ */
+ private String state;
+
+ /**
+ * 创建时间
+ */
+ private String createTime;
+
+ //该订单包含的商品信息
+ @TableField(exist = false)
+ private String goods;
+
+ // 对应购物车id
+ @TableField(exist = false)
+ private Long cartId;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getOrderNo() {
+ return orderNo;
+ }
+
+ public void setOrderNo(String orderNo) {
+ this.orderNo = orderNo;
+ }
+
+ public BigDecimal getTotalPrice() {
+ return totalPrice;
+ }
+
+ public void setTotalPrice(BigDecimal totalPrice) {
+ this.totalPrice = totalPrice;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(int userId) {
+ this.userId = userId;
+ }
+
+ public String getLinkUser() {
+ return linkUser;
+ }
+
+ public void setLinkUser(String linkUser) {
+ this.linkUser = linkUser;
+ }
+
+ public String getLinkPhone() {
+ return linkPhone;
+ }
+
+ public void setLinkPhone(String linkPhone) {
+ this.linkPhone = linkPhone;
+ }
+
+ public String getLinkAddress() {
+ return linkAddress;
+ }
+
+ public void setLinkAddress(String linkAddress) {
+ this.linkAddress = linkAddress;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(String createTime) {
+ this.createTime = createTime;
+ }
+
+ public String getGoods() {
+ return goods;
+ }
+
+ public void setGoods(String goods) {
+ this.goods = goods;
+ }
+
+ public Long getCartId() {
+ return cartId;
+ }
+
+ public void setCartId(Long cartId) {
+ this.cartId = cartId;
+ }
+
+ @Override
+ public String toString() {
+ return "Order{" +
+ "id=" + id +
+ ", orderNo='" + orderNo + '\'' +
+ ", totalPrice=" + totalPrice +
+ ", userId=" + userId +
+ ", linkUser='" + linkUser + '\'' +
+ ", linkPhone='" + linkPhone + '\'' +
+ ", linkAddress='" + linkAddress + '\'' +
+ ", state='" + state + '\'' +
+ ", createTime='" + createTime + '\'' +
+ ", goods='" + goods + '\'' +
+ ", cartId=" + cartId +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/rabbiter/em/entity/OrderGoods.java b/src/main/java/com/rabbiter/em/entity/OrderGoods.java
new file mode 100644
index 0000000..5f90fc5
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/OrderGoods.java
@@ -0,0 +1,86 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+@TableName("order_goods")
+public class OrderGoods extends Model {
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 订单id
+ */
+ private Long orderId;
+
+ /**
+ * 商品id
+ */
+ private Long goodId;
+
+ /**
+ * 数量
+ */
+ private Integer count;
+
+ /**
+ * 商品规格
+ */
+ private String standard;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Long getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(Long orderId) {
+ this.orderId = orderId;
+ }
+
+ public Long getGoodId() {
+ return goodId;
+ }
+
+ public void setGoodId(Long goodId) {
+ this.goodId = goodId;
+ }
+
+ public Integer getCount() {
+ return count;
+ }
+
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+
+ public String getStandard() {
+ return standard;
+ }
+
+ public void setStandard(String standard) {
+ this.standard = standard;
+ }
+
+ @Override
+ public String toString() {
+ return "OrderGoods{" +
+ "id=" + id +
+ ", orderId=" + orderId +
+ ", goodId=" + goodId +
+ ", count=" + count +
+ ", standard='" + standard + '\'' +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/rabbiter/em/entity/OrderItem.java b/src/main/java/com/rabbiter/em/entity/OrderItem.java
new file mode 100644
index 0000000..5865de3
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/OrderItem.java
@@ -0,0 +1,53 @@
+package com.rabbiter.em.entity;
+
+/*
+用来接收前台下订单时,传来的‘goods'参数
+ */
+public class OrderItem {
+
+ /*
+ 商品id
+ */
+ private long id;
+ /*
+ 商品规格
+ */
+ private String standard;
+ /*
+ 数量
+ */
+ private int num;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getStandard() {
+ return standard;
+ }
+
+ public void setStandard(String standard) {
+ this.standard = standard;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ @Override
+ public String toString() {
+ return "OrderItem{" +
+ "id=" + id +
+ ", standard='" + standard + '\'' +
+ ", num=" + num +
+ '}';
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/entity/Standard.java b/src/main/java/com/rabbiter/em/entity/Standard.java
new file mode 100644
index 0000000..1515e15
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/Standard.java
@@ -0,0 +1,72 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+
+import java.math.BigDecimal;
+
+@TableName("good_standard")
+public class Standard extends Model {
+
+ /**
+ * 商品id
+ */
+ private Integer goodId;
+
+ /**
+ * 商品规格
+ */
+ private String value;
+
+ /**
+ * 该规格的价格
+ */
+ private BigDecimal price;
+
+ /**
+ * 该规格的库存
+ */
+ private Integer store;
+
+ public Integer getGoodId() {
+ return goodId;
+ }
+
+ public void setGoodId(Integer goodId) {
+ this.goodId = goodId;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public BigDecimal getPrice() {
+ return price;
+ }
+
+ public void setPrice(BigDecimal price) {
+ this.price = price;
+ }
+
+ public Integer getStore() {
+ return store;
+ }
+
+ public void setStore(Integer store) {
+ this.store = store;
+ }
+
+ @Override
+ public String toString() {
+ return "Standard{" +
+ "goodId=" + goodId +
+ ", value='" + value + '\'' +
+ ", price=" + price +
+ ", store=" + store +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/rabbiter/em/entity/User.java b/src/main/java/com/rabbiter/em/entity/User.java
new file mode 100644
index 0000000..1f06916
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/User.java
@@ -0,0 +1,122 @@
+package com.rabbiter.em.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+@TableName("sys_user")
+public class User {
+ @TableId(type=IdType.AUTO)
+ private Integer id;
+ private String username;
+ @JsonIgnore
+ private String password;
+ private String nickname;
+ private String email;
+ private String phone;
+ private String address;
+ private String avatarUrl;
+ private String role;
+ @TableField(exist = false)
+ private String newPassword;
+
+ public User() {
+ }
+
+ public String getNewPassword() {
+ return newPassword;
+ }
+
+ public void setNewPassword(String newPassword) {
+ this.newPassword = newPassword;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer 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 getNickname() {
+ return nickname;
+ }
+
+ public void setNickname(String nickname) {
+ this.nickname = nickname;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getAvatarUrl() {
+ return avatarUrl;
+ }
+
+ public void setAvatarUrl(String avatarUrl) {
+ this.avatarUrl = avatarUrl;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ @Override
+ public String toString() {
+ return "User{" +
+ "id=" + id +
+ ", username='" + username + '\'' +
+ ", password='" + password + '\'' +
+ ", nickname='" + nickname + '\'' +
+ ", email='" + email + '\'' +
+ ", phone='" + phone + '\'' +
+ ", address='" + address + '\'' +
+ ", avatarUrl='" + avatarUrl + '\'' +
+ ", role='" + role + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/entity/dto/GoodDTO.java b/src/main/java/com/rabbiter/em/entity/dto/GoodDTO.java
new file mode 100644
index 0000000..05ba4d6
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/dto/GoodDTO.java
@@ -0,0 +1,52 @@
+package com.rabbiter.em.entity.dto;
+
+import java.math.BigDecimal;
+
+public class GoodDTO {
+ private Long id;
+ private String name;
+ private String imgs;
+ private BigDecimal price;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getImgs() {
+ return imgs;
+ }
+
+ public void setImgs(String imgs) {
+ this.imgs = imgs;
+ }
+
+ public BigDecimal getPrice() {
+ return price;
+ }
+
+ public void setPrice(BigDecimal price) {
+ this.price = price;
+ }
+
+ @Override
+ public String toString() {
+ return "GoodDTO{" +
+ "id=" + id +
+ ", name='" + name + '\'' +
+ ", imgs='" + imgs + '\'' +
+ ", price=" + price +
+ '}';
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/entity/dto/UserDTO.java b/src/main/java/com/rabbiter/em/entity/dto/UserDTO.java
new file mode 100644
index 0000000..4078d1d
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/entity/dto/UserDTO.java
@@ -0,0 +1,70 @@
+package com.rabbiter.em.entity.dto;
+
+public class UserDTO {
+ private int id;
+ private String username;
+ private String nickname;
+ private String avatarUrl;
+ private String token;
+ private String role;
+
+ 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 getNickname() {
+ return nickname;
+ }
+
+ public void setNickname(String nickname) {
+ this.nickname = nickname;
+ }
+
+ public String getAvatarUrl() {
+ return avatarUrl;
+ }
+
+ public void setAvatarUrl(String avatarUrl) {
+ this.avatarUrl = avatarUrl;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ @Override
+ public String toString() {
+ return "UserDTO{" +
+ "id=" + id +
+ ", username='" + username + '\'' +
+ ", nickname='" + nickname + '\'' +
+ ", avatarUrl='" + avatarUrl + '\'' +
+ ", token='" + token + '\'' +
+ ", role='" + role + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/exception/GlobalExceptionHandler.java b/src/main/java/com/rabbiter/em/exception/GlobalExceptionHandler.java
new file mode 100644
index 0000000..13e6370
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/exception/GlobalExceptionHandler.java
@@ -0,0 +1,19 @@
+package com.rabbiter.em.exception;
+
+import com.rabbiter.em.common.Result;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/*
+全局异常处理
+ */
+//@ControllerAdvice
+public class GlobalExceptionHandler {
+
+ @ExceptionHandler(ServiceException.class)
+ @ResponseBody
+ public Result handle(ServiceException se){
+ return Result.error(se.getCode(),se.getMessage());
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/exception/ServiceException.java b/src/main/java/com/rabbiter/em/exception/ServiceException.java
new file mode 100644
index 0000000..20cfb32
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/exception/ServiceException.java
@@ -0,0 +1,17 @@
+package com.rabbiter.em.exception;
+
+/*
+自定义异常
+ */
+public class ServiceException extends RuntimeException {
+ private String code;
+
+ public ServiceException(String code, String msg) {
+ super(msg);
+ this.code = code;
+ }
+
+ public String getCode() {
+ return code;
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/interceptor/AuthorityInterceptor.java b/src/main/java/com/rabbiter/em/interceptor/AuthorityInterceptor.java
new file mode 100644
index 0000000..40d86ab
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/interceptor/AuthorityInterceptor.java
@@ -0,0 +1,53 @@
+package com.rabbiter.em.interceptor;
+
+import com.rabbiter.em.annotation.Authority;
+import com.rabbiter.em.utils.TokenUtils;
+import com.rabbiter.em.entity.AuthorityType;
+import org.springframework.stereotype.Component;
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.lang.reflect.Method;
+
+@Component
+public class AuthorityInterceptor implements HandlerInterceptor {
+ @Override
+ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+ if(handler instanceof HandlerMethod){
+ HandlerMethod handlerMethod = (HandlerMethod) handler;
+ Method method = handlerMethod.getMethod();
+ Class> clazz = handlerMethod.getBeanType();
+ if(method!=null && clazz!=null){
+ boolean isMethodAnnotation = method.isAnnotationPresent(Authority.class);
+ boolean isClassAnnotation = clazz.isAnnotationPresent(Authority.class);
+ Authority authority = null;
+ //方法注解会覆盖类注解
+ if(isMethodAnnotation){
+ authority = method.getAnnotation(Authority.class);
+ }else if (isClassAnnotation){
+ authority = clazz.getAnnotation(Authority.class);
+ }
+ if(authority==null){
+ return true;
+ }
+ switch (authority.value()){
+ case requireLogin:
+ return TokenUtils.validateLogin();
+ case requireAuthority:
+ return TokenUtils.validateAuthority();
+ case noRequire:
+ return true;
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
+ HandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/interceptor/JwtInterceptor.java b/src/main/java/com/rabbiter/em/interceptor/JwtInterceptor.java
new file mode 100644
index 0000000..57e377e
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/interceptor/JwtInterceptor.java
@@ -0,0 +1,63 @@
+package com.rabbiter.em.interceptor;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.exceptions.JWTVerificationException;
+import com.rabbiter.em.constants.Constants;
+import com.rabbiter.em.constants.RedisConstants;
+import com.rabbiter.em.entity.User;
+import com.rabbiter.em.exception.ServiceException;
+import com.rabbiter.em.service.UserService;
+import com.rabbiter.em.utils.UserHolder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.concurrent.TimeUnit;
+
+/*
+第一层拦截器,验证用户token,把redis中的user存到threadlocal
+ */
+@Component
+public class JwtInterceptor implements HandlerInterceptor {
+ @Autowired
+ private UserService userService;
+ @Resource
+ RedisTemplate redisTemplate;
+ @Override
+ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
+ String token = request.getHeader("token");
+ //如果不是映射到方法,直接通过
+ if(!(handler instanceof HandlerMethod)){
+ return true;
+ }
+ //验证是否有token
+ if(!StringUtils.hasLength(token)){
+ throw new ServiceException(Constants.TOKEN_ERROR,"token失效,请重新登陆");
+ }
+ //通过token,将redis中的user存到threadlocal(UserHolder)
+ User user = redisTemplate.opsForValue().get(RedisConstants.USER_TOKEN_KEY + token);
+
+ if(user == null){
+ throw new ServiceException(Constants.TOKEN_ERROR,"token失效,请重新登陆");
+ }
+ UserHolder.saveUser(user);
+ //重置过期时间
+ redisTemplate.expire(RedisConstants.USER_TOKEN_KEY +token, RedisConstants.USER_TOKEN_TTL, TimeUnit.MINUTES);
+ //验证token
+ JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(user.getUsername())).build();
+ try {
+ jwtVerifier.verify(token);
+ }catch (JWTVerificationException e){
+ throw new ServiceException(Constants.TOKEN_ERROR,"token验证失败,请重新登陆");
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/com/rabbiter/em/mapper/AddressMapper.java b/src/main/java/com/rabbiter/em/mapper/AddressMapper.java
new file mode 100644
index 0000000..3c8efd3
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/mapper/AddressMapper.java
@@ -0,0 +1,8 @@
+package com.rabbiter.em.mapper;
+
+import com.rabbiter.em.entity.Address;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+public interface AddressMapper extends BaseMapper {
+
+}
diff --git a/src/main/java/com/rabbiter/em/mapper/AvatarMapper.java b/src/main/java/com/rabbiter/em/mapper/AvatarMapper.java
new file mode 100644
index 0000000..869c1ee
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/mapper/AvatarMapper.java
@@ -0,0 +1,28 @@
+package com.rabbiter.em.mapper;
+
+import com.rabbiter.em.entity.Avatar;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+@Mapper
+public interface AvatarMapper {
+ @Insert("insert into avatar(type, size, url, md5) values(#{type},#{size},#{url},#{md5})")
+ public void save(Avatar avatar);
+
+ @Select("select * from avatar where md5 = #{md5}")
+ public Avatar selectByMd5(String md5);
+
+ @Select("select * from avatar where id = #{id}")
+ public Avatar selectById(int id);
+
+ @Delete("delete from avatar where id = #{id}")
+ int delete(int id);
+ @Select("select * from avatar limit #{index},#{pageSize}")
+ List selectPage(int index,int pageSize);
+ @Select("select count(*) from avatar")
+ int getTotal();
+}
diff --git a/src/main/java/com/rabbiter/em/mapper/CarouselMapper.java b/src/main/java/com/rabbiter/em/mapper/CarouselMapper.java
new file mode 100644
index 0000000..6d71e52
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/mapper/CarouselMapper.java
@@ -0,0 +1,11 @@
+package com.rabbiter.em.mapper;
+
+import com.rabbiter.em.entity.Carousel;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import java.util.List;
+
+public interface CarouselMapper extends BaseMapper {
+
+ List getAllCarousel();
+}
diff --git a/src/main/java/com/rabbiter/em/mapper/CartMapper.java b/src/main/java/com/rabbiter/em/mapper/CartMapper.java
new file mode 100644
index 0000000..a1b002b
--- /dev/null
+++ b/src/main/java/com/rabbiter/em/mapper/CartMapper.java
@@ -0,0 +1,14 @@
+package com.rabbiter.em.mapper;
+
+import com.rabbiter.em.entity.Cart;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.MapKey;
+
+import java.util.List;
+import java.util.Map;
+
+public interface CartMapper extends BaseMapper {
+
+ @MapKey("id")
+ List