feat: read raw content

This commit is contained in:
2023-10-15 21:30:40 +08:00
parent d50a651865
commit 59a0efe59a
13 changed files with 468 additions and 167 deletions

View File

@@ -1,24 +1,25 @@
// Code generated by protoc-gen-coco. DO NOT EDIT.
// source: api_services/v1/pastebin_module.proto
// generate at: 2023-09-30 21:44:38
// generate at: 2023-10-15 21:21:24
package api_servicesv1
import (
"gitter.top/coco/coco/core"
"gitter.top/coco/coco"
)
type AutoGenPastebinServiceImpl interface {
List(ctx *core.Context, req *PastebinServiceListReq) (resp *PastebinServiceListResp, err error)
Add(ctx *core.Context, req *PastebinServiceAddReq) (resp *PastebinServiceAddResp, err error)
Update(ctx *core.Context, req *PastebinServiceUpdateReq) (resp *PastebinServiceUpdateResp, err error)
Get(ctx *core.Context, req *PastebinServiceGetReq) (resp *PastebinServiceGetResp, err error)
List(ctx *coco.Context, req *PastebinServiceListReq) (resp *PastebinServiceListResp, err error)
Add(ctx *coco.Context, req *PastebinServiceAddReq) (resp *PastebinServiceAddResp, err error)
Update(ctx *coco.Context, req *PastebinServiceUpdateReq) (resp *PastebinServiceUpdateResp, err error)
Get(ctx *coco.Context, req *PastebinServiceGetReq) (resp *PastebinServiceGetResp, err error)
Raw(ctx *coco.Context, req *PastebinServiceRawReq) (resp *PastebinServiceRawResp, err error)
}
var (
AutoGenPastebinServiceRouterMap = &core.Routers{
func (receiver *PastebinService) GetRouterMap() *coco.Routers {
return &coco.Routers{
BaseURL: "/v1/pastebin",
Apis: core.RouterMap{
Apis: coco.RouterMap{
"List": {
API: "/list",
Method: "GET",
@@ -43,6 +44,12 @@ var (
Author: "Young Xu",
Describe: "获取一条记录",
},
"Raw": {
API: "/raw",
Method: "GET",
Author: "Young Xu",
Describe: "获取原文内容",
},
},
}
)
}

View File

@@ -2,7 +2,7 @@ package api_servicesv1
import (
"github.com/sirupsen/logrus"
"gitter.top/coco/coco/core"
"gitter.top/coco/coco"
"pastebin/common"
"pastebin/internal/repositories"
modelv1 "pastebin/model/v1"
@@ -15,7 +15,7 @@ type PastebinService struct{}
var _ AutoGenPastebinServiceImpl = (*PastebinService)(nil)
// List 列表
func (receiver *PastebinService) List(ctx *core.Context, req *PastebinServiceListReq) (resp *PastebinServiceListResp, err error) {
func (receiver *PastebinService) List(ctx *coco.Context, req *PastebinServiceListReq) (resp *PastebinServiceListResp, err error) {
resp = new(PastebinServiceListResp)
if req.PageSize == 0 {
@@ -66,7 +66,7 @@ func (receiver *PastebinService) List(ctx *core.Context, req *PastebinServiceLis
}
// Add 新建
func (receiver *PastebinService) Add(ctx *core.Context, req *PastebinServiceAddReq) (resp *PastebinServiceAddResp, err error) {
func (receiver *PastebinService) Add(ctx *coco.Context, req *PastebinServiceAddReq) (resp *PastebinServiceAddResp, err error) {
resp = new(PastebinServiceAddResp)
var expiredAt = time.Now()
@@ -107,7 +107,7 @@ func (receiver *PastebinService) Add(ctx *core.Context, req *PastebinServiceAddR
}
// Update 更新
func (receiver *PastebinService) Update(ctx *core.Context, req *PastebinServiceUpdateReq) (resp *PastebinServiceUpdateResp, err error) {
func (receiver *PastebinService) Update(ctx *coco.Context, req *PastebinServiceUpdateReq) (resp *PastebinServiceUpdateResp, err error) {
resp = new(PastebinServiceUpdateResp)
// TODO impl...
@@ -116,7 +116,7 @@ func (receiver *PastebinService) Update(ctx *core.Context, req *PastebinServiceU
}
// Get 获取一条记录
func (receiver *PastebinService) Get(ctx *core.Context, req *PastebinServiceGetReq) (resp *PastebinServiceGetResp, err error) {
func (receiver *PastebinService) Get(ctx *coco.Context, req *PastebinServiceGetReq) (resp *PastebinServiceGetResp, err error) {
resp = new(PastebinServiceGetResp)
db := repositories.GetPastebin()
@@ -129,11 +129,11 @@ func (receiver *PastebinService) Get(ctx *core.Context, req *PastebinServiceGetR
}
if record.NeedPassword && req.Password == "" {
return nil, core.CreateErrorWithMsg(4001, "pastebin need password")
return nil, coco.CreateErrorWithMsg(4001, "pastebin need password")
}
if record.NeedPassword && req.Password != record.Password {
return nil, core.CreateErrorWithMsg(4002, "incorrect password")
return nil, coco.CreateErrorWithMsg(4002, "incorrect password")
}
item := &PastebinServiceRecord{
@@ -152,3 +152,30 @@ func (receiver *PastebinService) Get(ctx *core.Context, req *PastebinServiceGetR
return resp, nil
}
// Raw 获取原文内容
func (receiver *PastebinService) Raw(ctx *coco.Context, req *PastebinServiceRawReq) (resp *PastebinServiceRawResp, err error) {
resp = new(PastebinServiceRawResp)
db := repositories.GetPastebin()
var record modelv1.ModelPastebin
if err := db.Find().SetWhere("short_id = ?", req.Key).FindOne(&record); err != nil {
logrus.Errorf("query records failed: %v", err)
return nil, err
}
if record.NeedPassword && req.Password == "" {
return nil, coco.CreateErrorWithMsg(4001, "pastebin need password")
}
if record.NeedPassword && req.Password != record.Password {
return nil, coco.CreateErrorWithMsg(4002, "incorrect password")
}
_, _ = ctx.Writer.WriteString(record.Content)
ctx.Header("Content-Type", "text/plain")
return resp, nil
}

View File

@@ -592,6 +592,99 @@ func (x *PastebinServiceGetResp) GetRecord() *PastebinServiceRecord {
return nil
}
type PastebinServiceRawReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
}
func (x *PastebinServiceRawReq) Reset() {
*x = PastebinServiceRawReq{}
if protoimpl.UnsafeEnabled {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PastebinServiceRawReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PastebinServiceRawReq) ProtoMessage() {}
func (x *PastebinServiceRawReq) ProtoReflect() protoreflect.Message {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[9]
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 PastebinServiceRawReq.ProtoReflect.Descriptor instead.
func (*PastebinServiceRawReq) Descriptor() ([]byte, []int) {
return file_api_services_v1_pastebin_module_proto_rawDescGZIP(), []int{9}
}
func (x *PastebinServiceRawReq) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
func (x *PastebinServiceRawReq) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
type PastebinServiceRawResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *PastebinServiceRawResp) Reset() {
*x = PastebinServiceRawResp{}
if protoimpl.UnsafeEnabled {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PastebinServiceRawResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PastebinServiceRawResp) ProtoMessage() {}
func (x *PastebinServiceRawResp) ProtoReflect() protoreflect.Message {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[10]
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 PastebinServiceRawResp.ProtoReflect.Descriptor instead.
func (*PastebinServiceRawResp) Descriptor() ([]byte, []int) {
return file_api_services_v1_pastebin_module_proto_rawDescGZIP(), []int{10}
}
var File_api_services_v1_pastebin_module_proto protoreflect.FileDescriptor
var file_api_services_v1_pastebin_module_proto_rawDesc = []byte{
@@ -659,47 +752,59 @@ var file_api_services_v1_pastebin_module_proto_rawDesc = []byte{
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62,
0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52,
0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2a, 0x42, 0x0a, 0x0b, 0x45, 0x78, 0x70, 0x69, 0x72,
0x65, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x6f, 0x72, 0x65, 0x76, 0x65,
0x72, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x61, 0x79, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04,
0x57, 0x65, 0x65, 0x6b, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x4d, 0x6f, 0x6e, 0x74, 0x68, 0x10,
0x03, 0x12, 0x08, 0x0a, 0x04, 0x59, 0x65, 0x61, 0x72, 0x10, 0x04, 0x32, 0xfd, 0x02, 0x0a, 0x0f,
0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
0x59, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x27, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62,
0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71,
0x1a, 0x28, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e,
0x76, 0x31, 0x2e, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x56, 0x0a, 0x03, 0x41, 0x64,
0x64, 0x12, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x22, 0x45, 0x0a, 0x15, 0x50, 0x61, 0x73, 0x74, 0x65,
0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x61, 0x77, 0x52, 0x65, 0x71,
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b,
0x65, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x18,
0x0a, 0x16, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x52, 0x61, 0x77, 0x52, 0x65, 0x73, 0x70, 0x2a, 0x42, 0x0a, 0x0b, 0x45, 0x78, 0x70, 0x69,
0x72, 0x65, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x6f, 0x72, 0x65, 0x76,
0x65, 0x72, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x61, 0x79, 0x10, 0x01, 0x12, 0x08, 0x0a,
0x04, 0x57, 0x65, 0x65, 0x6b, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x4d, 0x6f, 0x6e, 0x74, 0x68,
0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x59, 0x65, 0x61, 0x72, 0x10, 0x04, 0x32, 0xd5, 0x03, 0x0a,
0x0f, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x12, 0x59, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x27, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73, 0x74, 0x65,
0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65,
0x71, 0x1a, 0x28, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x27, 0x2e, 0x61, 0x70, 0x69, 0x5f,
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73, 0x74,
0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x41, 0x64, 0x64, 0x52, 0x65,
0x73, 0x70, 0x12, 0x5f, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x29, 0x2e, 0x61,
0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50,
0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62,
0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52,
0x65, 0x73, 0x70, 0x12, 0x56, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x26, 0x2e, 0x61, 0x70, 0x69,
0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73,
0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x47, 0x65, 0x74, 0x52,
0x65, 0x71, 0x1a, 0x27, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x56, 0x0a, 0x03, 0x41,
0x64, 0x64, 0x12, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x42, 0xb9, 0x01, 0x0a, 0x13,
0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
0x2e, 0x76, 0x31, 0x42, 0x13, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x4d, 0x6f, 0x64,
0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x70, 0x61, 0x73, 0x74,
0x65, 0x62, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x73, 0x2f, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x76,
0x31, 0x3b, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x76, 0x31,
0xa2, 0x02, 0x03, 0x41, 0x58, 0x58, 0xaa, 0x02, 0x0e, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0e, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1a, 0x41, 0x70, 0x69, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74,
0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0f, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x76, 0x69, 0x63, 0x65, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x27, 0x2e, 0x61, 0x70, 0x69,
0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73,
0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x41, 0x64, 0x64, 0x52,
0x65, 0x73, 0x70, 0x12, 0x5f, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x29, 0x2e,
0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e,
0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x55,
0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73, 0x74, 0x65,
0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
0x52, 0x65, 0x73, 0x70, 0x12, 0x56, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x26, 0x2e, 0x61, 0x70,
0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61,
0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x47, 0x65, 0x74,
0x52, 0x65, 0x71, 0x1a, 0x27, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x56, 0x0a, 0x03,
0x52, 0x61, 0x77, 0x12, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x61, 0x77, 0x52, 0x65, 0x71, 0x1a, 0x27, 0x2e, 0x61, 0x70,
0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61,
0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x61, 0x77,
0x52, 0x65, 0x73, 0x70, 0x42, 0xb9, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69,
0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x13, 0x50, 0x61,
0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74,
0x6f, 0x50, 0x01, 0x5a, 0x34, 0x70, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x2f, 0x61, 0x70,
0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x5f, 0x73,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x5f, 0x73,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x41, 0x58, 0x58, 0xaa,
0x02, 0x0e, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x56, 0x31,
0xca, 0x02, 0x0e, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x56,
0x31, 0xe2, 0x02, 0x1a, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c,
0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02,
0x0f, 0x41, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x31,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -715,7 +820,7 @@ func file_api_services_v1_pastebin_module_proto_rawDescGZIP() []byte {
}
var file_api_services_v1_pastebin_module_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_api_services_v1_pastebin_module_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_api_services_v1_pastebin_module_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_api_services_v1_pastebin_module_proto_goTypes = []interface{}{
(ExpireLevel)(0), // 0: api_services.v1.ExpireLevel
(*PastebinServiceRecord)(nil), // 1: api_services.v1.PastebinServiceRecord
@@ -727,26 +832,30 @@ var file_api_services_v1_pastebin_module_proto_goTypes = []interface{}{
(*PastebinServiceUpdateResp)(nil), // 7: api_services.v1.PastebinServiceUpdateResp
(*PastebinServiceGetReq)(nil), // 8: api_services.v1.PastebinServiceGetReq
(*PastebinServiceGetResp)(nil), // 9: api_services.v1.PastebinServiceGetResp
(*PastebinServiceRawReq)(nil), // 10: api_services.v1.PastebinServiceRawReq
(*PastebinServiceRawResp)(nil), // 11: api_services.v1.PastebinServiceRawResp
}
var file_api_services_v1_pastebin_module_proto_depIdxs = []int32{
0, // 0: api_services.v1.PastebinServiceRecord.expire_level:type_name -> api_services.v1.ExpireLevel
1, // 1: api_services.v1.PastebinServiceListResp.items:type_name -> api_services.v1.PastebinServiceRecord
1, // 2: api_services.v1.PastebinServiceAddReq.record:type_name -> api_services.v1.PastebinServiceRecord
1, // 3: api_services.v1.PastebinServiceUpdateReq.record:type_name -> api_services.v1.PastebinServiceRecord
1, // 4: api_services.v1.PastebinServiceGetResp.record:type_name -> api_services.v1.PastebinServiceRecord
2, // 5: api_services.v1.PastebinService.List:input_type -> api_services.v1.PastebinServiceListReq
4, // 6: api_services.v1.PastebinService.Add:input_type -> api_services.v1.PastebinServiceAddReq
6, // 7: api_services.v1.PastebinService.Update:input_type -> api_services.v1.PastebinServiceUpdateReq
8, // 8: api_services.v1.PastebinService.Get:input_type -> api_services.v1.PastebinServiceGetReq
3, // 9: api_services.v1.PastebinService.List:output_type -> api_services.v1.PastebinServiceListResp
5, // 10: api_services.v1.PastebinService.Add:output_type -> api_services.v1.PastebinServiceAddResp
7, // 11: api_services.v1.PastebinService.Update:output_type -> api_services.v1.PastebinServiceUpdateResp
9, // 12: api_services.v1.PastebinService.Get:output_type -> api_services.v1.PastebinServiceGetResp
9, // [9:13] is the sub-list for method output_type
5, // [5:9] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
0, // 0: api_services.v1.PastebinServiceRecord.expire_level:type_name -> api_services.v1.ExpireLevel
1, // 1: api_services.v1.PastebinServiceListResp.items:type_name -> api_services.v1.PastebinServiceRecord
1, // 2: api_services.v1.PastebinServiceAddReq.record:type_name -> api_services.v1.PastebinServiceRecord
1, // 3: api_services.v1.PastebinServiceUpdateReq.record:type_name -> api_services.v1.PastebinServiceRecord
1, // 4: api_services.v1.PastebinServiceGetResp.record:type_name -> api_services.v1.PastebinServiceRecord
2, // 5: api_services.v1.PastebinService.List:input_type -> api_services.v1.PastebinServiceListReq
4, // 6: api_services.v1.PastebinService.Add:input_type -> api_services.v1.PastebinServiceAddReq
6, // 7: api_services.v1.PastebinService.Update:input_type -> api_services.v1.PastebinServiceUpdateReq
8, // 8: api_services.v1.PastebinService.Get:input_type -> api_services.v1.PastebinServiceGetReq
10, // 9: api_services.v1.PastebinService.Raw:input_type -> api_services.v1.PastebinServiceRawReq
3, // 10: api_services.v1.PastebinService.List:output_type -> api_services.v1.PastebinServiceListResp
5, // 11: api_services.v1.PastebinService.Add:output_type -> api_services.v1.PastebinServiceAddResp
7, // 12: api_services.v1.PastebinService.Update:output_type -> api_services.v1.PastebinServiceUpdateResp
9, // 13: api_services.v1.PastebinService.Get:output_type -> api_services.v1.PastebinServiceGetResp
11, // 14: api_services.v1.PastebinService.Raw:output_type -> api_services.v1.PastebinServiceRawResp
10, // [10:15] is the sub-list for method output_type
5, // [5:10] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { file_api_services_v1_pastebin_module_proto_init() }
@@ -863,6 +972,30 @@ func file_api_services_v1_pastebin_module_proto_init() {
return nil
}
}
file_api_services_v1_pastebin_module_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PastebinServiceRawReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_services_v1_pastebin_module_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PastebinServiceRawResp); 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{
@@ -870,7 +1003,7 @@ func file_api_services_v1_pastebin_module_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_services_v1_pastebin_module_proto_rawDesc,
NumEnums: 1,
NumMessages: 9,
NumMessages: 11,
NumExtensions: 0,
NumServices: 1,
},

View File

@@ -29,6 +29,11 @@ service PastebinService {
// @method: GET
// @api: /get
rpc Get (PastebinServiceGetReq) returns (PastebinServiceGetResp);
// @desc: 获取原文内容
// @author: Young Xu
// @method: GET
// @api: /raw
rpc Raw (PastebinServiceRawReq) returns (PastebinServiceRawResp);
}
@@ -85,3 +90,10 @@ message PastebinServiceGetReq {
message PastebinServiceGetResp {
PastebinServiceRecord record = 1;
}
message PastebinServiceRawReq {
string key = 1;
string password = 2;
}
message PastebinServiceRawResp {}