Browse Source

权限查询

duyj 3 năm trước cách đây
mục cha
commit
209f05e603

+ 11 - 0
suishenbang-common/src/main/java/com/dgtly/common/core/domain/Ztree.java

@@ -1,6 +1,7 @@
 package com.dgtly.common.core.domain;
 
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * Ztree树结构实体类
@@ -38,6 +39,16 @@ public class Ztree implements Serializable
     /** code */
     private String code;
 
+    private List<Ztree> children;
+
+    public List<Ztree> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<Ztree> children) {
+        this.children = children;
+    }
+
     public Long getId()
     {
         return id;

+ 11 - 0
suishenbang-system/src/main/java/com/dgtly/system/domain/SysUser.java

@@ -133,6 +133,17 @@ public class SysUser extends BaseEntity
      */
     private List<Ztree>  author;
 
+    /** 用户权限 TUC*/
+    private String  authorType;
+
+    public String getAuthorType() {
+        return authorType;
+    }
+
+    public void setAuthorType(String authorType) {
+        this.authorType = authorType;
+    }
+
     //    /** 所属销售组织等级 详见字典(sales_level) */
 //    private String salesLevel;
 //

+ 7 - 0
suishenbang-system/src/main/java/com/dgtly/system/service/ISysUserOrderAuthorService.java

@@ -76,4 +76,11 @@ public interface ISysUserOrderAuthorService
      * @return
      */
     public List<Ztree> userAuthorTreeData(Long userId);
+
+    /**
+     * 查询用户权限 接口
+     * @param userId
+     * @return
+     */
+    public List<Ztree> userAuthorTreeDataFmt(Long userId);
 }

+ 37 - 0
suishenbang-system/src/main/java/com/dgtly/system/service/impl/SysUserOrderAuthorServiceImpl.java

@@ -2,6 +2,9 @@ package com.dgtly.system.service.impl;
 
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
 import com.dgtly.common.core.domain.Ztree;
 import com.dgtly.common.utils.DateUtils;
 import com.dgtly.common.utils.StringUtils;
@@ -154,6 +157,40 @@ public class SysUserOrderAuthorServiceImpl implements ISysUserOrderAuthorService
         return ztrees;
     }
 
+    public List<Ztree> userAuthorTreeDataFmt(Long userId) {
+        List<Ztree> ztrees = new ArrayList<Ztree>();
+        List<SysUserOrderAuthor> menuList = sysUserOrderAuthorMapper.selectSysUserOrderAuthorList(new SysUserOrderAuthor());
+        List<Long> user = sysUserOrderAuthorMapper.selectAuthorTree(userId);
+        ztrees = initTree(menuList, user);
+        ztrees =ztrees.stream().filter(Ztree::isChecked).collect(Collectors.toList());
+        ztrees = buildTree(ztrees, 0l);
+
+        return ztrees;
+    }
+
+    //把一个List转成树
+    static List<Ztree> buildTree(List<Ztree> list,Long pid){
+        List<Ztree> tree=new ArrayList<>();
+        for(Ztree node:list){
+            if(Objects.equals(node.getpId(),pid)){
+                tree.add(findChild(node,list));
+            }
+        }
+        return tree;
+    }
+
+    static Ztree findChild(Ztree node, List<Ztree> list){
+        for(Ztree n:list){
+            if(Objects.equals(n.getpId(),node.getId())){
+                if(node.getChildren() == null){
+                    node.setChildren(new ArrayList<Ztree>());
+                }
+                node.getChildren().add(findChild(n,list));
+            }
+        }
+        return node;
+    }
+
     /**
      * 对象转树
      * @param sysUserOrderAuthorList

+ 6 - 1
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/WxController.java

@@ -479,7 +479,12 @@ public class WxController extends ApiBaseController {
         }
         String pass = EncryptPassWordClass.encryptPassword(user.getLoginName(),password,user.getSalt());
         if(pass.equals(user.getPassword())){
-            List<Ztree>  author = sysUserOrderAuthorService.userAuthorTreeData(user.getUserId());
+            List<Ztree>  author = sysUserOrderAuthorService.userAuthorTreeDataFmt(user.getUserId());
+            if (author.size() > 0 && author.get(0).getChildren().size() == 3) {
+                user.setAuthorType("TUC");
+            }else{
+                user.setAuthorType("");
+            }
             user.setAuthor(author);
             return AjaxResult.success().putKV("sysUser",user);
         }else{