config缓存bug
This commit is contained in:
parent
7b83871438
commit
0367d1ccc8
|
|
@ -8,6 +8,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import cn.hutool.json.JSONUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.IotConstants;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.entity.SurvConfig;
|
||||
import org.jeecg.common.vo.dict.DictVo;
|
||||
|
|
@ -20,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
|
|
@ -96,6 +99,7 @@ public class SurvConfigController extends JeecgController<SurvConfig, ISurvConfi
|
|||
@ApiOperation(value="业务参数配置表-编辑", notes="业务参数配置表-编辑")
|
||||
@RequiresPermissions("appmana:surv_config:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
@CacheEvict(value= {IotConstants.IOT_SURVCONFIG_CACHE}, allEntries=true)
|
||||
public Result<String> edit(@RequestBody SurvConfig survConfig, HttpServletRequest request) {
|
||||
//创建、更新时间不能编辑
|
||||
survConfig.setCreateTime(null);
|
||||
|
|
@ -119,6 +123,7 @@ public class SurvConfigController extends JeecgController<SurvConfig, ISurvConfi
|
|||
@ApiOperation(value="业务参数配置表-通过id删除", notes="业务参数配置表-通过id删除")
|
||||
@RequiresPermissions("appmana:surv_config:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
@CacheEvict(value= {IotConstants.IOT_SURVCONFIG_CACHE}, allEntries=true)
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
survConfigService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import org.jeecg.modules.appmana.service.ISurvHisdataOrientwaterService;
|
|||
import org.jeecg.modules.appmana.service.ISurvHisdataSoilService;
|
||||
import org.jeecg.common.vo.VOHisResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
|
@ -34,6 +35,7 @@ public class CommonServiceImpl {
|
|||
@Autowired
|
||||
private ISurvHisdataLivestockwaterService hisdataLivestockwaterService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private SurvConfigServiceImpl configService;
|
||||
|
||||
/**
|
||||
|
|
@ -146,4 +148,9 @@ public class CommonServiceImpl {
|
|||
}
|
||||
return survConfig;
|
||||
}
|
||||
|
||||
public SurvConfig queryCacheSurvConfig(String tenantId,String configType){
|
||||
return configService.getCacheConfig(tenantId, configType);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ import org.jeecg.common.entity.SurvConfig;
|
|||
import org.jeecg.common.vo.dict.DictVo;
|
||||
import org.jeecg.modules.appmana.mapper.SurvConfigMapper;
|
||||
import org.jeecg.modules.appmana.service.ISurvConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
@ -30,17 +32,25 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class SurvConfigServiceImpl extends ServiceImpl<SurvConfigMapper, SurvConfig> implements ISurvConfigService {
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private CommonServiceImpl commonService;
|
||||
|
||||
@Override
|
||||
public String getValueByKey(String key) {
|
||||
return baseMapper.getValueByKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = IotConstants.IOT_SURVCONFIG_CACHE, key = "#tenantId+':'+#type", unless = "#result == null ")
|
||||
public SurvConfig getOneByTypeWithTenant(String tenantId, String type) {
|
||||
if(StringUtils.isBlank(tenantId)){
|
||||
tenantId = "0";
|
||||
}
|
||||
return commonService.queryCacheSurvConfig(tenantId,type);
|
||||
}
|
||||
|
||||
@Cacheable(value = IotConstants.IOT_SURVCONFIG_CACHE, key = "#tenantId+':'+#type", unless = "#result == null ")
|
||||
public SurvConfig getCacheConfig(String tenantId, String type) {
|
||||
return baseMapper.getOneByTypeWithTenant(tenantId, type);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue