|
@@ -1,10 +1,12 @@
|
|
package service
|
|
package service
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "database/sql"
|
|
"errors"
|
|
"errors"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
. "app.yhyue.com/moapp/jybase/date"
|
|
. "app.yhyue.com/moapp/jybase/date"
|
|
|
|
+ . "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/db"
|
|
. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/entity"
|
|
. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/entity"
|
|
"bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/pb"
|
|
"bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/pb"
|
|
)
|
|
)
|
|
@@ -169,32 +171,17 @@ func HasPowers(appid string, account_id, ent_account_id, ent_id, ent_user_id int
|
|
* @param ent_user_id 企业用户id
|
|
* @param ent_user_id 企业用户id
|
|
* @return 0:失败 1:成功 -2:数量不足
|
|
* @return 0:失败 1:成功 -2:数量不足
|
|
*/
|
|
*/
|
|
-func ReEmpower(appid, function_code string, ent_id int64, ent_user_id []int64) (int64, error) {
|
|
|
|
|
|
+func ReEmpower(appid string, function_code []string, ent_id int64, ent_user_id []int64) (int64, error) {
|
|
if appid == "" {
|
|
if appid == "" {
|
|
return 0, errors.New("无效的参数appid")
|
|
return 0, errors.New("无效的参数appid")
|
|
- } else if function_code == "" {
|
|
|
|
|
|
+ } else if len(function_code) == 0 {
|
|
return 0, errors.New("无效的参数function_code")
|
|
return 0, errors.New("无效的参数function_code")
|
|
} else if ent_id == 0 {
|
|
} else if ent_id == 0 {
|
|
return 0, errors.New("无效的参数ent_id")
|
|
return 0, errors.New("无效的参数ent_id")
|
|
} else if len(ent_user_id) == 0 {
|
|
} else if len(ent_user_id) == 0 {
|
|
return 0, errors.New("无效的参数ent_user_id")
|
|
return 0, errors.New("无效的参数ent_user_id")
|
|
- } else if !Base_ent_wait_empower.CheckFunctionCode(appid, function_code, ent_id) {
|
|
|
|
- return 0, errors.New("无效的参数function_code")
|
|
|
|
- }
|
|
|
|
- bewes := Base_ent_wait_empower.WaitEmpowers(appid, function_code, ent_id)
|
|
|
|
- if bewes == nil {
|
|
|
|
- return -1, nil
|
|
|
|
- }
|
|
|
|
- var count int64
|
|
|
|
- for _, v := range *bewes {
|
|
|
|
- if v.Empower_count == -1 {
|
|
|
|
- count = -1
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- count += v.Empower_count
|
|
|
|
- }
|
|
|
|
- if count != -1 && int64(len(ent_user_id)) > count {
|
|
|
|
- return -2, nil
|
|
|
|
|
|
+ } else if status, err := Base_ent_wait_empower.CheckBeforeEmpower(appid, function_code, ent_id, ent_user_id); err != nil {
|
|
|
|
+ return status, err
|
|
}
|
|
}
|
|
if Base_ent_empower.ReEmpower(appid, function_code, ent_id, ent_user_id) {
|
|
if Base_ent_empower.ReEmpower(appid, function_code, ent_id, ent_user_id) {
|
|
return 1, nil
|
|
return 1, nil
|
|
@@ -210,17 +197,17 @@ func ReEmpower(appid, function_code string, ent_id int64, ent_user_id []int64) (
|
|
* @param ent_user_id 企业用户id
|
|
* @param ent_user_id 企业用户id
|
|
* @return 0:失败 1:成功
|
|
* @return 0:失败 1:成功
|
|
*/
|
|
*/
|
|
-func Empower(appid, function_code string, ent_id int64, ent_user_id []int64) (int64, error) {
|
|
|
|
|
|
+func Empower(appid string, function_code []string, ent_id int64, ent_user_id []int64) (int64, error) {
|
|
if appid == "" {
|
|
if appid == "" {
|
|
return 0, errors.New("无效的参数appid")
|
|
return 0, errors.New("无效的参数appid")
|
|
- } else if function_code == "" {
|
|
|
|
|
|
+ } else if len(function_code) == 0 {
|
|
return 0, errors.New("无效的参数function_code")
|
|
return 0, errors.New("无效的参数function_code")
|
|
} else if ent_id == 0 {
|
|
} else if ent_id == 0 {
|
|
return 0, errors.New("无效的参数ent_id")
|
|
return 0, errors.New("无效的参数ent_id")
|
|
} else if len(ent_user_id) == 0 {
|
|
} else if len(ent_user_id) == 0 {
|
|
return 0, errors.New("无效的参数ent_user_id")
|
|
return 0, errors.New("无效的参数ent_user_id")
|
|
- } else if !Base_ent_wait_empower.CheckFunctionCode(appid, function_code, ent_id) {
|
|
|
|
- return 0, errors.New("无效的参数function_code")
|
|
|
|
|
|
+ } else if status, err := Base_ent_wait_empower.CheckBeforeEmpower(appid, function_code, ent_id, ent_user_id); err != nil {
|
|
|
|
+ return status, err
|
|
}
|
|
}
|
|
if Base_ent_empower.Empower(appid, function_code, ent_id, ent_user_id) {
|
|
if Base_ent_empower.Empower(appid, function_code, ent_id, ent_user_id) {
|
|
return 1, nil
|
|
return 1, nil
|
|
@@ -236,19 +223,19 @@ func Empower(appid, function_code string, ent_id int64, ent_user_id []int64) (in
|
|
* @param ent_user_id 企业用户id
|
|
* @param ent_user_id 企业用户id
|
|
* @return 0:失败 1:成功
|
|
* @return 0:失败 1:成功
|
|
*/
|
|
*/
|
|
-func CancelEmpower(appid, function_code string, ent_id int64, ent_user_id []int64) (int64, error) {
|
|
|
|
|
|
+func CancelEmpower(appid string, function_code []string, ent_id int64, ent_user_id []int64) (int64, error) {
|
|
if appid == "" {
|
|
if appid == "" {
|
|
return 0, errors.New("无效的参数appid")
|
|
return 0, errors.New("无效的参数appid")
|
|
- } else if function_code == "" {
|
|
|
|
|
|
+ } else if len(function_code) == 0 {
|
|
return 0, errors.New("无效的参数function_code")
|
|
return 0, errors.New("无效的参数function_code")
|
|
} else if ent_id == 0 {
|
|
} else if ent_id == 0 {
|
|
return 0, errors.New("无效的参数ent_id")
|
|
return 0, errors.New("无效的参数ent_id")
|
|
} else if len(ent_user_id) == 0 {
|
|
} else if len(ent_user_id) == 0 {
|
|
return 0, errors.New("无效的参数ent_user_id")
|
|
return 0, errors.New("无效的参数ent_user_id")
|
|
- } else if !Base_ent_wait_empower.CheckFunctionCode(appid, function_code, ent_id) {
|
|
|
|
- return 0, errors.New("无效的参数function_code")
|
|
|
|
}
|
|
}
|
|
- if Base_ent_empower.CancelEmpower(appid, function_code, ent_id, ent_user_id) {
|
|
|
|
|
|
+ if Mysql_BaseService.ExecTx("取消授权", func(tx *sql.Tx) bool {
|
|
|
|
+ return Base_ent_empower.CancelEmpower(tx, appid, function_code, ent_id, ent_user_id)
|
|
|
|
+ }) {
|
|
return 1, nil
|
|
return 1, nil
|
|
}
|
|
}
|
|
return 0, nil
|
|
return 0, nil
|