From 2004d06189df4f32825dfc76b3fc4abb978fb3a8 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 22 七月 2020 13:29:53 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/web/AuthController.java |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/zy/common/web/AuthController.java b/src/main/java/com/zy/common/web/AuthController.java
index dc4dca3..0623254 100644
--- a/src/main/java/com/zy/common/web/AuthController.java
+++ b/src/main/java/com/zy/common/web/AuthController.java
@@ -4,6 +4,7 @@
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.zy.common.CodeRes;
+import com.zy.common.entity.Parameter;
 import com.zy.common.model.PowerDto;
 import com.zy.common.model.enums.HtmlNavIconType;
 import com.zy.common.utils.RandomValidateCodeUtil;
@@ -48,6 +49,7 @@
     private RolePermissionService rolePermissionService;
 
     @RequestMapping("/login.action")
+    @ManagerAuth(value = ManagerAuth.Auth.NONE, memo = "鐧诲綍")
     public R loginAction(String mobile, String password){
         if (mobile.equals("super") && password.equals(Cools.md5(superPwd))) {
             Map<String, Object> res = new HashMap<>();
@@ -72,11 +74,17 @@
         UserLogin userLogin = new UserLogin();
         userLogin.setUserId(user.getId());
         userLogin.setToken(token);
+        userLogin.setCreateTime(new Date());
         userLoginService.insert(userLogin);
         Map<String, Object> res = new HashMap<>();
         res.put("username", user.getUsername());
         res.put("token", token);
         return R.ok(res);
+    }
+
+    @RequestMapping("/code/switch.action")
+    public R code() {
+        return R.ok().add(Parameter.get().getCodeSwitch());
     }
 
     @RequestMapping("/code.action")
@@ -85,8 +93,18 @@
     }
 
     @RequestMapping("/code.do")
-    public String codeDo(@RequestParam String sd) {
-        String code = RandomValidateCodeUtil.code.get(sd);
+    public String codeDo(@RequestParam String sd) throws Exception {
+        String code = null;
+        int time = 0;
+        while (time < 3000) {
+            code = RandomValidateCodeUtil.code.get(sd);
+            if (!Cools.isEmpty(code)){
+                break;
+            } else {
+                Thread.sleep(10);
+                time = time + 100;
+            }
+        }
         RandomValidateCodeUtil.code.remove(sd);
         return code;
     }
@@ -129,7 +147,7 @@
 
                     // 鏄惁鎷ユ湁鏌ョ湅鏉冮檺
                     if (getUserId() != 9527) {
-                        Resource view = resourceService.selectOne(new EntityWrapper<Resource>().eq("resource_id", resource.getId()).like("code", "view"));
+                        Resource view = resourceService.selectOne(new EntityWrapper<Resource>().eq("resource_id", resource.getId()).like("code", "#view"));
                         if (!Cools.isEmpty(view)){
                             RoleResource param = new RoleResource();
                             param.setResourceId(view.getId());
@@ -241,7 +259,7 @@
     }
 
     @RequestMapping("/power/auth")
-    @ManagerAuth
+    @ManagerAuth(memo = "鎺堟潈")
     @Transactional
     public R power(Long roleId, String powers){
         Role role = roleService.selectById(roleId);

--
Gitblit v1.9.1