From 1760e8b9c8de222c5bd610b67b551e02e32d813f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sat, 23 Dec 2023 20:55:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=B7=E6=B1=82=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=AE=A1=E6=A0=B8=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/rpc.json | 121 +++ pkg/langs/codes/codes.go | 2 + pkg/langs/messages/messages_en_us.go | 2 + pkg/langs/messages/messages_zh_cn.go | 2 + .../protos/zh-cn/server_user_script.json | 4 + pkg/rpc/pb/model_user_script.pb.go | 255 ++++++ pkg/rpc/pb/service_user_script.pb.go | 762 ++++++++++++++++++ pkg/rpc/pb/service_user_script_grpc.pb.go | 304 +++++++ pkg/rpc/protos/models/model_user_script.proto | 23 + pkg/rpc/protos/service_user_script.proto | 75 ++ .../http_request_scripts_config.go | 11 + pkg/serverconfigs/script_config.go | 25 +- 12 files changed, 1585 insertions(+), 1 deletion(-) create mode 100644 pkg/langs/protos/zh-cn/server_user_script.json create mode 100644 pkg/rpc/pb/model_user_script.pb.go create mode 100644 pkg/rpc/pb/service_user_script.pb.go create mode 100644 pkg/rpc/pb/service_user_script_grpc.pb.go create mode 100644 pkg/rpc/protos/models/model_user_script.proto create mode 100644 pkg/rpc/protos/service_user_script.proto diff --git a/build/rpc.json b/build/rpc.json index 8842630..49f23f6 100644 --- a/build/rpc.json +++ b/build/rpc.json @@ -13338,6 +13338,77 @@ "filename": "service_user_plan.proto", "doc": "用户购买的套餐管理服务" }, + { + "name": "UserScriptService", + "methods": [ + { + "name": "findUserScript", + "requestMessageName": "FindUserScriptRequest", + "responseMessageName": "FindUserScriptResponse", + "code": "rpc findUserScript(FindUserScriptRequest) returns (FindUserScriptResponse);", + "doc": "查找单个用户脚本信息", + "roles": [ + "admin" + ], + "isDeprecated": false + }, + { + "name": "findUserScriptWithMD5", + "requestMessageName": "FindUserScriptWithMD5Request", + "responseMessageName": "FindUserScriptWithMD5Response", + "code": "rpc findUserScriptWithMD5(FindUserScriptWithMD5Request) returns (FindUserScriptWithMD5Response);", + "doc": "根据代码MD5查找脚本", + "roles": [], + "isDeprecated": false + }, + { + "name": "countUserScripts", + "requestMessageName": "CountUserScriptsRequest", + "responseMessageName": "RPCCountResponse", + "code": "rpc countUserScripts(CountUserScriptsRequest) returns (RPCCountResponse);", + "doc": "计算用户脚本数量", + "roles": [ + "admin" + ], + "isDeprecated": false + }, + { + "name": "listUserScripts", + "requestMessageName": "ListUserScriptsRequest", + "responseMessageName": "ListUserScriptsResponse", + "code": "rpc listUserScripts(ListUserScriptsRequest) returns (ListUserScriptsResponse);", + "doc": "列出单页用户脚本", + "roles": [ + "admin" + ], + "isDeprecated": false + }, + { + "name": "passUserScript", + "requestMessageName": "PassUserScriptRequest", + "responseMessageName": "RPCSuccess", + "code": "rpc passUserScript(PassUserScriptRequest) returns (RPCSuccess);", + "doc": "审核并通过用户脚本", + "roles": [ + "admin" + ], + "isDeprecated": false + }, + { + "name": "rejectUserScript", + "requestMessageName": "RejectUserScriptRequest", + "responseMessageName": "RPCSuccess", + "code": "rpc rejectUserScript(RejectUserScriptRequest) returns (RPCSuccess);", + "doc": "审核并驳回用户脚本", + "roles": [ + "admin" + ], + "isDeprecated": false + } + ], + "filename": "service_user_script.proto", + "doc": "用户脚本服务" + }, { "name": "UserTicketService", "methods": [ @@ -14740,6 +14811,11 @@ "code": "message CountUserAccountsRequest {\n\tstring keyword = 1; // 关键词\n}", "doc": "计算账户数量" }, + { + "name": "CountUserScriptsRequest", + "code": "message CountUserScriptsRequest {\n\tint64 userId = 1; // 所属用户ID\n\tbool isAuditing = 2; // 是否正在审核\n}", + "doc": "计算用户脚本数量" + }, { "name": "CountUserTicketLogsRequest", "code": "message CountUserTicketLogsRequest {\n\tint64 userTicketId = 1;\n}", @@ -19945,6 +20021,26 @@ "code": "message FindUserPriceInfoResponse {\n\tstring priceType = 1;\n\tstring pricePeriod = 2;\n}", "doc": "" }, + { + "name": "FindUserScriptRequest", + "code": "message FindUserScriptRequest {\n\tint64 userScriptId = 1; // 用户脚本ID\n}", + "doc": "查找单个用户脚本信息" + }, + { + "name": "FindUserScriptResponse", + "code": "message FindUserScriptResponse {\n\tUserScript userScript = 1; // 用户脚本信息\n}", + "doc": "" + }, + { + "name": "FindUserScriptWithMD5Request", + "code": "message FindUserScriptWithMD5Request {\n\tstring codeMD5 = 1; // 代码MD5(32位)\n}", + "doc": "根据代码MD5查找脚本" + }, + { + "name": "FindUserScriptWithMD5Response", + "code": "message FindUserScriptWithMD5Response {\n\tUserScript userScript = 1; // 用户脚本信息\n}", + "doc": "" + }, { "name": "FindUserTicketCategoryRequest", "code": "message FindUserTicketCategoryRequest {\n\tint64 userTicketCategoryId = 1;\n}", @@ -20880,6 +20976,16 @@ "code": "message ListUserBillsResponse {\n\trepeated UserBill userBills = 1;\n}", "doc": "" }, + { + "name": "ListUserScriptsRequest", + "code": "message ListUserScriptsRequest {\n\tint64 userId = 1; // 所属用户ID\n\tbool isAuditing = 2; // 是否正在审核\n\tint64 offset = 3; // 开始读取位置\n\tint64 size = 4; // 读取数量\n}", + "doc": "列出单页用户脚本" + }, + { + "name": "ListUserScriptsResponse", + "code": "message ListUserScriptsResponse {\n\trepeated UserScript userScripts = 1; // 用户脚本列表\n}", + "doc": "" + }, { "name": "ListUserTicketLogsRequest", "code": "message ListUserTicketLogsRequest {\n\tint64 userTicketId = 1;\n\tint64 offset = 2;\n\tint64 size = 3;\n}", @@ -21240,6 +21346,11 @@ "code": "message Origin {\n\tint64 id = 1;\n\tbool isOn = 2;\n\tstring name = 3;\n\tNetworkAddress addr = 4; // 源站网络地址\n\tbytes ossJSON = 9; // 源站网络地址为oss:开头时有此内容\n\tstring description = 5;\n\trepeated string domains = 6;\n\tstring host = 7;\n\tbool followPort = 8;\n\tbool http2Enabled = 10; // 是否支持HTTP/2,只在HTTPS源站时生效\n}", "doc": "" }, + { + "name": "PassUserScriptRequest", + "code": "message PassUserScriptRequest {\n\tint64 userScriptId = 1; // 用户脚本ID\n}", + "doc": "审核并通过用户脚本" + }, { "name": "PayUserBillRequest", "code": "message PayUserBillRequest {\n\tint64 userBillId = 1;\n}", @@ -21365,6 +21476,11 @@ "code": "message RejectUserIdentityRequest {\n\tint64 userIdentityId = 1;\n\tstring reason = 2;\n}", "doc": "拒绝用户实名认证信息" }, + { + "name": "RejectUserScriptRequest", + "code": "message RejectUserScriptRequest {\n\tint64 userScriptId = 1; // 用户脚本ID\n\tstring reason = 2; // 驳回理由\n}", + "doc": "审核并驳回用户脚本" + }, { "name": "RenewUserADInstanceRequest", "code": "message RenewUserADInstanceRequest {\n\tint64 userADInstanceId = 1;\n\tint64 adPackagePeriodId = 2;\n}", @@ -23085,6 +23201,11 @@ "code": "message UserPlan {\n\tint64 id = 1; // 套餐ID\n\tint64 userId = 2; // 用户ID\n\tint64 planId = 3; // 套餐定义ID\n\tbool isOn = 4; // 是否启用\n\tstring dayTo = 5; // 到期日期Y-m-d\n\tstring name = 6; // 自定义备注名称\n\n\tUser user = 30; // 用户信息\n\tPlan plan = 31; // 套餐定义信息\n\trepeated Server servers = 33; // 绑定的网站列表\n\n\tServer server = 32 [deprecated = true]; // 绑定的网站,已过期,使用 servers 代替\n}", "doc": "" }, + { + "name": "UserScript", + "code": "message UserScript {\n\tint64 id = 1; // 用户脚本ID\n\tint64 userId = 2; // 用户ID\n\tint64 adminId = 3; // 审核的管理员\n\tstring code = 4; // 脚本代码\n\tstring codeMD5 = 5; // 脚本代码MD5\n\tint64 createdAt = 6; // 创建时间\n\tbool isRejected = 7; // 是否被驳回\n\tint64 rejectedAt = 8; // 驳回时间\n\tstring rejectedReason = 9; // 驳回原因\n\tbool isPassed = 10; // 是否被通过\n\tint64 passedAt = 11; // 通过时间\n\n\tUser user = 30; // 用户信息\n}", + "doc": "用户脚本" + }, { "name": "UserTicket", "code": "message UserTicket {\n\tint64 id = 1;\n\tint64 categoryId = 2;\n\tint64 userId = 3;\n\tstring subject = 4;\n\tstring body = 5;\n\tstring status = 6;\n\tint64 createdAt = 7;\n\tint64 lastLogAt = 8;\n\n\tUserTicketCategory userTicketCategory = 30;\n\tUser user = 31;\n\tUserTicketLog latestUserTicketLog = 32;\n}", diff --git a/pkg/langs/codes/codes.go b/pkg/langs/codes/codes.go index 20fbfdb..e368e8d 100644 --- a/pkg/langs/codes/codes.go +++ b/pkg/langs/codes/codes.go @@ -619,6 +619,8 @@ const ( ServerUAM_LogUpdateUAMSettings langs.MessageCode = "server_uam@log_update_uam_settings" // 修改Web %d 全站防护模式 ServerUDP_LogUpdateUDPSettings langs.MessageCode = "server_udp@log_update_udp_settings" // 修改网站 %d UDP设置 ServerUserAgent_LogUpdateUserAgents langs.MessageCode = "server_user_agent@log_update_user_agents" // 修改Web %d User-Agent设置 + ServerUserScript_LogPassUserScript langs.MessageCode = "server_user_script@log_pass_user_script" // 通过用户脚本 %d + ServerUserScript_LogRejectUserScript langs.MessageCode = "server_user_script@log_reject_user_script" // 驳回用户脚本 %d ServerWAF_LogUpdateWAFSettings langs.MessageCode = "server_waf@log_update_waf_settings" // 修改Web %d 的WAF设置 ServerWebP_LogUpdateClusterWebPPolicy langs.MessageCode = "server_webp@log_update_cluster_webp_policy" // 修改集群 %d 的WebP设置 ServerWebsocket_LogUpdateWebsocketSettings langs.MessageCode = "server_websocket@log_update_websocket_settings" // 修改Web %d 的Websocket设置 diff --git a/pkg/langs/messages/messages_en_us.go b/pkg/langs/messages/messages_en_us.go index b35bce0..9c59835 100644 --- a/pkg/langs/messages/messages_en_us.go +++ b/pkg/langs/messages/messages_en_us.go @@ -620,6 +620,8 @@ func init() { "server_uam@log_update_uam_settings": "", "server_udp@log_update_udp_settings": "", "server_user_agent@log_update_user_agents": "", + "server_user_script@log_pass_user_script": "", + "server_user_script@log_reject_user_script": "", "server_waf@log_update_waf_settings": "", "server_webp@log_update_cluster_webp_policy": "", "server_websocket@log_update_websocket_settings": "", diff --git a/pkg/langs/messages/messages_zh_cn.go b/pkg/langs/messages/messages_zh_cn.go index 7f1db59..066ee12 100644 --- a/pkg/langs/messages/messages_zh_cn.go +++ b/pkg/langs/messages/messages_zh_cn.go @@ -620,6 +620,8 @@ func init() { "server_uam@log_update_uam_settings": "修改Web %d 全站防护模式", "server_udp@log_update_udp_settings": "修改网站 %d UDP设置", "server_user_agent@log_update_user_agents": "修改Web %d User-Agent设置", + "server_user_script@log_pass_user_script": "通过用户脚本 %d", + "server_user_script@log_reject_user_script": "驳回用户脚本 %d", "server_waf@log_update_waf_settings": "修改Web %d 的WAF设置", "server_webp@log_update_cluster_webp_policy": "修改集群 %d 的WebP设置", "server_websocket@log_update_websocket_settings": "修改Web %d 的Websocket设置", diff --git a/pkg/langs/protos/zh-cn/server_user_script.json b/pkg/langs/protos/zh-cn/server_user_script.json new file mode 100644 index 0000000..c85a5ad --- /dev/null +++ b/pkg/langs/protos/zh-cn/server_user_script.json @@ -0,0 +1,4 @@ +{ + "log_pass_user_script": "通过用户脚本 %d", + "log_reject_user_script": "驳回用户脚本 %d" +} \ No newline at end of file diff --git a/pkg/rpc/pb/model_user_script.pb.go b/pkg/rpc/pb/model_user_script.pb.go new file mode 100644 index 0000000..e96cc76 --- /dev/null +++ b/pkg/rpc/pb/model_user_script.pb.go @@ -0,0 +1,255 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.4 +// source: models/model_user_script.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// 用户脚本 +type UserScript struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 用户脚本ID + UserId int64 `protobuf:"varint,2,opt,name=userId,proto3" json:"userId,omitempty"` // 用户ID + AdminId int64 `protobuf:"varint,3,opt,name=adminId,proto3" json:"adminId,omitempty"` // 审核的管理员 + Code string `protobuf:"bytes,4,opt,name=code,proto3" json:"code,omitempty"` // 脚本代码 + CodeMD5 string `protobuf:"bytes,5,opt,name=codeMD5,proto3" json:"codeMD5,omitempty"` // 脚本代码MD5 + CreatedAt int64 `protobuf:"varint,6,opt,name=createdAt,proto3" json:"createdAt,omitempty"` // 创建时间 + IsRejected bool `protobuf:"varint,7,opt,name=isRejected,proto3" json:"isRejected,omitempty"` // 是否被驳回 + RejectedAt int64 `protobuf:"varint,8,opt,name=rejectedAt,proto3" json:"rejectedAt,omitempty"` // 驳回时间 + RejectedReason string `protobuf:"bytes,9,opt,name=rejectedReason,proto3" json:"rejectedReason,omitempty"` // 驳回原因 + IsPassed bool `protobuf:"varint,10,opt,name=isPassed,proto3" json:"isPassed,omitempty"` // 是否被通过 + PassedAt int64 `protobuf:"varint,11,opt,name=passedAt,proto3" json:"passedAt,omitempty"` // 通过时间 + User *User `protobuf:"bytes,30,opt,name=user,proto3" json:"user,omitempty"` // 用户信息 +} + +func (x *UserScript) Reset() { + *x = UserScript{} + if protoimpl.UnsafeEnabled { + mi := &file_models_model_user_script_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserScript) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserScript) ProtoMessage() {} + +func (x *UserScript) ProtoReflect() protoreflect.Message { + mi := &file_models_model_user_script_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserScript.ProtoReflect.Descriptor instead. +func (*UserScript) Descriptor() ([]byte, []int) { + return file_models_model_user_script_proto_rawDescGZIP(), []int{0} +} + +func (x *UserScript) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UserScript) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *UserScript) GetAdminId() int64 { + if x != nil { + return x.AdminId + } + return 0 +} + +func (x *UserScript) GetCode() string { + if x != nil { + return x.Code + } + return "" +} + +func (x *UserScript) GetCodeMD5() string { + if x != nil { + return x.CodeMD5 + } + return "" +} + +func (x *UserScript) GetCreatedAt() int64 { + if x != nil { + return x.CreatedAt + } + return 0 +} + +func (x *UserScript) GetIsRejected() bool { + if x != nil { + return x.IsRejected + } + return false +} + +func (x *UserScript) GetRejectedAt() int64 { + if x != nil { + return x.RejectedAt + } + return 0 +} + +func (x *UserScript) GetRejectedReason() string { + if x != nil { + return x.RejectedReason + } + return "" +} + +func (x *UserScript) GetIsPassed() bool { + if x != nil { + return x.IsPassed + } + return false +} + +func (x *UserScript) GetPassedAt() int64 { + if x != nil { + return x.PassedAt + } + return 0 +} + +func (x *UserScript) GetUser() *User { + if x != nil { + return x.User + } + return nil +} + +var File_models_model_user_script_proto protoreflect.FileDescriptor + +var file_models_model_user_script_proto_rawDesc = []byte{ + 0x0a, 0x1e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x02, 0x70, 0x62, 0x1a, 0x17, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, + 0x65, 0x6c, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd8, 0x02, + 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, + 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, + 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x12, + 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, + 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x4d, 0x44, 0x35, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x4d, 0x44, 0x35, 0x12, 0x1c, 0x0a, 0x09, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, + 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, + 0x69, 0x73, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, + 0x6a, 0x65, 0x63, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, + 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x72, 0x65, + 0x6a, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0e, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x65, 0x61, 0x73, + 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x73, 0x50, 0x61, 0x73, 0x73, 0x65, 0x64, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x50, 0x61, 0x73, 0x73, 0x65, 0x64, 0x12, 0x1a, + 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1c, 0x0a, 0x04, 0x75, 0x73, + 0x65, 0x72, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x73, + 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_models_model_user_script_proto_rawDescOnce sync.Once + file_models_model_user_script_proto_rawDescData = file_models_model_user_script_proto_rawDesc +) + +func file_models_model_user_script_proto_rawDescGZIP() []byte { + file_models_model_user_script_proto_rawDescOnce.Do(func() { + file_models_model_user_script_proto_rawDescData = protoimpl.X.CompressGZIP(file_models_model_user_script_proto_rawDescData) + }) + return file_models_model_user_script_proto_rawDescData +} + +var file_models_model_user_script_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_models_model_user_script_proto_goTypes = []interface{}{ + (*UserScript)(nil), // 0: pb.UserScript + (*User)(nil), // 1: pb.User +} +var file_models_model_user_script_proto_depIdxs = []int32{ + 1, // 0: pb.UserScript.user:type_name -> pb.User + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_models_model_user_script_proto_init() } +func file_models_model_user_script_proto_init() { + if File_models_model_user_script_proto != nil { + return + } + file_models_model_user_proto_init() + if !protoimpl.UnsafeEnabled { + file_models_model_user_script_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserScript); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_models_model_user_script_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_models_model_user_script_proto_goTypes, + DependencyIndexes: file_models_model_user_script_proto_depIdxs, + MessageInfos: file_models_model_user_script_proto_msgTypes, + }.Build() + File_models_model_user_script_proto = out.File + file_models_model_user_script_proto_rawDesc = nil + file_models_model_user_script_proto_goTypes = nil + file_models_model_user_script_proto_depIdxs = nil +} diff --git a/pkg/rpc/pb/service_user_script.pb.go b/pkg/rpc/pb/service_user_script.pb.go new file mode 100644 index 0000000..3212493 --- /dev/null +++ b/pkg/rpc/pb/service_user_script.pb.go @@ -0,0 +1,762 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.4 +// source: service_user_script.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// 查找单个用户脚本信息 +type FindUserScriptRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserScriptId int64 `protobuf:"varint,1,opt,name=userScriptId,proto3" json:"userScriptId,omitempty"` // 用户脚本ID +} + +func (x *FindUserScriptRequest) Reset() { + *x = FindUserScriptRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_user_script_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FindUserScriptRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FindUserScriptRequest) ProtoMessage() {} + +func (x *FindUserScriptRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_user_script_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FindUserScriptRequest.ProtoReflect.Descriptor instead. +func (*FindUserScriptRequest) Descriptor() ([]byte, []int) { + return file_service_user_script_proto_rawDescGZIP(), []int{0} +} + +func (x *FindUserScriptRequest) GetUserScriptId() int64 { + if x != nil { + return x.UserScriptId + } + return 0 +} + +type FindUserScriptResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserScript *UserScript `protobuf:"bytes,1,opt,name=userScript,proto3" json:"userScript,omitempty"` // 用户脚本信息 +} + +func (x *FindUserScriptResponse) Reset() { + *x = FindUserScriptResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_user_script_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FindUserScriptResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FindUserScriptResponse) ProtoMessage() {} + +func (x *FindUserScriptResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_user_script_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FindUserScriptResponse.ProtoReflect.Descriptor instead. +func (*FindUserScriptResponse) Descriptor() ([]byte, []int) { + return file_service_user_script_proto_rawDescGZIP(), []int{1} +} + +func (x *FindUserScriptResponse) GetUserScript() *UserScript { + if x != nil { + return x.UserScript + } + return nil +} + +// 根据代码MD5查找脚本 +type FindUserScriptWithMD5Request struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CodeMD5 string `protobuf:"bytes,1,opt,name=codeMD5,proto3" json:"codeMD5,omitempty"` // 代码MD5(32位) +} + +func (x *FindUserScriptWithMD5Request) Reset() { + *x = FindUserScriptWithMD5Request{} + if protoimpl.UnsafeEnabled { + mi := &file_service_user_script_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FindUserScriptWithMD5Request) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FindUserScriptWithMD5Request) ProtoMessage() {} + +func (x *FindUserScriptWithMD5Request) ProtoReflect() protoreflect.Message { + mi := &file_service_user_script_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FindUserScriptWithMD5Request.ProtoReflect.Descriptor instead. +func (*FindUserScriptWithMD5Request) Descriptor() ([]byte, []int) { + return file_service_user_script_proto_rawDescGZIP(), []int{2} +} + +func (x *FindUserScriptWithMD5Request) GetCodeMD5() string { + if x != nil { + return x.CodeMD5 + } + return "" +} + +type FindUserScriptWithMD5Response struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserScript *UserScript `protobuf:"bytes,1,opt,name=userScript,proto3" json:"userScript,omitempty"` // 用户脚本信息 +} + +func (x *FindUserScriptWithMD5Response) Reset() { + *x = FindUserScriptWithMD5Response{} + if protoimpl.UnsafeEnabled { + mi := &file_service_user_script_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FindUserScriptWithMD5Response) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FindUserScriptWithMD5Response) ProtoMessage() {} + +func (x *FindUserScriptWithMD5Response) ProtoReflect() protoreflect.Message { + mi := &file_service_user_script_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FindUserScriptWithMD5Response.ProtoReflect.Descriptor instead. +func (*FindUserScriptWithMD5Response) Descriptor() ([]byte, []int) { + return file_service_user_script_proto_rawDescGZIP(), []int{3} +} + +func (x *FindUserScriptWithMD5Response) GetUserScript() *UserScript { + if x != nil { + return x.UserScript + } + return nil +} + +// 计算用户脚本数量 +type CountUserScriptsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId int64 `protobuf:"varint,1,opt,name=userId,proto3" json:"userId,omitempty"` // 所属用户ID + IsAuditing bool `protobuf:"varint,2,opt,name=isAuditing,proto3" json:"isAuditing,omitempty"` // 是否正在审核 +} + +func (x *CountUserScriptsRequest) Reset() { + *x = CountUserScriptsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_user_script_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CountUserScriptsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CountUserScriptsRequest) ProtoMessage() {} + +func (x *CountUserScriptsRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_user_script_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CountUserScriptsRequest.ProtoReflect.Descriptor instead. +func (*CountUserScriptsRequest) Descriptor() ([]byte, []int) { + return file_service_user_script_proto_rawDescGZIP(), []int{4} +} + +func (x *CountUserScriptsRequest) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *CountUserScriptsRequest) GetIsAuditing() bool { + if x != nil { + return x.IsAuditing + } + return false +} + +// 列出单页用户脚本 +type ListUserScriptsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId int64 `protobuf:"varint,1,opt,name=userId,proto3" json:"userId,omitempty"` // 所属用户ID + IsAuditing bool `protobuf:"varint,2,opt,name=isAuditing,proto3" json:"isAuditing,omitempty"` // 是否正在审核 + Offset int64 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"` // 开始读取位置 + Size int64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` // 读取数量 +} + +func (x *ListUserScriptsRequest) Reset() { + *x = ListUserScriptsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_user_script_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListUserScriptsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListUserScriptsRequest) ProtoMessage() {} + +func (x *ListUserScriptsRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_user_script_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListUserScriptsRequest.ProtoReflect.Descriptor instead. +func (*ListUserScriptsRequest) Descriptor() ([]byte, []int) { + return file_service_user_script_proto_rawDescGZIP(), []int{5} +} + +func (x *ListUserScriptsRequest) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *ListUserScriptsRequest) GetIsAuditing() bool { + if x != nil { + return x.IsAuditing + } + return false +} + +func (x *ListUserScriptsRequest) GetOffset() int64 { + if x != nil { + return x.Offset + } + return 0 +} + +func (x *ListUserScriptsRequest) GetSize() int64 { + if x != nil { + return x.Size + } + return 0 +} + +type ListUserScriptsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserScripts []*UserScript `protobuf:"bytes,1,rep,name=userScripts,proto3" json:"userScripts,omitempty"` // 用户脚本列表 +} + +func (x *ListUserScriptsResponse) Reset() { + *x = ListUserScriptsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_service_user_script_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListUserScriptsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListUserScriptsResponse) ProtoMessage() {} + +func (x *ListUserScriptsResponse) ProtoReflect() protoreflect.Message { + mi := &file_service_user_script_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListUserScriptsResponse.ProtoReflect.Descriptor instead. +func (*ListUserScriptsResponse) Descriptor() ([]byte, []int) { + return file_service_user_script_proto_rawDescGZIP(), []int{6} +} + +func (x *ListUserScriptsResponse) GetUserScripts() []*UserScript { + if x != nil { + return x.UserScripts + } + return nil +} + +// 审核并通过用户脚本 +type PassUserScriptRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserScriptId int64 `protobuf:"varint,1,opt,name=userScriptId,proto3" json:"userScriptId,omitempty"` // 用户脚本ID +} + +func (x *PassUserScriptRequest) Reset() { + *x = PassUserScriptRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_user_script_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PassUserScriptRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PassUserScriptRequest) ProtoMessage() {} + +func (x *PassUserScriptRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_user_script_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PassUserScriptRequest.ProtoReflect.Descriptor instead. +func (*PassUserScriptRequest) Descriptor() ([]byte, []int) { + return file_service_user_script_proto_rawDescGZIP(), []int{7} +} + +func (x *PassUserScriptRequest) GetUserScriptId() int64 { + if x != nil { + return x.UserScriptId + } + return 0 +} + +// 审核并驳回用户脚本 +type RejectUserScriptRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserScriptId int64 `protobuf:"varint,1,opt,name=userScriptId,proto3" json:"userScriptId,omitempty"` // 用户脚本ID + Reason string `protobuf:"bytes,2,opt,name=reason,proto3" json:"reason,omitempty"` // 驳回理由 +} + +func (x *RejectUserScriptRequest) Reset() { + *x = RejectUserScriptRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_user_script_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RejectUserScriptRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RejectUserScriptRequest) ProtoMessage() {} + +func (x *RejectUserScriptRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_user_script_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RejectUserScriptRequest.ProtoReflect.Descriptor instead. +func (*RejectUserScriptRequest) Descriptor() ([]byte, []int) { + return file_service_user_script_proto_rawDescGZIP(), []int{8} +} + +func (x *RejectUserScriptRequest) GetUserScriptId() int64 { + if x != nil { + return x.UserScriptId + } + return 0 +} + +func (x *RejectUserScriptRequest) GetReason() string { + if x != nil { + return x.Reason + } + return "" +} + +var File_service_user_script_proto protoreflect.FileDescriptor + +var file_service_user_script_proto_rawDesc = []byte{ + 0x0a, 0x19, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, + 0x1e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x75, 0x73, + 0x65, 0x72, 0x5f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x19, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x72, 0x70, 0x63, 0x5f, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3b, 0x0a, 0x15, 0x46, 0x69, + 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x75, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x75, 0x73, 0x65, 0x72, 0x53, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x49, 0x64, 0x22, 0x48, 0x0a, 0x16, 0x46, 0x69, 0x6e, 0x64, 0x55, + 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x2e, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x53, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x22, 0x38, 0x0a, 0x1c, 0x46, 0x69, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x57, 0x69, 0x74, 0x68, 0x4d, 0x44, 0x35, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x4d, 0x44, 0x35, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x4d, 0x44, 0x35, 0x22, 0x4f, 0x0a, 0x1d, 0x46, + 0x69, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x57, 0x69, 0x74, + 0x68, 0x4d, 0x44, 0x35, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x0a, + 0x75, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x52, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x22, 0x51, 0x0a, 0x17, + 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, + 0x1e, 0x0a, 0x0a, 0x69, 0x73, 0x41, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x41, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x22, + 0x7c, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, + 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, + 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, 0x41, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x41, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, + 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x4b, 0x0a, + 0x17, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x75, 0x73, 0x65, 0x72, + 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, + 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x0b, 0x75, + 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x15, 0x50, 0x61, + 0x73, 0x73, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x75, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x75, 0x73, 0x65, 0x72, 0x53, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x49, 0x64, 0x22, 0x55, 0x0a, 0x17, 0x52, 0x65, 0x6a, 0x65, 0x63, + 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x75, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x75, 0x73, 0x65, 0x72, 0x53, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x32, 0xcb, + 0x03, 0x0a, 0x11, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x0e, 0x66, 0x69, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, + 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, + 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x53, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, + 0x15, 0x66, 0x69, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x57, + 0x69, 0x74, 0x68, 0x4d, 0x44, 0x35, 0x12, 0x20, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, + 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x57, 0x69, 0x74, 0x68, 0x4d, 0x44, + 0x35, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, + 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x57, 0x69, 0x74, 0x68, + 0x4d, 0x44, 0x35, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x10, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x12, + 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, + 0x62, 0x2e, 0x52, 0x50, 0x43, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x6c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x73, 0x12, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, + 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, + 0x0a, 0x0e, 0x70, 0x61, 0x73, 0x73, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x12, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x61, 0x73, 0x73, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, + 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x3f, 0x0a, 0x10, 0x72, + 0x65, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x12, + 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, + 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, + 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_service_user_script_proto_rawDescOnce sync.Once + file_service_user_script_proto_rawDescData = file_service_user_script_proto_rawDesc +) + +func file_service_user_script_proto_rawDescGZIP() []byte { + file_service_user_script_proto_rawDescOnce.Do(func() { + file_service_user_script_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_user_script_proto_rawDescData) + }) + return file_service_user_script_proto_rawDescData +} + +var file_service_user_script_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_service_user_script_proto_goTypes = []interface{}{ + (*FindUserScriptRequest)(nil), // 0: pb.FindUserScriptRequest + (*FindUserScriptResponse)(nil), // 1: pb.FindUserScriptResponse + (*FindUserScriptWithMD5Request)(nil), // 2: pb.FindUserScriptWithMD5Request + (*FindUserScriptWithMD5Response)(nil), // 3: pb.FindUserScriptWithMD5Response + (*CountUserScriptsRequest)(nil), // 4: pb.CountUserScriptsRequest + (*ListUserScriptsRequest)(nil), // 5: pb.ListUserScriptsRequest + (*ListUserScriptsResponse)(nil), // 6: pb.ListUserScriptsResponse + (*PassUserScriptRequest)(nil), // 7: pb.PassUserScriptRequest + (*RejectUserScriptRequest)(nil), // 8: pb.RejectUserScriptRequest + (*UserScript)(nil), // 9: pb.UserScript + (*RPCCountResponse)(nil), // 10: pb.RPCCountResponse + (*RPCSuccess)(nil), // 11: pb.RPCSuccess +} +var file_service_user_script_proto_depIdxs = []int32{ + 9, // 0: pb.FindUserScriptResponse.userScript:type_name -> pb.UserScript + 9, // 1: pb.FindUserScriptWithMD5Response.userScript:type_name -> pb.UserScript + 9, // 2: pb.ListUserScriptsResponse.userScripts:type_name -> pb.UserScript + 0, // 3: pb.UserScriptService.findUserScript:input_type -> pb.FindUserScriptRequest + 2, // 4: pb.UserScriptService.findUserScriptWithMD5:input_type -> pb.FindUserScriptWithMD5Request + 4, // 5: pb.UserScriptService.countUserScripts:input_type -> pb.CountUserScriptsRequest + 5, // 6: pb.UserScriptService.listUserScripts:input_type -> pb.ListUserScriptsRequest + 7, // 7: pb.UserScriptService.passUserScript:input_type -> pb.PassUserScriptRequest + 8, // 8: pb.UserScriptService.rejectUserScript:input_type -> pb.RejectUserScriptRequest + 1, // 9: pb.UserScriptService.findUserScript:output_type -> pb.FindUserScriptResponse + 3, // 10: pb.UserScriptService.findUserScriptWithMD5:output_type -> pb.FindUserScriptWithMD5Response + 10, // 11: pb.UserScriptService.countUserScripts:output_type -> pb.RPCCountResponse + 6, // 12: pb.UserScriptService.listUserScripts:output_type -> pb.ListUserScriptsResponse + 11, // 13: pb.UserScriptService.passUserScript:output_type -> pb.RPCSuccess + 11, // 14: pb.UserScriptService.rejectUserScript:output_type -> pb.RPCSuccess + 9, // [9:15] is the sub-list for method output_type + 3, // [3:9] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_service_user_script_proto_init() } +func file_service_user_script_proto_init() { + if File_service_user_script_proto != nil { + return + } + file_models_model_user_script_proto_init() + file_models_rpc_messages_proto_init() + if !protoimpl.UnsafeEnabled { + file_service_user_script_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FindUserScriptRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_user_script_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FindUserScriptResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_user_script_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FindUserScriptWithMD5Request); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_user_script_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FindUserScriptWithMD5Response); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_user_script_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CountUserScriptsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_user_script_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListUserScriptsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_user_script_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListUserScriptsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_user_script_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PassUserScriptRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_user_script_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RejectUserScriptRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_service_user_script_proto_rawDesc, + NumEnums: 0, + NumMessages: 9, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_service_user_script_proto_goTypes, + DependencyIndexes: file_service_user_script_proto_depIdxs, + MessageInfos: file_service_user_script_proto_msgTypes, + }.Build() + File_service_user_script_proto = out.File + file_service_user_script_proto_rawDesc = nil + file_service_user_script_proto_goTypes = nil + file_service_user_script_proto_depIdxs = nil +} diff --git a/pkg/rpc/pb/service_user_script_grpc.pb.go b/pkg/rpc/pb/service_user_script_grpc.pb.go new file mode 100644 index 0000000..53de7b8 --- /dev/null +++ b/pkg/rpc/pb/service_user_script_grpc.pb.go @@ -0,0 +1,304 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v3.19.4 +// source: service_user_script.proto + +package pb + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + UserScriptService_FindUserScript_FullMethodName = "/pb.UserScriptService/findUserScript" + UserScriptService_FindUserScriptWithMD5_FullMethodName = "/pb.UserScriptService/findUserScriptWithMD5" + UserScriptService_CountUserScripts_FullMethodName = "/pb.UserScriptService/countUserScripts" + UserScriptService_ListUserScripts_FullMethodName = "/pb.UserScriptService/listUserScripts" + UserScriptService_PassUserScript_FullMethodName = "/pb.UserScriptService/passUserScript" + UserScriptService_RejectUserScript_FullMethodName = "/pb.UserScriptService/rejectUserScript" +) + +// UserScriptServiceClient is the client API for UserScriptService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type UserScriptServiceClient interface { + // 查找单个用户脚本信息 + FindUserScript(ctx context.Context, in *FindUserScriptRequest, opts ...grpc.CallOption) (*FindUserScriptResponse, error) + // 根据代码MD5查找脚本 + FindUserScriptWithMD5(ctx context.Context, in *FindUserScriptWithMD5Request, opts ...grpc.CallOption) (*FindUserScriptWithMD5Response, error) + // 计算用户脚本数量 + CountUserScripts(ctx context.Context, in *CountUserScriptsRequest, opts ...grpc.CallOption) (*RPCCountResponse, error) + // 列出单页用户脚本 + ListUserScripts(ctx context.Context, in *ListUserScriptsRequest, opts ...grpc.CallOption) (*ListUserScriptsResponse, error) + // 审核并通过用户脚本 + PassUserScript(ctx context.Context, in *PassUserScriptRequest, opts ...grpc.CallOption) (*RPCSuccess, error) + // 审核并驳回用户脚本 + RejectUserScript(ctx context.Context, in *RejectUserScriptRequest, opts ...grpc.CallOption) (*RPCSuccess, error) +} + +type userScriptServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewUserScriptServiceClient(cc grpc.ClientConnInterface) UserScriptServiceClient { + return &userScriptServiceClient{cc} +} + +func (c *userScriptServiceClient) FindUserScript(ctx context.Context, in *FindUserScriptRequest, opts ...grpc.CallOption) (*FindUserScriptResponse, error) { + out := new(FindUserScriptResponse) + err := c.cc.Invoke(ctx, UserScriptService_FindUserScript_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userScriptServiceClient) FindUserScriptWithMD5(ctx context.Context, in *FindUserScriptWithMD5Request, opts ...grpc.CallOption) (*FindUserScriptWithMD5Response, error) { + out := new(FindUserScriptWithMD5Response) + err := c.cc.Invoke(ctx, UserScriptService_FindUserScriptWithMD5_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userScriptServiceClient) CountUserScripts(ctx context.Context, in *CountUserScriptsRequest, opts ...grpc.CallOption) (*RPCCountResponse, error) { + out := new(RPCCountResponse) + err := c.cc.Invoke(ctx, UserScriptService_CountUserScripts_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userScriptServiceClient) ListUserScripts(ctx context.Context, in *ListUserScriptsRequest, opts ...grpc.CallOption) (*ListUserScriptsResponse, error) { + out := new(ListUserScriptsResponse) + err := c.cc.Invoke(ctx, UserScriptService_ListUserScripts_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userScriptServiceClient) PassUserScript(ctx context.Context, in *PassUserScriptRequest, opts ...grpc.CallOption) (*RPCSuccess, error) { + out := new(RPCSuccess) + err := c.cc.Invoke(ctx, UserScriptService_PassUserScript_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userScriptServiceClient) RejectUserScript(ctx context.Context, in *RejectUserScriptRequest, opts ...grpc.CallOption) (*RPCSuccess, error) { + out := new(RPCSuccess) + err := c.cc.Invoke(ctx, UserScriptService_RejectUserScript_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// UserScriptServiceServer is the server API for UserScriptService service. +// All implementations should embed UnimplementedUserScriptServiceServer +// for forward compatibility +type UserScriptServiceServer interface { + // 查找单个用户脚本信息 + FindUserScript(context.Context, *FindUserScriptRequest) (*FindUserScriptResponse, error) + // 根据代码MD5查找脚本 + FindUserScriptWithMD5(context.Context, *FindUserScriptWithMD5Request) (*FindUserScriptWithMD5Response, error) + // 计算用户脚本数量 + CountUserScripts(context.Context, *CountUserScriptsRequest) (*RPCCountResponse, error) + // 列出单页用户脚本 + ListUserScripts(context.Context, *ListUserScriptsRequest) (*ListUserScriptsResponse, error) + // 审核并通过用户脚本 + PassUserScript(context.Context, *PassUserScriptRequest) (*RPCSuccess, error) + // 审核并驳回用户脚本 + RejectUserScript(context.Context, *RejectUserScriptRequest) (*RPCSuccess, error) +} + +// UnimplementedUserScriptServiceServer should be embedded to have forward compatible implementations. +type UnimplementedUserScriptServiceServer struct { +} + +func (UnimplementedUserScriptServiceServer) FindUserScript(context.Context, *FindUserScriptRequest) (*FindUserScriptResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FindUserScript not implemented") +} +func (UnimplementedUserScriptServiceServer) FindUserScriptWithMD5(context.Context, *FindUserScriptWithMD5Request) (*FindUserScriptWithMD5Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method FindUserScriptWithMD5 not implemented") +} +func (UnimplementedUserScriptServiceServer) CountUserScripts(context.Context, *CountUserScriptsRequest) (*RPCCountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CountUserScripts not implemented") +} +func (UnimplementedUserScriptServiceServer) ListUserScripts(context.Context, *ListUserScriptsRequest) (*ListUserScriptsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListUserScripts not implemented") +} +func (UnimplementedUserScriptServiceServer) PassUserScript(context.Context, *PassUserScriptRequest) (*RPCSuccess, error) { + return nil, status.Errorf(codes.Unimplemented, "method PassUserScript not implemented") +} +func (UnimplementedUserScriptServiceServer) RejectUserScript(context.Context, *RejectUserScriptRequest) (*RPCSuccess, error) { + return nil, status.Errorf(codes.Unimplemented, "method RejectUserScript not implemented") +} + +// UnsafeUserScriptServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to UserScriptServiceServer will +// result in compilation errors. +type UnsafeUserScriptServiceServer interface { + mustEmbedUnimplementedUserScriptServiceServer() +} + +func RegisterUserScriptServiceServer(s grpc.ServiceRegistrar, srv UserScriptServiceServer) { + s.RegisterService(&UserScriptService_ServiceDesc, srv) +} + +func _UserScriptService_FindUserScript_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FindUserScriptRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserScriptServiceServer).FindUserScript(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserScriptService_FindUserScript_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserScriptServiceServer).FindUserScript(ctx, req.(*FindUserScriptRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserScriptService_FindUserScriptWithMD5_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FindUserScriptWithMD5Request) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserScriptServiceServer).FindUserScriptWithMD5(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserScriptService_FindUserScriptWithMD5_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserScriptServiceServer).FindUserScriptWithMD5(ctx, req.(*FindUserScriptWithMD5Request)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserScriptService_CountUserScripts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CountUserScriptsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserScriptServiceServer).CountUserScripts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserScriptService_CountUserScripts_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserScriptServiceServer).CountUserScripts(ctx, req.(*CountUserScriptsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserScriptService_ListUserScripts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListUserScriptsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserScriptServiceServer).ListUserScripts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserScriptService_ListUserScripts_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserScriptServiceServer).ListUserScripts(ctx, req.(*ListUserScriptsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserScriptService_PassUserScript_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PassUserScriptRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserScriptServiceServer).PassUserScript(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserScriptService_PassUserScript_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserScriptServiceServer).PassUserScript(ctx, req.(*PassUserScriptRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserScriptService_RejectUserScript_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RejectUserScriptRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserScriptServiceServer).RejectUserScript(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserScriptService_RejectUserScript_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserScriptServiceServer).RejectUserScript(ctx, req.(*RejectUserScriptRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// UserScriptService_ServiceDesc is the grpc.ServiceDesc for UserScriptService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var UserScriptService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "pb.UserScriptService", + HandlerType: (*UserScriptServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "findUserScript", + Handler: _UserScriptService_FindUserScript_Handler, + }, + { + MethodName: "findUserScriptWithMD5", + Handler: _UserScriptService_FindUserScriptWithMD5_Handler, + }, + { + MethodName: "countUserScripts", + Handler: _UserScriptService_CountUserScripts_Handler, + }, + { + MethodName: "listUserScripts", + Handler: _UserScriptService_ListUserScripts_Handler, + }, + { + MethodName: "passUserScript", + Handler: _UserScriptService_PassUserScript_Handler, + }, + { + MethodName: "rejectUserScript", + Handler: _UserScriptService_RejectUserScript_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "service_user_script.proto", +} diff --git a/pkg/rpc/protos/models/model_user_script.proto b/pkg/rpc/protos/models/model_user_script.proto new file mode 100644 index 0000000..4e287d1 --- /dev/null +++ b/pkg/rpc/protos/models/model_user_script.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +option go_package = "./pb"; + +package pb; + +import "models/model_user.proto"; + +// 用户脚本 +message UserScript { + int64 id = 1; // 用户脚本ID + int64 userId = 2; // 用户ID + int64 adminId = 3; // 审核的管理员 + string code = 4; // 脚本代码 + string codeMD5 = 5; // 脚本代码MD5 + int64 createdAt = 6; // 创建时间 + bool isRejected = 7; // 是否被驳回 + int64 rejectedAt = 8; // 驳回时间 + string rejectedReason = 9; // 驳回原因 + bool isPassed = 10; // 是否被通过 + int64 passedAt = 11; // 通过时间 + + User user = 30; // 用户信息 +} \ No newline at end of file diff --git a/pkg/rpc/protos/service_user_script.proto b/pkg/rpc/protos/service_user_script.proto new file mode 100644 index 0000000..26905bf --- /dev/null +++ b/pkg/rpc/protos/service_user_script.proto @@ -0,0 +1,75 @@ +syntax = "proto3"; +option go_package = "./pb"; + +package pb; + +import "models/model_user_script.proto"; +import "models/rpc_messages.proto"; + +// 用户脚本服务 +service UserScriptService { + // 查找单个用户脚本信息 + rpc findUserScript(FindUserScriptRequest) returns (FindUserScriptResponse); + + // 根据代码MD5查找脚本 + rpc findUserScriptWithMD5(FindUserScriptWithMD5Request) returns (FindUserScriptWithMD5Response); + + // 计算用户脚本数量 + rpc countUserScripts(CountUserScriptsRequest) returns (RPCCountResponse); + + // 列出单页用户脚本 + rpc listUserScripts(ListUserScriptsRequest) returns (ListUserScriptsResponse); + + // 审核并通过用户脚本 + rpc passUserScript(PassUserScriptRequest) returns (RPCSuccess); + + // 审核并驳回用户脚本 + rpc rejectUserScript(RejectUserScriptRequest) returns (RPCSuccess); +} + +// 查找单个用户脚本信息 +message FindUserScriptRequest { + int64 userScriptId = 1; // 用户脚本ID +} + +message FindUserScriptResponse { + UserScript userScript = 1; // 用户脚本信息 +} + +// 根据代码MD5查找脚本 +message FindUserScriptWithMD5Request { + string codeMD5 = 1; // 代码MD5(32位) +} + +message FindUserScriptWithMD5Response { + UserScript userScript = 1; // 用户脚本信息 +} + +// 计算用户脚本数量 +message CountUserScriptsRequest { + int64 userId = 1; // 所属用户ID + bool isAuditing = 2; // 是否正在审核 +} + +// 列出单页用户脚本 +message ListUserScriptsRequest { + int64 userId = 1; // 所属用户ID + bool isAuditing = 2; // 是否正在审核 + int64 offset = 3; // 开始读取位置 + int64 size = 4; // 读取数量 +} + +message ListUserScriptsResponse { + repeated UserScript userScripts = 1; // 用户脚本列表 +} + +// 审核并通过用户脚本 +message PassUserScriptRequest { + int64 userScriptId = 1; // 用户脚本ID +} + +// 审核并驳回用户脚本 +message RejectUserScriptRequest { + int64 userScriptId = 1; // 用户脚本ID + string reason = 2; // 驳回理由 +} diff --git a/pkg/serverconfigs/http_request_scripts_config.go b/pkg/serverconfigs/http_request_scripts_config.go index f2cd6b5..a577df6 100644 --- a/pkg/serverconfigs/http_request_scripts_config.go +++ b/pkg/serverconfigs/http_request_scripts_config.go @@ -29,3 +29,14 @@ func (this *HTTPRequestScriptsConfig) IsEmpty() bool { return (this.InitGroup == nil || this.InitGroup.IsEmpty()) && (this.RequestGroup == nil || this.RequestGroup.IsEmpty()) } + +func (this *HTTPRequestScriptsConfig) AllGroups() []*ScriptGroupConfig { + var result []*ScriptGroupConfig + if this.InitGroup != nil { + result = append(result, this.InitGroup) + } + if this.RequestGroup != nil { + result = append(result, this.RequestGroup) + } + return result +} diff --git a/pkg/serverconfigs/script_config.go b/pkg/serverconfigs/script_config.go index 04ad38d..2bc2dd7 100644 --- a/pkg/serverconfigs/script_config.go +++ b/pkg/serverconfigs/script_config.go @@ -2,13 +2,36 @@ package serverconfigs +import ( + stringutil "github.com/iwind/TeaGo/utils/string" + "strings" +) + type ScriptConfig struct { IsPrior bool `yaml:"isPrior" json:"isPrior"` IsOn bool `yaml:"isOn" json:"isOn"` - Code string `yaml:"code" json:"code"` + Code string `yaml:"code" json:"code"` // 当前运行的代码 + AuditingCode string `yaml:"auditingCode" json:"auditingCode"` // 审核中的代码 + AuditingCodeMD5 string `yaml:"auditingCodeMD5" json:"auditingCodeMD5"` // 审核中的代码MD5 + + realCode string } func (this *ScriptConfig) Init() error { + this.realCode = this.TrimCode() + return nil } + +func (this *ScriptConfig) TrimCode() string { + return strings.TrimSpace(this.Code) +} + +func (this *ScriptConfig) RealCode() string { + return this.realCode +} + +func (this *ScriptConfig) CodeMD5() string { + return stringutil.Md5(this.TrimCode()) +}