|
|
|
@ -1,26 +1,39 @@
|
|
|
|
|
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysLocaleResourceService;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.BeanCopyTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.SerializeTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.util.StringUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleLanguage;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleResource;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysMenu;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.repository.SysLocaleLanguageRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.repository.SysLocaleResourceRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ImppRedis;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description : 系统资源
|
|
|
|
@ -39,6 +52,10 @@ public class SysLocaleResourceService implements ISysLocaleResourceService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysLocaleLanguageRepository sysLocaleLanguageRDao;
|
|
|
|
|
|
|
|
|
|
@Resource(name= CommonConstWords.IMPP_REDIS_RES)
|
|
|
|
|
private ImppRedis redisRes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ApiOperation(value = "新增系统资源")
|
|
|
|
|
public SysLocaleResource insertSysLocaleResource(SysLocaleResource sysLocaleResource) {
|
|
|
|
@ -174,4 +191,67 @@ public class SysLocaleResourceService implements ISysLocaleResourceService {
|
|
|
|
|
public SysLocaleResource getSysLocaleResourceById(Long id) {
|
|
|
|
|
return sysLocaleResourceRDao.getById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SysMenu> tranSysMenu(List<SysMenu> menuList) {
|
|
|
|
|
if(menuList != null && menuList.size() > 0){
|
|
|
|
|
String languageCode = (String) AuthUtil.getSessionLanguage();
|
|
|
|
|
List<SysLocaleLanguage> languageList = sysLocaleLanguageRDao.list();
|
|
|
|
|
menuList = (List<SysMenu>) SerializeTool.copyObject(menuList);
|
|
|
|
|
Map<String,String> resourceMap = new HashMap<>();
|
|
|
|
|
List<SysLocaleResource> insertList = new ArrayList<>();
|
|
|
|
|
SysLocaleResource insert = null;
|
|
|
|
|
String redisMenuKey = null;
|
|
|
|
|
String redisMenuParentKey = null;
|
|
|
|
|
|
|
|
|
|
for (SysMenu menu : menuList) {
|
|
|
|
|
if(menu != null){
|
|
|
|
|
redisMenuKey = CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE +":" + menu.getName();
|
|
|
|
|
redisMenuParentKey = CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE +":" + menu.getParentId();
|
|
|
|
|
Map menuResourceMap = redisRes.getHashMap(redisMenuKey);
|
|
|
|
|
Map menuParentSesourceMap = redisRes.getHashMap(redisMenuParentKey);
|
|
|
|
|
|
|
|
|
|
if(menuResourceMap == null || menuResourceMap.size() <= 0){
|
|
|
|
|
menuResourceMap = new HashMap();
|
|
|
|
|
if(languageList != null){
|
|
|
|
|
for (SysLocaleLanguage language : languageList) {
|
|
|
|
|
insert = new SysLocaleResource();
|
|
|
|
|
insert.setResourceType(CommonEnumUtil.SYS_LOCALE_RESOURCE_TYPE.MENU.getValue());
|
|
|
|
|
insert.setLanguageCode(language.getLanguageCode());
|
|
|
|
|
insert.setLanguageNameRdd(language.getLanguageName());
|
|
|
|
|
insert.setResourceKey(menu.getName());
|
|
|
|
|
insert.setResourceValue(menu.getName());
|
|
|
|
|
insert.setIsSystem(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
ConvertBean.serviceModelInitialize(insert, PlatformConstWords.SYSTEM_INIT_USER);
|
|
|
|
|
|
|
|
|
|
insertList.add(insert);
|
|
|
|
|
menuResourceMap.put(language.getLanguageCode(),insert.getResourceValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 保存 Redis */
|
|
|
|
|
redisRes.putHashMap(redisMenuKey, menuResourceMap, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 菜单名称 国际化 */
|
|
|
|
|
if(menuResourceMap != null && menuResourceMap.size() > 0){
|
|
|
|
|
String menuName = (String)menuResourceMap.get(languageCode);
|
|
|
|
|
menu.setName(StringUtils.isNotBlank(menuName) ? menuName : menu.getName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 功能菜单 父节点国际化 */
|
|
|
|
|
if(menuParentSesourceMap != null && menuParentSesourceMap.size() > 0){
|
|
|
|
|
String parentNameRdd = (String)menuParentSesourceMap.get(languageCode);
|
|
|
|
|
menu.setParentNameRdd(StringUtils.isNotBlank(parentNameRdd) ? parentNameRdd : menu.getParentNameRdd());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 保存资源信息 */
|
|
|
|
|
if(insertList != null && insertList.size() > 0){
|
|
|
|
|
sysLocaleResourceRDao.saveAll(insertList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return menuList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|