go_dreamfactory/modules/sys/api_getlist.go
2023-06-30 23:08:31 +08:00

67 lines
1.5 KiB
Go

package sys
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
func (this *apiComp) FuncGetListCheck(session comm.IUserSession, req *pb.SysFuncGetListReq) (errdata *pb.ErrorData) {
return
}
func (this *apiComp) FuncGetList(session comm.IUserSession, req *pb.SysFuncGetListReq) (errdata *pb.ErrorData) {
var (
bChange bool
)
rsp := &pb.SysFuncGetListResp{}
rsp.Cond = make(map[string]int32, 0)
opencfg, err := this.module.configure.getOpencondCfg()
if err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Message: err.Error(),
}
return
}
list, _ := this.module.modelSys.GetOpenCondList(session.GetUserId())
if len(req.Keys) == 0 {
for _, v := range opencfg.GetDataList() {
if list.Cond[v.Id] == 0 {
id := this.module.modelSys.validCond(session.GetUserId(), v)
if id != "" {
rsp.Cond[id] = 1
list.Cond[id] = 1 //设置激活
bChange = true
}
} else {
rsp.Cond[v.Id] = 1
}
}
} else {
for _, key := range req.Keys {
if list.Cond[key] == 0 {
if conf, ok := opencfg.GetDataMap()[key]; ok {
id := this.module.modelSys.validCond(session.GetUserId(), conf)
if id != "" {
rsp.Cond[id] = 1
list.Cond[key] = 1 //设置激活
bChange = true
}
}
} else {
rsp.Cond[key] = 1
}
}
}
if bChange {
this.module.modelSys.ChangeOpenCondData(session.GetUserId(), map[string]interface{}{
"cond": list.Cond,
})
}
session.SendMsg(string(this.module.GetType()), "funcgetlist", rsp)
return
}