53 lines
1.3 KiB
Go
53 lines
1.3 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.moduleSys.ModuleUser
|
|
user := iuser.GetUser(session.GetUserId())
|
|
if user == nil {
|
|
code = pb.ErrorCode_UserSessionNobeing
|
|
return
|
|
}
|
|
|
|
var funcList []string
|
|
if len(req.Keys) == 0 {
|
|
confList := this.moduleSys.configure.getOpencondList()
|
|
for _, v := range confList {
|
|
id := this.moduleSys.modelSys.validCond(session.GetUserId(), v)
|
|
if id != "" {
|
|
funcList = append(funcList, id)
|
|
}
|
|
}
|
|
} else {
|
|
for _, key := range req.Keys {
|
|
opencfg, err := this.moduleSys.configure.getOpencondCfg()
|
|
if err != nil {
|
|
continue
|
|
}
|
|
if conf, ok := opencfg.GetDataMap()[key]; ok {
|
|
id := this.moduleSys.modelSys.validCond(session.GetUserId(), conf)
|
|
if id != "" {
|
|
funcList = append(funcList, id)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
rsp.FuncIds = funcList
|
|
if err := session.SendMsg(string(this.moduleSys.GetType()), SysSubTypeFunc, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|