|
@@ -58,11 +58,11 @@ func (b *base_ent_empower) HasEmpower(appid, function_code string, ent_id, ent_u
|
|
|
}
|
|
|
|
|
|
//重新授权
|
|
|
-func (b *base_ent_empower) ReEmpower(appid, function_code string, ent_id int64, ent_user_id []int64) bool {
|
|
|
+func (b *base_ent_empower) ReEmpower(appid string, function_code []string, ent_id int64, ent_user_id []int64) bool {
|
|
|
return Mysql_BaseService.ExecTx("重新授权", func(tx *sql.Tx) bool {
|
|
|
args := []interface{}{appid, ent_id}
|
|
|
wh := []string{}
|
|
|
- for _, v := range strings.Split(function_code, ",") {
|
|
|
+ for _, v := range function_code {
|
|
|
wh = append(wh, "?")
|
|
|
args = append(args, v)
|
|
|
}
|
|
@@ -70,7 +70,7 @@ func (b *base_ent_empower) ReEmpower(appid, function_code string, ent_id int64,
|
|
|
nowFormat := NowFormat(Date_Full_Layout)
|
|
|
values := []interface{}{}
|
|
|
for _, v := range ent_user_id {
|
|
|
- for _, vv := range strings.Split(function_code, ",") {
|
|
|
+ for _, vv := range function_code {
|
|
|
values = append(values, appid, ent_id, v, vv, nowFormat)
|
|
|
}
|
|
|
}
|
|
@@ -78,32 +78,32 @@ func (b *base_ent_empower) ReEmpower(appid, function_code string, ent_id int64,
|
|
|
if len(values) > 0 {
|
|
|
r2, r3 = Mysql_BaseService.InsertBatchByTx(tx, "base_ent_empower", []string{"appid", "ent_id", "ent_user_id", "function_code", "create_time"}, values)
|
|
|
}
|
|
|
- return r1 >= 0 && r2 == int64(len(ent_user_id)) && r3 > 0
|
|
|
+ return r1 >= 0 && r2 == int64(len(function_code)*len(ent_user_id)) && r3 > 0
|
|
|
})
|
|
|
}
|
|
|
|
|
|
//授权
|
|
|
-func (b *base_ent_empower) Empower(appid, function_code string, ent_id int64, ent_user_id []int64) bool {
|
|
|
+func (b *base_ent_empower) Empower(appid string, function_code []string, ent_id int64, ent_user_id []int64) bool {
|
|
|
fields := []string{"appid", "ent_id", "ent_user_id", "function_code", "create_time"}
|
|
|
nowFormat := NowFormat(Date_Full_Layout)
|
|
|
values := []interface{}{}
|
|
|
- functionCodes := strings.Split(function_code, ",")
|
|
|
for _, v := range ent_user_id {
|
|
|
- for _, vv := range functionCodes {
|
|
|
+ for _, vv := range function_code {
|
|
|
values = append(values, appid, ent_id, v, vv, nowFormat)
|
|
|
}
|
|
|
}
|
|
|
- b.CancelEmpower(appid, function_code, ent_id, ent_user_id)
|
|
|
- r1, _ := Mysql_BaseService.InsertBatch("base_ent_empower", fields, values)
|
|
|
- return r1 == int64(len(functionCodes)*len(ent_user_id))
|
|
|
+ return Mysql_BaseService.ExecTx("授权", func(tx *sql.Tx) bool {
|
|
|
+ b.CancelEmpower(tx, appid, function_code, ent_id, ent_user_id)
|
|
|
+ r1, _ := Mysql_BaseService.InsertBatchByTx(tx, "base_ent_empower", fields, values)
|
|
|
+ return r1 == int64(len(function_code)*len(ent_user_id))
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
//取消授权
|
|
|
-func (b *base_ent_empower) CancelEmpower(appid, function_code string, ent_id int64, ent_user_id []int64) bool {
|
|
|
+func (b *base_ent_empower) CancelEmpower(tx *sql.Tx, appid string, function_code []string, ent_id int64, ent_user_id []int64) bool {
|
|
|
args := []interface{}{appid, ent_id}
|
|
|
wh1 := []string{}
|
|
|
- functionCodes := strings.Split(function_code, ",")
|
|
|
- for _, v := range functionCodes {
|
|
|
+ for _, v := range function_code {
|
|
|
wh1 = append(wh1, "?")
|
|
|
args = append(args, v)
|
|
|
}
|
|
@@ -112,6 +112,8 @@ func (b *base_ent_empower) CancelEmpower(appid, function_code string, ent_id int
|
|
|
wh2 = append(wh2, "?")
|
|
|
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(functionCodes)*len(ent_user_id))
|
|
|
+ return Mysql_BaseService.ExecTx("取消授权", func(tx *sql.Tx) bool {
|
|
|
+ r1 := Mysql_BaseService.UpdateOrDeleteBySqlByTx(tx, `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(function_code)*len(ent_user_id))
|
|
|
+ })
|
|
|
}
|