浏览代码

feat:企业分配权限判断

wangshan 2 年之前
父节点
当前提交
1a83566b09
共有 1 个文件被更改,包括 16 次插入14 次删除
  1. 16 14
      entity/user.go

+ 16 - 14
entity/user.go

@@ -232,24 +232,26 @@ func (m *WorkDesktopMenu) AutoUserPowerInfo() map[string]int {
 				UserPowerMap["500"] = 1
 			}
 			//当前用户是否被分配权限
-			entnichePowers := Mysql.SelectBySql(fmt.Sprintf(`SELECT a.product_type,a.ent_id FROM %s a LEFT JOIN %s b ON a.id = b.wait_empower_id WHERE b.status = 1 AND b.ent_user_id = ?`, EntnicheWaitEmpower, EntnichePower), m.EntUserId)
-			if entnichePowers != nil && len(*entnichePowers) > 0 {
-				for _, entnichePower := range *entnichePowers {
-					//排除非当前企业分配的权限
-					if MC.Int64All(entnichePower["ent_id"]) != m.EntId {
-						productType := MC.ObjToString(entnichePower["product_type"])
-						if strings.Contains(productType, "大会员") && len(serviceIds["M"]) > 0 {
-							for _, v := range serviceIds["M"] {
-								UserPowerMap[v] = 0
+			if m.EntUserId > 0 {
+				entnichePowers := Mysql.SelectBySql(fmt.Sprintf(`SELECT a.product_type,a.ent_id FROM %s a LEFT JOIN %s b ON a.id = b.wait_empower_id WHERE b.status = 1 AND b.ent_user_id = ?`, EntnicheWaitEmpower, EntnichePower), m.EntUserId)
+				if entnichePowers != nil && len(*entnichePowers) > 0 {
+					for _, entnichePower := range *entnichePowers {
+						//排除非当前企业分配的权限
+						if MC.Int64All(entnichePower["ent_id"]) != m.EntId {
+							productType := MC.ObjToString(entnichePower["product_type"])
+							if strings.Contains(productType, "大会员") && len(serviceIds["M"]) > 0 {
+								for _, v := range serviceIds["M"] {
+									UserPowerMap[v] = 0
+								}
 							}
-						}
-						if strings.Contains(productType, "VIP订阅") && len(serviceIds["V"]) > 0 {
-							for _, v := range serviceIds["V"] {
-								UserPowerMap[v] = 0
+							if strings.Contains(productType, "VIP订阅") && len(serviceIds["V"]) > 0 {
+								for _, v := range serviceIds["V"] {
+									UserPowerMap[v] = 0
+								}
 							}
 						}
-					}
 
+					}
 				}
 			}
 		}