Commit c9e3d48c authored by fangxinjiang's avatar fangxinjiang

清理字典缓存-缓存更新

parent ca290086
...@@ -27,6 +27,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -27,6 +27,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDict; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDict;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem;
import com.yifu.cloud.plus.v1.yifu.admin.init.DictItemRedisInit;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDictItemMapper; import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDictItemMapper;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDictItemService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysDictItemService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDictService; import com.yifu.cloud.plus.v1.yifu.admin.service.SysDictService;
...@@ -39,6 +40,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils; ...@@ -39,6 +40,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil; import com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -57,6 +59,7 @@ import java.util.stream.Collectors; ...@@ -57,6 +59,7 @@ import java.util.stream.Collectors;
* @author lengleng * @author lengleng
* @date 2019/03/19 * @date 2019/03/19
*/ */
@Log4j2
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements SysDictItemService { public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements SysDictItemService {
...@@ -233,7 +236,14 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi ...@@ -233,7 +236,14 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
@CacheEvict(value = CacheConstants.DICT_ITEM_DETAILS, allEntries = true) @CacheEvict(value = CacheConstants.DICT_ITEM_DETAILS, allEntries = true)
@Override @Override
public void clearDictItemCache() { public void clearDictItemCache() {
log.info("字典数据加入缓存初始化开始...");
Map<String, Object> dictItem = this.getAllDictItemSub();
if (Common.isNotNull(dictItem)){
for (Map.Entry<String,Object> entry:dictItem.entrySet()){
redisUtil.set(entry.getKey(),entry.getValue());
}
}
log.info("字典数据加入缓存初始化结束...");
} }
private void extracted(List<SysDictItem> allList, Map<String, Object> resultMap) { private void extracted(List<SysDictItem> allList, Map<String, Object> resultMap) {
if (Common.isNotNull(allList)){ if (Common.isNotNull(allList)){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment