tianwu.sun пре 1 месец
родитељ
комит
d9e820a9aa

Разлика између датотеке није приказан због своје велике величине
+ 7489 - 0
log/cic-data-reportin.out


+ 1 - 1
src/main/java/com/bootdo/system/controller/LoginController.java

@@ -49,7 +49,7 @@ public class LoginController extends BaseController {
     public String sysCity;
 
     //登录地址
-    @Value("${login.url:#{null}}")
+    @Value("${login_url:#{null}}")
     public String loginUrl;
 
 

+ 61 - 1
src/main/java/com/bootdo/system/controller/UserController.java

@@ -1,13 +1,16 @@
 package com.bootdo.system.controller;
 
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 
 import com.bootdo.common.domain.DictDO;
+import com.bootdo.common.token.TokenUtil;
 import com.bootdo.common.utils.*;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.slf4j.Logger;
@@ -16,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
+import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -44,7 +48,8 @@ public class UserController extends BaseController {
     RoleService roleService;
     @Autowired
     DictService dictService;
-
+    @Resource
+    private TokenUtil tokenUtil;
 
     @Value("${sysProvince:#{null}}")
     public String sysProvince;
@@ -52,6 +57,9 @@ public class UserController extends BaseController {
     @Value("${sysCity:#{null}}")
     public String sysCity;
 
+    @Value("${back_manange_sso_url:#{null}}")
+    public String backManangeSsoUrl;
+
     @Log("访问用户管理")
     @RequiresPermissions("sys:user:user")
     @GetMapping("")
@@ -320,4 +328,56 @@ public class UserController extends BaseController {
         }
 
     }
+
+    @ResponseBody
+    @GetMapping("/hasBackManangePerm")
+    public boolean hasBackManangePerm() {
+        try {
+            //获取当前登录账号信息
+            UserDO currUser = ShiroUtils.getUser();
+            if (ObjectUtils.isEmpty(currUser)) {
+                return false;
+            }
+            List<Integer> list = userService.getCurrUserSysList(currUser.getUserId());
+            if(!ObjectUtils.isEmpty(list) && list.contains(0)){
+                return true;
+            } else {
+                return false;
+            }
+
+        } catch (Exception e){
+            e.printStackTrace();
+            return false;
+        }
+
+    }
+
+    @GetMapping("/getBackManangeSSoUrl")
+    public String getBackManangeSSoUrl() {
+        try {
+            //获取当前登录账号信息
+            UserDO currUser = ShiroUtils.getUser();
+            if (ObjectUtils.isEmpty(currUser)) {
+                return null;
+            }
+
+            List<Integer> list = userService.getCurrUserSysList(currUser.getUserId());
+            if(ObjectUtils.isEmpty(list) || !list.contains(0)){
+                return null;
+            }
+
+            String cacheToken = tokenUtil.getLoginUser(currUser.getUsername());
+            if (ObjectUtils.isEmpty(cacheToken)) {
+                return null;
+            }
+            String tokenStr = cacheToken.split("_")[0];
+            return "redirect:" + backManangeSsoUrl + "?token=" + URLEncoder.encode(tokenStr);
+        } catch (Exception e){
+            e.printStackTrace();
+            return null;
+        }
+
+    }
+
+
 }

+ 2 - 0
src/main/java/com/bootdo/system/dao/UserDao.java

@@ -32,4 +32,6 @@ public interface UserDao {
 	Long[] listAllDept();
 
     UserDO getByHobbyAndUserName(Map<String, Object> map);
+
+	List<Integer> getCurrUserSysList(Long userId);
 }

+ 2 - 0
src/main/java/com/bootdo/system/service/UserService.java

@@ -67,4 +67,6 @@ public interface UserService {
      * @return
      */
     UserDO getByHobbyAndUserName(String username);
+
+	List<Integer> getCurrUserSysList(Long userId);
 }

+ 5 - 0
src/main/java/com/bootdo/system/service/impl/UserServiceImpl.java

@@ -273,6 +273,11 @@ public class UserServiceImpl implements UserService {
         return userMapper.getByHobbyAndUserName(map);
     }
 
+    @Override
+    public List<Integer> getCurrUserSysList(Long userId){
+        return userMapper.getCurrUserSysList(userId);
+    }
+
     @Override
     public void batchUpdateThirdPartUser(List<UserDO> userDOS) {
         userDOS.forEach(userDO -> {

+ 3 - 2
src/main/resources/application-dev.yml

@@ -77,9 +77,10 @@ spring:
 api-allow-ip: 127.0.0.1
 
 #登录页地址
-login.url: http://127.0.0.1:19087/login
-
+login_url: http://127.0.0.1:19087/login
 
+#后台管理
+back_manange_sso_url: http://127.0.0.1:19087/system/user
 
 # 退出登录,需要跳转的地址
 logout:

+ 3 - 2
src/main/resources/application-prod.yml

@@ -84,9 +84,10 @@ spring:
 api-allow-ip: 127.0.0.1,172.18.105.10,172.18.105.11,218.89.240.185
 
 #登录页地址
-login.url: http://218.89.240.185:19087/login
-
+login_url: http://218.89.240.185:19087/login
 
+#后台管理
+back_manange_sso_url: http://218.89.240.185:19087/system/user
 
 # 退出登录,需要跳转的地址
 logout:

+ 3 - 2
src/main/resources/application-test.yml

@@ -77,9 +77,10 @@ spring:
 api-allow-ip: 127.0.0.1,124.70.58.209
 
 #登录页地址
-login:
-  url: http://124.70.58.209:19087/login
+login_url: http://124.70.58.209:19087/login
 
+#后台管理
+back_manange_sso_url: http://124.70.58.209:19087/system/user
 
 # 退出登录,需要跳转的地址
 logout:

+ 6 - 0
src/main/resources/mybatis/system/UserMapper.xml

@@ -182,4 +182,10 @@
         </where>
 
 	 </select>
+
+    <select id="getCurrUserSysList" resultType="Integer">
+        select distinct t.`sys_flag` sysFlag from sys_menu t where t.menu_id in
+                                                                   (select a.menu_id from sys_role_menu a where a.role_id in
+                                                                                                                (select b.role_id from sys_user_role b where b.user_id=#{userId}))
+    </select>
 </mapper>

+ 13 - 0
src/main/resources/static/js/code.js

@@ -1,5 +1,6 @@
 $().ready(function () {
     check();
+    hasBackManangePerm();
 });
 
 /**
@@ -37,4 +38,16 @@ function check() {
             }
         });
     }, 240000);
+}
+
+function hasBackManangePerm(){
+    $.ajax({
+        url: '/sys/user/hasBackManangePerm',
+        success: function (data) {
+           if(!data){
+               $('#back_manange').hide();
+           }
+        }
+    });
+
 }

+ 2 - 1
src/main/resources/templates/index_v1.html

@@ -112,7 +112,7 @@
                     </form>
                 </div>
                 <ul class="nav navbar-top-links navbar-right">
-
+                    <a id=“back_manange” href="/sys/user/getBackManangeSSoUrl">后台管理</a>
                     <div style="display: inline-block; color: #333; font-size: 15px; padding: 5px 16px 4px; border-radius: 3px;
                                 text-align: center; position: relative; margin: 14px 5px 5px 8px; font-weight: bold;">工信安全备案工具V1.0</div>
                     <li class="dropdown hidden"><a class="dropdown-toggle count-info"
@@ -332,6 +332,7 @@
             }
         }
     })
+
 </script>
 </body>
 </html>