go_dreamfactory/modules/sys/api_getlist.go
2023-04-14 12:21:58 +08:00

63 lines
1.4 KiB
Go

package sys
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
func (this *apiComp) FuncGetListCheck(session comm.IUserSession, req *pb.SysFuncGetListReq) (code pb.ErrorCode) {
return
}
func (this *apiComp) FuncGetList(session comm.IUserSession, req *pb.SysFuncGetListReq) (code pb.ErrorCode, data *pb.ErrorData) {
rsp := &pb.SysFuncGetListResp{}
rsp.Cond = make(map[string]int32, 0)
list, _ := this.module.modelSys.GetOpenCondList(session.GetUserId())
if len(req.Keys) == 0 {
confList := this.module.configure.getOpencondList()
for _, v := range confList {
id := this.module.modelSys.validCond(session.GetUserId(), v)
if id != "" {
if v.ActivateType == 1 {
if _, ok := list.Cond[id]; ok {
rsp.Cond[id] = 1
} else {
rsp.Cond[id] = 0
}
} else {
rsp.Cond[id] = 1
}
}
}
} else {
for _, key := range req.Keys {
opencfg, err := this.module.configure.getOpencondCfg()
if err != nil {
continue
}
if conf, ok := opencfg.GetDataMap()[key]; ok {
id := this.module.modelSys.validCond(session.GetUserId(), conf)
if id != "" {
if conf.ActivateType == 1 {
if _, ok := list.Cond[id]; ok {
rsp.Cond[id] = 1
} else {
rsp.Cond[id] = 0
}
} else {
rsp.Cond[id] = 1
}
}
}
}
}
if err := session.SendMsg(string(this.module.GetType()), "funcgetlist", rsp); err != nil {
code = pb.ErrorCode_SystemError
}
return
}