fix: 修复参数缓存未及时过期的问题
This commit is contained in:
parent
6be1b6cfb1
commit
976e9c43df
@ -16,16 +16,14 @@
|
|||||||
|
|
||||||
package top.charles7c.continew.admin.system.model.req;
|
package top.charles7c.continew.admin.system.model.req;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数重置信息
|
* 参数重置信息
|
||||||
*
|
*
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package top.charles7c.continew.admin.system.service.impl;
|
package top.charles7c.continew.admin.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.alicp.jetcache.anno.CacheInvalidate;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import top.charles7c.continew.admin.common.constant.CacheConstants;
|
import top.charles7c.continew.admin.common.constant.CacheConstants;
|
||||||
@ -28,6 +27,8 @@ import top.charles7c.continew.admin.system.model.req.OptionReq;
|
|||||||
import top.charles7c.continew.admin.system.model.req.OptionResetValueReq;
|
import top.charles7c.continew.admin.system.model.req.OptionResetValueReq;
|
||||||
import top.charles7c.continew.admin.system.model.resp.OptionResp;
|
import top.charles7c.continew.admin.system.model.resp.OptionResp;
|
||||||
import top.charles7c.continew.admin.system.service.OptionService;
|
import top.charles7c.continew.admin.system.service.OptionService;
|
||||||
|
import top.charles7c.continew.starter.cache.redisson.util.RedisUtils;
|
||||||
|
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||||
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryWrapperHelper;
|
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryWrapperHelper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -51,12 +52,13 @@ public class OptionServiceImpl implements OptionService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(List<OptionReq> req) {
|
public void update(List<OptionReq> req) {
|
||||||
|
RedisUtils.deleteByPattern(CacheConstants.OPTION_KEY_PREFIX + StringConstants.ASTERISK);
|
||||||
baseMapper.updateBatchById(BeanUtil.copyToList(req, OptionDO.class));
|
baseMapper.updateBatchById(BeanUtil.copyToList(req, OptionDO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CacheInvalidate(key = "#req.code", name = CacheConstants.OPTION_KEY_PREFIX, multi = true)
|
|
||||||
public void resetValue(OptionResetValueReq req) {
|
public void resetValue(OptionResetValueReq req) {
|
||||||
|
RedisUtils.deleteByPattern(CacheConstants.OPTION_KEY_PREFIX + StringConstants.ASTERISK);
|
||||||
baseMapper.lambdaUpdate().set(OptionDO::getValue, null).in(OptionDO::getCode, req.getCode()).update();
|
baseMapper.lambdaUpdate().set(OptionDO::getValue, null).in(OptionDO::getCode, req.getCode()).update();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -116,7 +116,7 @@ public class CommonController {
|
|||||||
@SaIgnore
|
@SaIgnore
|
||||||
@Operation(summary = "查询参数", description = "查询参数")
|
@Operation(summary = "查询参数", description = "查询参数")
|
||||||
@GetMapping("/option")
|
@GetMapping("/option")
|
||||||
@Cached(name = CacheConstants.OPTION_KEY_PREFIX)
|
@Cached(key = "#query.code", name = CacheConstants.OPTION_KEY_PREFIX)
|
||||||
public R<List<LabelValueResp<String>>> listOption(@Validated OptionQuery query) {
|
public R<List<LabelValueResp<String>>> listOption(@Validated OptionQuery query) {
|
||||||
return R.ok(optionService.list(query)
|
return R.ok(optionService.list(query)
|
||||||
.stream()
|
.stream()
|
||||||
|
Loading…
Reference in New Issue
Block a user