85 lines
2.1 KiB
Go
85 lines
2.1 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
|
|
change []string = make([]string, 0)
|
|
list *pb.DBOpenCond
|
|
)
|
|
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
|
|
}
|
|
if list, err = this.module.modelSys.GetOpenCondList(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if len(req.Keys) == 0 {
|
|
for _, v := range opencfg.GetDataList() {
|
|
if list.Cond[v.Id] == 0 {
|
|
|
|
id := this.module.modelSys.CheckValidCond(session.GetUserId(), v, list)
|
|
if id != "" {
|
|
if v.ActivateType == 1 { // 需要手动激活的
|
|
list.Cond[id] = 1 //设置激活
|
|
} else {
|
|
list.Cond[id] = 2 //自动激活
|
|
change = append(change, id)
|
|
}
|
|
bChange = true
|
|
}
|
|
}
|
|
rsp.Cond[v.Id] = list.Cond[v.Id]
|
|
}
|
|
} else {
|
|
for _, key := range req.Keys {
|
|
if list.Cond[key] == 0 {
|
|
if conf, ok := opencfg.GetDataMap()[key]; ok {
|
|
id := this.module.modelSys.CheckValidCond(session.GetUserId(), conf, list)
|
|
if id != "" {
|
|
if conf.ActivateType == 1 { // 需要手动激活的
|
|
list.Cond[id] = 1 //设置激活
|
|
} else {
|
|
list.Cond[id] = 2 //自动激活
|
|
change = append(change, id)
|
|
}
|
|
bChange = true
|
|
}
|
|
}
|
|
}
|
|
rsp.Cond[key] = list.Cond[key]
|
|
}
|
|
}
|
|
|
|
if bChange {
|
|
this.module.modelSys.ChangeOpenCondData(session.GetUserId(), map[string]interface{}{
|
|
"cond": list.Cond,
|
|
})
|
|
}
|
|
if len(change) > 0 {
|
|
go this.module.wtask.OpenCmdNotice(session.GetUserId(), change...)
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "funcgetlist", rsp)
|
|
return
|
|
}
|