CREATE TABLE `t_dictionary` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`dict_id` bigint(20) NOT NULL COMMENT '业务主键',
`parent_id` bigint(20) DEFAULT NULL COMMENT '父节点主键',
`parent_path` varchar(500) DEFAULT NULL COMMENT '父节点路径, `-`号分隔',
`node_type` varchar(100) DEFAULT NULL COMMENT '节点类型: DIRECTORY / DICTIONARY',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`name_en` varchar(255) DEFAULT NULL COMMENT '英文名称',
`value` varchar(500) DEFAULT NULL COMMENT '值',
`dict_type` varchar(100) DEFAULT NULL COMMENT '字典类型(目录节点为空)',
`icon` varchar(200) DEFAULT NULL COMMENT 'icon',
`sort` tinyint(5) unsigned DEFAULT '0' COMMENT '排序',
`is_default` bit(1) DEFAULT b'0' COMMENT '是否默认',
`remark` varchar(256) DEFAULT NULL COMMENT '备注',
`status` varchar(20) DEFAULT 'NORMAL' COMMENT '状态: NORMAL / DISABLED',
`create_user` bigint(20) unsigned DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_user` bigint(20) unsigned DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`is_deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uniq_dict_id` (`dict_id`) USING BTREE COMMENT '业务主键索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='字典表';
INSERT INTO `t_dictionary`(`id`, `dict_id`, `parent_id`, `parent_path`, `node_type`, `name`, `name_en`, `value`, `dict_type`, `icon`, `sort`, `is_default`, `remark`, `status`, `create_user`, `create_time`, `update_user`, `update_time`, `is_deleted`) VALUES (1, 1, NULL, NULL, 'DIRECTORY', '游戏', NULL, NULL, NULL, NULL, 1, b'0', NULL, 'NORMAL', NULL, '2024-08-25 21:33:01', NULL, '2024-08-26 00:12:18', b'0');
INSERT INTO `t_dictionary`(`id`, `dict_id`, `parent_id`, `parent_path`, `node_type`, `name`, `name_en`, `value`, `dict_type`, `icon`, `sort`, `is_default`, `remark`, `status`, `create_user`, `create_time`, `update_user`, `update_time`, `is_deleted`) VALUES (2, 2, 1, '1', 'DIRECTORY', '英雄联盟', NULL, NULL, NULL, NULL, 1, b'0', NULL, 'NORMAL', NULL, '2024-08-25 21:33:01', NULL, '2024-08-26 00:12:11', b'0');
INSERT INTO `t_dictionary`(`id`, `dict_id`, `parent_id`, `parent_path`, `node_type`, `name`, `name_en`, `value`, `dict_type`, `icon`, `sort`, `is_default`, `remark`, `status`, `create_user`, `create_time`, `update_user`, `update_time`, `is_deleted`) VALUES (3, 3, 2, '1-2', 'DICTIONARY', '薇恩', NULL, 'VayneValue', 'LOL', NULL, 1, b'0', NULL, 'NORMAL', NULL, '2024-08-25 21:34:00', NULL, '2024-08-25 23:41:09', b'0');
INSERT INTO `t_dictionary`(`id`, `dict_id`, `parent_id`, `parent_path`, `node_type`, `name`, `name_en`, `value`, `dict_type`, `icon`, `sort`, `is_default`, `remark`, `status`, `create_user`, `create_time`, `update_user`, `update_time`, `is_deleted`) VALUES (4, 4, 2, '1-2', 'DICTIONARY', '盲僧', NULL, 'LeeSinValue', 'LOL', NULL, 2, b'0', NULL, 'NORMAL', NULL, '2024-08-25 21:35:12', NULL, '2024-08-25 23:41:51', b'0');
注意:只有叶子节点的 dict_type 为具体值,方便快速根据类型查询出字典数据。非叶子结点的 dict_type 不设定具体值,比如下面的目录结点:英雄联盟,它属于类型 GAME 还是 LOL 呢?换个角度来说,目录结点也不是实际存储字典值的结点。