diff --git a/src/main/java/com/gxwebsoft/cms/entity/CmsProductCategory.java b/src/main/java/com/gxwebsoft/cms/entity/CmsProductCategory.java index 5006a96..9d7b494 100644 --- a/src/main/java/com/gxwebsoft/cms/entity/CmsProductCategory.java +++ b/src/main/java/com/gxwebsoft/cms/entity/CmsProductCategory.java @@ -31,6 +31,9 @@ public class CmsProductCategory implements Serializable { @TableId(value = "category_id", type = IdType.AUTO) private Integer categoryId; + @Schema(description = "上级分类ID, 0=顶级") + private Integer parentId; + @Schema(description = "分类名称") private String categoryName; diff --git a/src/main/java/com/gxwebsoft/cms/param/CmsProductCategoryParam.java b/src/main/java/com/gxwebsoft/cms/param/CmsProductCategoryParam.java index 5130866..e379bec 100644 --- a/src/main/java/com/gxwebsoft/cms/param/CmsProductCategoryParam.java +++ b/src/main/java/com/gxwebsoft/cms/param/CmsProductCategoryParam.java @@ -23,6 +23,10 @@ public class CmsProductCategoryParam extends BaseParam { @QueryField(type = QueryType.EQ) private Integer categoryId; + @Schema(description = "上级分类ID, 0=顶级") + @QueryField(type = QueryType.EQ) + private Integer parentId; + @Schema(description = "分类名称") @QueryField(type = QueryType.LIKE) private String categoryName; diff --git a/src/main/java/com/gxwebsoft/cms/sql/cms_new_modules.sql b/src/main/java/com/gxwebsoft/cms/sql/cms_new_modules.sql index 1d2f254..0f0e2cd 100644 --- a/src/main/java/com/gxwebsoft/cms/sql/cms_new_modules.sql +++ b/src/main/java/com/gxwebsoft/cms/sql/cms_new_modules.sql @@ -4,6 +4,7 @@ -- ---------------------------- CREATE TABLE IF NOT EXISTS `cms_product_category` ( `category_id` INT NOT NULL AUTO_INCREMENT COMMENT '分类ID', + `parent_id` INT NOT NULL DEFAULT 0 COMMENT '上级分类ID, 0=顶级', `category_name` VARCHAR(100) NOT NULL COMMENT '分类名称', `status` TINYINT NOT NULL DEFAULT 1 COMMENT '状态: 1启用 0禁用', `sort_number` INT NOT NULL DEFAULT 0 COMMENT '排序(数字越小越靠前)', @@ -12,9 +13,13 @@ CREATE TABLE IF NOT EXISTS `cms_product_category` ( `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`category_id`), - KEY `idx_tenant_id` (`tenant_id`) + KEY `idx_tenant_id` (`tenant_id`), + KEY `idx_parent_id` (`parent_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品分类'; +-- 兼容已有库:补齐 parent_id 列(已存在则忽略) +-- ALTER TABLE `cms_product_category` ADD COLUMN `parent_id` INT NOT NULL DEFAULT 0 COMMENT '上级分类ID, 0=顶级' AFTER `category_id`, ADD KEY `idx_parent_id` (`parent_id`); + -- ---------------------------- -- 产品表 -- 官网展示的云产品