Merge pull request '清除redis缓存' (#15) from master-xiantao-lhj0830 into test

Reviewed-on: http://192.168.0.40:3000/root/nflg_project/pulls/15
This commit is contained in:
10002327 2024-09-05 10:19:20 +08:00
commit 7ccae15631
1 changed files with 15 additions and 5 deletions

View File

@ -8,12 +8,12 @@ import com.nflg.product.bomnew.service.BomNewLogService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import nflg.product.common.vo.ResultVO; import nflg.product.common.vo.ResultVO;
import org.springframework.web.bind.annotation.PostMapping; import org.hibernate.validator.constraints.Length;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Set;
/** /**
* t_bom_new_log 表控制层 * t_bom_new_log 表控制层
@ -27,6 +27,8 @@ import javax.annotation.Resource;
@RequestMapping("bomNewLogEntity") @RequestMapping("bomNewLogEntity")
public class BomNewLogApi extends BaseApi { public class BomNewLogApi extends BaseApi {
@Resource
private RedisTemplate<String, String> redisTemplate;
/** /**
* 服务对象 * 服务对象
*/ */
@ -44,7 +46,15 @@ public class BomNewLogApi extends BaseApi {
public ResultVO<IPage<BomNewLogEntity>> selectBomNewLogEntityPageByCondition(@RequestBody BomNewLogQuery query) { public ResultVO<IPage<BomNewLogEntity>> selectBomNewLogEntityPageByCondition(@RequestBody BomNewLogQuery query) {
return ResultVO.success(bomNewLogService.getListByPage(query)); return ResultVO.success(bomNewLogService.getListByPage(query));
} }
@GetMapping("delRedisKey")
public ResultVO<Long> delRedisKey(@RequestParam(name = "key") @Length(min = 4, message = "长度不能少于4个字符") String key){
Set<String> keys = redisTemplate.keys(key);
if(!keys.isEmpty()){
return ResultVO.success(redisTemplate.delete(keys));
}
return ResultVO.success(0l);
}
} }