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