mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
fix: TODO pid 改成 parentId 字段
This commit is contained in:
parent
1fc5c3c71c
commit
ff307a4c86
32
sql/mall.sql
32
sql/mall.sql
@ -24,7 +24,7 @@ DROP TABLE IF EXISTS `product_category`;
|
||||
CREATE TABLE `product_category`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类编号',
|
||||
`pid` bigint NOT NULL COMMENT '父分类编号',
|
||||
`parent_id` bigint NOT NULL COMMENT '父分类编号',
|
||||
`name` varchar(255) NOT NULL COMMENT '分类名称',
|
||||
`icon` varchar(100) NOT NULL DEFAULT '#' COMMENT '分类图标',
|
||||
`banner_url` varchar(255) NOT NULL COMMENT '分类图片',
|
||||
@ -62,29 +62,29 @@ CREATE TABLE `product_brand`
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB COMMENT='品牌';
|
||||
|
||||
-- TODO 父级菜单的 id 处理
|
||||
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);
|
||||
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);
|
||||
-- TODO 父级菜单的 id 处理: 2000 、 2001
|
||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES (2000, '商城', '', 1, 1, 0, '/mall', 'merchant', NULL, 0);
|
||||
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES (2001, '商品管理', '', 1, 1, 2000, 'product', 'dict', NULL, 0);
|
||||
-- 商品分类 菜单 SQL
|
||||
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);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类管理', '', 2, 0, 2001, 'category', '', 'mall/product/category/index', 0);
|
||||
-- 按钮父菜单ID
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
-- 按钮 SQL
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类查询', 'product:category:query', 3, 1, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类创建', 'product:category:create', 3, 2, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类更新', 'product:category:update', 3, 3, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类删除', 'product:category:delete', 3, 4, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类导出', 'product:category:export', 3, 5, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类查询', 'product:category:query', 3, 1, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类创建', 'product:category:create', 3, 2, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类更新', 'product:category:update', 3, 3, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类删除', 'product:category:delete', 3, 4, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类导出', 'product:category:export', 3, 5, @parentId, '', '', '', 0);
|
||||
-- 品牌管理 菜单 SQL
|
||||
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);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌管理', '', 2, 0, 2001, 'brand', '', 'mall/product/brand/index', 0);
|
||||
-- 按钮父菜单ID
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
-- 按钮 SQL
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌查询', 'product:brand:query', 3, 1, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌创建', 'product:brand:create', 3, 2, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌更新', 'product:brand:update', 3, 3, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌删除', 'product:brand:delete', 3, 4, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌导出', 'product:brand:export', 3, 5, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌查询', 'product:brand:query', 3, 1, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌创建', 'product:brand:create', 3, 2, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌更新', 'product:brand:update', 3, 3, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌删除', 'product:brand:delete', 3, 4, @parentId, '', '', '', 0);
|
||||
INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌导出', 'product:brand:export', 3, 5, @parentId, '', '', '', 0);
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
|
@ -15,7 +15,7 @@ public class CategoryBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "父分类编号", required = true, example = "1")
|
||||
@NotNull(message = "父分类编号不能为空")
|
||||
private Long pid;
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty(value = "分类名称", required = true, example = "办公文具")
|
||||
@NotBlank(message = "分类名称不能为空")
|
||||
|
@ -1,12 +1,11 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.category.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
@ -21,7 +20,7 @@ public class CategoryExcelVO {
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("父分类编号")
|
||||
private Long pid;
|
||||
private Long parentId;
|
||||
|
||||
@ExcelProperty("分类名称")
|
||||
private String name;
|
||||
|
@ -28,8 +28,7 @@ public class CategoryDO extends BaseDO {
|
||||
/**
|
||||
* 父分类编号
|
||||
*/
|
||||
// TODO @JeromeSoar:改成 parentId 字段
|
||||
private Long pid;
|
||||
private Long parentId;
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
|
@ -105,7 +105,7 @@ public class CategoryServiceImplTest extends BaseDbUnitTest {
|
||||
public void testGetCategoryPage() {
|
||||
// mock 数据
|
||||
CategoryDO dbCategory = randomPojo(CategoryDO.class, o -> { // 等会查询到
|
||||
o.setPid(null);
|
||||
o.setParentId(null);
|
||||
o.setName(null);
|
||||
o.setIcon(null);
|
||||
o.setBannerUrl(null);
|
||||
@ -116,7 +116,7 @@ public class CategoryServiceImplTest extends BaseDbUnitTest {
|
||||
});
|
||||
categoryMapper.insert(dbCategory);
|
||||
// 测试 pid 不匹配
|
||||
categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setPid(null)));
|
||||
categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setParentId(null)));
|
||||
// 测试 name 不匹配
|
||||
categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName(null)));
|
||||
// 测试 icon 不匹配
|
||||
@ -151,7 +151,7 @@ public class CategoryServiceImplTest extends BaseDbUnitTest {
|
||||
public void testGetCategoryList() {
|
||||
// mock 数据
|
||||
CategoryDO dbCategory = randomPojo(CategoryDO.class, o -> { // 等会查询到
|
||||
o.setPid(null);
|
||||
o.setParentId(null);
|
||||
o.setName(null);
|
||||
o.setIcon(null);
|
||||
o.setBannerUrl(null);
|
||||
@ -162,7 +162,7 @@ public class CategoryServiceImplTest extends BaseDbUnitTest {
|
||||
});
|
||||
categoryMapper.insert(dbCategory);
|
||||
// 测试 pid 不匹配
|
||||
categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setPid(null)));
|
||||
categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setParentId(null)));
|
||||
// 测试 name 不匹配
|
||||
categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName(null)));
|
||||
// 测试 icon 不匹配
|
||||
|
@ -1,6 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS "product_category" (
|
||||
"id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"pid" bigint(20) NOT NULL,
|
||||
"parent_id" bigint(20) NOT NULL,
|
||||
"name" varchar(255) NOT NULL,
|
||||
"icon" varchar(100),
|
||||
"banner_url" varchar(255) NOT NULL,
|
||||
|
@ -77,8 +77,9 @@
|
||||
<!-- 对话框(添加 / 修改) -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="上级分类" prop="pid">
|
||||
<Treeselect v-model="form.pid" :options="parentCategoryOptions" :normalizer="normalizer" :show-count="true"
|
||||
<el-form-item label="上级分类" prop="parentId">
|
||||
<Treeselect v-model="form.parentId" :options="parentCategoryOptions" :normalizer="normalizer"
|
||||
:show-count="true"
|
||||
placeholder="上级分类"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类名称" prop="name">
|
||||
@ -172,7 +173,7 @@ export default {
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
pid: [{required: true, message: "请选择上级分类", trigger: "blur"}],
|
||||
parentId: [{required: true, message: "请选择上级分类", trigger: "blur"}],
|
||||
name: [{required: true, message: "分类名称不能为空", trigger: "blur"}],
|
||||
icon: [{required: true, message: "分类图标不能为空", trigger: "blur"}],
|
||||
bannerUrl: [{required: true, message: "分类图片不能为空", trigger: "blur"}],
|
||||
@ -191,7 +192,7 @@ export default {
|
||||
let params = {...this.queryParams};
|
||||
// 执行查询
|
||||
listCategory(params).then(response => {
|
||||
this.list = this.handleTree(response.data, "id", "pid");
|
||||
this.list = this.handleTree(response.data, "id", "parentId");
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
@ -215,7 +216,7 @@ export default {
|
||||
listCategory().then(response => {
|
||||
this.parentCategoryOptions = [];
|
||||
const menu = {id: 0, name: '主分类', children: []};
|
||||
menu.children = this.handleTree(response.data, "id", "pid");
|
||||
menu.children = this.handleTree(response.data, "id", "parentId");
|
||||
this.parentCategoryOptions.push(menu);
|
||||
});
|
||||
},
|
||||
@ -228,7 +229,7 @@ export default {
|
||||
reset() {
|
||||
this.form = {
|
||||
id: undefined,
|
||||
pid: undefined,
|
||||
parentId: undefined,
|
||||
name: undefined,
|
||||
icon: undefined,
|
||||
bannerUrl: undefined,
|
||||
|
Loading…
Reference in New Issue
Block a user