瀏覽代碼

新增清除用户缓存功能

sangwenwei 7 月之前
父節點
當前提交
1997825bb7

+ 17 - 0
src/main/java/com/jeeplus/modules/sys/web/UserController.java

@@ -1300,6 +1300,23 @@ public class UserController extends BaseController {
         return "redirect:" + adminPath + "/login";
     }
 
+    @RequestMapping(value = "removeRedis")
+    public String removeRedis(String userId,RedirectAttributes redirectAttributes){
+        User user = userService.get(userId);
+        if (user != null){
+            //将该用户存在redis中的缓存清除
+            String key = "loginFailNum:"+user.getLoginName();
+            String loginFailNum = JedisUtils.getResource().get(key);
+            if (StringUtils.isNotBlank(loginFailNum)){
+                int num = Integer.parseInt(loginFailNum);
+                JedisUtils.set(key,"0",0);
+                Map<String, Integer> loginFailMap = (Map<String, Integer>)CacheUtils.get("loginFailMap");
+                loginFailMap.remove(user.getLoginName());
+            }
+            addMessage(redirectAttributes, "清除缓存成功");
+        }
+        return "redirect:"+Global.getAdminPath()+"/workstaff/workStaffBasicInfo/?repage";
+    }
 
 
 //	@InitBinder

+ 6 - 2
src/main/webapp/webpage/modules/workstaff/workStaffBasicInfoList.jsp

@@ -358,7 +358,7 @@
                     }}*/
                 ,{field:'status',align:'center', title: '员工状态', minWidth:80}
                 ,{field:'entryDate', align:'center',sort:true,title: '入职日期',width:100}
-                ,{field:'op',align:'center',title:"操作",width:200,templet:function(d){
+                ,{field:'op',align:'center',title:"操作",width:240,templet:function(d){
                         ////对操作进行初始化
                         var xml = "<div class=\"layui-btn-group\">";
 
@@ -381,7 +381,11 @@
 
                         if(d.candelete != undefined && d.candelete == "1")
                             xml +="<a href=\"${ctx}/workstaff/workStaffBasicInfo/delete?id=" + d.id + "\" onclick=\"return confirmx('确认要删除信息吗?', this.href)\"   class=\"layui-btn layui-btn-xs layui-bg-red\"> 删除</a>";
-                        xml+="</div>"
+
+                        if(d.canedit != undefined && d.canedit == "1"){
+                            xml +="<a href=\"${ctx}/sys/user/removeRedis?userId=" + d.userId + "\" onclick=\"return confirmx('确认要清除缓存吗?', this.href)\"   class=\"layui-btn layui-btn-xs layui-bg-green\"> 清除缓存</a>";
+                        }
+                            xml+="</div>"
                         return xml;
                     }}
             ]]