CREATE TABLE `sys_dict` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`type_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字典类型编码',
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '字典项名称',
`value` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '字典项值'
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=417 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='字典数据表';
(2) Mypper.xml
<select id="translateDictByKeys" resultType="com.wangyao.common.database.model.DictModel">
select
${name} as "value",
${value} as "code"
from sys_dict
where ${value}
IN (
<foreach item="key" collection="keys" separator=",">
#{key}
</foreach>
)
</select>
<select id="queryManyDictByKeys" resultType="com.wangyao.common.database.model.DictModelMany">
SELECT
item.type_code AS dictCode,
item.name AS "value",
item.value AS "code"
FROM
sys_dict item
WHERE item.type_code IN (
<foreach item="dictCode" collection="dictCodeList" separator=",">
#{dictCode}
</foreach>
)
AND item.value IN (
<foreach item="key" collection="keys" separator=",">
#{key}
</foreach>
)
</select>
<select id="translateAllDict" resultType="com.wangyao.common.database.model.DictModelMany">
select
type_code as "dictCode",
name as "value",
`value` as "code"
from sys_dict
</select>