作者 唐旭辉

bug fix

@@ -371,14 +371,21 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.ResponseUserHasMenu, er @@ -371,14 +371,21 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.ResponseUserHasMenu, er
371 log.Error("EXECUTE SQL err:%s", err) 371 log.Error("EXECUTE SQL err:%s", err)
372 return nil, protocol.NewErrWithMessage("1") 372 return nil, protocol.NewErrWithMessage("1")
373 } 373 }
  374 + paramMap := map[int64]bool{}
374 for i := range list { 375 for i := range list {
375 for _, v := range menuids { 376 for _, v := range menuids {
376 if list[i].Id == v { 377 if list[i].Id == v {
377 list[i].StatusYes() 378 list[i].StatusYes()
  379 + paramMap[list[i].ParentId] = true
378 break 380 break
379 } 381 }
380 } 382 }
381 } 383 }
  384 + for i := range list {
  385 + if _, ok := paramMap[list[i].Id]; ok {
  386 + list[i].StatusYes()
  387 + }
  388 + }
382 return list, nil 389 return list, nil
383 } 390 }
384 391
@@ -498,6 +505,6 @@ func SmsCodeCheck(phone string, code string) error { @@ -498,6 +505,6 @@ func SmsCodeCheck(phone string, code string) error {
498 505
499 //InitPermission 登录时权限初始化 506 //InitPermission 登录时权限初始化
500 func InitPermission(usercompanyid int, userid int64) error { 507 func InitPermission(usercompanyid int, userid int64) error {
501 - // datasql = `` 508 +
502 return nil 509 return nil
503 } 510 }
@@ -25,7 +25,7 @@ const ( @@ -25,7 +25,7 @@ const (
25 type PermissionOptionObject interface { 25 type PermissionOptionObject interface {
26 // StringUnmarshal(string) error 26 // StringUnmarshal(string) error
27 // ObjectMarshal() string 27 // ObjectMarshal() string
28 - GetValidFunc(string) func(UserObject) bool 28 + GetValidFunc(string) bool
29 MergeObject(string) error 29 MergeObject(string) error
30 } 30 }
31 31
@@ -25,7 +25,7 @@ func NewPermissionOptionBase() PermissionOptionObject { @@ -25,7 +25,7 @@ func NewPermissionOptionBase() PermissionOptionObject {
25 } 25 }
26 } 26 }
27 27
28 -func (p *PermissionOptionBase) ValidDefault(obj UserObject) bool { 28 +func (p *PermissionOptionBase) ValidDefault() bool {
29 if p.Check == 1 { 29 if p.Check == 1 {
30 return true 30 return true
31 } 31 }
@@ -33,14 +33,15 @@ func (p *PermissionOptionBase) ValidDefault(obj UserObject) bool { @@ -33,14 +33,15 @@ func (p *PermissionOptionBase) ValidDefault(obj UserObject) bool {
33 } 33 }
34 34
35 //GetValidFunc PermissionOptionBase 接口实现 35 //GetValidFunc PermissionOptionBase 接口实现
36 -func (p *PermissionOptionBase) GetValidFunc(k string) func(UserObject) bool {  
37 - m := map[string]func(UserObject) bool{ 36 +func (p *PermissionOptionBase) GetValidFunc(k string) bool {
  37 + m := map[string]func() bool{
38 "default": p.ValidDefault, 38 "default": p.ValidDefault,
39 } 39 }
40 - if _, ok := m[k]; ok {  
41 - return m[k] 40 + if fn, ok := m[k]; ok {
  41 + b := fn()
  42 + return b
42 } 43 }
43 - return nil 44 + return false
44 } 45 }
45 46
46 func (p *PermissionOptionBase) MergeObject(jsonString string) error { 47 func (p *PermissionOptionBase) MergeObject(jsonString string) error {
@@ -131,14 +132,15 @@ func NewOptionOpportunity() PermissionOptionObject { @@ -131,14 +132,15 @@ func NewOptionOpportunity() PermissionOptionObject {
131 } 132 }
132 133
133 //GetValidFunc PermissionOptionBase 接口实现 134 //GetValidFunc PermissionOptionBase 接口实现
134 -func (p *OptionOpportunity) GetValidFunc(k string) func(UserObject) bool {  
135 - m := map[string]func(UserObject) bool{ 135 +func (p *OptionOpportunity) GetValidFunc(k string) bool {
  136 + m := map[string]func() bool{
136 "check": p.ValidCheck, 137 "check": p.ValidCheck,
137 } 138 }
138 - if _, ok := m[k]; ok {  
139 - return m[k] 139 + if fn, ok := m[k]; ok {
  140 + b := fn()
  141 + return b
140 } 142 }
141 - return nil 143 + return false
142 } 144 }
143 145
144 //MergeObject PermissionOptionBase 接口实现 146 //MergeObject PermissionOptionBase 接口实现
@@ -195,20 +197,20 @@ func (p *OptionOpportunity) MergeObject(jsonString string) error { @@ -195,20 +197,20 @@ func (p *OptionOpportunity) MergeObject(jsonString string) error {
195 return nil 197 return nil
196 } 198 }
197 199
198 -func (p *OptionOpportunity) ValidCheck(obj UserObject) bool { 200 +func (p *OptionOpportunity) ValidCheck() bool {
199 if p.Check > 0 { 201 if p.Check > 0 {
200 return true 202 return true
201 } 203 }
202 return false 204 return false
203 } 205 }
204 206
205 -func (p *OptionOpportunity) ValidEditSorce(obj UserObject) bool { 207 +func (p *OptionOpportunity) ValidEditSorce() bool {
206 if p.EditSorce > 0 { 208 if p.EditSorce > 0 {
207 return true 209 return true
208 } 210 }
209 return false 211 return false
210 } 212 }
211 -func (p *OptionOpportunity) ValidEditPublicStatus(obj UserObject) bool { 213 +func (p *OptionOpportunity) ValidEditPublicStatus() bool {
212 if p.EditPublicStatus > 0 { 214 if p.EditPublicStatus > 0 {
213 return true 215 return true
214 } 216 }