55 lines
1.4 KiB
Go
55 lines
1.4 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) (code pb.ErrorCode) {
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) FuncActivate(session comm.IUserSession, req *pb.SysFuncActivateReq) (code pb.ErrorCode, data *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 == "" { // 条件不满足
|
|
code = pb.ErrorCode_OpenCondErr
|
|
return
|
|
}
|
|
}
|
|
|
|
list, _ := this.module.modelSys.GetOpenCondList(session.GetUserId())
|
|
for k, v := range list.Cond {
|
|
if k == req.Cid && v != 0 {
|
|
code = pb.ErrorCode_OpenCondActivate
|
|
return
|
|
}
|
|
}
|
|
list.Cond[req.Cid] = 1
|
|
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 {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
|
|
//手动激活通知模块
|
|
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
|
|
}
|