65 lines
1.7 KiB
Go
65 lines
1.7 KiB
Go
package sys
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
func (this *apiComp) FuncActivateCheck(session comm.IUserSession, req *pb.SysFuncActivateReq) (errdata *pb.ErrorData) {
|
|
return
|
|
}
|
|
|
|
// cond 值 为0 表示功能未开启 1 功能开启 需要手动激活 2 功能开启并激活
|
|
func (this *apiComp) FuncActivate(session comm.IUserSession, req *pb.SysFuncActivateReq) (errdata *pb.ErrorData) {
|
|
|
|
rsp := &pb.SysFuncActivateResp{}
|
|
|
|
opencfg := this.module.configure.getOpencondCfgByCid(req.Cid)
|
|
if opencfg != nil {
|
|
if id := this.module.modelSys.validCond(session.GetUserId(), opencfg); id == "" { // 条件不满足
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_OpenCondErr,
|
|
Title: pb.ErrorCode_OpenCondErr.ToString(),
|
|
}
|
|
return
|
|
}
|
|
}
|
|
|
|
list, _ := this.module.modelSys.GetOpenCondList(session.GetUserId())
|
|
|
|
if v, ok := list.Cond[req.Cid]; !ok || v != 1 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_OpenCondActivate,
|
|
Title: pb.ErrorCode_OpenCondActivate.ToString(),
|
|
}
|
|
return
|
|
}
|
|
list.Cond[req.Cid] = 2
|
|
this.module.modelSys.ChangeOpenCondData(session.GetUserId(), map[string]interface{}{
|
|
"cond": list.Cond,
|
|
})
|
|
rsp.Cid = req.Cid
|
|
if err := session.SendMsg(string(this.module.GetType()), "funcactivate", rsp); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_SystemError,
|
|
Title: pb.ErrorCode_SystemError.ToString(),
|
|
}
|
|
return
|
|
}
|
|
|
|
//手动激活通知模块
|
|
for _, m := range opencfg.Notify {
|
|
i, err := this.service.GetModule(core.M_Modules(m))
|
|
if err != nil {
|
|
this.module.Errorln(err)
|
|
continue
|
|
}
|
|
|
|
if ic, ok := i.(comm.IOpenCmdNotice); ok {
|
|
ic.OpenCmdNotice(session, req.Cid)
|
|
}
|
|
}
|
|
return
|
|
}
|