|
@@ -60,14 +60,19 @@ 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, function_code string, ent_id int64, ent_user_id []int64) bool {
|
|
return Mysql_BaseService.ExecTx("重新授权", func(tx *sql.Tx) bool {
|
|
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=?`, appid, ent_id, function_code)
|
|
|
|
|
|
+ args := []interface{}{appid, ent_id}
|
|
|
|
+ wh := []string{}
|
|
|
|
+ for _, v := range strings.Split(function_code, ",") {
|
|
|
|
+ wh = append(wh, "?")
|
|
|
|
+ args = append(args, v)
|
|
|
|
+ }
|
|
|
|
+ r1 := Mysql_BaseService.UpdateOrDeleteBySqlByTx(tx, `delete from base_ent_empower where appid=? and ent_id=? and function_code in (`+strings.Join(wh, ",")+`)`, args...)
|
|
|
|
+ nowFormat := NowFormat(Date_Full_Layout)
|
|
values := []interface{}{}
|
|
values := []interface{}{}
|
|
- now := NowFormat(Date_Full_Layout)
|
|
|
|
for _, v := range ent_user_id {
|
|
for _, v := range ent_user_id {
|
|
- if v <= 0 {
|
|
|
|
- continue
|
|
|
|
|
|
+ for _, vv := range strings.Split(function_code, ",") {
|
|
|
|
+ values = append(values, appid, ent_id, v, vv, nowFormat)
|
|
}
|
|
}
|
|
- values = append(values, appid, ent_id, v, function_code, now)
|
|
|
|
}
|
|
}
|
|
r2, r3 := int64(-1), int64(-1)
|
|
r2, r3 := int64(-1), int64(-1)
|
|
if len(values) > 0 {
|
|
if len(values) > 0 {
|
|
@@ -79,17 +84,18 @@ func (b *base_ent_empower) ReEmpower(appid, function_code string, ent_id int64,
|
|
|
|
|
|
//授权
|
|
//授权
|
|
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, function_code string, ent_id int64, ent_user_id []int64) bool {
|
|
- b.CancelEmpower(appid, function_code, ent_id, ent_user_id)
|
|
|
|
fields := []string{"appid", "ent_id", "ent_user_id", "function_code", "create_time"}
|
|
fields := []string{"appid", "ent_id", "ent_user_id", "function_code", "create_time"}
|
|
nowFormat := NowFormat(Date_Full_Layout)
|
|
nowFormat := NowFormat(Date_Full_Layout)
|
|
values := []interface{}{}
|
|
values := []interface{}{}
|
|
|
|
+ functionCodes := strings.Split(function_code, ",")
|
|
for _, v := range ent_user_id {
|
|
for _, v := range ent_user_id {
|
|
- for _, vv := range strings.Split(function_code, ",") {
|
|
|
|
- values = append(values, appid, ent_id, Int64All(v), vv, nowFormat)
|
|
|
|
|
|
+ for _, vv := range functionCodes {
|
|
|
|
+ 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)
|
|
r1, _ := Mysql_BaseService.InsertBatch("base_ent_empower", fields, values)
|
|
- return r1 == int64(len(ent_user_id))
|
|
|
|
|
|
+ return r1 == int64(len(functionCodes))*int64(len(ent_user_id))
|
|
}
|
|
}
|
|
|
|
|
|
//取消授权
|
|
//取消授权
|