Explorar o código

feat:修改判断

wangchuanjin hai 1 ano
pai
achega
e3d6ab72ce
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      public/entity/base_ent_empower.go

+ 4 - 3
public/entity/base_ent_empower.go

@@ -95,14 +95,15 @@ func (b *base_ent_empower) Empower(appid, function_code string, ent_id int64, en
 	}
 	b.CancelEmpower(appid, function_code, ent_id, ent_user_id)
 	r1, _ := Mysql_BaseService.InsertBatch("base_ent_empower", fields, values)
-	return r1 == int64(len(functionCodes))*int64(len(ent_user_id))
+	return r1 == int64(len(functionCodes)*len(ent_user_id))
 }
 
 //取消授权
 func (b *base_ent_empower) CancelEmpower(appid, function_code string, ent_id int64, ent_user_id []int64) bool {
 	args := []interface{}{appid, ent_id}
 	wh1 := []string{}
-	for _, v := range strings.Split(function_code, ",") {
+	functionCodes := strings.Split(function_code, ",")
+	for _, v := range functionCodes {
 		wh1 = append(wh1, "?")
 		args = append(args, v)
 	}
@@ -112,5 +113,5 @@ func (b *base_ent_empower) CancelEmpower(appid, function_code string, ent_id int
 		args = append(args, v)
 	}
 	r1 := Mysql_BaseService.UpdateOrDeleteBySql(`delete from base_ent_empower where appid=? and ent_id=? and function_code in (`+strings.Join(wh1, ",")+`) and ent_user_id in (`+strings.Join(wh2, ",")+`)`, args...)
-	return r1 == int64(len(ent_user_id))
+	return r1 == int64(len(functionCodes)*len(ent_user_id))
 }