From c02ecb336d38cf85d43f0e66eeac571097a88a5c Mon Sep 17 00:00:00 2001 From: 10002327 Date: Thu, 5 Sep 2024 10:12:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E9=99=A4redis=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/api/user/BomNewLogApi.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BomNewLogApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BomNewLogApi.java index 15908bc1..cd01fa97 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BomNewLogApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BomNewLogApi.java @@ -8,12 +8,12 @@ import com.nflg.product.bomnew.service.BomNewLogService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import nflg.product.common.vo.ResultVO; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.hibernate.validator.constraints.Length; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.Set; /** * t_bom_new_log 表控制层 @@ -27,6 +27,8 @@ import javax.annotation.Resource; @RequestMapping("bomNewLogEntity") public class BomNewLogApi extends BaseApi { + @Resource + private RedisTemplate redisTemplate; /** * 服务对象 */ @@ -44,7 +46,15 @@ public class BomNewLogApi extends BaseApi { public ResultVO> selectBomNewLogEntityPageByCondition(@RequestBody BomNewLogQuery query) { return ResultVO.success(bomNewLogService.getListByPage(query)); } - + + @GetMapping("delRedisKey") + public ResultVO delRedisKey(@RequestParam(name = "key") @Length(min = 4, message = "长度不能少于4个字符") String key){ + Set keys = redisTemplate.keys(key); + if(!keys.isEmpty()){ + return ResultVO.success(redisTemplate.delete(keys)); + } + return ResultVO.success(0l); + } }