mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-23 05:00:25 +08:00
refactor: 品牌分类重构
This commit is contained in:
parent
9f19a13363
commit
6e8d069ec7
@ -78,17 +78,17 @@ INSERT INTO `pms_category_attribute` VALUES (35, 5, '规格', 1, '2021-07-11 18:
|
||||
INSERT INTO `pms_category_attribute` VALUES (36, 5, '上市时间', 2, '2021-07-11 18:00:08', '2022-06-01 17:41:05');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pms_category_brand
|
||||
-- Table structure for pms_brand_category
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `pms_category_brand`;
|
||||
CREATE TABLE `pms_category_brand` (
|
||||
DROP TABLE IF EXISTS `pms_brand_category`;
|
||||
CREATE TABLE `pms_brand_category` (
|
||||
`category_id` bigint NOT NULL,
|
||||
`brand_id` bigint NOT NULL,
|
||||
PRIMARY KEY (`category_id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of pms_category_brand
|
||||
-- Records of pms_brand_category
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
|
@ -1,6 +1,18 @@
|
||||
/*
|
||||
Navicat Premium Data Transfer
|
||||
|
||||
use youlai_mall_pms;
|
||||
Source Server : localhost
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80027
|
||||
Source Host : 192.168.10.192:3306
|
||||
Source Schema : youlai_mall_pms
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80027
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 07/05/2024 22:27:58
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
@ -70,6 +82,23 @@ INSERT INTO `pms_brand` VALUES (11, '华硕', 'http://a.youlai.tech:9000/default
|
||||
INSERT INTO `pms_brand` VALUES (20, '华为', 'https://oss.youlai.tech/default/ff61bd639b23491d8f2aa85d09fcf788.jpg', 1, '2022-05-06 23:08:33', '2022-05-06 23:08:33', 0);
|
||||
INSERT INTO `pms_brand` VALUES (33, '惠普', 'https://oss.youlai.tech/default/4cf579add9544c6eaafb41ce1131559e.gif', 1, '2022-07-07 00:12:16', '2022-07-07 00:12:16', 0);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pms_brand_category
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `pms_brand_category`;
|
||||
CREATE TABLE `pms_brand_category` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`brand_id` bigint NOT NULL COMMENT '品牌ID',
|
||||
`category_id` bigint NOT NULL COMMENT '分类ID',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`create_by` bigint NULL DEFAULT NULL COMMENT '创建人ID',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '品牌分类关联' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of pms_brand_category
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pms_category
|
||||
-- ----------------------------
|
||||
@ -99,21 +128,6 @@ INSERT INTO `pms_category` VALUES (99, '三星轻薄本', 97, 'https://oss.youla
|
||||
INSERT INTO `pms_category` VALUES (100, '全能本', 97, 'https://oss.youlai.tech/default/37cc080ec61b4ce7b0583b002568ebaa.png', 100, 1, '2022-07-08 00:14:10', '2022-07-08 00:27:01', 0);
|
||||
INSERT INTO `pms_category` VALUES (101, '游戏本', 97, 'https://oss.youlai.tech/default/5c1a2d5427534b48bc382caa55197f11.png', 100, 1, '2022-07-08 00:14:18', '2022-07-08 00:27:11', 0);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pms_category_brand
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `pms_category_brand`;
|
||||
CREATE TABLE `pms_category_brand` (
|
||||
`id` bigint NOT NULL,
|
||||
`category_id` bigint NOT NULL,
|
||||
`brand_id` bigint NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of pms_category_brand
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pms_sku
|
||||
-- ----------------------------
|
||||
@ -137,23 +151,10 @@ CREATE TABLE `pms_sku` (
|
||||
-- ----------------------------
|
||||
-- Records of pms_sku
|
||||
-- ----------------------------
|
||||
INSERT INTO `pms_sku` VALUES (1, 'sn001', 1, '黑 6+128g', 399900, 990, 150, 'https://www.youlai.tech/files/default/c25b39470474494485633c49101a0f5d.png', '2021-08-08 00:43:26', '2022-07-03 14:16:16', 0);
|
||||
INSERT INTO `pms_sku` VALUES (1, 'sn001', 288, '绿色', 699900, 100, 150, 'https://www.youlai.tech/files/default/c25b39470474494485633c49101a0f5d.png', '2021-08-08 00:43:26', '2024-05-07 17:35:42', 0);
|
||||
INSERT INTO `pms_sku` VALUES (2, 'sn002', 1, '黑 8+256g', 499900, 999, 0, 'https://www.youlai.tech/files/default/c25b39470474494485633c49101a0f5d.png', '2021-08-08 00:43:26', '2022-07-03 14:16:16', 0);
|
||||
INSERT INTO `pms_sku` VALUES (3, 'sn003', 1, '蓝 6+128g', 399900, 999, 0, 'https://www.youlai.tech/files/default/835d73a337964b9b97e5c7c90acc8cb2.png', '2022-03-05 09:25:53', '2022-07-03 14:16:16', 0);
|
||||
INSERT INTO `pms_sku` VALUES (4, 'sn004', 1, '蓝 8+256g', 499900, 999, 0, 'https://www.youlai.tech/files/default/835d73a337964b9b97e5c7c90acc8cb2.png', '2022-03-05 09:25:53', '2022-07-03 14:16:16', 0);
|
||||
INSERT INTO `pms_sku` VALUES (5, '10000001', 2, '魔幻青 RTX3060/i7-12700H/165Hz 2.5K屏', 1025000, 998, 0, 'http://a.youlai.tech:9000/default/8815c9a46fcc4b1ea952623406750da5.jpg', '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_sku` VALUES (6, '10000002', 2, '魔幻青 RTX3050tTi/12代i5/144Hz高色域屏', 925000, 999, 0, 'http://a.youlai.tech:9000/default/8815c9a46fcc4b1ea952623406750da5.jpg', '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_sku` VALUES (7, '10000003', 2, '日蚀灰 RTX3060/i7-12700H/165Hz 2.5K屏', 1025000, 999, 0, 'http://a.youlai.tech:9000/default/3210cd1ffb6c4346b743a10855d3cb37.jpg', '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_sku` VALUES (8, '10000004', 2, '日蚀灰 RTX3050tTi/12代i5/144Hz高色域屏', 925000, 999, 0, 'http://a.youlai.tech:9000/default/3210cd1ffb6c4346b743a10855d3cb37.jpg', '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_sku` VALUES (9, '111', 3, '16g 512g 【2022款】锐龙六核R5-6600U/核芯显卡/100%sRGB高色域', 589900, 992, 1, 'https://oss.youlai.tech/youlai-boot/2023/06/08/78b8efecb753426f81e5dcfcd175495f.jpg', '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_sku` VALUES (10, '112', 3, '16g 512g 【2022款】锐龙八核R7-6800U/核芯显卡/100%sRGB高色域', 629900, 999, 0, 'https://oss.youlai.tech/youlai-boot/2023/06/08/93cbc9dc6fe144f5a59793a6248479a0.jpg', '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_sku` VALUES (11, '113', 3, '16g 1t 【2022款】锐龙六核R5-6600U/核芯显卡/100%sRGB高色域', 639900, 999, 0, 'https://oss.youlai.tech/youlai-boot/2023/06/08/78b8efecb753426f81e5dcfcd175495f.jpg', '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_sku` VALUES (12, '114', 3, '16g 1t 【2022款】锐龙八核R7-6800U/核芯显卡/100%sRGB高色域', 639900, 999, 0, 'https://oss.youlai.tech/youlai-boot/2023/06/08/93cbc9dc6fe144f5a59793a6248479a0.jpg', '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_sku` VALUES (13, '115', 3, '32g 512g 【2022款】锐龙六核R5-6600U/核芯显卡/100%sRGB高色域', 589900, 999, 0, 'https://oss.youlai.tech/youlai-boot/2023/06/08/78b8efecb753426f81e5dcfcd175495f.jpg', '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_sku` VALUES (14, '116', 3, '32g 512g 【2022款】锐龙八核R7-6800U/核芯显卡/100%sRGB高色域', 629900, 999, 0, 'https://oss.youlai.tech/youlai-boot/2023/06/08/93cbc9dc6fe144f5a59793a6248479a0.jpg', '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_sku` VALUES (15, '117', 3, '32g 1t 【2022款】锐龙六核R5-6600U/核芯显卡/100%sRGB高色域', 639900, 999, 0, 'https://oss.youlai.tech/youlai-boot/2023/06/08/78b8efecb753426f81e5dcfcd175495f.jpg', '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_sku` VALUES (16, '118', 3, '32g 1t 【2022款】锐龙八核R7-6800U/核芯显卡/100%sRGB高色域', 639900, 999, 0, 'https://oss.youlai.tech/youlai-boot/2023/06/08/93cbc9dc6fe144f5a59793a6248479a0.jpg', '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_sku` VALUES (17, 'sn001', 4, '黑 6+128g', 399900, 999, 0, 'https://oss.youlai.tech/youlai-boot/2023/06/08/6b83dd33eaa248ed8e11cff0003287ee.jpg', '2021-08-08 00:43:26', '2022-07-03 14:16:16', 0);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pms_sku_spec_value
|
||||
@ -172,6 +173,7 @@ CREATE TABLE `pms_sku_spec_value` (
|
||||
-- ----------------------------
|
||||
-- Records of pms_sku_spec_value
|
||||
-- ----------------------------
|
||||
INSERT INTO `pms_sku_spec_value` VALUES (1, 1, 1, '颜色', '黑色', 1);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pms_spu
|
||||
@ -186,7 +188,6 @@ CREATE TABLE `pms_spu` (
|
||||
`img_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品主图',
|
||||
`unit` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单位',
|
||||
`description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品简介',
|
||||
`detail` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '商品详情',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`is_deleted` tinyint NULL DEFAULT NULL COMMENT '逻辑删除标识:0-未删除,1-已删除',
|
||||
@ -198,10 +199,8 @@ CREATE TABLE `pms_spu` (
|
||||
-- ----------------------------
|
||||
-- Records of pms_spu
|
||||
-- ----------------------------
|
||||
INSERT INTO `pms_spu` VALUES (1, 'Galaxy Z Fold5', 1, 5, 10, 'https://shop-image.samsung.com.cn/productv5/img/2023/07/26/64c0e30fe4b08db29258c50c.png', '台', '好快,好稳,\n好一次强上加强。\n高通全新一代芯片赋能,速度大幅提升。\n三大专业主摄影像加持,能力全面进化。\n大师级设计理念新诠释,质感简而不凡。\n斩获十五项纪录旗舰屏,感官万般出众。', '<p><img src=\"https://shop-image.samsung.com.cn/productv5/img/2023/11/03/65449d3ee4b08db20823bcbe.jpg\" alt=\"\" data-href=\"\" style=\"width: 449.00px;height: 449.00px;\"/></p>', NULL, '2022-07-03 14:16:16', 0);
|
||||
INSERT INTO `pms_spu` VALUES (2, '华硕天选3', 1, 101, 11, 'https://www.youlai.tech/files/default/d97457b3fd7d4aef8846da96fe032bf8.jpg', NULL, '中国台湾华硕电脑股份有限公司 [1] 是当前全球第一大主板生产商、全球第三大显卡生产商,同时也是全球领先的3C解决方案提供商之一,致力于为个人和企业用户提供最具创新价值的产品及应用方案。华硕的产品线完整覆盖至笔记本电脑、主板、显卡、服务器、光存储、有线/无线网络通讯产品、LCD、掌上电脑、智能手机等全线3C产品。其中显卡和主板以及笔记本电脑三大产品已经成为华硕的主要竞争实力。', '<p><img src=\"http://a.youlai.tech:9000/default/5e4fb81b04244a74aacaabb4685101e2.png\" alt=\"\" data-href=\"\" style=\"\"/><img src=\"http://a.youlai.tech:9000/default/0744c5b6d77b47b294eb111ee992c62b.png\" alt=\"\" data-href=\"\" style=\"\"/></p>', '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_spu` VALUES (3, '惠普战X ', 1, 99, 33, 'https://oss.youlai.tech/default/e59859e0effb4b66a0f7380ff5369d66.jpg', NULL, '【2022新款】HP/惠普战X 16英寸锐龙新款6000系列R5六核/R7八核高性能学生家用轻薄办公商用笔记本电脑\n六核/八核处理器,高性能集成显卡', '<p><img src=\"https://oss.youlai.tech/default/d645a6f642794e2183cc44d340613b9d.jpg\" alt=\"\" data-href=\"\" style=\"\"/></p>', '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_spu` VALUES (4, '小米13', 1, 5, 10, 'https://oss.youlai.tech/youlai-boot/2023/06/08/6b83dd33eaa248ed8e11cff0003287ee.jpg', '台', '好快,好稳,\n好一次强上加强。\n高通全新一代芯片赋能,速度大幅提升。\n三大专业主摄影像加持,能力全面进化。\n大师级设计理念新诠释,质感简而不凡。\n斩获十五项纪录旗舰屏,感官万般出众。', '<p><img src=\"http://a.youlai.tech:9000/default/1a69357664c24962ac23953905c3c38f.png\" alt=\"\" data-href=\"\" style=\"width: 449.00px;height: 449.00px;\"/></p>', NULL, '2022-07-03 14:16:16', 0);
|
||||
INSERT INTO `pms_spu` VALUES (1, '小米13', 1, 5, 10, 'https://oss.youlai.tech/youlai-boot/2023/06/08/6b83dd33eaa248ed8e11cff0003287ee.jpg', '台', '好快,好稳,\n好一次强上加强。\n高通全新一代芯片赋能,速度大幅提升。\n三大专业主摄影像加持,能力全面进化。\n大师级设计理念新诠释,质感简而不凡。\n斩获十五项纪录旗舰屏,感官万般出众。', NULL, '2022-07-03 14:16:16', 0);
|
||||
INSERT INTO `pms_spu` VALUES (288, 'Apple iPhone 12', 1, 1, 1, 'https://youlai-mall.oss-cn-shenzhen.aliyuncs.com/images/2021/04/23/1619163660000.jpg', NULL, 'Apple iPhone 12 64GB 绿色', '2024-05-07 17:35:42', '2024-05-07 17:35:42', NULL);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pms_spu_attribute_value
|
||||
@ -220,34 +219,31 @@ CREATE TABLE `pms_spu_attribute_value` (
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `fk_pms_spu_attribute_pms_attr`(`attr_name`) USING BTREE,
|
||||
INDEX `fk_pms_spu_attribute_pms_spu`(`spu_id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 847 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '商品属性/规格表' ROW_FORMAT = DYNAMIC;
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '商品属性/规格表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of pms_spu_attribute_value
|
||||
-- ----------------------------
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (1, 1, NULL, '颜色', '黑', 1, NULL, '2022-07-03 14:16:16', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (3, 1, NULL, '规格', '6+128g', 1, NULL, '2022-07-03 14:16:16', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (4, 1, NULL, '规格', '8+256g', 1, NULL, '2022-07-03 14:16:16', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (5, 1, NULL, '上市时间', '2021-07-17', 1, NULL, '2022-07-03 14:16:16', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (216, 1, NULL, '颜色', '蓝', 1, '2022-03-05 09:25:53', '2022-07-03 14:16:16', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (251, 2, NULL, '上市时间', '2022/3/11', 1, '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (252, 2, NULL, '商品名称', '华硕天选3', 1, '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (253, 2, NULL, '商品编号', '100032610338', 1, '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (254, 2, NULL, '商品毛重', '4.05kg', 1, '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (255, 2, NULL, '系统', 'windows11', 1, '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (256, 2, NULL, '颜色', '魔幻青', 1, '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (257, 2, NULL, '颜色', '日蚀灰', 1, '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (258, 2, NULL, '规格', 'RTX3060/i7-12700H/165Hz 2.5K屏', 1, '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (259, 2, NULL, '规格', 'RTX3050tTi/12代i5/144Hz高色域屏', 1, '2022-03-11 14:39:21', '2022-07-08 00:29:56', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (838, 3, NULL, '内存', '16g 32g', 1, '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (839, 3, NULL, '重量', '1.5kg(含)-2kg(不含)', 1, '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (840, 3, NULL, '显卡类型', '核芯显卡', 1, '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (841, 3, NULL, '内存容量', '16g', 1, '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (842, 3, NULL, '内存容量', '32g', 1, '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (843, 3, NULL, '硬盘容量', '512g', 1, '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (844, 3, NULL, '硬盘容量', '1t', 1, '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (845, 3, NULL, '套餐类型', '【2022款】锐龙六核R5-6600U/核芯显卡/100%sRGB高色域', 1, '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (846, 3, NULL, '套餐类型', '【2022款】锐龙八核R7-6800U/核芯显卡/100%sRGB高色域', 1, '2022-07-07 00:22:13', '2022-07-08 00:29:41', 0);
|
||||
INSERT INTO `pms_spu_attribute_value` VALUES (1, 288, NULL, '上市时间', '2021-07-17', 1, '2024-05-07 14:16:16', '2024-05-07 17:35:42', 0);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pms_spu_detail
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `pms_spu_detail`;
|
||||
CREATE TABLE `pms_spu_detail` (
|
||||
`id` bigint NOT NULL COMMENT '主键',
|
||||
`spu_id` bigint NOT NULL COMMENT 'SPU ID',
|
||||
`detail` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '详情',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`is_deleted` tinyint NULL DEFAULT NULL COMMENT '逻辑删除[0-未删除,1-已删除]',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商品详情' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of pms_spu_detail
|
||||
-- ----------------------------
|
||||
INSERT INTO `pms_spu_detail` VALUES (1, 1, '<p><img src=\"http://a.youlai.tech:9000/default/1a69357664c24962ac23953905c3c38f.png\" alt=\"\" data-href=\"\" style=\"width: 449.00px;height: 449.00px;\"/></p>', '2024-05-07 16:18:35', '2024-05-07 16:18:39', NULL);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pms_spu_image
|
||||
@ -267,6 +263,7 @@ CREATE TABLE `pms_spu_image` (
|
||||
-- ----------------------------
|
||||
-- Records of pms_spu_image
|
||||
-- ----------------------------
|
||||
INSERT INTO `pms_spu_image` VALUES (1, 288, 'https://youlai-mall.oss-cn-shenzhen.aliyuncs.com/images/2021/04/23/1619163660000.jpg', 1, '2024-05-07 17:35:42', '2024-05-07 17:35:42', 0);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for undo_log
|
||||
|
@ -6,8 +6,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.youlai.common.result.PageResult;
|
||||
import com.youlai.common.result.Result;
|
||||
import com.youlai.mall.product.model.entity.Brand;
|
||||
import com.youlai.mall.product.model.query.BrandCategoryQuery;
|
||||
import com.youlai.mall.product.model.query.BrandPageQuery;
|
||||
import com.youlai.mall.product.model.vo.BrandCategoryVO;
|
||||
import com.youlai.mall.product.service.BrandCategoryService;
|
||||
import com.youlai.mall.product.service.BrandService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -22,7 +24,7 @@ import java.util.List;
|
||||
* 品牌前端控制器
|
||||
*
|
||||
* @author Ray Hao
|
||||
* @since 2022/7/2
|
||||
* @since 2024/5/7
|
||||
*/
|
||||
@Tag(name = "Admin-品牌接口")
|
||||
@RestController
|
||||
@ -32,6 +34,8 @@ public class BrandController {
|
||||
|
||||
private final BrandService brandService;
|
||||
|
||||
private final BrandCategoryService brandCategoryService;
|
||||
|
||||
@Operation(summary = "品牌分页列表")
|
||||
@GetMapping("/page")
|
||||
public PageResult listPagedBrands(BrandPageQuery queryParams) {
|
||||
@ -88,13 +92,20 @@ public class BrandController {
|
||||
return Result.judge(status);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "品牌分类列表")
|
||||
@GetMapping("/{brandId}/categories")
|
||||
public Result<List<BrandCategoryVO>> listBrandCategories(@PathVariable Long brandId) {
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
@Operation(summary = "获取品牌分类关联列表")
|
||||
@GetMapping("/{brandId}/brand-categories")
|
||||
public Result<List<BrandCategoryVO>> listBrandCategories(BrandCategoryQuery queryParams) {
|
||||
List<BrandCategoryVO> list = brandCategoryService.listBrandCategories(queryParams);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "保存品牌分类关联")
|
||||
@PostMapping("/{brandId}/brand-categories")
|
||||
public Result saveBrandCategories(
|
||||
@Parameter(description = "品牌ID") @PathVariable Long brandId,
|
||||
@RequestBody List<Long> categoryIds) {
|
||||
brandCategoryService.saveBrandCategories(brandId, categoryIds);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.youlai.mall.product.converter;
|
||||
|
||||
import com.youlai.mall.product.model.entity.BrandCategory;
|
||||
import com.youlai.mall.product.model.form.BrandCategoryForm;
|
||||
import com.youlai.mall.product.model.vo.BrandCategoryVO;
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 品牌分类关联转换器
|
||||
*
|
||||
* @author Ray Hao
|
||||
* @since 2024-05-06
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface BrandCategoryConverter {
|
||||
|
||||
List<BrandCategoryVO> entity2Vo(List<BrandCategory> list);
|
||||
|
||||
BrandCategoryForm entity2Form(BrandCategory entity);
|
||||
|
||||
@InheritInverseConfiguration(name = "entity2Form")
|
||||
BrandCategory form2Entity(BrandCategoryForm entity);
|
||||
|
||||
}
|
@ -21,5 +21,6 @@ public interface SkuSpecValueConverter{
|
||||
|
||||
@InheritInverseConfiguration(name = "entity2Form")
|
||||
SkuSpecValue form2Entity(SkuSpecValueForm entity);
|
||||
SkuSpecValue convertToEntity(SpuForm.Attribute spec);
|
||||
|
||||
SkuSpecValue convertToEntity(SpuForm.AttributeValue spec);
|
||||
}
|
@ -16,7 +16,7 @@ import java.util.List;
|
||||
public interface SpuAttributeConverter {
|
||||
|
||||
|
||||
SpuAttributeValue formAttribute2Entity(SpuForm.Attribute formAttribute);
|
||||
SpuAttributeValue formAttribute2Entity(SpuForm.AttributeValue formAttribute);
|
||||
|
||||
List<SpuAttributeValue> formAttribute2Entity(List<SpuForm.Attribute> formAttribute);
|
||||
List<SpuAttributeValue> formAttribute2Entity(List<SpuForm.AttributeValue> formAttribute);
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.youlai.mall.product.mapper;
|
||||
|
||||
import com.youlai.mall.product.model.entity.BrandCategory;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 品牌分类关联 Mapper 接口
|
||||
*
|
||||
* @author Ray Hao
|
||||
* @since 2024-05-06
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
public interface BrandCategoryMapper extends BaseMapper<BrandCategory> {
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package com.youlai.mall.product.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.youlai.mall.product.model.entity.CategoryBrand;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CategoryBrandMapper extends BaseMapper<CategoryBrand> {
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.youlai.mall.product.model.dto;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
/**
|
||||
* 品牌分类关联 DTO
|
||||
*
|
||||
* @author Ray Hao
|
||||
* @since 2024-05-06
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema( description = "品牌分类关联传输层对象")
|
||||
public class BrandCategoryDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键")
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "分类ID")
|
||||
|
||||
private Long categoryId;
|
||||
|
||||
@Schema(description = "品牌ID")
|
||||
|
||||
private Long brandId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "创建人ID")
|
||||
|
||||
private Long createBy;
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.youlai.mall.product.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 品牌分类关联实体
|
||||
*
|
||||
* @author Ray Hao
|
||||
* @since 2024-05-06
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("pms_brand_category")
|
||||
public class BrandCategory implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 分类ID
|
||||
*/
|
||||
private Long categoryId;
|
||||
|
||||
/**
|
||||
* 品牌ID
|
||||
*/
|
||||
private Long brandId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package com.youlai.mall.product.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 分类品牌
|
||||
*
|
||||
* @author haoxr
|
||||
* @since 2022/7/2
|
||||
*/
|
||||
@TableName("pms_category_brand")
|
||||
@Data
|
||||
public class CategoryBrand {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 分类ID
|
||||
*/
|
||||
private Long categoryId;
|
||||
|
||||
/**
|
||||
* 品牌ID
|
||||
*/
|
||||
private Long brandId;
|
||||
|
||||
}
|
@ -46,11 +46,6 @@ public class Spu extends BaseEntity {
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 商品详情
|
||||
*/
|
||||
private String detail;
|
||||
|
||||
/**
|
||||
* 商品状态:1-上架,0-下架
|
||||
*/
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.youlai.mall.product.model.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 品牌分类关联 表单对象
|
||||
*
|
||||
* @author Ray Hao
|
||||
* @since 2024-05-06
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "品牌分类关联表单对象")
|
||||
public class BrandCategoryForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "品牌ID")
|
||||
@NotNull(message = "品牌ID不能为空")
|
||||
private Long brandId;
|
||||
|
||||
|
||||
@Schema(description = "分类ID")
|
||||
@NotNull(message = "分类ID不能为空")
|
||||
private Long categoryId;
|
||||
|
||||
|
||||
}
|
@ -19,32 +19,35 @@ public class SpuForm {
|
||||
@Schema(description = "商品ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "商品名称")
|
||||
@Schema(description = "商品名称",example = "Apple iPhone 12")
|
||||
@NotBlank(message = "商品名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "分类ID")
|
||||
@Schema(description = "分类ID",example = "1")
|
||||
private Long categoryId;
|
||||
|
||||
@Schema(description = "品牌ID")
|
||||
@Schema(description = "品牌ID",example = "1")
|
||||
private Long brandId;
|
||||
|
||||
@Schema(description = "商品主图URL")
|
||||
@Schema(description = "商品主图URL",example = "https://youlai-mall.oss-cn-shenzhen.aliyuncs.com/images/2021/04/23/1619163660000.jpg")
|
||||
private String imgUrl;
|
||||
|
||||
@Schema(description = "商品图册(详情页轮播图)")
|
||||
private List<Image> galleryImageList;
|
||||
@Schema(description = "商品图册(详情页轮播图)",example = "[{\"imgUrl\":\"https://youlai-mall.oss-cn-shenzhen.aliyuncs.com/images/2021/04/23/1619163660000.jpg\",\"sort\":1}]")
|
||||
private List<Image> imgList;
|
||||
|
||||
@Schema(description = "商品描述")
|
||||
@Schema(description = "商品单位",example = "台")
|
||||
private String unit;
|
||||
|
||||
@Schema(description = "商品描述",example = "Apple iPhone 12 64GB 绿色")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "商品详情")
|
||||
@Schema(description = "商品详情",example = "<p>Apple iPhone 12 64GB 绿色</p>")
|
||||
private String detail;
|
||||
|
||||
@Schema(description = "商品参数列表")
|
||||
private List<Attribute> attributeList;
|
||||
@Schema(description = "商品参数列表",example = "[{\"id\":1,\"name\":\"颜色\",\"value\":\"绿色\",\"sort\":1}]")
|
||||
private List<AttributeValue> attributeList;
|
||||
|
||||
@Schema(description = "SKU列表")
|
||||
@Schema(description = "SKU列表",example = "[{\"id\":1,\"name\":\"绿色\",\"price\":699900,\"stock\":100,\"specList\":[{\"id\":1,\"name\":\"颜色\",\"value\":\"绿色\",\"sort\":1}]}]")
|
||||
private List<Sku> skuList;
|
||||
|
||||
@Schema(description = "商品图片")
|
||||
@ -64,7 +67,7 @@ public class SpuForm {
|
||||
|
||||
@Schema(description = "属性")
|
||||
@Data
|
||||
public static class Attribute {
|
||||
public static class AttributeValue {
|
||||
|
||||
@Schema(description = "属性ID")
|
||||
private Long id;
|
||||
@ -96,8 +99,8 @@ public class SpuForm {
|
||||
@Schema(description = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@Schema(description = "规格列表")
|
||||
private List<Attribute> specList;
|
||||
@Schema(description = "规格值列表")
|
||||
private List<AttributeValue> specList;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.youlai.mall.product.model.query;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 品牌分类关联查询对象
|
||||
*
|
||||
* @author Ray Hao
|
||||
* @since 2024-05-06
|
||||
*/
|
||||
@Schema(description ="品牌分类关联查询对象")
|
||||
@Data
|
||||
public class BrandCategoryQuery {
|
||||
|
||||
@Schema(description="关键字")
|
||||
private String keywords;
|
||||
|
||||
@Schema(description="品牌ID")
|
||||
private Long brandId;
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.youlai.mall.product.service;
|
||||
|
||||
import com.youlai.mall.product.model.entity.BrandCategory;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.mall.product.model.query.BrandCategoryQuery;
|
||||
import com.youlai.mall.product.model.vo.BrandCategoryVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 品牌分类关联 服务类
|
||||
*
|
||||
* @author Ray Hao
|
||||
* @since 2024-05-06
|
||||
*/
|
||||
public interface BrandCategoryService extends IService<BrandCategory> {
|
||||
|
||||
/**
|
||||
* 品牌分类关联列表
|
||||
* <p>
|
||||
* {@link List<BrandCategoryVO>} 品牌分类关联分页列表
|
||||
*/
|
||||
List<BrandCategoryVO> listBrandCategories(BrandCategoryQuery queryParams);
|
||||
|
||||
|
||||
/**
|
||||
* 新增品牌分类关联
|
||||
*
|
||||
* @param brandId 品牌ID
|
||||
* @param categoryIds 分类ID列表
|
||||
*/
|
||||
void saveBrandCategories(Long brandId, List<Long> categoryIds);
|
||||
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.youlai.mall.product.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.youlai.mall.product.model.entity.CategoryBrand;
|
||||
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:xianrui0365@163.com">haoxr</a>
|
||||
*/
|
||||
public interface CategoryBrandService extends IService<CategoryBrand> {
|
||||
|
||||
}
|
@ -14,5 +14,5 @@ import java.util.List;
|
||||
*/
|
||||
public interface SkuSpecValueService extends IService<SkuSpecValue> {
|
||||
|
||||
void saveSkuSpecValues(Long id, List<SpuForm.Attribute> specList);
|
||||
void saveSkuSpecValues(Long id, List<SpuForm.AttributeValue> specList);
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ public interface SpuAttributeService extends IService<SpuAttributeValue> {
|
||||
* @param spuId SPU ID
|
||||
* @param attributeList 属性列表
|
||||
*/
|
||||
void saveSpuAttributes(Long spuId, List<SpuForm.Attribute> attributeList);
|
||||
void saveSpuAttributes(Long spuId, List<SpuForm.AttributeValue> attributeList);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,107 @@
|
||||
package com.youlai.mall.product.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.youlai.common.security.util.SecurityUtils;
|
||||
import com.youlai.mall.product.model.entity.Brand;
|
||||
import com.youlai.mall.product.model.entity.BrandCategory;
|
||||
import com.youlai.mall.product.mapper.BrandCategoryMapper;
|
||||
import com.youlai.mall.product.model.vo.BrandCategoryVO;
|
||||
import com.youlai.mall.product.service.BrandCategoryService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.youlai.mall.product.model.form.BrandCategoryForm;
|
||||
import com.youlai.mall.product.model.query.BrandCategoryQuery;
|
||||
import com.youlai.mall.product.converter.BrandCategoryConverter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* 品牌分类关联服务实现类
|
||||
*
|
||||
* @author Ray Hao
|
||||
* @since 2024-05-06
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class BrandCategoryServiceImpl extends ServiceImpl<BrandCategoryMapper, BrandCategory> implements BrandCategoryService {
|
||||
|
||||
private final BrandCategoryConverter brandCategoryConverter;
|
||||
|
||||
/**
|
||||
* 获取品牌分类关联分页列表
|
||||
*
|
||||
* @param queryParams 查询参数
|
||||
* @return {@link List<BrandCategoryVO>} 品牌分类关联分页列表
|
||||
*/
|
||||
@Override
|
||||
public List<BrandCategoryVO> listBrandCategories(BrandCategoryQuery queryParams) {
|
||||
List<BrandCategory> list = this.list(new LambdaQueryWrapper<BrandCategory>()
|
||||
.eq(queryParams.getBrandId() != null, BrandCategory::getBrandId, queryParams.getBrandId())
|
||||
);
|
||||
|
||||
return brandCategoryConverter.entity2Vo(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增品牌分类关联
|
||||
*
|
||||
* @param brandId 品牌ID
|
||||
* @param categoryIds 分类ID列表
|
||||
*/
|
||||
@Override
|
||||
public void saveBrandCategories(Long brandId, List<Long> categoryIds) {
|
||||
|
||||
// 获取已存在的品牌分类关联
|
||||
List<Long> existCategoryIds = this.list(
|
||||
new LambdaQueryWrapper<>(BrandCategory.class).eq(BrandCategory::getBrandId, brandId))
|
||||
.stream()
|
||||
.map(BrandCategory::getCategoryId)
|
||||
.toList();
|
||||
|
||||
// 删除已存在的品牌分类关联
|
||||
List<Long> removeCategoryIds = existCategoryIds.stream()
|
||||
.filter(item -> !categoryIds.contains(item))
|
||||
.toList();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(removeCategoryIds)) {
|
||||
this.remove(
|
||||
new LambdaQueryWrapper<>(BrandCategory.class)
|
||||
.eq(BrandCategory::getBrandId, brandId)
|
||||
.in(BrandCategory::getId, removeCategoryIds)
|
||||
);
|
||||
}
|
||||
|
||||
// 新增品牌分类关联
|
||||
List<Long> newCategoryIds = categoryIds.stream()
|
||||
.filter(item -> !existCategoryIds.contains(item))
|
||||
.toList();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(newCategoryIds)) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
List<BrandCategory> newBrandCategories = newCategoryIds.stream()
|
||||
.map(categoryId -> {
|
||||
BrandCategory brandCategory = new BrandCategory();
|
||||
brandCategory.setBrandId(brandId);
|
||||
brandCategory.setCategoryId(categoryId);
|
||||
brandCategory.setCreateBy(userId);
|
||||
brandCategory.setCreateTime(now);
|
||||
return brandCategory;
|
||||
})
|
||||
.toList();
|
||||
|
||||
this.saveBatch(newBrandCategories);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.youlai.mall.product.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.youlai.mall.product.mapper.CategoryBrandMapper;
|
||||
import com.youlai.mall.product.model.entity.CategoryBrand;
|
||||
import com.youlai.mall.product.service.CategoryBrandService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class CategoryBrandServiceImpl extends ServiceImpl<CategoryBrandMapper, CategoryBrand> implements CategoryBrandService {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -34,14 +34,14 @@ public class SkuSpecValueServiceImpl extends ServiceImpl<SkuSpecValueMapper, Sku
|
||||
* @param specList 规格值列表
|
||||
*/
|
||||
@Override
|
||||
public void saveSkuSpecValues(Long skuId, List<SpuForm.Attribute> specList) {
|
||||
public void saveSkuSpecValues(Long skuId, List<SpuForm.AttributeValue> specList) {
|
||||
|
||||
// 检索数据库中与sku关联的规格值
|
||||
List<SkuSpecValue> existingInDb = this.list(new LambdaQueryWrapper<SkuSpecValue>().eq(SkuSpecValue::getSkuId, skuId));
|
||||
|
||||
// 从提交的表单中提取所有非空的SKU ID
|
||||
List<Long> submittedIds = specList.stream()
|
||||
.map(SpuForm.Attribute::getId)
|
||||
.map(SpuForm.AttributeValue::getId)
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
|
||||
@ -59,8 +59,9 @@ public class SkuSpecValueServiceImpl extends ServiceImpl<SkuSpecValueMapper, Sku
|
||||
// 删除SKU关联的规格值
|
||||
this.removeByIds(specValueIdsToDelete);
|
||||
}
|
||||
|
||||
// 循环处理提交的每个规格值
|
||||
for (SpuForm.Attribute spec : specList) {
|
||||
for (SpuForm.AttributeValue spec : specList) {
|
||||
SkuSpecValue entity = skuSpecValueConverter.convertToEntity(spec);
|
||||
entity.setSkuId(skuId);
|
||||
this.saveOrUpdate(entity);
|
||||
|
@ -37,7 +37,7 @@ public class SpuAttributeServiceImpl extends ServiceImpl<SpuAttributeMapper, Spu
|
||||
* @param formAttributes 属性列表
|
||||
*/
|
||||
@Override
|
||||
public void saveSpuAttributes(Long spuId, List<SpuForm.Attribute> formAttributes) {
|
||||
public void saveSpuAttributes(Long spuId, List<SpuForm.AttributeValue> formAttributes) {
|
||||
// 如果属性列表为空,则删除所有旧属性
|
||||
if (CollectionUtil.isEmpty(formAttributes)) {
|
||||
this.remove(new LambdaQueryWrapper<SpuAttributeValue>().eq(SpuAttributeValue::getSpuId, spuId));
|
||||
|
@ -88,7 +88,6 @@ public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements SpuSe
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean saveSpu(SpuForm formData) {
|
||||
|
||||
Spu entity = spuConverter.form2Entity(formData);
|
||||
@ -97,10 +96,10 @@ public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements SpuSe
|
||||
if (result) {
|
||||
Long spuId = entity.getId();
|
||||
// 保存商品图片
|
||||
List<SpuForm.Image> galleryImageList = formData.getGalleryImageList();
|
||||
spuImageService.saveSpuImages(spuId, galleryImageList);
|
||||
List<SpuForm.Image> imgList = formData.getImgList();
|
||||
spuImageService.saveSpuImages(spuId, imgList);
|
||||
// 保存商品属性
|
||||
List<SpuForm.Attribute> attributeList = formData.getAttributeList();
|
||||
List<SpuForm.AttributeValue> attributeList = formData.getAttributeList();
|
||||
spuAttributeService.saveSpuAttributes(spuId, attributeList);
|
||||
// 保存 SKU
|
||||
List<SpuForm.Sku> skuList = formData.getSkuList();
|
||||
@ -133,13 +132,13 @@ public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements SpuSe
|
||||
BeanUtil.copyProperties(item, image);
|
||||
return image;
|
||||
}).collect(Collectors.toList());
|
||||
spuForm.setGalleryImageList(galleryImageList);
|
||||
spuForm.setImgList(galleryImageList);
|
||||
|
||||
// 商品属性
|
||||
List<SpuForm.Attribute> attributeList = spuAttributeService.list(new LambdaQueryWrapper<SpuAttributeValue>()
|
||||
List<SpuForm.AttributeValue> attributeList = spuAttributeService.list(new LambdaQueryWrapper<SpuAttributeValue>()
|
||||
.eq(SpuAttributeValue::getSpuId, spuId))
|
||||
.stream().map(item -> {
|
||||
SpuForm.Attribute attribute = new SpuForm.Attribute();
|
||||
SpuForm.AttributeValue attribute = new SpuForm.AttributeValue();
|
||||
BeanUtil.copyProperties(item, attribute);
|
||||
return attribute;
|
||||
}).collect(Collectors.toList());
|
||||
@ -153,10 +152,10 @@ public class SpuServiceImpl extends ServiceImpl<SpuMapper, Spu> implements SpuSe
|
||||
|
||||
Long skuId = item.getId();
|
||||
// 获取SKU规格值
|
||||
List<SpuForm.Attribute> skuSpecList = skuSpecValueService.list(new LambdaQueryWrapper<SkuSpecValue>()
|
||||
List<SpuForm.AttributeValue> skuSpecList = skuSpecValueService.list(new LambdaQueryWrapper<SkuSpecValue>()
|
||||
.eq(SkuSpecValue::getSkuId, skuId))
|
||||
.stream().map(skuSpec -> {
|
||||
SpuForm.Attribute attribute = new SpuForm.Attribute();
|
||||
SpuForm.AttributeValue attribute = new SpuForm.AttributeValue();
|
||||
BeanUtil.copyProperties(skuSpec, attribute);
|
||||
return attribute;
|
||||
}).collect(Collectors.toList());
|
||||
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.youlai.mall.product.mapper.BrandCategoryMapper">
|
||||
|
||||
|
||||
</mapper>
|
@ -24,9 +24,9 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
|
||||
|
||||
/**
|
||||
* 获取用户分页列表
|
||||
* $!{table.comment}分页列表
|
||||
*
|
||||
* @param page
|
||||
* @param page 分页对象
|
||||
* @param queryParams 查询参数
|
||||
* @return
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user