mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-10 20:57:14 +08:00
refactor: 优化字典管理相关 API
1.合并 DictResp 及 DictDetailResp 2.合并 DictItemResp 及 DictItemDetailResp 3.字典项增加状态 status 字段
This commit is contained in:
@@ -20,8 +20,6 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alicp.jetcache.anno.CachePenetrationProtect;
|
||||
import com.alicp.jetcache.anno.CacheRefresh;
|
||||
import com.alicp.jetcache.anno.Cached;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@@ -106,9 +104,6 @@ public class CommonController {
|
||||
@Operation(summary = "查询字典", description = "查询字典列表")
|
||||
@Parameter(name = "code", description = "字典编码", example = "announcement_type", in = ParameterIn.PATH)
|
||||
@GetMapping("/dict/{code}")
|
||||
@CachePenetrationProtect
|
||||
@CacheRefresh(refresh = 3600, stopRefreshAfterLastAccess = 7200)
|
||||
@Cached(key = "#code", name = CacheConstants.DICT_KEY_PREFIX)
|
||||
public R<List<LabelValueResp<Serializable>>> listDict(@PathVariable String code) {
|
||||
Optional<Class<?>> enumClassOptional = this.getEnumClassByName(code);
|
||||
return R.ok(enumClassOptional.map(this::listEnumDict).orElseGet(() -> dictItemService.listByDictCode(code)));
|
||||
|
@@ -17,16 +17,14 @@
|
||||
package top.charles7c.continew.admin.webapi.system;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.charles7c.continew.admin.system.model.query.DictQuery;
|
||||
import top.charles7c.continew.admin.system.model.req.DictReq;
|
||||
import top.charles7c.continew.admin.system.model.resp.DictDetailResp;
|
||||
import top.charles7c.continew.admin.system.model.resp.DictResp;
|
||||
import top.charles7c.continew.admin.system.service.DictService;
|
||||
import top.charles7c.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||
import top.charles7c.continew.starter.extension.crud.controller.BaseController;
|
||||
import top.charles7c.continew.starter.extension.crud.enums.Api;
|
||||
|
||||
/**
|
||||
* 字典管理 API
|
||||
@@ -36,5 +34,5 @@ import top.charles7c.continew.starter.extension.crud.controller.BaseController;
|
||||
*/
|
||||
@Tag(name = "字典管理 API")
|
||||
@RestController
|
||||
@CrudRequestMapping("/system/dict")
|
||||
public class DictController extends BaseController<DictService, DictResp, DictDetailResp, DictQuery, DictReq> {}
|
||||
@CrudRequestMapping(value = "/system/dict", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE})
|
||||
public class DictController extends BaseController<DictService, DictResp, DictResp, DictQuery, DictReq> {}
|
@@ -17,12 +17,9 @@
|
||||
package top.charles7c.continew.admin.webapi.system;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.charles7c.continew.admin.system.model.query.DictItemQuery;
|
||||
import top.charles7c.continew.admin.system.model.req.DictItemReq;
|
||||
import top.charles7c.continew.admin.system.model.resp.DictItemDetailResp;
|
||||
import top.charles7c.continew.admin.system.model.resp.DictItemResp;
|
||||
import top.charles7c.continew.admin.system.service.DictItemService;
|
||||
import top.charles7c.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||
@@ -38,4 +35,4 @@ import top.charles7c.continew.starter.extension.crud.enums.Api;
|
||||
@Tag(name = "字典项管理 API")
|
||||
@RestController
|
||||
@CrudRequestMapping(value = "/system/dict/item", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE})
|
||||
public class DictItemController extends BaseController<DictItemService, DictItemResp, DictItemDetailResp, DictItemQuery, DictItemReq> {}
|
||||
public class DictItemController extends BaseController<DictItemService, DictItemResp, DictItemResp, DictItemQuery, DictItemReq> {}
|
@@ -124,10 +124,10 @@ VALUES
|
||||
(547889614262632491, '公告类型', 'announcement_type', NULL, b'1', 1, NOW(), NULL, NULL);
|
||||
|
||||
INSERT INTO `sys_dict_item`
|
||||
(`id`, `label`, `value`, `color`, `sort`, `description`, `dict_id`, `create_user`, `create_time`, `update_user`, `update_time`)
|
||||
(`id`, `label`, `value`, `color`, `sort`, `description`, `status`, `dict_id`, `create_user`, `create_time`, `update_user`, `update_time`)
|
||||
VALUES
|
||||
(547889649658363951, '通知', '1', 'blue', 1, NULL, 547889614262632491, 1, NOW(), NULL, NULL),
|
||||
(547890124537462835, '活动', '2', 'orangered', 2, NULL, 547889614262632491, 1, NOW(), NULL, NULL);
|
||||
(547889649658363951, '通知', '1', 'blue', 1, NULL, 1, 547889614262632491, 1, NOW(), NULL, NULL),
|
||||
(547890124537462835, '活动', '2', 'orangered', 2, NULL, 1, 547889614262632491, 1, NOW(), NULL, NULL);
|
||||
|
||||
-- 初始化默认用户和角色关联数据
|
||||
INSERT INTO `sys_user_role`
|
||||
|
@@ -151,17 +151,18 @@ CREATE TABLE IF NOT EXISTS `sys_dict` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='字典表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sys_dict_item` (
|
||||
`id` bigint(20) NOT NULL COMMENT 'ID',
|
||||
`label` varchar(30) NOT NULL COMMENT '标签',
|
||||
`value` varchar(30) NOT NULL COMMENT '值',
|
||||
`color` varchar(30) DEFAULT NULL COMMENT '标签颜色',
|
||||
`sort` int NOT NULL DEFAULT 999 COMMENT '排序',
|
||||
`description` varchar(200) DEFAULT NULL COMMENT '描述',
|
||||
`dict_id` bigint(20) NOT NULL COMMENT '字典ID',
|
||||
`create_user` bigint(20) NOT NULL COMMENT '创建人',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_user` bigint(20) DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '修改时间',
|
||||
`id` bigint(20) NOT NULL COMMENT 'ID',
|
||||
`label` varchar(30) NOT NULL COMMENT '标签',
|
||||
`value` varchar(30) NOT NULL COMMENT '值',
|
||||
`color` varchar(30) DEFAULT NULL COMMENT '标签颜色',
|
||||
`sort` int NOT NULL DEFAULT 999 COMMENT '排序',
|
||||
`description` varchar(200) DEFAULT NULL COMMENT '描述',
|
||||
`status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态(1:启用;2:禁用)',
|
||||
`dict_id` bigint(20) NOT NULL COMMENT '字典ID',
|
||||
`create_user` bigint(20) NOT NULL COMMENT '创建人',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_user` bigint(20) DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_value_dict_id`(`value`, `dict_id`) USING BTREE,
|
||||
INDEX `idx_dict_id`(`dict_id`) USING BTREE,
|
||||
|
@@ -124,10 +124,10 @@ VALUES
|
||||
(547889614262632491, '公告类型', 'announcement_type', NULL, true, 1, NOW(), NULL, NULL);
|
||||
|
||||
INSERT INTO "sys_dict_item"
|
||||
("id", "label", "value", "color", "sort", "description", "dict_id", "create_user", "create_time", "update_user", "update_time")
|
||||
("id", "label", "value", "color", "sort", "description", "status", "dict_id", "create_user", "create_time", "update_user", "update_time")
|
||||
VALUES
|
||||
(547889649658363951, '通知', '1', 'blue', 1, NULL, 547889614262632491, 1, NOW(), NULL, NULL),
|
||||
(547890124537462835, '活动', '2', 'orangered', 2, NULL, 547889614262632491, 1, NOW(), NULL, NULL);
|
||||
(547889649658363951, '通知', '1', 'blue', 1, NULL, 547889614262632491, 1, 1, NOW(), NULL, NULL),
|
||||
(547890124537462835, '活动', '2', 'orangered', 2, NULL, 547889614262632491, 1, 1, NOW(), NULL, NULL);
|
||||
|
||||
-- 初始化默认用户和角色关联数据
|
||||
INSERT INTO "sys_user_role"
|
||||
|
@@ -256,6 +256,7 @@ CREATE TABLE IF NOT EXISTS "sys_dict_item" (
|
||||
"color" varchar(30) DEFAULT NULL,
|
||||
"sort" int4 NOT NULL DEFAULT 999,
|
||||
"description" varchar(200) DEFAULT NULL,
|
||||
"status" int2 NOT NULL DEFAULT 1,
|
||||
"dict_id" int8 NOT NULL,
|
||||
"create_user" int8 NOT NULL,
|
||||
"create_time" timestamp NOT NULL,
|
||||
@@ -273,6 +274,7 @@ COMMENT ON COLUMN "sys_dict_item"."value" IS '值';
|
||||
COMMENT ON COLUMN "sys_dict_item"."color" IS '标签颜色';
|
||||
COMMENT ON COLUMN "sys_dict_item"."sort" IS '排序';
|
||||
COMMENT ON COLUMN "sys_dict_item"."description" IS '描述';
|
||||
COMMENT ON COLUMN "sys_dict_item"."status" IS '状态(1:启用;2:禁用)';
|
||||
COMMENT ON COLUMN "sys_dict_item"."dict_id" IS '字典ID';
|
||||
COMMENT ON COLUMN "sys_dict_item"."create_user" IS '创建人';
|
||||
COMMENT ON COLUMN "sys_dict_item"."create_time" IS '创建时间';
|
||||
|
Reference in New Issue
Block a user