diff --git a/modules/sys/api_activate.go b/modules/sys/api_activate.go index bad8a3141..3282c4b95 100644 --- a/modules/sys/api_activate.go +++ b/modules/sys/api_activate.go @@ -10,6 +10,7 @@ func (this *apiComp) FuncActivateCheck(session comm.IUserSession, req *pb.SysFun return } +// cond 值 为0 表示功能未开启 1 功能开启 需要手动激活 2 功能开启并激活 func (this *apiComp) FuncActivate(session comm.IUserSession, req *pb.SysFuncActivateReq) (errdata *pb.ErrorData) { rsp := &pb.SysFuncActivateResp{} @@ -26,16 +27,15 @@ func (this *apiComp) FuncActivate(session comm.IUserSession, req *pb.SysFuncActi } list, _ := this.module.modelSys.GetOpenCondList(session.GetUserId()) - for k, v := range list.Cond { - if k == req.Cid && v != 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_OpenCondActivate, - Title: pb.ErrorCode_OpenCondActivate.ToString(), - } - return + + 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] = 1 + list.Cond[req.Cid] = 2 this.module.modelSys.ChangeOpenCondData(session.GetUserId(), map[string]interface{}{ "cond": list.Cond, }) diff --git a/modules/sys/api_getlist.go b/modules/sys/api_getlist.go index 93ff63767..20f50b71b 100644 --- a/modules/sys/api_getlist.go +++ b/modules/sys/api_getlist.go @@ -30,13 +30,15 @@ func (this *apiComp) FuncGetList(session comm.IUserSession, req *pb.SysFuncGetLi if list.Cond[v.Id] == 0 { id := this.module.modelSys.validCond(session.GetUserId(), v) if id != "" { - rsp.Cond[id] = 1 - list.Cond[id] = 1 //设置激活 + if v.ActivateType == 1 { // 需要手动激活的 + list.Cond[id] = 1 //设置激活 + } else { + list.Cond[id] = 2 //自动激活 + } bChange = true } - } else { - rsp.Cond[v.Id] = 1 } + rsp.Cond[v.Id] = list.Cond[v.Id] } } else { for _, key := range req.Keys { @@ -44,15 +46,16 @@ func (this *apiComp) FuncGetList(session comm.IUserSession, req *pb.SysFuncGetLi 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 //设置激活 + if conf.ActivateType == 1 { // 需要手动激活的 + list.Cond[id] = 1 //设置激活 + } else { + list.Cond[id] = 2 //自动激活 + } bChange = true } } - } else { - rsp.Cond[key] = 1 } - + rsp.Cond[key] = list.Cond[key] } }