...
|
...
|
@@ -256,7 +256,7 @@ func (p *OptionOpportunity) ValidEditPublicStatus(obj UserObject) bool { |
|
|
return false
|
|
|
}
|
|
|
|
|
|
func GetUserPermission(userCompanyid int64) (map[string]PermissionOptionObject, error) {
|
|
|
func getUserPermission(userCompanyid int64) (map[string]PermissionOptionObject, error) {
|
|
|
type CodeOpptionData struct {
|
|
|
Code string `orm:"column(code)"`
|
|
|
Opption string `orm:"column(opption)"`
|
...
|
...
|
@@ -265,13 +265,13 @@ func GetUserPermission(userCompanyid int64) (map[string]PermissionOptionObject, |
|
|
FROM role_menu AS a
|
|
|
JOIN user_role AS b ON a.role_id = b.role_id
|
|
|
JOIN role AS c ON a.role_id = c.id
|
|
|
WHERE b.user_company_id=? AND c.delete_at =0`
|
|
|
WHERE a.code=? AND b.user_company_id=? AND c.delete_at =0`
|
|
|
var (
|
|
|
data []CodeOpptionData
|
|
|
err error
|
|
|
objMap = make(map[string]PermissionOptionObject)
|
|
|
)
|
|
|
err = utils.ExecuteQueryAll(&data, datasql, userCompanyid)
|
|
|
err = utils.ExecuteQueryAll(&data, datasql, M_SYSTEM_OPPORTUNITY, userCompanyid)
|
|
|
if err != nil {
|
|
|
e := fmt.Errorf("EXCUTE SQL ERR:%s", err)
|
|
|
return nil, e
|
...
|
...
|
@@ -287,7 +287,7 @@ func GetUserPermission(userCompanyid int64) (map[string]PermissionOptionObject, |
|
|
if fn, ok := CodePermissionObject[v.Code]; ok {
|
|
|
obj := fn()
|
|
|
if err = json.Unmarshal([]byte(v.Opption), obj); err != nil {
|
|
|
log.Debug("解析权限配置option 失败%s", err)
|
|
|
log.Debug("解析权限配置option 失败", v.Opption, err)
|
|
|
}
|
|
|
objMap[v.Code] = obj
|
|
|
} else {
|
...
|
...
|
@@ -297,3 +297,21 @@ func GetUserPermission(userCompanyid int64) (map[string]PermissionOptionObject, |
|
|
}
|
|
|
return objMap, nil
|
|
|
}
|
|
|
|
|
|
//获取用户权限
|
|
|
func GetUserPermission(userCompanyid int64) (op *OptionOpportunity, err error) {
|
|
|
op = &OptionOpportunity{}
|
|
|
mp, e := getUserPermission(userCompanyid)
|
|
|
if e != nil {
|
|
|
log.Error(e)
|
|
|
}
|
|
|
if len(mp) == 0 {
|
|
|
return
|
|
|
}
|
|
|
if v, ok := mp[M_SYSTEM_OPPORTUNITY]; ok {
|
|
|
if op, ok = v.(*OptionOpportunity); ok {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|