go_dreamfactory/modules/sys/api_getlist.go
2023-04-10 15:49:05 +08:00

53 lines
1.2 KiB
Go

package sys
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
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 proto.Message) {
rsp := &pb.SysFuncGetListResp{}
rsp.Cond = make(map[string]int32, 0)
if len(req.Keys) == 0 {
confList := this.module.configure.getOpencondList()
for _, v := range confList {
id := this.module.modelSys.validCond(session.GetUserId(), v)
if id != "" {
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 != "" {
rsp.Cond[id] = 1
}
}
}
}
list, _ := this.module.modelSys.GetOpenCondList(session.GetUserId())
for k, v := range list.Cond {
//if _, ok := rsp.Cond[k]; ok {
rsp.Cond[k] = v
//}
}
if err := session.SendMsg(string(this.module.GetType()), "funcgetlist", rsp); err != nil {
code = pb.ErrorCode_SystemError
}
return
}