From 2b425befab18ffb80d4758c5dd39ec547562a09d Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Sun, 29 Jan 2023 15:02:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=97=E8=A1=A8=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/v2/ui/views/sys_funclist.go | 10 ++++++++++ modules/sys/api_func.go | 31 +++++++++++++++++++++++++------ pb/sys_msg.pb.go | 22 ++++++++++++++++------ 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/cmd/v2/ui/views/sys_funclist.go b/cmd/v2/ui/views/sys_funclist.go index 5365ff1e1..2638954bf 100644 --- a/cmd/v2/ui/views/sys_funclist.go +++ b/cmd/v2/ui/views/sys_funclist.go @@ -4,8 +4,10 @@ import ( "go_dreamfactory/cmd/v2/model" "go_dreamfactory/cmd/v2/service" "go_dreamfactory/pb" + "strings" "fyne.io/fyne/v2" + "fyne.io/fyne/v2/widget" "github.com/sirupsen/logrus" ) @@ -14,8 +16,16 @@ type SysFuncListView struct { } func (this *SysFuncListView) CreateView(t *model.TestCase) fyne.CanvasObject { + keyEntry := widget.NewEntry() + this.form.AppendItem(widget.NewFormItem("Key", keyEntry)) this.form.OnSubmit = func() { + s := strings.SplitN(keyEntry.Text, ",", 2) req := &pb.SysFuncListReq{} + if s[0] == "" { + req.Keys = []string{} + } else { + req.Keys = s + } if err := service.GetPttService().SendToClient( t.MainType, t.SubType, diff --git a/modules/sys/api_func.go b/modules/sys/api_func.go index ec4a53786..2522634f1 100644 --- a/modules/sys/api_func.go +++ b/modules/sys/api_func.go @@ -22,14 +22,33 @@ func (this *apiComp) Funclist(session comm.IUserSession, req *pb.SysFuncListReq) } var funcList []string - confList := this.moduleSys.configure.getOpencondList() - for _, v := range confList { - // 返回未开启的功能列表 - for _, conf := range v.Main { - if conf.Key == "platlv" && user.Lv < conf.Param { - funcList = append(funcList, v.Id) + if len(req.Keys) == 0 { + confList := this.moduleSys.configure.getOpencondList() + for _, v := range confList { + // 返回未开启的功能列表 + for _, conf := range v.Main { + // 校验玩家等级 + if conf.Key == "platlv" && user.Lv >= conf.Param { + funcList = append(funcList, v.Id) + continue + } + } + } + } else { + for _, key := range req.Keys { + opencfg, err := this.moduleSys.configure.getOpencondCfg() + if err != nil { continue } + if conf, ok := opencfg.GetDataMap()[key]; ok { + for _, main := range conf.Main { + // 校验玩家等级 + if main.Key == "platlv" && user.Lv >= main.Param { + funcList = append(funcList, key) + continue + } + } + } } } rsp.FuncIds = funcList diff --git a/pb/sys_msg.pb.go b/pb/sys_msg.pb.go index b7fbe2267..6f3516af4 100644 --- a/pb/sys_msg.pb.go +++ b/pb/sys_msg.pb.go @@ -24,6 +24,8 @@ type SysFuncListReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Keys []string `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys"` //功能ID } func (x *SysFuncListReq) Reset() { @@ -58,6 +60,13 @@ func (*SysFuncListReq) Descriptor() ([]byte, []int) { return file_sys_sys_msg_proto_rawDescGZIP(), []int{0} } +func (x *SysFuncListReq) GetKeys() []string { + if x != nil { + return x.Keys + } + return nil +} + type SysFuncListResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -109,12 +118,13 @@ var File_sys_sys_msg_proto protoreflect.FileDescriptor var file_sys_sys_msg_proto_rawDesc = []byte{ 0x0a, 0x11, 0x73, 0x79, 0x73, 0x2f, 0x73, 0x79, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0x10, 0x0a, 0x0e, 0x53, 0x79, 0x73, 0x46, 0x75, 0x6e, 0x63, 0x4c, 0x69, - 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x2b, 0x0a, 0x0f, 0x53, 0x79, 0x73, 0x46, 0x75, 0x6e, 0x63, - 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x75, 0x6e, 0x63, - 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x66, 0x75, 0x6e, 0x63, 0x49, - 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6f, 0x74, 0x6f, 0x22, 0x24, 0x0a, 0x0e, 0x53, 0x79, 0x73, 0x46, 0x75, 0x6e, 0x63, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x22, 0x2b, 0x0a, 0x0f, 0x53, 0x79, 0x73, + 0x46, 0x75, 0x6e, 0x63, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x18, 0x0a, 0x07, + 0x66, 0x75, 0x6e, 0x63, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x66, + 0x75, 0x6e, 0x63, 0x49, 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var (