fix: 静态字典和动态字典转换中文方法
This commit is contained in:
parent
a37c7248ab
commit
0d6647aa45
@ -1,6 +1,7 @@
|
||||
package com.yfd.platform.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
||||
import com.yfd.platform.system.domain.SysDictionary;
|
||||
import com.yfd.platform.system.domain.SysDictionaryItems;
|
||||
@ -106,6 +107,46 @@ public class DictCodeToNameConverter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页结果转换:将 Page 中所有记录的 code 字段转换为对应的 name 字段
|
||||
*
|
||||
* <pre>
|
||||
* 使用示例:
|
||||
* Page<SdHbrvDic> page = hbrvDicService.queryPageList(...);
|
||||
* dictCodeToNameConverter.convertCodeToName(page, CODE_TO_NAME_META_LIST);
|
||||
* </pre>
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param metadataList 元数据配置列表
|
||||
* @param <T> VO 类型
|
||||
*/
|
||||
public <T> void convertCodeToName(Page<T> page, List<CodeToNameMetadataBo> metadataList) {
|
||||
if (page == null || page.getRecords() == null || page.getRecords().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
convertCodeToName(page.getRecords(), metadataList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个对象转换:将单个对象的 code 字段转换为对应的 name 字段
|
||||
*
|
||||
* <pre>
|
||||
* 使用示例:
|
||||
* SdHbrvDic hbrvDic = hbrvDicService.getById(hbrvcd);
|
||||
* dictCodeToNameConverter.convertCodeToName(hbrvDic, CODE_TO_NAME_META_LIST);
|
||||
* </pre>
|
||||
*
|
||||
* @param obj 单个对象
|
||||
* @param metadataList 元数据配置列表
|
||||
* @param <T> VO 类型
|
||||
*/
|
||||
public <T> void convertCodeToName(T obj, List<CodeToNameMetadataBo> metadataList) {
|
||||
if (obj == null || metadataList == null || metadataList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
convertCodeToName(Collections.singletonList(obj), metadataList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载静态字典映射
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user