Commit ff307a4c864a6e0d0540066e13780f6920ef0b1c
1 parent
1fc5c3c7
fix: TODO pid 改成 parentId 字段
Showing
7 changed files
with
35 additions
and
36 deletions
sql/mall.sql
| ... | ... | @@ -24,7 +24,7 @@ DROP TABLE IF EXISTS `product_category`; |
| 24 | 24 | CREATE TABLE `product_category` |
| 25 | 25 | ( |
| 26 | 26 | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类编号', |
| 27 | - `pid` bigint NOT NULL COMMENT '父分类编号', | |
| 27 | + `parent_id` bigint NOT NULL COMMENT '父分类编号', | |
| 28 | 28 | `name` varchar(255) NOT NULL COMMENT '分类名称', |
| 29 | 29 | `icon` varchar(100) NOT NULL DEFAULT '#' COMMENT '分类图标', |
| 30 | 30 | `banner_url` varchar(255) NOT NULL COMMENT '分类图片', |
| ... | ... | @@ -62,29 +62,29 @@ CREATE TABLE `product_brand` |
| 62 | 62 | PRIMARY KEY (`id`) USING BTREE |
| 63 | 63 | ) ENGINE=InnoDB COMMENT='品牌'; |
| 64 | 64 | |
| 65 | --- TODO 父级菜单的 id 处理 | |
| 66 | -INSERT INTO `system_menu` (`id`, `name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES (2000, '商城', '', 1, 1, 0, '/mall', 'merchant', NULL, 0); | |
| 67 | -INSERT INTO `system_menu` (`id`, `name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES (2001, '商品管理', '', 1, 1, 2000, 'product', 'dict', NULL, 0); | |
| 65 | +-- TODO 父级菜单的 id 处理: 2000 、 2001 | |
| 66 | +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES (2000, '商城', '', 1, 1, 0, '/mall', 'merchant', NULL, 0); | |
| 67 | +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES (2001, '商品管理', '', 1, 1, 2000, 'product', 'dict', NULL, 0); | |
| 68 | 68 | -- 商品分类 菜单 SQL |
| 69 | -INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类管理', '', 2, 0, 2001, 'category', '', 'mall/product/category/index', 0); | |
| 69 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类管理', '', 2, 0, 2001, 'category', '', 'mall/product/category/index', 0); | |
| 70 | 70 | -- 按钮父菜单ID |
| 71 | 71 | SELECT @parentId := LAST_INSERT_ID(); |
| 72 | 72 | -- 按钮 SQL |
| 73 | -INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类查询', 'product:category:query', 3, 1, @parentId, '', '', '', 0); | |
| 74 | -INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类创建', 'product:category:create', 3, 2, @parentId, '', '', '', 0); | |
| 75 | -INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类更新', 'product:category:update', 3, 3, @parentId, '', '', '', 0); | |
| 76 | -INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类删除', 'product:category:delete', 3, 4, @parentId, '', '', '', 0); | |
| 77 | -INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类导出', 'product:category:export', 3, 5, @parentId, '', '', '', 0); | |
| 73 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类查询', 'product:category:query', 3, 1, @parentId, '', '', '', 0); | |
| 74 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类创建', 'product:category:create', 3, 2, @parentId, '', '', '', 0); | |
| 75 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类更新', 'product:category:update', 3, 3, @parentId, '', '', '', 0); | |
| 76 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类删除', 'product:category:delete', 3, 4, @parentId, '', '', '', 0); | |
| 77 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类导出', 'product:category:export', 3, 5, @parentId, '', '', '', 0); | |
| 78 | 78 | -- 品牌管理 菜单 SQL |
| 79 | -INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌管理', '', 2, 0, 2001, 'brand', '', 'mall/product/brand/index', 0); | |
| 79 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌管理', '', 2, 0, 2001, 'brand', '', 'mall/product/brand/index', 0); | |
| 80 | 80 | -- 按钮父菜单ID |
| 81 | 81 | SELECT @parentId := LAST_INSERT_ID(); |
| 82 | 82 | -- 按钮 SQL |
| 83 | -INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌查询', 'product:brand:query', 3, 1, @parentId, '', '', '', 0); | |
| 84 | -INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌创建', 'product:brand:create', 3, 2, @parentId, '', '', '', 0); | |
| 85 | -INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌更新', 'product:brand:update', 3, 3, @parentId, '', '', '', 0); | |
| 86 | -INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌删除', 'product:brand:delete', 3, 4, @parentId, '', '', '', 0); | |
| 87 | -INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌导出', 'product:brand:export', 3, 5, @parentId, '', '', '', 0); | |
| 83 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌查询', 'product:brand:query', 3, 1, @parentId, '', '', '', 0); | |
| 84 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌创建', 'product:brand:create', 3, 2, @parentId, '', '', '', 0); | |
| 85 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌更新', 'product:brand:update', 3, 3, @parentId, '', '', '', 0); | |
| 86 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌删除', 'product:brand:delete', 3, 4, @parentId, '', '', '', 0); | |
| 87 | +INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌导出', 'product:brand:export', 3, 5, @parentId, '', '', '', 0); | |
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | -- ---------------------------- | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/CategoryBaseVO.java
| ... | ... | @@ -15,7 +15,7 @@ public class CategoryBaseVO { |
| 15 | 15 | |
| 16 | 16 | @ApiModelProperty(value = "父分类编号", required = true, example = "1") |
| 17 | 17 | @NotNull(message = "父分类编号不能为空") |
| 18 | - private Long pid; | |
| 18 | + private Long parentId; | |
| 19 | 19 | |
| 20 | 20 | @ApiModelProperty(value = "分类名称", required = true, example = "办公文具") |
| 21 | 21 | @NotBlank(message = "分类名称不能为空") | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/CategoryExcelVO.java
| 1 | 1 | package cn.iocoder.yudao.module.product.controller.admin.category.vo; |
| 2 | 2 | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import io.swagger.annotations.*; | |
| 6 | - | |
| 7 | -import com.alibaba.excel.annotation.ExcelProperty; | |
| 8 | 3 | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; |
| 9 | 4 | import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; |
| 5 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import java.util.Date; | |
| 10 | 9 | |
| 11 | 10 | |
| 12 | 11 | /** |
| ... | ... | @@ -21,7 +20,7 @@ public class CategoryExcelVO { |
| 21 | 20 | private Long id; |
| 22 | 21 | |
| 23 | 22 | @ExcelProperty("父分类编号") |
| 24 | - private Long pid; | |
| 23 | + private Long parentId; | |
| 25 | 24 | |
| 26 | 25 | @ExcelProperty("分类名称") |
| 27 | 26 | private String name; | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/category/CategoryDO.java
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/category/CategoryServiceImplTest.java
| ... | ... | @@ -105,7 +105,7 @@ public class CategoryServiceImplTest extends BaseDbUnitTest { |
| 105 | 105 | public void testGetCategoryPage() { |
| 106 | 106 | // mock 数据 |
| 107 | 107 | CategoryDO dbCategory = randomPojo(CategoryDO.class, o -> { // 等会查询到 |
| 108 | - o.setPid(null); | |
| 108 | + o.setParentId(null); | |
| 109 | 109 | o.setName(null); |
| 110 | 110 | o.setIcon(null); |
| 111 | 111 | o.setBannerUrl(null); |
| ... | ... | @@ -116,7 +116,7 @@ public class CategoryServiceImplTest extends BaseDbUnitTest { |
| 116 | 116 | }); |
| 117 | 117 | categoryMapper.insert(dbCategory); |
| 118 | 118 | // 测试 pid 不匹配 |
| 119 | - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setPid(null))); | |
| 119 | + categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setParentId(null))); | |
| 120 | 120 | // 测试 name 不匹配 |
| 121 | 121 | categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName(null))); |
| 122 | 122 | // 测试 icon 不匹配 |
| ... | ... | @@ -151,7 +151,7 @@ public class CategoryServiceImplTest extends BaseDbUnitTest { |
| 151 | 151 | public void testGetCategoryList() { |
| 152 | 152 | // mock 数据 |
| 153 | 153 | CategoryDO dbCategory = randomPojo(CategoryDO.class, o -> { // 等会查询到 |
| 154 | - o.setPid(null); | |
| 154 | + o.setParentId(null); | |
| 155 | 155 | o.setName(null); |
| 156 | 156 | o.setIcon(null); |
| 157 | 157 | o.setBannerUrl(null); |
| ... | ... | @@ -162,7 +162,7 @@ public class CategoryServiceImplTest extends BaseDbUnitTest { |
| 162 | 162 | }); |
| 163 | 163 | categoryMapper.insert(dbCategory); |
| 164 | 164 | // 测试 pid 不匹配 |
| 165 | - categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setPid(null))); | |
| 165 | + categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setParentId(null))); | |
| 166 | 166 | // 测试 name 不匹配 |
| 167 | 167 | categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName(null))); |
| 168 | 168 | // 测试 icon 不匹配 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql
yudao-ui-admin/src/views/mall/product/category/index.vue
| ... | ... | @@ -77,8 +77,9 @@ |
| 77 | 77 | <!-- 对话框(添加 / 修改) --> |
| 78 | 78 | <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
| 79 | 79 | <el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
| 80 | - <el-form-item label="上级分类" prop="pid"> | |
| 81 | - <Treeselect v-model="form.pid" :options="parentCategoryOptions" :normalizer="normalizer" :show-count="true" | |
| 80 | + <el-form-item label="上级分类" prop="parentId"> | |
| 81 | + <Treeselect v-model="form.parentId" :options="parentCategoryOptions" :normalizer="normalizer" | |
| 82 | + :show-count="true" | |
| 82 | 83 | placeholder="上级分类"/> |
| 83 | 84 | </el-form-item> |
| 84 | 85 | <el-form-item label="分类名称" prop="name"> |
| ... | ... | @@ -172,7 +173,7 @@ export default { |
| 172 | 173 | form: {}, |
| 173 | 174 | // 表单校验 |
| 174 | 175 | rules: { |
| 175 | - pid: [{required: true, message: "请选择上级分类", trigger: "blur"}], | |
| 176 | + parentId: [{required: true, message: "请选择上级分类", trigger: "blur"}], | |
| 176 | 177 | name: [{required: true, message: "分类名称不能为空", trigger: "blur"}], |
| 177 | 178 | icon: [{required: true, message: "分类图标不能为空", trigger: "blur"}], |
| 178 | 179 | bannerUrl: [{required: true, message: "分类图片不能为空", trigger: "blur"}], |
| ... | ... | @@ -191,7 +192,7 @@ export default { |
| 191 | 192 | let params = {...this.queryParams}; |
| 192 | 193 | // 执行查询 |
| 193 | 194 | listCategory(params).then(response => { |
| 194 | - this.list = this.handleTree(response.data, "id", "pid"); | |
| 195 | + this.list = this.handleTree(response.data, "id", "parentId"); | |
| 195 | 196 | this.loading = false; |
| 196 | 197 | }); |
| 197 | 198 | }, |
| ... | ... | @@ -215,7 +216,7 @@ export default { |
| 215 | 216 | listCategory().then(response => { |
| 216 | 217 | this.parentCategoryOptions = []; |
| 217 | 218 | const menu = {id: 0, name: '主分类', children: []}; |
| 218 | - menu.children = this.handleTree(response.data, "id", "pid"); | |
| 219 | + menu.children = this.handleTree(response.data, "id", "parentId"); | |
| 219 | 220 | this.parentCategoryOptions.push(menu); |
| 220 | 221 | }); |
| 221 | 222 | }, |
| ... | ... | @@ -228,7 +229,7 @@ export default { |
| 228 | 229 | reset() { |
| 229 | 230 | this.form = { |
| 230 | 231 | id: undefined, |
| 231 | - pid: undefined, | |
| 232 | + parentId: undefined, | |
| 232 | 233 | name: undefined, |
| 233 | 234 | icon: undefined, |
| 234 | 235 | bannerUrl: undefined, | ... | ... |