jeecgboot 框架改造
上篇 jeecgboot 改造@Dict注解 实现可以翻译list集合 实体 以及map集合 文章中留个续集
@Slf4j
@Component
public class JeecgUtils {
@Autowired
public RedisTemplate redisTemplate;
@Lazy
@Autowired
private CommonAPI commonApi;
/**
* 翻译字典文本
* @param code
* @param text
* @param table
* @param key
* @return
*/
public String translateDictValue(String code, String text, String table, String key) {
if(oConvertUtils.isEmpty(key)) {
return null;
}
StringBuffer textValue=new StringBuffer();
String[] keys = key.split(",");
for (String k : keys) {
String tmpValue = null;
log.debug(" 字典 key : "+ k);
if (k.trim().length() == 0) {
continue; //跳过循环
}
if (!StringUtils.isEmpty(table)){
log.debug("--DictAspect------dicTable="+ table+" ,dicText= "+text+" ,dicCode="+code);
String keyString = String.format("sys:cache:dictTable::SimpleKey [%s,%s,%s,%s]",table,text,code,k.trim());
if (redisTemplate.hasKey(keyString)){
try {
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
} catch (Exception e) {
log.warn(e.getMessage());
}
}else {
tmpValue= commonApi.translateDictFromTable(table,text,code,k.trim());
}
}else {
String keyString = String.format("sys:cache:dict::%s:%s",code,k.trim());
if (redisTemplate.hasKey(keyString)){
try {
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
} catch (Exception e) {
log.warn(e.getMessage());
}
}else {
tmpValue = commonApi.translateDict(code, k.trim());
}
}
if (tmpValue != null) {
if (!"".equals(textValue.toString())) {
textValue.append(",");
}
textValue.append(tmpValue);
}
}
return textValue.toString();
}
}
本文链接:https://nwjshm.cn/archives/38.html
阿猪的博客
https://yfzhu.cn/
流量卡知识网
http://53go.cn/
专注于移动 / 联通 / 电信运营商官方推出的大流量多语音活动长短期套餐手机卡的相关知识的介绍普及听说互换友情链接可以增加网站的收录量,特此来换,如果同意的话就给 internetyewu@163.com[微信 ganenboy] 发信息或者就在此回复下吧!【建站问题也可以一起讨论!】