fix 77980 标签项管理--展示区域管理 修改展示区域后,使用该展示区域的数据,没有自动更新
This commit is contained in:
@@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jero.common.api.CommonAPI;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.Dict;
|
||||
import com.jero.common.constant.CacheConstant;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.common.system.vo.DictModel;
|
||||
import com.jero.common.util.oConvertUtils;
|
||||
@@ -299,7 +300,7 @@ public class DictAspect {
|
||||
private void setRedis(String dictCode, List<DictModel> texts) {
|
||||
// 做 redis 缓存
|
||||
for (DictModel dict : texts) {
|
||||
String redisKey = String.format("sys:cache:dictTable::SimpleKey [%s,%s]", dictCode, dict.getValue());
|
||||
String redisKey = String.format(CacheConstant.SYS_DICT_TABLE_CACHE_SIMPLE_KEY, dictCode, dict.getValue());
|
||||
try {
|
||||
// 保留10分钟
|
||||
redisTemplate.opsForValue().set(redisKey, dict.getText(), 600, TimeUnit.SECONDS);
|
||||
@@ -316,7 +317,7 @@ public class DictAspect {
|
||||
continue; //跳过循环
|
||||
}
|
||||
if (dictCode.contains(",")) {
|
||||
String keyString = String.format("sys:cache:dictTable::SimpleKey [%s,%s]", dictCode, data);
|
||||
String keyString = String.format(CacheConstant.SYS_DICT_TABLE_CACHE_SIMPLE_KEY, dictCode, data);
|
||||
if (Boolean.TRUE.equals(redisTemplate.hasKey(keyString))) {
|
||||
addList(translText, dictCode, data, keyString);
|
||||
} else if (!needTranslDataTable.contains(data)) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.jero.common.constant;
|
||||
|
||||
import org.springframework.cache.interceptor.SimpleKey;
|
||||
|
||||
/**
|
||||
* @author: huangxutao
|
||||
* @date: 2019-06-14
|
||||
@@ -26,6 +28,8 @@ public class CacheConstant {
|
||||
public static final String SYS_DICT_TABLE_CACHE = "sys:cache:dictTable";
|
||||
public static final String SYS_DICT_TABLE_BY_KEYS_CACHE = SYS_DICT_TABLE_CACHE + "ByKeys";
|
||||
|
||||
public static final String SYS_DICT_TABLE_CACHE_SIMPLE_KEY = SYS_DICT_TABLE_CACHE + "::SimpleKey [%s,%s]";
|
||||
|
||||
/**
|
||||
* 数据权限配置缓存
|
||||
*/
|
||||
|
||||
+21
-12
@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.common.constant.CacheConstant;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.common.util.RedisUtil;
|
||||
import com.jero.modules.system.service.ISysDictItemService;
|
||||
import com.jero.modules.tag.entity.LawsArea;
|
||||
import com.jero.modules.tag.service.ILawsAreaService;
|
||||
@@ -44,6 +46,10 @@ public class LawsAreaController extends JeroController<LawsArea, ILawsAreaServic
|
||||
private ISysDictItemService sysDictItemService;
|
||||
@Autowired
|
||||
private ILawsTagService lawsTagService;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
private static final String REDIS_KEY = "laws_area,show_area,id";
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
@@ -117,20 +123,23 @@ public class LawsAreaController extends JeroController<LawsArea, ILawsAreaServic
|
||||
@RequiresPermissions("area:edit")
|
||||
public Result<?> edit(@Validated @RequestBody LawsArea lawsArea) {
|
||||
|
||||
QueryWrapper<LawsArea> queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.eq("show_area", lawsArea.getShowArea()).eq("is_model", lawsArea.getIsModel());
|
||||
List<LawsArea> existAreaList= lawsAreaService.list(queryWrapper);
|
||||
if(!existAreaList.isEmpty()){//有同名数据
|
||||
if(existAreaList.get(0).getId().equals(lawsArea.getId())) {//已存在同名的数据,就是正在编辑的这个
|
||||
lawsAreaService.editById(lawsArea);
|
||||
return Result.OK(ResultCommon.EDIT_OK);
|
||||
}else {
|
||||
return Result.error(ResultCommon.TAG_ERROR_1);
|
||||
}
|
||||
}else {
|
||||
QueryWrapper<LawsArea> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("show_area", lawsArea.getShowArea()).eq("is_model", lawsArea.getIsModel());
|
||||
List<LawsArea> existAreaList = lawsAreaService.list(queryWrapper);
|
||||
//有同名数据
|
||||
if (!existAreaList.isEmpty()) {
|
||||
//已存在同名的数据,就是正在编辑的这个
|
||||
if (existAreaList.get(0).getId().equals(lawsArea.getId())) {
|
||||
lawsAreaService.editById(lawsArea);
|
||||
} else {
|
||||
return Result.error(ResultCommon.TAG_ERROR_1);
|
||||
}
|
||||
} else {
|
||||
lawsAreaService.editById(lawsArea);
|
||||
return Result.OK(ResultCommon.EDIT_OK);
|
||||
}
|
||||
//编辑后要清除redis缓存
|
||||
redisUtil.del(String.format(CacheConstant.SYS_DICT_TABLE_CACHE_SIMPLE_KEY,REDIS_KEY,lawsArea.getId()));
|
||||
return Result.OK(ResultCommon.EDIT_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user