治理字典存储redis
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.njcn.system.init;
|
||||
|
||||
import com.njcn.system.service.IEleEpdPqdService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class InitEpdPqd implements CommandLineRunner {
|
||||
|
||||
private final IEleEpdPqdService epdPqdService;
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
epdPqdService.refreshEpdPqdDataCache();
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ import com.njcn.system.pojo.param.EleEpdPqdParam;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
|
||||
import com.njcn.system.pojo.vo.EleEpdPqdVO;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -23,6 +21,12 @@ import java.util.Map;
|
||||
*/
|
||||
public interface IEleEpdPqdService extends IService<EleEpdPqd> {
|
||||
|
||||
/**
|
||||
* 刷新epd内容
|
||||
*/
|
||||
void refreshEpdPqdDataCache();
|
||||
|
||||
|
||||
/**
|
||||
* 存储模板的字典数据
|
||||
* @param eleEpdPqdParam
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.enums.SystemResponseEnum;
|
||||
import com.njcn.system.mapper.EleEpdPqdMapper;
|
||||
import com.njcn.system.pojo.dto.EpdDTO;
|
||||
@@ -43,6 +45,18 @@ public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd
|
||||
|
||||
private final IDictDataService idictDataService;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public void refreshEpdPqdDataCache() {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
List<EpdDTO> list = findAll();
|
||||
list.forEach(item->{
|
||||
map.put(item.getDictName(),item.getTableName());
|
||||
});
|
||||
redisUtil.saveByKey(AppRedisKey.ELE_EPD_PQD,map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData(List<EleEpdPqdParam> eleEpdPqdParam) {
|
||||
List<EleEpdPqd> list = eleEpdPqdParam.stream().map(item->{
|
||||
@@ -58,7 +72,10 @@ public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd
|
||||
return eleEpdPqd;
|
||||
}).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
this.saveBatch(list,1000);
|
||||
boolean result = this.saveBatch(list,1000);
|
||||
if (result) {
|
||||
refreshEpdPqdDataCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +91,10 @@ public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd
|
||||
eleEpdPqd.setPhase("M");
|
||||
}
|
||||
eleEpdPqd.setStatus(1);
|
||||
this.save(eleEpdPqd);
|
||||
boolean result = this.save(eleEpdPqd);
|
||||
if (result) {
|
||||
refreshEpdPqdDataCache();
|
||||
}
|
||||
return eleEpdPqd;
|
||||
}
|
||||
|
||||
@@ -82,7 +102,10 @@ public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd
|
||||
public void delete(String id) {
|
||||
EleEpdPqd eleEpdPqd = this.lambdaQuery().eq(EleEpdPqd::getId,id).one();
|
||||
eleEpdPqd.setStatus(0);
|
||||
this.updateById(eleEpdPqd);
|
||||
boolean result = this.updateById(eleEpdPqd);
|
||||
if (result) {
|
||||
refreshEpdPqdDataCache();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,7 +120,10 @@ public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd
|
||||
if (Objects.isNull(updateParam.getPhase())){
|
||||
eleEpdPqd.setPhase("M");
|
||||
}
|
||||
this.updateById(eleEpdPqd);
|
||||
boolean result = this.updateById(eleEpdPqd);
|
||||
if (result) {
|
||||
refreshEpdPqdDataCache();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user