根据需求开发:组件库系统开发完成

This commit is contained in:
lizhengwei 2026-03-07 17:34:14 +08:00
parent e730c7745e
commit 2d79940ce8
9 changed files with 40 additions and 36 deletions

View File

@ -3,7 +3,7 @@
-- 1. 组件分类表 (两级分类)
CREATE TABLE `h5_component_category` (
[id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37) BIGINT NOT NULL COMMENT '主键 ID',
`id` BIGINT NOT NULL COMMENT '主键 ID',
`parent_id` BIGINT NOT NULL DEFAULT 0 COMMENT '父分类 ID(0 为一级分类)',
`name` VARCHAR(100) NOT NULL COMMENT '分类名称',
`type` VARCHAR(50) NOT NULL COMMENT '分类类型 (text/image/extension/background/music)',
@ -13,7 +13,7 @@ CREATE TABLE `h5_component_category` (
`is_system` TINYINT NOT NULL DEFAULT 0 COMMENT '是否系统预设 (1:是 0:否)',
`create_time` BIGINT NOT NULL COMMENT '创建时间 (Unix 时间戳秒级)',
`update_time` BIGINT DEFAULT NULL COMMENT '更新时间 (Unix 时间戳秒级)',
PRIMARY KEY ([id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37)),
PRIMARY KEY (`id`),
INDEX `idx_parent_id` (`parent_id`),
INDEX `idx_type` (`type`),
INDEX `idx_sort` (`sort`)
@ -21,7 +21,7 @@ CREATE TABLE `h5_component_category` (
-- 2. 组件表
CREATE TABLE `h5_component` (
[id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37) BIGINT NOT NULL COMMENT '主键 ID',
`id` BIGINT NOT NULL COMMENT '主键 ID',
`name` VARCHAR(200) NOT NULL COMMENT '组件名称',
`type` VARCHAR(50) NOT NULL COMMENT '组件类型 (text/image/form/map/background/music)',
`thumbnail_url` VARCHAR(500) DEFAULT NULL COMMENT '缩略图 URL',
@ -35,7 +35,7 @@ CREATE TABLE `h5_component` (
`remark` VARCHAR(1000) DEFAULT NULL COMMENT '备注说明',
`create_time` BIGINT NOT NULL COMMENT '创建时间 (Unix 时间戳秒级)',
`update_time` BIGINT DEFAULT NULL COMMENT '更新时间 (Unix 时间戳秒级)',
PRIMARY KEY ([id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37)),
PRIMARY KEY (`id`),
INDEX `idx_type` (`type`),
INDEX `idx_status` (`status`),
INDEX `idx_usage_count` (`usage_count`),
@ -44,7 +44,7 @@ CREATE TABLE `h5_component` (
-- 3. 标签表
CREATE TABLE `h5_tag` (
[id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37) BIGINT NOT NULL COMMENT '主键 ID',
`id` BIGINT NOT NULL COMMENT '主键 ID',
`name` VARCHAR(100) NOT NULL COMMENT '标签名称',
`type` VARCHAR(50) DEFAULT NULL COMMENT '标签适用类型NULL 表示通用',
`sort` INT NOT NULL DEFAULT 0 COMMENT '排序值',
@ -52,7 +52,7 @@ CREATE TABLE `h5_tag` (
`use_count` BIGINT NOT NULL DEFAULT 0 COMMENT '使用次数',
`create_time` BIGINT NOT NULL COMMENT '创建时间 (Unix 时间戳秒级)',
`update_time` BIGINT DEFAULT NULL COMMENT '更新时间 (Unix 时间戳秒级)',
PRIMARY KEY ([id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37)),
PRIMARY KEY (`id`),
UNIQUE INDEX `uk_name` (`name`),
INDEX `idx_type` (`type`),
INDEX `idx_is_hot` (`is_hot`),
@ -61,28 +61,28 @@ CREATE TABLE `h5_tag` (
-- 4. 组件分类关联表 (多对多)
CREATE TABLE `h5_component_category_rel` (
[id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37) BIGINT NOT NULL COMMENT '主键 ID',
`id` BIGINT NOT NULL COMMENT '主键 ID',
`component_id` BIGINT NOT NULL COMMENT '组件 ID',
`category_id` BIGINT NOT NULL COMMENT '分类 ID',
`create_time` BIGINT NOT NULL COMMENT '创建时间 (Unix 时间戳秒级)',
PRIMARY KEY ([id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37)),
PRIMARY KEY (`id`),
UNIQUE INDEX `uk_component_category` (`component_id`, `category_id`),
INDEX `idx_category_id` (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='H5 组件与分类关联表';
-- 5. 组件标签关联表 (多对多)
CREATE TABLE `h5_component_tag_rel` (
[id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37) BIGINT NOT NULL COMMENT '主键 ID',
`id` BIGINT NOT NULL COMMENT '主键 ID',
`component_id` BIGINT NOT NULL COMMENT '组件 ID',
`tag_id` BIGINT NOT NULL COMMENT '标签 ID',
`create_time` BIGINT NOT NULL COMMENT '创建时间 (Unix 时间戳秒级)',
PRIMARY KEY ([id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37)),
PRIMARY KEY (`id`),
UNIQUE INDEX `uk_component_tag` (`component_id`, `tag_id`),
INDEX `idx_tag_id` (`tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='H5 组件与标签关联表';
-- 初始化数据 - 一级分类 (固定 5 大类)
INSERT INTO `h5_component_category` ([id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37), `parent_id`, [name](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-common\ruoyi-common-translation\src\main\java\org\dromara\common\translation\core\TranslationInterface.java#L27-L27), `type`, `sort`, `icon`, `description`, `is_system`, `create_time`) VALUES
INSERT INTO `h5_component_category` (`id`, `parent_id`, `name`, `type`, `sort`, `icon`, `description`, `is_system`, `create_time`) VALUES
(1, 0, '文字', 'text', 1, NULL, '文字类组件,包括标题、正文、艺术字等', 1, UNIX_TIMESTAMP()),
(2, 0, '图片', 'image', 2, NULL, '图片类组件,包括产品图、背景图、装饰图等', 1, UNIX_TIMESTAMP()),
(3, 0, '扩展', 'extension', 3, NULL, '扩展功能组件,包括表单、定位、微信头像等', 1, UNIX_TIMESTAMP()),
@ -90,7 +90,7 @@ INSERT INTO `h5_component_category` ([id](file://D:\project\gitee\RuoYi-Vue-Plus
(5, 0, '音乐', 'music', 5, NULL, '音乐音频类组件', 1, UNIX_TIMESTAMP());
-- 初始化数据 - 二级分类示例
INSERT INTO `h5_component_category` ([id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37), `parent_id`, [name](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-common\ruoyi-common-translation\src\main\java\org\dromara\common\translation\core\TranslationInterface.java#L27-L27), `type`, `sort`, `is_system`, `create_time`) VALUES
INSERT INTO `h5_component_category` (`id`, `parent_id`, `name`, `type`, `sort`, `is_system`, `create_time`) VALUES
(101, 1, '标题文字', 'text', 1, 1, UNIX_TIMESTAMP()),
(102, 1, '正文文本', 'text', 2, 1, UNIX_TIMESTAMP()),
(103, 1, '艺术字', 'text', 3, 1, UNIX_TIMESTAMP()),
@ -101,7 +101,7 @@ INSERT INTO `h5_component_category` ([id](file://D:\project\gitee\RuoYi-Vue-Plus
(303, 3, '社交组件', 'extension', 3, 1, UNIX_TIMESTAMP());
-- 初始化数据 - 标签示例
INSERT INTO `h5_tag` ([id](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-admin\src\test\java\org\dromara\test\DemoUnitTest.java#L37-L37), [name](file://D:\project\gitee\RuoYi-Vue-Plus\ruoyi-common\ruoyi-common-translation\src\main\java\org\dromara\common\translation\core\TranslationInterface.java#L27-L27), `type`, `sort`, `is_hot`, `create_time`) VALUES
INSERT INTO `h5_tag` (`id`, `name`, `type`, `sort`, `is_hot`, `create_time`) VALUES
(1, '简约', NULL, 1, 1, UNIX_TIMESTAMP()),
(2, '商务', NULL, 2, 1, UNIX_TIMESTAMP()),
(3, '创意', NULL, 3, 1, UNIX_TIMESTAMP()),

View File

@ -68,7 +68,7 @@ public class H5ComponentCategoryController {
}
@Operation(summary = "更新分类")
@PutMapping("/{id}")
@PostMapping("/update/{id}")
public Result<Void> update(
@Parameter(description = "分类 ID", required = true) @PathVariable Long id,
@Parameter(description = "分类信息", required = true) @RequestBody @Validated H5ComponentCategory category) {
@ -79,7 +79,7 @@ public class H5ComponentCategoryController {
}
@Operation(summary = "删除分类")
@DeleteMapping("/{id}")
@PostMapping("/delete/{id}")
public Result<Void> deleteById(
@Parameter(description = "分类 ID", required = true) @PathVariable Long id) {
h5ComponentCategoryService.deleteById(id);

View File

@ -1,3 +1,4 @@
package com.luban.api.controller;
import cn.hutool.core.util.StrUtil;
@ -63,7 +64,7 @@ public class H5ComponentController {
}
@Operation(summary = "更新组件")
@PutMapping("/{id}")
@PostMapping("/update/{id}")
public Result<Void> update(
@Parameter(description = "组件 ID", required = true) @PathVariable Long id,
@Parameter(description = "组件信息", required = true) @RequestBody @Validated H5Component component,
@ -76,7 +77,7 @@ public class H5ComponentController {
}
@Operation(summary = "删除组件")
@DeleteMapping("/{id}")
@PostMapping("/delete/{id}")
public Result<Void> deleteById(
@Parameter(description = "组件 ID", required = true) @PathVariable Long id) {
h5ComponentService.deleteById(id);
@ -84,7 +85,7 @@ public class H5ComponentController {
}
@Operation(summary = "批量删除组件")
@DeleteMapping("/batch")
@PostMapping("/batch")
public Result<Void> deleteBatch(
@Parameter(description = "组件 ID 列表", required = true) @RequestBody List<Long> ids) {
h5ComponentService.deleteBatch(ids);

View File

@ -100,8 +100,8 @@ public class H5GroupController {
* @param h5Group H5分组信息
* @return 更新结果
*/
@Operation(summary = "更新H5分组")
@PutMapping("/{id}")
@Operation(summary = "更新 H5 分组")
@PostMapping("/update/{id}")
public boolean updateH5Group(@PathVariable Long id, @RequestBody H5Group h5Group) {
h5Group.setId(id);
return h5GroupService.updateById(h5Group);
@ -113,8 +113,8 @@ public class H5GroupController {
* @param id H5分组ID
* @return 删除结果
*/
@Operation(summary = "删除H5分组")
@DeleteMapping("/{id}")
@Operation(summary = "删除 H5 分组")
@PostMapping("/delete/{id}")
public boolean deleteH5Group(@PathVariable Long id) {
return h5GroupService.removeById(id);
}

View File

@ -105,8 +105,8 @@ public class H5ProjectController {
* @param request 包含H5项目信息和内容的请求
* @return 是否更新成功
*/
@Operation(summary = "更新H5项目")
@PutMapping("/{id}")
@Operation(summary = "更新 H5 项目")
@PostMapping("/update/{id}")
public Boolean updateH5Project(@PathVariable Long id, @RequestBody CreateH5ProjectRequest request) {
H5Project h5Project = h5ProjectService.getById(id);
if (h5Project == null) {
@ -135,8 +135,8 @@ public class H5ProjectController {
* @return 是否更新成功
*/
@Operation(summary = "更新状态")
@PutMapping("updateStatus")
public Boolean 更新状态H5Project(@RequestParam Long id, @RequestBody CreateH5ProjectRequest request) {
@PostMapping("updateStatus")
public Boolean updateStatus(@RequestParam Long id, @RequestBody CreateH5ProjectRequest request) {
H5Project h5Project = h5ProjectService.getById(id);
if (h5Project == null) {
throw new RuntimeException("项目不存在");
@ -164,8 +164,8 @@ public class H5ProjectController {
* @param id H5项目ID
* @return 是否删除成功
*/
@Operation(summary = "删除H5项目")
@DeleteMapping("/{id}")
@Operation(summary = "删除 H5 项目")
@PostMapping("/delete/{id}")
public Boolean deleteH5Project(@PathVariable Long id) {
return h5ProjectService.removeH5ProjectWithContent(id);
}

View File

@ -61,7 +61,7 @@ public class H5TagController {
}
@Operation(summary = "更新标签")
@PutMapping("/{id}")
@PostMapping("/update/{id}")
public Result<Void> update(
@Parameter(description = "标签 ID", required = true) @PathVariable Long id,
@Parameter(description = "标签信息", required = true) @RequestBody @Validated H5Tag tag) {
@ -72,7 +72,7 @@ public class H5TagController {
}
@Operation(summary = "删除标签")
@DeleteMapping("/{id}")
@PostMapping("/delete/{id}")
public Result<Void> deleteById(
@Parameter(description = "标签 ID", required = true) @PathVariable Long id) {
h5TagService.deleteById(id);

View File

@ -3,7 +3,6 @@ package com.luban.api.convert;
import com.luban.api.entity.H5Component;
import com.luban.api.vo.H5ComponentVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* H5 组件转换类
@ -14,7 +13,7 @@ import org.mapstruct.factory.Mappers;
@Mapper
public interface H5ComponentConvert {
H5ComponentConvert INSTANCE = Mappers.getMapper(H5ComponentConvert.class);
H5ComponentConvert INSTANCE = org.mapstruct.factory.Mappers.getMapper(H5ComponentConvert.class);
/**
* Entity VO

View File

@ -35,12 +35,11 @@ public class H5ComponentServiceImpl extends ServiceImpl<H5ComponentDao, H5Compon
private final H5ComponentCategoryRelDao h5ComponentCategoryRelDao;
private final H5ComponentTagRelDao h5ComponentTagRelDao;
private final H5ComponentConvert h5ComponentConvert;
@Override
public H5ComponentVO getById(Long id) {
H5Component component = baseMapper.selectById(id);
return h5ComponentConvert.toVO(component);
return H5ComponentConvert.INSTANCE.toVO(component);
}
@Override
@ -82,7 +81,7 @@ public class H5ComponentServiceImpl extends ServiceImpl<H5ComponentDao, H5Compon
Page<H5ComponentVO> voPage = new Page<>(resultPage.getCurrent(), resultPage.getSize(), resultPage.getTotal());
List<H5ComponentVO> voList = resultPage.getRecords().stream()
.map(h5ComponentConvert::toVO)
.map(H5ComponentConvert.INSTANCE::toVO)
.collect(Collectors.toList());
voPage.setRecords(voList);
@ -196,7 +195,7 @@ public class H5ComponentServiceImpl extends ServiceImpl<H5ComponentDao, H5Compon
List<H5Component> components = baseMapper.selectList(wrapper);
return components.stream()
.map(h5ComponentConvert::toVO)
.map(H5ComponentConvert.INSTANCE::toVO)
.collect(Collectors.toList());
}

View File

@ -59,6 +59,11 @@ tenant:
excludes:
- h5_group
- h5_project_group
- h5_component_category
- h5_component
- h5_tag
- h5_component_category_rel
- h5_component_tag_rel
# MyBatisPlus配置
# https://baomidou.com/config/