go_dreamfactory/modules/sys/api_func.go
2023-04-03 15:33:45 +08:00

51 lines
1.2 KiB
Go

package sys
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
func (this *apiComp) FunclistCheck(session comm.IUserSession, req *pb.SysFuncListReq) (code pb.ErrorCode) {
return
}
func (this *apiComp) Funclist(session comm.IUserSession, req *pb.SysFuncListReq) (code pb.ErrorCode, data proto.Message) {
rsp := &pb.SysFuncListResp{}
iuser := this.module.ModuleUser
user := iuser.GetUser(session.GetUserId())
if user == nil {
code = pb.ErrorCode_UserSessionNobeing
return
}
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.FuncIds = append(rsp.FuncIds, id)
}
}
} 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.FuncIds = append(rsp.FuncIds, id)
}
}
}
}
if err := session.SendMsg(string(this.module.GetType()), SysSubTypeFunc, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
return
}