浏览代码

feat: 手动清除锁定缓存

shc 10 月之前
父节点
当前提交
03913d7635

+ 24 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/InitController.java

@@ -24,11 +24,13 @@ import com.qunzhixinxi.hnqz.common.core.util.R;
 import com.qunzhixinxi.hnqz.common.security.annotation.Inner;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.http.MediaType;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 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;
 
@@ -37,6 +39,7 @@ import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -61,6 +64,7 @@ public class InitController {
     private final SysUserAreaService userAreaService;
     private final SysAreaEntityService areaEntityService;
     private final SysUserService userService;
+    private final RedisTemplate<String, Object> redisTemplate;
 
 
     @Inner(value = false)
@@ -378,5 +382,25 @@ public class InitController {
         return R.ok();
     }
 
+    @Inner(value = false)
+    @PostMapping(value = "/cnbg/cache/clean")
+    public R<Boolean> clean(@RequestBody Map<String, Object> params) {
+
+
+        Object o = params.get("username");
+
+        final String errorKey = "login:error:lock:" + o;
+
+        if (Boolean.TRUE.equals(redisTemplate.hasKey(errorKey))) {
+            Boolean delete = redisTemplate.delete(errorKey);
+
+            return R.ok(delete);
+        } else {
+            return R.ok(false, "key:" + errorKey + ",不存在");
+        }
+
+
+    }
+
 
 }