From 0389b95d065c9ba5a64498b1cbee8c32e437ff1a Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 4 Jul 2023 11:29:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=9D=A1=E4=BB=B6=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E9=BB=98=E8=AE=A4=E5=80=BC=E4=BF=AE=E6=94=B9=200=20?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E6=9C=AA=E5=BC=80=E5=90=AF=201=20=E5=B7=B2?= =?UTF-8?q?=E5=BC=80=E5=90=AF=20=E9=9C=80=E8=A6=81=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E6=BF=80=E6=B4=BB=EF=BC=8C=202=20=E5=B7=B2=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/sys/api_activate.go | 16 ++++++++-------- modules/sys/api_getlist.go | 21 ++++++++++++--------- 2 files changed, 20 insertions(+), 17 deletions(-) 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] } }