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> selectByUserId(Long userId); +} diff --git a/src/main/java/com/rabbiter/em/mapper/CategoryMapper.java b/src/main/java/com/rabbiter/em/mapper/CategoryMapper.java new file mode 100644 index 0000000..9297fd5 --- /dev/null +++ b/src/main/java/com/rabbiter/em/mapper/CategoryMapper.java @@ -0,0 +1,8 @@ +package com.rabbiter.em.mapper; + +import com.rabbiter.em.entity.Category; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface CategoryMapper extends BaseMapper { + +} diff --git a/src/main/java/com/rabbiter/em/mapper/FileMapper.java b/src/main/java/com/rabbiter/em/mapper/FileMapper.java new file mode 100644 index 0000000..2f3156d --- /dev/null +++ b/src/main/java/com/rabbiter/em/mapper/FileMapper.java @@ -0,0 +1,9 @@ +package com.rabbiter.em.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.rabbiter.em.entity.MyFile; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface FileMapper extends BaseMapper { +} diff --git a/src/main/java/com/rabbiter/em/mapper/GoodMapper.java b/src/main/java/com/rabbiter/em/mapper/GoodMapper.java new file mode 100644 index 0000000..6a31418 --- /dev/null +++ b/src/main/java/com/rabbiter/em/mapper/GoodMapper.java @@ -0,0 +1,34 @@ +package com.rabbiter.em.mapper; + +import com.rabbiter.em.entity.Good; +import com.rabbiter.em.entity.GoodStandard; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.rabbiter.em.entity.dto.GoodDTO; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.math.BigDecimal; +import java.util.List; + +public interface GoodMapper extends BaseMapper { + + @Select("select * from good_standard where good_id = #{id}") + List getStandardById(int id); + + List findFrontGoods(); + + @Update("update good set is_delete = 1 where id = #{id}") + void fakeDelete(Long id); + + void insertGood(@Param("good") Good good); + + @Select("SELECT discount * MIN(price) FROM good_standard gs, good WHERE good.id = gs.good_id AND good.id = #{id} ") + BigDecimal getMinPrice(Long id); + + boolean saleGood(@Param("id")Long goodId,@Param("count") int count,@Param("money") BigDecimal totalPrice); + + + @Select("SELECT * FROM `good` WHERE is_delete = 0 ORDER BY sale_money DESC LIMIT 0,#{num}") + List getSaleRank(int num); +} diff --git a/src/main/java/com/rabbiter/em/mapper/IconCategoryMapper.java b/src/main/java/com/rabbiter/em/mapper/IconCategoryMapper.java new file mode 100644 index 0000000..3fe8993 --- /dev/null +++ b/src/main/java/com/rabbiter/em/mapper/IconCategoryMapper.java @@ -0,0 +1,10 @@ +package com.rabbiter.em.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.rabbiter.em.entity.IconCategory; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface IconCategoryMapper extends BaseMapper { + +} diff --git a/src/main/java/com/rabbiter/em/mapper/IconMapper.java b/src/main/java/com/rabbiter/em/mapper/IconMapper.java new file mode 100644 index 0000000..6ad39e4 --- /dev/null +++ b/src/main/java/com/rabbiter/em/mapper/IconMapper.java @@ -0,0 +1,11 @@ +package com.rabbiter.em.mapper; + +import com.rabbiter.em.entity.Icon; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +public interface IconMapper extends BaseMapper { + + List getIconCategoryMapList(); +} diff --git a/src/main/java/com/rabbiter/em/mapper/IncomeMapper.java b/src/main/java/com/rabbiter/em/mapper/IncomeMapper.java new file mode 100644 index 0000000..f1fe754 --- /dev/null +++ b/src/main/java/com/rabbiter/em/mapper/IncomeMapper.java @@ -0,0 +1,17 @@ +package com.rabbiter.em.mapper; + +import org.apache.ibatis.annotations.MapKey; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +public interface IncomeMapper { + @MapKey("categoryId") + List> selectCategoryIncome(); + + BigDecimal selectSumIncome(); + + BigDecimal getDayIncome(@Param("thisDay")String thisDay,@Param("nextDay") String nextDay); +} diff --git a/src/main/java/com/rabbiter/em/mapper/OrderGoodsMapper.java b/src/main/java/com/rabbiter/em/mapper/OrderGoodsMapper.java new file mode 100644 index 0000000..b28eece --- /dev/null +++ b/src/main/java/com/rabbiter/em/mapper/OrderGoodsMapper.java @@ -0,0 +1,8 @@ +package com.rabbiter.em.mapper; + +import com.rabbiter.em.entity.OrderGoods; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface OrderGoodsMapper extends BaseMapper { + +} diff --git a/src/main/java/com/rabbiter/em/mapper/OrderMapper.java b/src/main/java/com/rabbiter/em/mapper/OrderMapper.java new file mode 100644 index 0000000..383d2d1 --- /dev/null +++ b/src/main/java/com/rabbiter/em/mapper/OrderMapper.java @@ -0,0 +1,22 @@ +package com.rabbiter.em.mapper; + +import com.rabbiter.em.entity.Order; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.MapKey; +import org.apache.ibatis.annotations.Update; + +import java.util.List; +import java.util.Map; + +public interface OrderMapper extends BaseMapper { + @Update("update t_order set state = '已支付' where order_no = #{orderNo}") + void payOrder(String orderNo); + + @MapKey("id") + List> selectByUserId(int userId); + + @Update("update t_order set state = '已收货' where order_no = #{orderNo}") + boolean receiveOrder(String orderNo); + + Map selectByOrderNo(String orderNo); +} diff --git a/src/main/java/com/rabbiter/em/mapper/StandardMapper.java b/src/main/java/com/rabbiter/em/mapper/StandardMapper.java new file mode 100644 index 0000000..3afd7bc --- /dev/null +++ b/src/main/java/com/rabbiter/em/mapper/StandardMapper.java @@ -0,0 +1,15 @@ +package com.rabbiter.em.mapper; + +import com.rabbiter.em.entity.Standard; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +public interface StandardMapper extends BaseMapper { + @Update("update good_standard set store = #{num} where good_id = #{good_id} and value = #{standard}") + void deductStore(@Param("good_id") long good_id, @Param("standard") String standard, @Param("num") int num); + + @Select("select store from good_standard where good_id = #{good_id} and value = #{standard}") + int getStore(@Param("good_id") long good_id, @Param("standard")String standard); +} diff --git a/src/main/java/com/rabbiter/em/mapper/UserMapper.java b/src/main/java/com/rabbiter/em/mapper/UserMapper.java new file mode 100644 index 0000000..fb2a2a7 --- /dev/null +++ b/src/main/java/com/rabbiter/em/mapper/UserMapper.java @@ -0,0 +1,27 @@ +package com.rabbiter.em.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.rabbiter.em.entity.User; +import org.apache.ibatis.annotations.Mapper; +@Mapper +public interface UserMapper extends BaseMapper { + /* + 以下为引入mybatis-plus之前的操作 + + @Select("select * from sys_user") + List findFrontGoods(); + @Insert("insert into sys_user(username,password,nickname,email,phone,address) " + + "values (#{username},#{password},#{nickname},#{email},#{phone},#{address})") + int insert(User user); + + int update(User user); + + @Delete("delete from sys_user where id = #{id}") + int deleteById(@Param("id") int id); + + List selectPage(int index,int pageSize,String username,String nickname); + + int searchTotal(String username, String nickname); + + */ +} diff --git a/src/main/java/com/rabbiter/em/service/AddressService.java b/src/main/java/com/rabbiter/em/service/AddressService.java new file mode 100644 index 0000000..ab8d1ac --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/AddressService.java @@ -0,0 +1,23 @@ +package com.rabbiter.em.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.rabbiter.em.entity.Address; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.rabbiter.em.mapper.AddressMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service +public class AddressService extends ServiceImpl { + + @Resource + private AddressMapper addressMapper; + + public List
findAllById(Long id) { + QueryWrapper
listQueryWrapper = new QueryWrapper<>(); + listQueryWrapper.eq("user_id",id); + return list(listQueryWrapper); + } +} diff --git a/src/main/java/com/rabbiter/em/service/AvatarService.java b/src/main/java/com/rabbiter/em/service/AvatarService.java new file mode 100644 index 0000000..d55eee9 --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/AvatarService.java @@ -0,0 +1,115 @@ +package com.rabbiter.em.service; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.SecureUtil; +import com.rabbiter.em.constants.Constants; +import com.rabbiter.em.entity.Avatar; +import com.rabbiter.em.exception.ServiceException; +import com.rabbiter.em.mapper.AvatarMapper; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URLEncoder; +import java.util.List; +import java.util.UUID; + +@Service +public class AvatarService { + @Resource + private AvatarMapper avatarMapper; + + public String upload(MultipartFile uploadFile){ + String url = null; + //通过md5判断文件是否已经存在,防止在服务器存储相同文件 + InputStream inputStream = null; + try { + inputStream = uploadFile.getInputStream(); + } catch (IOException e) { + e.printStackTrace(); + } + String md5 = SecureUtil.md5(inputStream); + Avatar dbAvatar = avatarMapper.selectByMd5(md5); + if(dbAvatar==null){ + String originalFilename = uploadFile.getOriginalFilename(); //文件原始名字 + String type = originalFilename.substring(originalFilename.lastIndexOf(".")+1); //文件后缀 + System.out.println(originalFilename+" "+type); + long size = uploadFile.getSize() / 1024; //文件大小,单位kb + //文件不存在,则保存文件 + File folder = new File(Constants.avatarFolderPath); + if(!folder.exists()){ + folder.mkdir(); + } + String folderPath = folder.getAbsolutePath()+"/"; //文件存储文件夹的位置 + System.out.println("文件存储地址"+folderPath); + + + //将文件保存为UUID的名字,通过uuid生成url + String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase(); + String finalFileName = uuid+"."+type; + File targetFile = new File(folderPath + finalFileName); + try { + uploadFile.transferTo(targetFile); + } catch (IOException e) { + e.printStackTrace(); + } + url = "/avatar/"+finalFileName; + Avatar avatar = new Avatar(type, size, url, md5); + System.out.println(avatar); + avatarMapper.save(avatar); + return url; + } + return dbAvatar.getUrl(); + } + //根据文件名下载文件 + public void download(String fileName, HttpServletResponse response){ + File file = new File(Constants.avatarFolderPath+fileName); + if(!file.exists()){ + throw new ServiceException(Constants.CODE_500,"文件不存在"); + } + try { + ServletOutputStream os = response.getOutputStream(); + response.addHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode(fileName,"UTF-8")); + response.setContentType("application/octet-stream"); + os.write(FileUtil.readBytes(file)); + os.flush(); + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public int delete(int id) { + Avatar avatar = avatarMapper.selectById(id); + int delete = avatarMapper.delete(id); + System.out.println(delete); + if(delete==1){ + String fileName = StrUtil.subAfter(avatar.getUrl(),"/",true); + System.out.println(fileName); + File file = new File(Constants.avatarFolderPath+fileName); + System.out.println(file.getAbsolutePath()); + if(file.exists()){ + + boolean delete1 = file.delete(); + if(delete1){ + System.out.println("删除成功"); + } + } + } + return delete; + } + + public List selectPage(int index, int pageSize) { + return avatarMapper.selectPage(index,pageSize); + } + + public int getTotal() { + return avatarMapper.getTotal(); + } +} diff --git a/src/main/java/com/rabbiter/em/service/CarouselService.java b/src/main/java/com/rabbiter/em/service/CarouselService.java new file mode 100644 index 0000000..eaaa5e5 --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/CarouselService.java @@ -0,0 +1,20 @@ +package com.rabbiter.em.service; + +import com.rabbiter.em.entity.Carousel; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.rabbiter.em.mapper.CarouselMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service +public class CarouselService extends ServiceImpl { + + @Resource + private CarouselMapper carouselMapper; + + public List getAllCarousel() { + return carouselMapper.getAllCarousel(); + } +} diff --git a/src/main/java/com/rabbiter/em/service/CartService.java b/src/main/java/com/rabbiter/em/service/CartService.java new file mode 100644 index 0000000..bd57cb7 --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/CartService.java @@ -0,0 +1,21 @@ +package com.rabbiter.em.service; + +import com.rabbiter.em.entity.Cart; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.rabbiter.em.mapper.CartMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Service +public class CartService extends ServiceImpl { + + @Resource + private CartMapper cartMapper; + + public List> selectByUserId(Long userId) { + return cartMapper.selectByUserId(userId); + } +} diff --git a/src/main/java/com/rabbiter/em/service/CategoryService.java b/src/main/java/com/rabbiter/em/service/CategoryService.java new file mode 100644 index 0000000..7bd3f05 --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/CategoryService.java @@ -0,0 +1,51 @@ +package com.rabbiter.em.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.rabbiter.em.entity.Category; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.rabbiter.em.entity.IconCategory; +import com.rabbiter.em.mapper.CategoryMapper; +import com.rabbiter.em.mapper.IconCategoryMapper; +import com.rabbiter.em.utils.BaseApi; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Map; + +@Service +public class CategoryService extends ServiceImpl { + + @Resource + private CategoryMapper categoryMapper; + @Resource + private IconCategoryMapper iconCategoryMapper; + + /** + * 新增下级分类 + 上下级分类关联 + * + * @param category 下级分类 + */ + public void add(Category category) { + save(category); + IconCategory iconCategory = new IconCategory(); + iconCategory.setCategoryId(category.getId()); + iconCategory.setIconId(category.getIconId()); + iconCategoryMapper.insert(iconCategory); + } + + /** + * 删除分类 + * + * @param id id + * @return 结果 + */ + public Map delete(Long id) { + // 删除关联 + iconCategoryMapper.delete( + new QueryWrapper().eq("category_id", id) + ); + // 删除下级分类 + removeById(id); + return BaseApi.success(); + } +} diff --git a/src/main/java/com/rabbiter/em/service/FileService.java b/src/main/java/com/rabbiter/em/service/FileService.java new file mode 100644 index 0000000..5cffb7c --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/FileService.java @@ -0,0 +1,125 @@ +package com.rabbiter.em.service; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.crypto.SecureUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.rabbiter.em.constants.Constants; +import com.rabbiter.em.entity.MyFile; +import com.rabbiter.em.exception.ServiceException; +import com.rabbiter.em.mapper.FileMapper; +import com.sun.xml.fastinfoset.stax.events.Util; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URLEncoder; +import java.util.List; +import java.util.UUID; + +@Service +public class FileService extends ServiceImpl { + @Resource + private FileMapper fileMapper; + + public String upload(MultipartFile uploadFile){ + String originalFilename = uploadFile.getOriginalFilename(); //文件原始名字 + String type = originalFilename.substring(originalFilename.lastIndexOf(".")+1); //文件后缀 + long size = uploadFile.getSize() / 1024; //文件大小,单位kb + String url; + MyFile myFile = new MyFile(); //用于保存于数据库的实体类Files + myFile.setName(originalFilename); + myFile.setSize(size); + myFile.setType(type); + + //通过md5判断文件是否已经存在,防止在服务器存储相同文件 + InputStream inputStream = null; + try { + inputStream = uploadFile.getInputStream(); + } catch (IOException e) { + e.printStackTrace(); + } + String md5 = SecureUtil.md5(inputStream); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("md5",md5); + List dbMyFileList = fileMapper.selectList(queryWrapper); + if(dbMyFileList.size() != 0){ + //数据库中已有该md5,则拷贝其url + url = dbMyFileList.get(0) .getUrl(); + myFile.setUrl(url); + }else{ + //文件不存在,则保存文件 + File folder = new File(Constants.fileFolderPath); + if(!folder.exists()){ + folder.mkdir(); + } + String folderPath = folder.getAbsolutePath()+"/"; //文件存储文件夹的位置 + System.out.println("文件存储地址"+folderPath); + //将文件保存为UUID的名字,通过uuid生成url + String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase(); + String finalFileName = uuid+"."+type; + File targetFile = new File(folderPath + finalFileName); + try { + uploadFile.transferTo(targetFile); + } catch (IOException e) { + e.printStackTrace(); + } + url = "/file/"+finalFileName; + myFile.setUrl(url); + } + myFile.setMd5(md5); + + fileMapper.insert(myFile); + System.out.println("文件"+originalFilename+" "+url); + return url; + } + + //根据文件名下载文件 + public void download(String fileName, HttpServletResponse response){ + File file = new File(Constants.fileFolderPath+fileName); + if(!file.exists()){ + throw new ServiceException(Constants.CODE_500,"文件不存在"); + } + try { + ServletOutputStream os = response.getOutputStream(); + response.addHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode(fileName,"UTF-8")); + response.setContentType("application/octet-stream"); + os.write(FileUtil.readBytes(file)); + os.flush(); + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + public int fakeDelete(int id){ + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("id",id).set("is_delete",true); + return fileMapper.update(null,updateWrapper); + } + + public IPage selectPage(int pageNum,int pageSize,String fileName) { + IPage filesPage = new Page<>(pageNum, pageSize); + QueryWrapper filesQueryWrapper = new QueryWrapper<>(); + if(!Util.isEmptyString(fileName)){ + filesQueryWrapper.like("name",fileName); + } + filesQueryWrapper.eq("is_delete",false); + filesQueryWrapper.orderByDesc("id"); + return page(filesPage, filesQueryWrapper); + } + + + public int changeEnable(int id, boolean enable) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("id",id).set("enable",enable); + return fileMapper.update(null, updateWrapper); + } +} diff --git a/src/main/java/com/rabbiter/em/service/GoodService.java b/src/main/java/com/rabbiter/em/service/GoodService.java new file mode 100644 index 0000000..af91e3c --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/GoodService.java @@ -0,0 +1,162 @@ +package com.rabbiter.em.service; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.rabbiter.em.constants.Constants; +import com.rabbiter.em.entity.Good; +import com.rabbiter.em.entity.GoodStandard; +import com.rabbiter.em.entity.dto.GoodDTO; +import com.rabbiter.em.exception.ServiceException; +import com.rabbiter.em.mapper.GoodMapper; + +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static com.rabbiter.em.constants.RedisConstants.GOOD_TOKEN_KEY; +import static com.rabbiter.em.constants.RedisConstants.GOOD_TOKEN_TTL; + +@Service +public class GoodService extends ServiceImpl { + + @Resource + private GoodMapper goodMapper; + @Resource + private RedisTemplate redisTemplate; + + //查询一个商品的信息 + public Good getGoodById(Long id) { + String redisKey = GOOD_TOKEN_KEY + id; + //从redis中查,若有则返回 + ValueOperations valueOperations = redisTemplate.opsForValue(); + Good redisGood = valueOperations.get(redisKey); + if(redisGood!=null){ + redisTemplate.expire(redisKey,GOOD_TOKEN_TTL, TimeUnit.MINUTES); + return redisGood; + } + //若redis中没有则去数据库查 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Good::getIsDelete,false); + queryWrapper.eq(Good::getId,id); + Good dbGood = getOne(queryWrapper); + if(dbGood!=null){ + //将商品信息存入redis + valueOperations.set(redisKey,dbGood); + redisTemplate.expire(redisKey,GOOD_TOKEN_TTL, TimeUnit.MINUTES); + return dbGood; + } + //数据库中没有则返回异常 + throw new ServiceException(Constants.NO_RESULT,"无结果"); + + } + //查询商品的规格 + public String getStandard(int id){ + List standards = goodMapper.getStandardById(id); + if(standards.size()==0){ + throw new ServiceException(Constants.NO_RESULT,"无结果"); + } + return JSON.toJSONString(standards); + } + //查询某商品的最低规格价 + public BigDecimal getMinPrice(Long id){ + return goodMapper.getMinPrice(id); + } + //查询全部(首页推荐商品) + public List findFrontGoods() { + return goodMapper.findFrontGoods(); + } + + + //假删除 + public void deleteGood(Long id) { + redisTemplate.delete(GOOD_TOKEN_KEY+id); + goodMapper.fakeDelete(id); + } + //保存商品信息 + public Long saveOrUpdateGood(Good good) { + System.out.println(good); + if(good.getId()==null){ + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + good.setCreateTime(df.format(LocalDateTime.now())); + goodMapper.insertGood(good); + }else{ + saveOrUpdate(good); + redisTemplate.delete(GOOD_TOKEN_KEY + good.getId()); + } + return good.getId(); + } + + public boolean setRecommend(Long id,Boolean isRecommend) { + LambdaUpdateWrapper goodsLambdaUpdateWrapper = new LambdaUpdateWrapper<>(); + goodsLambdaUpdateWrapper.eq(Good::getId,id) + .set(Good::getRecommend,isRecommend); + return update(goodsLambdaUpdateWrapper); + } + + public List getSaleRank(int num) { + return goodMapper.getSaleRank(num); + } + + + public void update(Good good) { + updateById(good); + redisTemplate.delete(GOOD_TOKEN_KEY + good.getId()); + } + //分页查询 + public IPage findPage(Integer pageNum, Integer pageSize, String searchText, Integer categoryId) { + LambdaQueryWrapper query = Wrappers.lambdaQuery().orderByDesc(Good::getId); + //对名称和描述进行模糊查询 + if (StrUtil.isNotBlank(searchText)) { + query.like(Good::getName, searchText).or().like(Good::getDescription,searchText).or().eq(Good::getId,searchText); + } + if(categoryId != null){ + query.eq(Good::getCategoryId,categoryId); + } + //筛除掉已被删除的商品 + query.eq(Good::getIsDelete,false); + IPage page = this.page(new Page<>(pageNum, pageSize), query); + //把good转为dto + IPage goodDTOPage = page.convert(good -> { + GoodDTO goodDTO = new GoodDTO(); + BeanUtil.copyProperties(good, goodDTO); + return goodDTO; + }); + for (GoodDTO good : goodDTOPage.getRecords()) { + //附上最低价格 + good.setPrice(getMinPrice(good.getId())); + } + return goodDTOPage; + } + public IPage findFullPage(Integer pageNum, Integer pageSize, String searchText, Integer categoryId) { + LambdaQueryWrapper query = Wrappers.lambdaQuery().orderByDesc(Good::getId); + //对名称和描述进行模糊查询 + if (StrUtil.isNotBlank(searchText)) { + query.like(Good::getName, searchText).or().like(Good::getDescription,searchText).or().eq(Good::getId,searchText); + } + if(categoryId != null){ + query.eq(Good::getCategoryId,categoryId); + } + //筛除掉已被删除的商品 + query.eq(Good::getIsDelete,false); + IPage page = this.page(new Page<>(pageNum, pageSize), query); + for (Good good : page.getRecords()) { + //附上最低价格 + good.setPrice(getMinPrice(good.getId())); + } + return page; + } +} diff --git a/src/main/java/com/rabbiter/em/service/IconService.java b/src/main/java/com/rabbiter/em/service/IconService.java new file mode 100644 index 0000000..ede9698 --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/IconService.java @@ -0,0 +1,45 @@ +package com.rabbiter.em.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.rabbiter.em.entity.Icon; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.rabbiter.em.entity.IconCategory; +import com.rabbiter.em.mapper.IconCategoryMapper; +import com.rabbiter.em.mapper.IconMapper; +import com.rabbiter.em.utils.BaseApi; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Service +public class IconService extends ServiceImpl { + + @Resource + private IconMapper iconMapper; + + @Resource + private IconCategoryMapper iconCategoryMapper; + + public List getIconCategoryMapList() { + return iconMapper.getIconCategoryMapList(); + } + + /** + * 删除上级分类 + * + * @param id id + */ + public Map deleteById(Long id) { + // 检查是否包含下级分类 + Long count = iconCategoryMapper.selectCount( + new QueryWrapper().eq("icon_id", id) + ); + if (count > 0) { + return BaseApi.error("该上级分类存在下级分类,请删除所有下级分类再尝试删除"); + } + super.removeById(id); + return BaseApi.success(); + } +} diff --git a/src/main/java/com/rabbiter/em/service/IncomeService.java b/src/main/java/com/rabbiter/em/service/IncomeService.java new file mode 100644 index 0000000..9688b45 --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/IncomeService.java @@ -0,0 +1,75 @@ +package com.rabbiter.em.service; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import com.rabbiter.em.mapper.IncomeMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class IncomeService { + @Resource + private IncomeMapper incomeMapper; + + public Map getChart() { + Map chartMap = new HashMap<>(); + //查询每个分类及其收入 + List> categoryIncomes = incomeMapper.selectCategoryIncome(); + //查询总收入 + BigDecimal sumIncome = incomeMapper.selectSumIncome(); + //放入HashMap中并返回 + chartMap.put("categoryIncomes",categoryIncomes); + chartMap.put("sumIncome",sumIncome); + return chartMap; + } + + public Map getWeekIncome() { + ArrayList weekIncome = new ArrayList<>(); + ArrayList weekDays = new ArrayList<>(); + DateTime dateTime = DateUtil.beginOfWeek(DateUtil.date()); + for (int i = 0; i < 7; i++) { + DateTime thisDay = DateUtil.offsetDay(dateTime, i); + DateTime nextDay = DateUtil.offsetDay(dateTime, i+1); + String weekDay = thisDay.toString(); + String formattedWeekday = weekDay.substring(weekDay.indexOf("-")+1,weekDay.indexOf(" ")); + weekDays.add(formattedWeekday); + BigDecimal dayIncome = incomeMapper.getDayIncome(thisDay.toString(), nextDay.toString()); + if(dayIncome == null){ + dayIncome = new BigDecimal(0); + } + weekIncome.add(dayIncome); + } + HashMap map = new HashMap<>(); + map.put("weekDays",weekDays); + map.put("weekIncome",weekIncome); + return map; + } + + public Map getMonthIncome() { + ArrayList monthIncome = new ArrayList<>(); + ArrayList monthDays = new ArrayList<>(); + DateTime dateTime = DateUtil.beginOfMonth(DateUtil.date()); + for (int i = 0; i < 30; i++) { + DateTime thisDay = DateUtil.offsetDay(dateTime, i); + DateTime nextDay = DateUtil.offsetDay(dateTime, i+1); + String weekDay = thisDay.toString(); + String formattedWeekday = weekDay.substring(weekDay.indexOf("-")+1,weekDay.indexOf(" ")); + monthDays.add(formattedWeekday); + BigDecimal dayIncome = incomeMapper.getDayIncome(thisDay.toString(), nextDay.toString()); + if(dayIncome == null){ + dayIncome = new BigDecimal(0); + } + monthIncome.add(dayIncome); + } + HashMap map = new HashMap<>(); + map.put("monthDays",monthDays); + map.put("monthIncome",monthIncome); + return map; + } +} diff --git a/src/main/java/com/rabbiter/em/service/OrderGoodsService.java b/src/main/java/com/rabbiter/em/service/OrderGoodsService.java new file mode 100644 index 0000000..3378293 --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/OrderGoodsService.java @@ -0,0 +1,16 @@ +package com.rabbiter.em.service; + +import com.rabbiter.em.entity.OrderGoods; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.rabbiter.em.mapper.OrderGoodsMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class OrderGoodsService extends ServiceImpl { + + @Resource + private OrderGoodsMapper orderGoodsMapper; + +} diff --git a/src/main/java/com/rabbiter/em/service/OrderService.java b/src/main/java/com/rabbiter/em/service/OrderService.java new file mode 100644 index 0000000..78fa155 --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/OrderService.java @@ -0,0 +1,143 @@ +package com.rabbiter.em.service; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.RandomUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.rabbiter.em.constants.Constants; +import com.rabbiter.em.entity.Good; +import com.rabbiter.em.entity.Order; +import com.rabbiter.em.entity.OrderGoods; +import com.rabbiter.em.entity.OrderItem; +import com.rabbiter.em.exception.ServiceException; +import com.rabbiter.em.mapper.GoodMapper; +import com.rabbiter.em.mapper.OrderGoodsMapper; +import com.rabbiter.em.mapper.OrderMapper; +import com.rabbiter.em.mapper.StandardMapper; +import com.rabbiter.em.utils.TokenUtils; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import static com.rabbiter.em.constants.RedisConstants.GOOD_TOKEN_KEY; + +@Service +public class OrderService extends ServiceImpl { + + @Resource + private OrderMapper orderMapper; + @Resource + private OrderGoodsMapper orderGoodsMapper; + @Resource + private StandardMapper standardMapper; + @Resource + private GoodMapper goodMapper; + @Resource + private CartService cartService; + @Resource + private RedisTemplate redisTemplate; + + @Transactional + public String saveOrder(Order order) { + order.setUserId(TokenUtils.getCurrentUser().getId()); + String orderNo = DateUtil.format(new Date(), "yyyyMMddHHmmss") + RandomUtil.randomNumbers(6); + order.setOrderNo(orderNo); + order.setCreateTime(DateUtil.now()); + orderMapper.insert(order); + + OrderGoods orderGoods = new OrderGoods(); + orderGoods.setOrderId(order.getId()); + //遍历order里携带的goods数组,并用orderItem对象来接收 + String goods = order.getGoods(); + List orderItems = JSON.parseArray(goods, OrderItem.class); + for (OrderItem orderItem : orderItems) { + long good_id = orderItem.getId(); + String standard = orderItem.getStandard(); + int num = orderItem.getNum(); + orderGoods.setGoodId(good_id); + orderGoods.setCount(num); + orderGoods.setStandard(standard); + //插入到order_good表 + orderGoodsMapper.insert(orderGoods); + } + // 清除购物车 + cartService.removeById(order.getCartId()); + return orderNo; + } + + //给订单付款 + @Transactional + public void payOrder(String orderNo) { + //更改状态为代付款 + orderMapper.payOrder(orderNo); + //给对应规格减库存 + Map orderMap = orderMapper.selectByOrderNo(orderNo); + int count = (int) orderMap.get("count"); + Object goodIdObj = orderMap.get("goodId"); + Long goodId = null; + if(goodIdObj instanceof Long) { + goodId = (Long) goodIdObj; + } else if(goodIdObj != null) { + try { + goodId = Long.parseLong(goodIdObj.toString()); + } catch (NumberFormatException e) { + throw new ServiceException(Constants.CODE_500, "商品ID不正确"); + } + } + + if(goodId == null) { + throw new ServiceException(Constants.CODE_500, "商品ID不存在"); + } + String standard = (String) orderMap.get("standard"); + int store = standardMapper.getStore(goodId, standard); + if (store < count) { + throw new ServiceException(Constants.CODE_500, "库存不足"); + } + standardMapper.deductStore(goodId, standard, store - count); + + //给对应商品加销量和销售额 + LambdaQueryWrapper orderLambdaQueryWrapper = new LambdaQueryWrapper<>(); + orderLambdaQueryWrapper.eq(Order::getOrderNo, orderNo); + Order one = getOne(orderLambdaQueryWrapper); + BigDecimal totalPrice = one.getTotalPrice(); + goodMapper.saleGood(goodId, count, totalPrice); + + // redis 增销量 + String redisKey = GOOD_TOKEN_KEY + goodId; + ValueOperations valueOperations = redisTemplate.opsForValue(); + Good good = valueOperations.get(redisKey); + if(!ObjectUtils.isEmpty(good)) { + good.setSales(good.getSales() + count); + valueOperations.set(redisKey, good); + } + } + + public List> selectByUserId(int userId) { + return orderMapper.selectByUserId(userId); + } + + public boolean receiveOrder(String orderNo) { + return orderMapper.receiveOrder(orderNo); + } + + public Map selectByOrderNo(String orderNo) { + return orderMapper.selectByOrderNo(orderNo); + } + + public void delivery(String orderNo) { + LambdaUpdateWrapper orderLambdaUpdateWrapper = new LambdaUpdateWrapper<>(); + orderLambdaUpdateWrapper.eq(Order::getOrderNo, orderNo) + .set(Order::getState, "已发货"); + update(orderLambdaUpdateWrapper); + } +} diff --git a/src/main/java/com/rabbiter/em/service/StandardService.java b/src/main/java/com/rabbiter/em/service/StandardService.java new file mode 100644 index 0000000..be56e0d --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/StandardService.java @@ -0,0 +1,30 @@ +package com.rabbiter.em.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.rabbiter.em.entity.Standard; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.rabbiter.em.mapper.StandardMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class StandardService extends ServiceImpl { + + @Resource + private StandardMapper standardMapper; + + public boolean delete(Standard standard) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("good_id",standard.getGoodId()); + queryWrapper.eq("value",standard.getValue()); + return remove(queryWrapper); + } + + + public void deleteAll(int GoodId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("good_id",GoodId); + remove(queryWrapper); + } +} diff --git a/src/main/java/com/rabbiter/em/service/UserService.java b/src/main/java/com/rabbiter/em/service/UserService.java new file mode 100644 index 0000000..e9bdeda --- /dev/null +++ b/src/main/java/com/rabbiter/em/service/UserService.java @@ -0,0 +1,115 @@ +package com.rabbiter.em.service; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.rabbiter.em.common.Result; +import com.rabbiter.em.constants.Constants; +import com.rabbiter.em.constants.RedisConstants; +import com.rabbiter.em.entity.LoginForm; +import com.rabbiter.em.entity.User; +import com.rabbiter.em.entity.dto.UserDTO; +import com.rabbiter.em.exception.ServiceException; +import com.rabbiter.em.mapper.UserMapper; +import com.rabbiter.em.utils.TokenUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import javax.annotation.Resource; +import java.io.Serializable; +import java.util.concurrent.TimeUnit; + + +@Service +public class UserService extends ServiceImpl { + @Resource + RedisTemplate redisTemplate; + + public UserDTO login(LoginForm loginForm) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("username",loginForm.getUsername()); + queryWrapper.eq("password",loginForm.getPassword()); + User user = getOne(queryWrapper); + if(user == null) { + throw new ServiceException(Constants.CODE_403,"用户名或密码错误"); + } + String token = TokenUtils.genToken(user.getId().toString(), user.getUsername()); + //把用户存到redis中 + redisTemplate.opsForValue().set(RedisConstants.USER_TOKEN_KEY + token,user); + //jwt不设置过期时间,只设置redis过期时间。 + redisTemplate.expire(RedisConstants.USER_TOKEN_KEY +token, RedisConstants.USER_TOKEN_TTL, TimeUnit.MINUTES); + //把查到的user的一些属性赋值给userDTO + UserDTO userDTO = BeanUtil.copyProperties(user,UserDTO.class); + //设置token + userDTO.setToken(token); + return userDTO; + + } + + public User register(LoginForm loginForm) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("username",loginForm.getUsername()); + User user = getOne(queryWrapper); + if(user!=null){ + throw new ServiceException(Constants.CODE_403,"用户名已被使用"); + }else{ + user = new User(); + BeanUtils.copyProperties(loginForm,user); + user.setNickname("新用户"); + user.setRole("user"); + save(user); + return user; + } + } + + public User getOne(String username){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("username",username); + return getOne(queryWrapper); + } + + public Result saveUpdate(User user) { + if(user.getId() != null) { + // 修改 + User old = this.baseMapper.selectById(user.getId()); + old.setNickname(ObjectUtils.isEmpty(user.getNickname()) ? old.getNickname() : user.getNickname()); + old.setAvatarUrl(ObjectUtils.isEmpty(user.getAvatarUrl()) ? old.getAvatarUrl() : user.getAvatarUrl()); + old.setRole(ObjectUtils.isEmpty(user.getRole()) ? old.getRole() : user.getRole()); + old.setPhone(ObjectUtils.isEmpty(user.getPhone()) ? old.getPhone() : user.getPhone()); + old.setEmail(ObjectUtils.isEmpty(user.getEmail()) ? old.getEmail() : user.getEmail()); + old.setAddress(ObjectUtils.isEmpty(user.getAddress()) ? old.getAddress() : user.getAddress()); + super.updateById(old); + return Result.success("修改成功"); + } else { + // 新增 + if(!ObjectUtils.isEmpty(this.getOne(user.getUsername()))) { + return Result.error("400", "用户名已存在"); + } + user.setPassword(user.getNewPassword()); + super.save(user); + return Result.success("新增成功"); + } + } + + @Override + public boolean removeById(Serializable id) { + return super.removeById(id); + } + + /** + * 重置密码 + * + * @param id 用户id + * @param newPassword 新密码 + */ + public void resetPassword(String id, String newPassword) { + User user = this.getById(id); + if(user == null) { + return; + } + user.setPassword(newPassword); + this.updateById(user); + } +} diff --git a/src/main/java/com/rabbiter/em/utils/BaseApi.java b/src/main/java/com/rabbiter/em/utils/BaseApi.java new file mode 100644 index 0000000..2e3a6fa --- /dev/null +++ b/src/main/java/com/rabbiter/em/utils/BaseApi.java @@ -0,0 +1,27 @@ +package com.rabbiter.em.utils; + +import java.util.HashMap; +import java.util.Map; + +public class BaseApi { + private static Map map(String code, Object data, String msg) { + Map map = new HashMap<>(); + map.put("code", code); + map.put("data", data); + map.put("msg", msg); + return map; + } + + public static Map success() { + return map("200", null, null); + } + + public static Map success(Object data) { + return map("200", data, null); + } + + public static Map error(String msg) { + return map("400", null, msg); + } + +} diff --git a/src/main/java/com/rabbiter/em/utils/PathUtils.java b/src/main/java/com/rabbiter/em/utils/PathUtils.java new file mode 100644 index 0000000..4f23897 --- /dev/null +++ b/src/main/java/com/rabbiter/em/utils/PathUtils.java @@ -0,0 +1,29 @@ +package com.rabbiter.em.utils; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; + +public class PathUtils { + public static String getClassLoadRootPath() { + String path = ""; + try { + String prePath = URLDecoder.decode(PathUtils.class.getClassLoader().getResource("").getPath(),"utf-8").replace("/target/classes", ""); + String osName = System.getProperty("os.name"); + if (osName.toLowerCase().startsWith("mac")) { + // 苹果 + path = prePath.substring(0, prePath.length() - 1); + } else if (osName.toLowerCase().startsWith("windows")) { + // windows + path = prePath.substring(1, prePath.length() - 1); + } else if(osName.toLowerCase().startsWith("linux") || osName.toLowerCase().startsWith("unix")) { + // unix or linux + path = prePath.substring(0, prePath.length() - 1); + } else { + path = prePath.substring(1, prePath.length() - 1); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return path; + } +} diff --git a/src/main/java/com/rabbiter/em/utils/TokenUtils.java b/src/main/java/com/rabbiter/em/utils/TokenUtils.java new file mode 100644 index 0000000..1f6ee70 --- /dev/null +++ b/src/main/java/com/rabbiter/em/utils/TokenUtils.java @@ -0,0 +1,61 @@ +package com.rabbiter.em.utils; + +import com.auth0.jwt.JWT; +import com.auth0.jwt.algorithms.Algorithm; +import com.rabbiter.em.constants.Constants; +import com.rabbiter.em.entity.User; +import com.rabbiter.em.exception.ServiceException; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.Objects; + +@Component +public class TokenUtils { + + public static String genToken(String userId, String username){ + String token = JWT.create() + .withAudience(userId) + .sign(Algorithm.HMAC256(username)); + return token; + } + + + public static User getCurrentUser(){ + try{ + return UserHolder.getUser(); + }catch (Exception e){ + return null; + } + } + public static boolean validateLogin(){ + try{ + HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); + String token = request.getHeader("token"); + if(StringUtils.hasLength(token)){ + JWT.decode(token).getAudience(); + return true; + }else{ + return false; + } + }catch (Exception e){ + throw new ServiceException(Constants.CODE_401,"登录状态失效!"); + } + } + + public static boolean validateAuthority(){ + try{ + User user = getCurrentUser(); + if(user.getRole().equals("admin")){ + return true; + } + }catch (Exception e){ + return false; + } + throw new ServiceException(Constants.CODE_403,"无权限!"); + } + +} diff --git a/src/main/java/com/rabbiter/em/utils/UserHolder.java b/src/main/java/com/rabbiter/em/utils/UserHolder.java new file mode 100644 index 0000000..49ceda1 --- /dev/null +++ b/src/main/java/com/rabbiter/em/utils/UserHolder.java @@ -0,0 +1,19 @@ +package com.rabbiter.em.utils; + +import com.rabbiter.em.entity.User; + +public class UserHolder { + private static final ThreadLocal userThreadLocal = new ThreadLocal<>(); + + public static void saveUser(User user){ + userThreadLocal.set(user); + } + + public static User getUser(){ + return userThreadLocal.get(); + } + + public static void removeUser(){ + userThreadLocal.remove(); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..37a0d80 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,27 @@ +server: + port: 9191 +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/electronic_mall?serverTimezone=GMT%2b8&userSSL=false&allowPublicKeyRetrieval=true + username: root + password: 'root' + servlet: + multipart: + max-file-size: 30MB + redis: + database: 0 + host: 127.0.0.1 + port: 6379 + lettuce: + pool: + min-idle: 0 + max-active: 8 + max-idle: 8 + max-wait: -1ms + connect-timeout: 30000ms + +mybatis: + mapper-locations: classpath:mapper/*.xml + configuration: + map-underscore-to-camel-case: true diff --git a/src/main/resources/mapper/Address.xml b/src/main/resources/mapper/Address.xml new file mode 100644 index 0000000..f166ed3 --- /dev/null +++ b/src/main/resources/mapper/Address.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/Carousel.xml b/src/main/resources/mapper/Carousel.xml new file mode 100644 index 0000000..3759c94 --- /dev/null +++ b/src/main/resources/mapper/Carousel.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/main/resources/mapper/Cart.xml b/src/main/resources/mapper/Cart.xml new file mode 100644 index 0000000..04ce155 --- /dev/null +++ b/src/main/resources/mapper/Cart.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/Category.xml b/src/main/resources/mapper/Category.xml new file mode 100644 index 0000000..5faa268 --- /dev/null +++ b/src/main/resources/mapper/Category.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/GoodMapper.xml b/src/main/resources/mapper/GoodMapper.xml new file mode 100644 index 0000000..4d422ea --- /dev/null +++ b/src/main/resources/mapper/GoodMapper.xml @@ -0,0 +1,15 @@ + + + + + insert into good(name, description, discount, category_id, imgs, create_time) value (#{good.name},#{good.description},#{good.discount},#{good.categoryId},#{good.imgs},#{good.createTime}) + + + update `good` set sales = sales + #{count} ,sale_money = sale_money + #{money} where good.id = #{id} + + + + + diff --git a/src/main/resources/mapper/Icon.xml b/src/main/resources/mapper/Icon.xml new file mode 100644 index 0000000..3f71392 --- /dev/null +++ b/src/main/resources/mapper/Icon.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/src/main/resources/mapper/Income.xml b/src/main/resources/mapper/Income.xml new file mode 100644 index 0000000..b0734bb --- /dev/null +++ b/src/main/resources/mapper/Income.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/src/main/resources/mapper/Order.xml b/src/main/resources/mapper/Order.xml new file mode 100644 index 0000000..16deec6 --- /dev/null +++ b/src/main/resources/mapper/Order.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/OrderGoods.xml b/src/main/resources/mapper/OrderGoods.xml new file mode 100644 index 0000000..5e4539d --- /dev/null +++ b/src/main/resources/mapper/OrderGoods.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/Standard.xml b/src/main/resources/mapper/Standard.xml new file mode 100644 index 0000000..be54355 --- /dev/null +++ b/src/main/resources/mapper/Standard.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/User.xml b/src/main/resources/mapper/User.xml new file mode 100644 index 0000000..011cdfa --- /dev/null +++ b/src/main/resources/mapper/User.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/target/classes/application.yml b/target/classes/application.yml new file mode 100644 index 0000000..37a0d80 --- /dev/null +++ b/target/classes/application.yml @@ -0,0 +1,27 @@ +server: + port: 9191 +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/electronic_mall?serverTimezone=GMT%2b8&userSSL=false&allowPublicKeyRetrieval=true + username: root + password: 'root' + servlet: + multipart: + max-file-size: 30MB + redis: + database: 0 + host: 127.0.0.1 + port: 6379 + lettuce: + pool: + min-idle: 0 + max-active: 8 + max-idle: 8 + max-wait: -1ms + connect-timeout: 30000ms + +mybatis: + mapper-locations: classpath:mapper/*.xml + configuration: + map-underscore-to-camel-case: true diff --git a/target/classes/com/rabbiter/em/ElectronicMallApplication.class b/target/classes/com/rabbiter/em/ElectronicMallApplication.class new file mode 100644 index 0000000..fb12e26 Binary files /dev/null and b/target/classes/com/rabbiter/em/ElectronicMallApplication.class differ diff --git a/target/classes/com/rabbiter/em/annotation/Authority.class b/target/classes/com/rabbiter/em/annotation/Authority.class new file mode 100644 index 0000000..274fff2 Binary files /dev/null and b/target/classes/com/rabbiter/em/annotation/Authority.class differ diff --git a/target/classes/com/rabbiter/em/common/Result.class b/target/classes/com/rabbiter/em/common/Result.class new file mode 100644 index 0000000..305f3e0 Binary files /dev/null and b/target/classes/com/rabbiter/em/common/Result.class differ diff --git a/target/classes/com/rabbiter/em/config/CorsConfig.class b/target/classes/com/rabbiter/em/config/CorsConfig.class new file mode 100644 index 0000000..7550553 Binary files /dev/null and b/target/classes/com/rabbiter/em/config/CorsConfig.class differ diff --git a/target/classes/com/rabbiter/em/config/GlobalExceptionHandler.class b/target/classes/com/rabbiter/em/config/GlobalExceptionHandler.class new file mode 100644 index 0000000..fc9231b Binary files /dev/null and b/target/classes/com/rabbiter/em/config/GlobalExceptionHandler.class differ diff --git a/target/classes/com/rabbiter/em/config/InterceptorConfig.class b/target/classes/com/rabbiter/em/config/InterceptorConfig.class new file mode 100644 index 0000000..237ed96 Binary files /dev/null and b/target/classes/com/rabbiter/em/config/InterceptorConfig.class differ diff --git a/target/classes/com/rabbiter/em/config/MybatisPlusConfig.class b/target/classes/com/rabbiter/em/config/MybatisPlusConfig.class new file mode 100644 index 0000000..0e18092 Binary files /dev/null and b/target/classes/com/rabbiter/em/config/MybatisPlusConfig.class differ diff --git a/target/classes/com/rabbiter/em/config/ProcessContextAware.class b/target/classes/com/rabbiter/em/config/ProcessContextAware.class new file mode 100644 index 0000000..a2542d2 Binary files /dev/null and b/target/classes/com/rabbiter/em/config/ProcessContextAware.class differ diff --git a/target/classes/com/rabbiter/em/config/RedisConfig.class b/target/classes/com/rabbiter/em/config/RedisConfig.class new file mode 100644 index 0000000..9903345 Binary files /dev/null and b/target/classes/com/rabbiter/em/config/RedisConfig.class differ diff --git a/target/classes/com/rabbiter/em/config/SwaggerConfig.class b/target/classes/com/rabbiter/em/config/SwaggerConfig.class new file mode 100644 index 0000000..443e5e1 Binary files /dev/null and b/target/classes/com/rabbiter/em/config/SwaggerConfig.class differ diff --git a/target/classes/com/rabbiter/em/constants/Constants.class b/target/classes/com/rabbiter/em/constants/Constants.class new file mode 100644 index 0000000..1aa3a6b Binary files /dev/null and b/target/classes/com/rabbiter/em/constants/Constants.class differ diff --git a/target/classes/com/rabbiter/em/constants/RedisConstants.class b/target/classes/com/rabbiter/em/constants/RedisConstants.class new file mode 100644 index 0000000..3d4d5d6 Binary files /dev/null and b/target/classes/com/rabbiter/em/constants/RedisConstants.class differ diff --git a/target/classes/com/rabbiter/em/controller/AddressController.class b/target/classes/com/rabbiter/em/controller/AddressController.class new file mode 100644 index 0000000..cea45db Binary files /dev/null and b/target/classes/com/rabbiter/em/controller/AddressController.class differ diff --git a/target/classes/com/rabbiter/em/controller/AvatarController.class b/target/classes/com/rabbiter/em/controller/AvatarController.class new file mode 100644 index 0000000..be942c7 Binary files /dev/null and b/target/classes/com/rabbiter/em/controller/AvatarController.class differ diff --git a/target/classes/com/rabbiter/em/controller/CarouselController.class b/target/classes/com/rabbiter/em/controller/CarouselController.class new file mode 100644 index 0000000..34482e5 Binary files /dev/null and b/target/classes/com/rabbiter/em/controller/CarouselController.class differ diff --git a/target/classes/com/rabbiter/em/controller/CartController.class b/target/classes/com/rabbiter/em/controller/CartController.class new file mode 100644 index 0000000..7fc5644 Binary files /dev/null and b/target/classes/com/rabbiter/em/controller/CartController.class differ diff --git a/target/classes/com/rabbiter/em/controller/CategoryController.class b/target/classes/com/rabbiter/em/controller/CategoryController.class new file mode 100644 index 0000000..721e8ae Binary files /dev/null and b/target/classes/com/rabbiter/em/controller/CategoryController.class differ diff --git a/target/classes/com/rabbiter/em/controller/FileController.class b/target/classes/com/rabbiter/em/controller/FileController.class new file mode 100644 index 0000000..8f8736d Binary files /dev/null and b/target/classes/com/rabbiter/em/controller/FileController.class differ diff --git a/target/classes/com/rabbiter/em/controller/GoodController.class b/target/classes/com/rabbiter/em/controller/GoodController.class new file mode 100644 index 0000000..c38e390 Binary files /dev/null and b/target/classes/com/rabbiter/em/controller/GoodController.class differ diff --git a/target/classes/com/rabbiter/em/controller/IconController.class b/target/classes/com/rabbiter/em/controller/IconController.class new file mode 100644 index 0000000..08262e7 Binary files /dev/null and b/target/classes/com/rabbiter/em/controller/IconController.class differ diff --git a/target/classes/com/rabbiter/em/controller/IncomeController.class b/target/classes/com/rabbiter/em/controller/IncomeController.class new file mode 100644 index 0000000..b30ac6f Binary files /dev/null and b/target/classes/com/rabbiter/em/controller/IncomeController.class differ diff --git a/target/classes/com/rabbiter/em/controller/OrderController.class b/target/classes/com/rabbiter/em/controller/OrderController.class new file mode 100644 index 0000000..3617402 Binary files /dev/null and b/target/classes/com/rabbiter/em/controller/OrderController.class differ diff --git a/target/classes/com/rabbiter/em/controller/RoleController.class b/target/classes/com/rabbiter/em/controller/RoleController.class new file mode 100644 index 0000000..d356b93 Binary files /dev/null and b/target/classes/com/rabbiter/em/controller/RoleController.class differ diff --git a/target/classes/com/rabbiter/em/controller/UserController.class b/target/classes/com/rabbiter/em/controller/UserController.class new file mode 100644 index 0000000..d493ad2 Binary files /dev/null and b/target/classes/com/rabbiter/em/controller/UserController.class differ diff --git a/target/classes/com/rabbiter/em/entity/Address.class b/target/classes/com/rabbiter/em/entity/Address.class new file mode 100644 index 0000000..dfcc908 Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/Address.class differ diff --git a/target/classes/com/rabbiter/em/entity/AuthorityType.class b/target/classes/com/rabbiter/em/entity/AuthorityType.class new file mode 100644 index 0000000..d26c905 Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/AuthorityType.class differ diff --git a/target/classes/com/rabbiter/em/entity/Avatar.class b/target/classes/com/rabbiter/em/entity/Avatar.class new file mode 100644 index 0000000..975fb40 Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/Avatar.class differ diff --git a/target/classes/com/rabbiter/em/entity/Carousel.class b/target/classes/com/rabbiter/em/entity/Carousel.class new file mode 100644 index 0000000..59f4e84 Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/Carousel.class differ diff --git a/target/classes/com/rabbiter/em/entity/Cart.class b/target/classes/com/rabbiter/em/entity/Cart.class new file mode 100644 index 0000000..bd3f8f7 Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/Cart.class differ diff --git a/target/classes/com/rabbiter/em/entity/Category.class b/target/classes/com/rabbiter/em/entity/Category.class new file mode 100644 index 0000000..bba2421 Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/Category.class differ diff --git a/target/classes/com/rabbiter/em/entity/Good.class b/target/classes/com/rabbiter/em/entity/Good.class new file mode 100644 index 0000000..6b991c5 Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/Good.class differ diff --git a/target/classes/com/rabbiter/em/entity/GoodStandard.class b/target/classes/com/rabbiter/em/entity/GoodStandard.class new file mode 100644 index 0000000..4ca4a95 Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/GoodStandard.class differ diff --git a/target/classes/com/rabbiter/em/entity/Icon.class b/target/classes/com/rabbiter/em/entity/Icon.class new file mode 100644 index 0000000..804de2f Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/Icon.class differ diff --git a/target/classes/com/rabbiter/em/entity/IconCategory.class b/target/classes/com/rabbiter/em/entity/IconCategory.class new file mode 100644 index 0000000..271789e Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/IconCategory.class differ diff --git a/target/classes/com/rabbiter/em/entity/LoginForm.class b/target/classes/com/rabbiter/em/entity/LoginForm.class new file mode 100644 index 0000000..526b9d5 Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/LoginForm.class differ diff --git a/target/classes/com/rabbiter/em/entity/MyFile.class b/target/classes/com/rabbiter/em/entity/MyFile.class new file mode 100644 index 0000000..31e0ccf Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/MyFile.class differ diff --git a/target/classes/com/rabbiter/em/entity/Order.class b/target/classes/com/rabbiter/em/entity/Order.class new file mode 100644 index 0000000..438217d Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/Order.class differ diff --git a/target/classes/com/rabbiter/em/entity/OrderGoods.class b/target/classes/com/rabbiter/em/entity/OrderGoods.class new file mode 100644 index 0000000..ae5b7af Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/OrderGoods.class differ diff --git a/target/classes/com/rabbiter/em/entity/OrderItem.class b/target/classes/com/rabbiter/em/entity/OrderItem.class new file mode 100644 index 0000000..f4ee7fd Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/OrderItem.class differ diff --git a/target/classes/com/rabbiter/em/entity/Standard.class b/target/classes/com/rabbiter/em/entity/Standard.class new file mode 100644 index 0000000..8b9d344 Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/Standard.class differ diff --git a/target/classes/com/rabbiter/em/entity/User.class b/target/classes/com/rabbiter/em/entity/User.class new file mode 100644 index 0000000..60c07f5 Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/User.class differ diff --git a/target/classes/com/rabbiter/em/entity/dto/GoodDTO.class b/target/classes/com/rabbiter/em/entity/dto/GoodDTO.class new file mode 100644 index 0000000..be8812c Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/dto/GoodDTO.class differ diff --git a/target/classes/com/rabbiter/em/entity/dto/UserDTO.class b/target/classes/com/rabbiter/em/entity/dto/UserDTO.class new file mode 100644 index 0000000..b9434bc Binary files /dev/null and b/target/classes/com/rabbiter/em/entity/dto/UserDTO.class differ diff --git a/target/classes/com/rabbiter/em/exception/GlobalExceptionHandler.class b/target/classes/com/rabbiter/em/exception/GlobalExceptionHandler.class new file mode 100644 index 0000000..0700310 Binary files /dev/null and b/target/classes/com/rabbiter/em/exception/GlobalExceptionHandler.class differ diff --git a/target/classes/com/rabbiter/em/exception/ServiceException.class b/target/classes/com/rabbiter/em/exception/ServiceException.class new file mode 100644 index 0000000..869bb43 Binary files /dev/null and b/target/classes/com/rabbiter/em/exception/ServiceException.class differ diff --git a/target/classes/com/rabbiter/em/interceptor/AuthorityInterceptor.class b/target/classes/com/rabbiter/em/interceptor/AuthorityInterceptor.class new file mode 100644 index 0000000..98bc2d3 Binary files /dev/null and b/target/classes/com/rabbiter/em/interceptor/AuthorityInterceptor.class differ diff --git a/target/classes/com/rabbiter/em/interceptor/JwtInterceptor.class b/target/classes/com/rabbiter/em/interceptor/JwtInterceptor.class new file mode 100644 index 0000000..4bc0706 Binary files /dev/null and b/target/classes/com/rabbiter/em/interceptor/JwtInterceptor.class differ diff --git a/target/classes/com/rabbiter/em/mapper/AddressMapper.class b/target/classes/com/rabbiter/em/mapper/AddressMapper.class new file mode 100644 index 0000000..9c99a35 Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/AddressMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/AvatarMapper.class b/target/classes/com/rabbiter/em/mapper/AvatarMapper.class new file mode 100644 index 0000000..815213f Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/AvatarMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/CarouselMapper.class b/target/classes/com/rabbiter/em/mapper/CarouselMapper.class new file mode 100644 index 0000000..f83d433 Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/CarouselMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/CartMapper.class b/target/classes/com/rabbiter/em/mapper/CartMapper.class new file mode 100644 index 0000000..d86df23 Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/CartMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/CategoryMapper.class b/target/classes/com/rabbiter/em/mapper/CategoryMapper.class new file mode 100644 index 0000000..2df05ef Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/CategoryMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/FileMapper.class b/target/classes/com/rabbiter/em/mapper/FileMapper.class new file mode 100644 index 0000000..707d9f1 Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/FileMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/GoodMapper.class b/target/classes/com/rabbiter/em/mapper/GoodMapper.class new file mode 100644 index 0000000..7f8833f Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/GoodMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/IconCategoryMapper.class b/target/classes/com/rabbiter/em/mapper/IconCategoryMapper.class new file mode 100644 index 0000000..fa4cafd Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/IconCategoryMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/IconMapper.class b/target/classes/com/rabbiter/em/mapper/IconMapper.class new file mode 100644 index 0000000..3499381 Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/IconMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/IncomeMapper.class b/target/classes/com/rabbiter/em/mapper/IncomeMapper.class new file mode 100644 index 0000000..10649f1 Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/IncomeMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/OrderGoodsMapper.class b/target/classes/com/rabbiter/em/mapper/OrderGoodsMapper.class new file mode 100644 index 0000000..a783084 Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/OrderGoodsMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/OrderMapper.class b/target/classes/com/rabbiter/em/mapper/OrderMapper.class new file mode 100644 index 0000000..5ddd477 Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/OrderMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/StandardMapper.class b/target/classes/com/rabbiter/em/mapper/StandardMapper.class new file mode 100644 index 0000000..54092fa Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/StandardMapper.class differ diff --git a/target/classes/com/rabbiter/em/mapper/UserMapper.class b/target/classes/com/rabbiter/em/mapper/UserMapper.class new file mode 100644 index 0000000..5b6781f Binary files /dev/null and b/target/classes/com/rabbiter/em/mapper/UserMapper.class differ diff --git a/target/classes/com/rabbiter/em/service/AddressService.class b/target/classes/com/rabbiter/em/service/AddressService.class new file mode 100644 index 0000000..c5363a7 Binary files /dev/null and b/target/classes/com/rabbiter/em/service/AddressService.class differ diff --git a/target/classes/com/rabbiter/em/service/AvatarService.class b/target/classes/com/rabbiter/em/service/AvatarService.class new file mode 100644 index 0000000..3762db9 Binary files /dev/null and b/target/classes/com/rabbiter/em/service/AvatarService.class differ diff --git a/target/classes/com/rabbiter/em/service/CarouselService.class b/target/classes/com/rabbiter/em/service/CarouselService.class new file mode 100644 index 0000000..c0af0be Binary files /dev/null and b/target/classes/com/rabbiter/em/service/CarouselService.class differ diff --git a/target/classes/com/rabbiter/em/service/CartService.class b/target/classes/com/rabbiter/em/service/CartService.class new file mode 100644 index 0000000..84ea27f Binary files /dev/null and b/target/classes/com/rabbiter/em/service/CartService.class differ diff --git a/target/classes/com/rabbiter/em/service/CategoryService.class b/target/classes/com/rabbiter/em/service/CategoryService.class new file mode 100644 index 0000000..0fcdc5e Binary files /dev/null and b/target/classes/com/rabbiter/em/service/CategoryService.class differ diff --git a/target/classes/com/rabbiter/em/service/FileService.class b/target/classes/com/rabbiter/em/service/FileService.class new file mode 100644 index 0000000..4bc9d20 Binary files /dev/null and b/target/classes/com/rabbiter/em/service/FileService.class differ diff --git a/target/classes/com/rabbiter/em/service/GoodService.class b/target/classes/com/rabbiter/em/service/GoodService.class new file mode 100644 index 0000000..a4ceb7e Binary files /dev/null and b/target/classes/com/rabbiter/em/service/GoodService.class differ diff --git a/target/classes/com/rabbiter/em/service/IconService.class b/target/classes/com/rabbiter/em/service/IconService.class new file mode 100644 index 0000000..0c5ef3d Binary files /dev/null and b/target/classes/com/rabbiter/em/service/IconService.class differ diff --git a/target/classes/com/rabbiter/em/service/IncomeService.class b/target/classes/com/rabbiter/em/service/IncomeService.class new file mode 100644 index 0000000..dd92ae2 Binary files /dev/null and b/target/classes/com/rabbiter/em/service/IncomeService.class differ diff --git a/target/classes/com/rabbiter/em/service/OrderGoodsService.class b/target/classes/com/rabbiter/em/service/OrderGoodsService.class new file mode 100644 index 0000000..73d7ae4 Binary files /dev/null and b/target/classes/com/rabbiter/em/service/OrderGoodsService.class differ diff --git a/target/classes/com/rabbiter/em/service/OrderService.class b/target/classes/com/rabbiter/em/service/OrderService.class new file mode 100644 index 0000000..8da2642 Binary files /dev/null and b/target/classes/com/rabbiter/em/service/OrderService.class differ diff --git a/target/classes/com/rabbiter/em/service/StandardService.class b/target/classes/com/rabbiter/em/service/StandardService.class new file mode 100644 index 0000000..f13efe6 Binary files /dev/null and b/target/classes/com/rabbiter/em/service/StandardService.class differ diff --git a/target/classes/com/rabbiter/em/service/UserService.class b/target/classes/com/rabbiter/em/service/UserService.class new file mode 100644 index 0000000..3a9f85a Binary files /dev/null and b/target/classes/com/rabbiter/em/service/UserService.class differ diff --git a/target/classes/com/rabbiter/em/utils/BaseApi.class b/target/classes/com/rabbiter/em/utils/BaseApi.class new file mode 100644 index 0000000..b9910b0 Binary files /dev/null and b/target/classes/com/rabbiter/em/utils/BaseApi.class differ diff --git a/target/classes/com/rabbiter/em/utils/PathUtils.class b/target/classes/com/rabbiter/em/utils/PathUtils.class new file mode 100644 index 0000000..f35ad5d Binary files /dev/null and b/target/classes/com/rabbiter/em/utils/PathUtils.class differ diff --git a/target/classes/com/rabbiter/em/utils/TokenUtils.class b/target/classes/com/rabbiter/em/utils/TokenUtils.class new file mode 100644 index 0000000..bcb8ef6 Binary files /dev/null and b/target/classes/com/rabbiter/em/utils/TokenUtils.class differ diff --git a/target/classes/com/rabbiter/em/utils/UserHolder.class b/target/classes/com/rabbiter/em/utils/UserHolder.class new file mode 100644 index 0000000..2a41f29 Binary files /dev/null and b/target/classes/com/rabbiter/em/utils/UserHolder.class differ diff --git a/target/classes/mapper/Address.xml b/target/classes/mapper/Address.xml new file mode 100644 index 0000000..f166ed3 --- /dev/null +++ b/target/classes/mapper/Address.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/target/classes/mapper/Carousel.xml b/target/classes/mapper/Carousel.xml new file mode 100644 index 0000000..3759c94 --- /dev/null +++ b/target/classes/mapper/Carousel.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/target/classes/mapper/Cart.xml b/target/classes/mapper/Cart.xml new file mode 100644 index 0000000..04ce155 --- /dev/null +++ b/target/classes/mapper/Cart.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + diff --git a/target/classes/mapper/Category.xml b/target/classes/mapper/Category.xml new file mode 100644 index 0000000..5faa268 --- /dev/null +++ b/target/classes/mapper/Category.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/target/classes/mapper/GoodMapper.xml b/target/classes/mapper/GoodMapper.xml new file mode 100644 index 0000000..4d422ea --- /dev/null +++ b/target/classes/mapper/GoodMapper.xml @@ -0,0 +1,15 @@ + + + + + insert into good(name, description, discount, category_id, imgs, create_time) value (#{good.name},#{good.description},#{good.discount},#{good.categoryId},#{good.imgs},#{good.createTime}) + + + update `good` set sales = sales + #{count} ,sale_money = sale_money + #{money} where good.id = #{id} + + + + + diff --git a/target/classes/mapper/Icon.xml b/target/classes/mapper/Icon.xml new file mode 100644 index 0000000..3f71392 --- /dev/null +++ b/target/classes/mapper/Icon.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/target/classes/mapper/Income.xml b/target/classes/mapper/Income.xml new file mode 100644 index 0000000..b0734bb --- /dev/null +++ b/target/classes/mapper/Income.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/target/classes/mapper/Order.xml b/target/classes/mapper/Order.xml new file mode 100644 index 0000000..16deec6 --- /dev/null +++ b/target/classes/mapper/Order.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + diff --git a/target/classes/mapper/OrderGoods.xml b/target/classes/mapper/OrderGoods.xml new file mode 100644 index 0000000..5e4539d --- /dev/null +++ b/target/classes/mapper/OrderGoods.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/target/classes/mapper/Standard.xml b/target/classes/mapper/Standard.xml new file mode 100644 index 0000000..be54355 --- /dev/null +++ b/target/classes/mapper/Standard.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/target/classes/mapper/User.xml b/target/classes/mapper/User.xml new file mode 100644 index 0000000..011cdfa --- /dev/null +++ b/target/classes/mapper/User.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +