作者 唐旭辉

bug fix

... ... @@ -371,14 +371,21 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.ResponseUserHasMenu, er
log.Error("EXECUTE SQL err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
paramMap := map[int64]bool{}
for i := range list {
for _, v := range menuids {
if list[i].Id == v {
list[i].StatusYes()
paramMap[list[i].ParentId] = true
break
}
}
}
for i := range list {
if _, ok := paramMap[list[i].Id]; ok {
list[i].StatusYes()
}
}
return list, nil
}
... ... @@ -498,6 +505,6 @@ func SmsCodeCheck(phone string, code string) error {
//InitPermission 登录时权限初始化
func InitPermission(usercompanyid int, userid int64) error {
// datasql = ``
return nil
}
... ...
... ... @@ -25,7 +25,7 @@ const (
type PermissionOptionObject interface {
// StringUnmarshal(string) error
// ObjectMarshal() string
GetValidFunc(string) func(UserObject) bool
GetValidFunc(string) bool
MergeObject(string) error
}
... ...
... ... @@ -25,7 +25,7 @@ func NewPermissionOptionBase() PermissionOptionObject {
}
}
func (p *PermissionOptionBase) ValidDefault(obj UserObject) bool {
func (p *PermissionOptionBase) ValidDefault() bool {
if p.Check == 1 {
return true
}
... ... @@ -33,14 +33,15 @@ func (p *PermissionOptionBase) ValidDefault(obj UserObject) bool {
}
//GetValidFunc PermissionOptionBase 接口实现
func (p *PermissionOptionBase) GetValidFunc(k string) func(UserObject) bool {
m := map[string]func(UserObject) bool{
func (p *PermissionOptionBase) GetValidFunc(k string) bool {
m := map[string]func() bool{
"default": p.ValidDefault,
}
if _, ok := m[k]; ok {
return m[k]
if fn, ok := m[k]; ok {
b := fn()
return b
}
return nil
return false
}
func (p *PermissionOptionBase) MergeObject(jsonString string) error {
... ... @@ -131,14 +132,15 @@ func NewOptionOpportunity() PermissionOptionObject {
}
//GetValidFunc PermissionOptionBase 接口实现
func (p *OptionOpportunity) GetValidFunc(k string) func(UserObject) bool {
m := map[string]func(UserObject) bool{
func (p *OptionOpportunity) GetValidFunc(k string) bool {
m := map[string]func() bool{
"check": p.ValidCheck,
}
if _, ok := m[k]; ok {
return m[k]
if fn, ok := m[k]; ok {
b := fn()
return b
}
return nil
return false
}
//MergeObject PermissionOptionBase 接口实现
... ... @@ -195,20 +197,20 @@ func (p *OptionOpportunity) MergeObject(jsonString string) error {
return nil
}
func (p *OptionOpportunity) ValidCheck(obj UserObject) bool {
func (p *OptionOpportunity) ValidCheck() bool {
if p.Check > 0 {
return true
}
return false
}
func (p *OptionOpportunity) ValidEditSorce(obj UserObject) bool {
func (p *OptionOpportunity) ValidEditSorce() bool {
if p.EditSorce > 0 {
return true
}
return false
}
func (p *OptionOpportunity) ValidEditPublicStatus(obj UserObject) bool {
func (p *OptionOpportunity) ValidEditPublicStatus() bool {
if p.EditPublicStatus > 0 {
return true
}
... ...