用户密码加密侧率功能完成
parent
73629bfd1f
commit
af5a43a4c5
@ -0,0 +1,41 @@
|
||||
package cn.estsh.i3plus.core.api.iservice.base;
|
||||
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @Description : 系统启动加载服务
|
||||
* @Reference :
|
||||
* @Author : Adair Peng
|
||||
* @CreateDate : 2019-01-11 10:02
|
||||
* @Modify:
|
||||
**/
|
||||
public interface ISystemInitService {
|
||||
|
||||
/**
|
||||
* 系统初始化加载
|
||||
*/
|
||||
@ApiOperation(value = "初始化加载所有数据",notes = "初始化加载所有数据")
|
||||
void loadAll();
|
||||
|
||||
/**
|
||||
* 加载系统配置
|
||||
*/
|
||||
@ApiOperation(value = "加载系统配置",notes = "加载系统配置")
|
||||
void loadSysConfig();
|
||||
|
||||
/**
|
||||
* 加载系统字典
|
||||
*/
|
||||
@ApiOperation(value = "加载字典数据",notes = "加载字典数据")
|
||||
void loadSysDictionary();
|
||||
|
||||
/**
|
||||
* 加载系统语言信息
|
||||
*/
|
||||
@ApiOperation(value = "加载语言数据",notes = "加载语言数据")
|
||||
void loadSysLocaleLanguage();
|
||||
|
||||
@ApiOperation(value = "获取缓存中的数据",notes = "获取缓存中的数据")
|
||||
Object getDataFromCache(String key,Class dataType);
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.estsh.i3plus.core.apiservice.configuration;
|
||||
|
||||
import cn.estsh.i3plus.core.api.iservice.base.ISystemInitService;
|
||||
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
* @Reference :
|
||||
* @Author : Adair Peng
|
||||
* @CreateDate : 2019-01-11 9:55
|
||||
* @Modify:
|
||||
**/
|
||||
@Component
|
||||
public class AppStartSystemInit implements CommandLineRunner {
|
||||
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(CommonConstWords.SYSTEM_LOG);
|
||||
|
||||
@Autowired
|
||||
private ISystemInitService systemInitService;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
LOGGER.info(" Start Core Init Thread ");
|
||||
systemInitService.loadAll();
|
||||
}
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
package cn.estsh.i3plus.core.apiservice.serviceimpl.base;
|
||||
|
||||
import cn.estsh.i3plus.core.api.iservice.base.ISystemInitService;
|
||||
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.platform.bean.SysConfig;
|
||||
import cn.estsh.i3plus.pojo.platform.bean.SysDictionary;
|
||||
import cn.estsh.i3plus.pojo.platform.repository.SysConfigRepository;
|
||||
import cn.estsh.i3plus.pojo.platform.repository.SysDictionaryRepository;
|
||||
import cn.estsh.i3plus.pojo.platform.repository.SysLocaleLanguageRepository;
|
||||
import cn.estsh.impp.framework.boot.util.ImppRedis;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
* @Reference :
|
||||
* @Author : Adair Peng
|
||||
* @CreateDate : 2019-01-11 12:34
|
||||
* @Modify:
|
||||
**/
|
||||
@Service
|
||||
public class SystemInitService implements ISystemInitService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SystemLoginService.class);
|
||||
|
||||
@Autowired
|
||||
private SysConfigRepository configRDao;
|
||||
|
||||
@Autowired
|
||||
private SysDictionaryRepository dictionaryRDao;
|
||||
|
||||
@Autowired
|
||||
private SysLocaleLanguageRepository localeLanguageRDao;
|
||||
|
||||
@Resource(name="redisRes")
|
||||
private ImppRedis redisRes;
|
||||
|
||||
private int type = ImppEnumUtil.SYS_CACHE_TYPE.REDIS.getValue();
|
||||
|
||||
@Override
|
||||
@ApiOperation(value = "初始化加载所有数据",notes = "初始化加载所有数据")
|
||||
public void loadAll() {
|
||||
type = ImppEnumUtil.SYS_CACHE_TYPE.REDIS.getValue();
|
||||
loadSysConfig();
|
||||
loadSysDictionary();
|
||||
loadSysLocaleLanguage();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ApiOperation(value = "加载系统配置",notes = "加载系统配置")
|
||||
public void loadSysConfig() {
|
||||
String redisKey = null;
|
||||
List<SysConfig> list = configRDao.findAll();
|
||||
for (SysConfig config : list) {
|
||||
redisKey = CommonConstWords.REDIS_PREFIX_CACHE_CONFIG + "_" + config.getConfigCode();
|
||||
|
||||
//存放于缓存
|
||||
putDataToCache(redisKey, config,SysConfig.class);
|
||||
}
|
||||
LOGGER.info("加载系统配置数量:【{}】",list.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ApiOperation(value = "加载字典数据",notes = "加载字典数据")
|
||||
public void loadSysDictionary() {
|
||||
List<SysDictionary> list = dictionaryRDao.findAll();
|
||||
if(list != null && list.size() > 0){
|
||||
Map<String, List<SysDictionary>> parentCodeMap = list.stream().collect(Collectors.groupingBy(SysDictionary::getParentCodeRdd));
|
||||
Map<Long, List<SysDictionary>> parentIdMap = list.stream().collect(Collectors.groupingBy(SysDictionary::getParentId));
|
||||
|
||||
for (String key : parentCodeMap.keySet()) {
|
||||
//存放于缓存
|
||||
putDataToCache(CommonConstWords.REDIS_PREFIX_CACHE_DICTIONARY + "_" + key,
|
||||
parentCodeMap.get(key),List.class);
|
||||
}
|
||||
|
||||
for (long key : parentIdMap.keySet()) {
|
||||
putDataToCache(CommonConstWords.REDIS_PREFIX_CACHE_DICTIONARY + "_" + key,
|
||||
parentIdMap.get(key),List.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ApiOperation(value = "加载语言数据",notes = "加载语言数据")
|
||||
public void loadSysLocaleLanguage() {
|
||||
// Redis 缓存
|
||||
if(type == ImppEnumUtil.SYS_CACHE_TYPE.REDIS.getValue()){
|
||||
// TODO 汪云昊 实现
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 缓存存放数据统一管理
|
||||
* @param key
|
||||
* @param data
|
||||
* @param dataType
|
||||
*/
|
||||
private void putDataToCache(String key,Object data,Class dataType){
|
||||
if(type == ImppEnumUtil.SYS_CACHE_TYPE.REDIS.getValue()){
|
||||
LOGGER.info(" Put Cache Redis Key:{},value:{},dataType:{}",key,data,dataType);
|
||||
// Redis 缓存
|
||||
if(dataType == List.class){
|
||||
redisRes.putList(key,data,-1);
|
||||
}else if(dataType == SysConfig.class){
|
||||
redisRes.putObject(key,data,-1);
|
||||
}else{
|
||||
LOGGER.error("不支持树形{}存放缓存!",dataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从缓存获取对象数据
|
||||
* @param key
|
||||
* @param dataType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@ApiOperation(value = "获取缓存中的数据",notes = "获取缓存中的数据")
|
||||
public Object getDataFromCache(String key,Class dataType){
|
||||
if(type == ImppEnumUtil.SYS_CACHE_TYPE.REDIS.getValue()){
|
||||
// Redis 缓存
|
||||
if(dataType == List.class){
|
||||
return redisRes.getList(key,0,-1);
|
||||
}else if(dataType == SysConfig.class){
|
||||
return redisRes.getObject(key);
|
||||
}else{
|
||||
LOGGER.error("不支持树形{}存放缓存!",dataType);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue