作者 唐旭辉

bug 修复

... ... @@ -12,10 +12,10 @@ AdminPort = 8088
##数据库连接
# sqlconn ="${MYSQL_CONN||root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8&loc=Asia%2FShanghai}"
mysql_user = "${MYSQL_USER||root}"
mysql_password = "${MYSQL_PASSWORD||sutianxia2015}"
mysql_host = "${MYSQL_HOST||115.29.205.99}"
mysql_password = "${MYSQL_PASSWORD||sutianxia2018}"
mysql_host = "${MYSQL_HOST||101.37.68.23}"
mysql_port = "${MYSQL_PORT||3306}"
mysql_db_name = "${MYSQL_DB_NAME||opportunity}"
mysql_db_name = "${MYSQL_DB_NAME||opportunity_test}"
##redis相关配置
redis_add = "${REDIS_HOST||127.0.0.1}"
redis_add_port = "${REDIS_PORT||6379}"
... ...
package rbac
import (
"encoding/json"
"fmt"
"oppmg/common/log"
"oppmg/utils"
... ... @@ -138,9 +137,7 @@ func GetUserPermission(userCompanyid int64, code ...string) (map[string]Permissi
}
if fn, ok := CodePermissionObject[v.Code]; ok {
obj := fn()
if err = json.Unmarshal([]byte(v.Opption), obj); err != nil {
log.Debug("解析权限配置option:%s %s失败%s", v.Code, v.Opption, err)
}
obj.MergeObject(v.Opption)
objMap[v.Code] = obj
} else {
log.Error("未知code:%s", v.Code)
... ...
... ... @@ -154,7 +154,11 @@ func (p *OptionOpportunity) GetValidFunc(k string) bool {
//MergeObject PermissionOptionBase 接口实现
func (p *OptionOpportunity) MergeObject(jsonString string) error {
var obj OptionOpportunity
obj := OptionOpportunity{
CheckOption: &CheckOpp{
Departments: []CheckDeparment{},
},
}
err := json.Unmarshal([]byte(jsonString), &obj)
if err != nil {
return err
... ...
... ... @@ -131,7 +131,7 @@ func GetUserPermission(userid int64, field string) (rbac.PermissionOptionObject,
return nil, errors.New("cannot get object")
}
permissionObj = fn()
err = json.Unmarshal([]byte(str), permissionObj)
err = json.Unmarshal([]byte(str), &permissionObj)
return permissionObj, err
}
... ...