fix: 修复参数缓存未及时过期的问题

This commit is contained in:
Charles7c 2024-02-20 22:19:34 +08:00
parent 6be1b6cfb1
commit 976e9c43df
3 changed files with 9 additions and 9 deletions

View File

@ -16,16 +16,14 @@
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.Serializable;
import java.util.List;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* 参数重置信息
*

View File

@ -17,7 +17,6 @@
package top.charles7c.continew.admin.system.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.alicp.jetcache.anno.CacheInvalidate;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
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.resp.OptionResp;
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 java.util.List;
@ -51,12 +52,13 @@ public class OptionServiceImpl implements OptionService {
@Override
public void update(List<OptionReq> req) {
RedisUtils.deleteByPattern(CacheConstants.OPTION_KEY_PREFIX + StringConstants.ASTERISK);
baseMapper.updateBatchById(BeanUtil.copyToList(req, OptionDO.class));
}
@Override
@CacheInvalidate(key = "#req.code", name = CacheConstants.OPTION_KEY_PREFIX, multi = true)
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();
}
}

View File

@ -116,7 +116,7 @@ public class CommonController {
@SaIgnore
@Operation(summary = "查询参数", description = "查询参数")
@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) {
return R.ok(optionService.list(query)
.stream()