|
@@ -3,6 +3,7 @@ package services
|
|
|
import (
|
|
|
"eta/eta_mobile/models/company"
|
|
|
"eta/eta_mobile/models/system"
|
|
|
+ "fmt"
|
|
|
)
|
|
|
|
|
|
// CheckAdminIsSameBigGroup 判断是否两个系统用户是否同一个大组内
|
|
@@ -54,3 +55,35 @@ func CheckAdminIsSameBigGroup(adminInfo1, adminInfo2 *system.Admin) (isSame bool
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+func BuildGroupTree(rootNode *system.GroupNode, groupList []*system.SysFullGroup, depth, current int) {
|
|
|
+ if current >= depth {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, group := range groupList {
|
|
|
+ if group.ParentId == rootNode.GroupId {
|
|
|
+ childNode := &system.GroupNode{
|
|
|
+ GroupId: group.GroupId,
|
|
|
+ GroupName: group.GroupName,
|
|
|
+ }
|
|
|
+ BuildGroupTree(childNode, groupList, depth, current+1)
|
|
|
+ rootNode.Child = append(rootNode.Child, childNode)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func GetGroupName(nodes []*system.GroupNode, groupId int) (find bool, groupName string) {
|
|
|
+ for _, child := range nodes {
|
|
|
+ if child.GroupId == groupId {
|
|
|
+ return true, child.GroupName
|
|
|
+ }
|
|
|
+ if len(child.Child) > 0 {
|
|
|
+ find, subGroupName := GetGroupName(child.Child, groupId)
|
|
|
+ if find {
|
|
|
+ groupName = fmt.Sprintf("%s/%s", child.GroupName, subGroupName)
|
|
|
+ return true, groupName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false, ""
|
|
|
+}
|