first commit

This commit is contained in:
xuthus5 2023-09-30 21:47:59 +08:00
commit d642ed1a9c
Signed by: xuthus5
GPG Key ID: A23CF9620CBB55F9
62 changed files with 8635 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
.idea
go.sum
pastebin
pastebin.exe
pastebin.exe~
pastebin.db

20
Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM fedora:latest
WORKDIR /app
ENV GOPROXY https://goproxy.cn
RUN sed -e 's|^metalink=|#metalink=|g' \
-e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.ustc.edu.cn/fedora|g' \
-i.bak \
/etc/yum.repos.d/fedora.repo \
/etc/yum.repos.d/fedora-modular.repo \
/etc/yum.repos.d/fedora-updates.repo \
/etc/yum.repos.d/fedora-updates-modular.repo &&\
dnf update -y && dnf install golang nodejs gcc make -y &&\
npm config set registry https://registry.npm.taobao.org
COPY . /app
RUN cd webui && npm install && npm run build &&\
cd .. && go mod tidy && go build .
EXPOSE 38080
ENTRYPOINT [ "./pastebin", "api" ]

11
Makefile Normal file
View File

@ -0,0 +1,11 @@
all:
cd webui && npm install && npm run build
go mod tidy && go build .
./pastebin api
ui:
cd webui && npm run build
api:
go build .
./pastebin api

View File

@ -0,0 +1,48 @@
// Code generated by protoc-gen-coco. DO NOT EDIT.
// source: api_services/v1/pastebin_module.proto
// generate at: 2023-09-30 21:44:38
package api_servicesv1
import (
"gitter.top/coco/coco/core"
)
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)
}
var (
AutoGenPastebinServiceRouterMap = &core.Routers{
BaseURL: "/v1/pastebin",
Apis: core.RouterMap{
"List": {
API: "/list",
Method: "GET",
Author: "Young Xu",
Describe: "列表",
},
"Add": {
API: "/add",
Method: "PUT",
Author: "Young Xu",
Describe: "新建",
},
"Update": {
API: "/update",
Method: "POST",
Author: "Young Xu",
Describe: "更新",
},
"Get": {
API: "/get",
Method: "GET",
Author: "Young Xu",
Describe: "获取一条记录",
},
},
}
)

View File

@ -0,0 +1,154 @@
package api_servicesv1
import (
"github.com/sirupsen/logrus"
"gitter.top/coco/coco/core"
"pastebin/common"
"pastebin/internal/repositories"
modelv1 "pastebin/model/v1"
"time"
)
type PastebinService struct{}
// IDE: PastebinService implemented PastebinServiceImpl interface
var _ AutoGenPastebinServiceImpl = (*PastebinService)(nil)
// List 列表
func (receiver *PastebinService) List(ctx *core.Context, req *PastebinServiceListReq) (resp *PastebinServiceListResp, err error) {
resp = new(PastebinServiceListResp)
if req.PageSize == 0 {
req.PageSize = 25
}
var limit = req.PageSize + 1
var offset int64
if req.CurrentPage == 0 {
req.CurrentPage = 1
}
offset = (req.CurrentPage - 1) * req.PageSize
db := repositories.GetPastebin()
var records []modelv1.ModelPastebin
if err := db.Find().SetWhere("expired_at > ?", time.Now().Unix()).SetLimit(int(limit)).
SetOffset(int(offset)).SetOrder("id desc").Find(&records); err != nil {
logrus.Errorf("query records failed: %v", err)
return nil, err
}
var hasMore bool
if len(records) >= int(limit) {
hasMore = true
records = records[:req.PageSize]
}
for _, record := range records {
item := &PastebinServiceRecord{
Id: record.Id,
Key: record.ShortId,
Title: record.Title,
Lang: record.Lang,
Author: record.Author,
CreatedAt: common.Unix2Datetime(record.CreatedAt),
ExpiredAt: common.Unix2Datetime(record.ExpiredAt),
NeedPassword: record.NeedPassword,
}
resp.Items = append(resp.Items, item)
}
resp.HasMore = hasMore
return resp, nil
}
// Add 新建
func (receiver *PastebinService) Add(ctx *core.Context, req *PastebinServiceAddReq) (resp *PastebinServiceAddResp, err error) {
resp = new(PastebinServiceAddResp)
var expiredAt = time.Now()
switch req.Record.ExpireLevel {
case ExpireLevel_Forever:
expiredAt = expiredAt.Add(time.Hour * 87600)
case ExpireLevel_Day:
expiredAt = expiredAt.Add(time.Hour * 24)
case ExpireLevel_Week:
expiredAt = expiredAt.Add(time.Hour * 168)
case ExpireLevel_Month:
expiredAt = expiredAt.Add(time.Hour * 720)
case ExpireLevel_Year:
expiredAt = expiredAt.Add(time.Hour * 8760)
}
var record = modelv1.ModelPastebin{
CreatedAt: time.Now().Unix(),
ExpiredAt: expiredAt.Unix(),
ShortId: common.UniqID(time.Now().UnixMilli()),
Title: req.Record.Title,
Content: req.Record.Content,
Lang: req.Record.Lang,
Password: req.Record.Password,
NeedPassword: req.Record.NeedPassword,
Editable: req.Record.Editable,
Author: req.Record.Author,
}
db := repositories.GetPastebin()
if err := db.Insert().Insert(&record); err != nil {
logrus.Errorf("insert record failed: %v", err)
return nil, err
}
return resp, nil
}
// Update 更新
func (receiver *PastebinService) Update(ctx *core.Context, req *PastebinServiceUpdateReq) (resp *PastebinServiceUpdateResp, err error) {
resp = new(PastebinServiceUpdateResp)
// TODO impl...
return resp, nil
}
// Get 获取一条记录
func (receiver *PastebinService) Get(ctx *core.Context, req *PastebinServiceGetReq) (resp *PastebinServiceGetResp, err error) {
resp = new(PastebinServiceGetResp)
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, core.CreateErrorWithMsg(4001, "pastebin need password")
}
if record.NeedPassword && req.Password != record.Password {
return nil, core.CreateErrorWithMsg(4002, "incorrect password")
}
item := &PastebinServiceRecord{
Id: record.Id,
Key: record.ShortId,
Title: record.Title,
Content: record.Content,
CreatedAt: common.Unix2Datetime(record.CreatedAt),
ExpiredAt: common.Unix2Datetime(record.ExpiredAt),
NeedPassword: record.NeedPassword,
Lang: record.Lang,
Author: record.Author,
}
resp.Record = item
return resp, nil
}

View File

@ -0,0 +1,886 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc (unknown)
// source: api_services/v1/pastebin_module.proto
package api_servicesv1
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 ExpireLevel int32
const (
ExpireLevel_Forever ExpireLevel = 0
ExpireLevel_Day ExpireLevel = 1
ExpireLevel_Week ExpireLevel = 2
ExpireLevel_Month ExpireLevel = 3
ExpireLevel_Year ExpireLevel = 4
)
// Enum value maps for ExpireLevel.
var (
ExpireLevel_name = map[int32]string{
0: "Forever",
1: "Day",
2: "Week",
3: "Month",
4: "Year",
}
ExpireLevel_value = map[string]int32{
"Forever": 0,
"Day": 1,
"Week": 2,
"Month": 3,
"Year": 4,
}
)
func (x ExpireLevel) Enum() *ExpireLevel {
p := new(ExpireLevel)
*p = x
return p
}
func (x ExpireLevel) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (ExpireLevel) Descriptor() protoreflect.EnumDescriptor {
return file_api_services_v1_pastebin_module_proto_enumTypes[0].Descriptor()
}
func (ExpireLevel) Type() protoreflect.EnumType {
return &file_api_services_v1_pastebin_module_proto_enumTypes[0]
}
func (x ExpireLevel) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use ExpireLevel.Descriptor instead.
func (ExpireLevel) EnumDescriptor() ([]byte, []int) {
return file_api_services_v1_pastebin_module_proto_rawDescGZIP(), []int{0}
}
type PastebinServiceRecord struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 记录ID
Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` // 记录别名
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` // 记录标题
Content string `protobuf:"bytes,5,opt,name=content,proto3" json:"content,omitempty"` // 记录渲染后内容
CreatedAt string `protobuf:"bytes,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // 记录创建时间
ExpiredAt string `protobuf:"bytes,7,opt,name=expired_at,json=expiredAt,proto3" json:"expired_at,omitempty"` // 过期时间
NeedPassword bool `protobuf:"varint,8,opt,name=need_password,json=needPassword,proto3" json:"need_password,omitempty"` // 是否需要密码
Editable bool `protobuf:"varint,9,opt,name=editable,proto3" json:"editable,omitempty"` // 是否可以修订
ExpireLevel ExpireLevel `protobuf:"varint,10,opt,name=expire_level,json=expireLevel,proto3,enum=api_services.v1.ExpireLevel" json:"expire_level,omitempty"` // 指定记录有效期
Password string `protobuf:"bytes,11,opt,name=password,proto3" json:"password,omitempty"` // 指定需要密码访问
Lang string `protobuf:"bytes,12,opt,name=lang,proto3" json:"lang,omitempty"` // 指定语言
Author string `protobuf:"bytes,13,opt,name=author,proto3" json:"author,omitempty"` // 作者
}
func (x *PastebinServiceRecord) Reset() {
*x = PastebinServiceRecord{}
if protoimpl.UnsafeEnabled {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PastebinServiceRecord) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PastebinServiceRecord) ProtoMessage() {}
func (x *PastebinServiceRecord) ProtoReflect() protoreflect.Message {
mi := &file_api_services_v1_pastebin_module_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 PastebinServiceRecord.ProtoReflect.Descriptor instead.
func (*PastebinServiceRecord) Descriptor() ([]byte, []int) {
return file_api_services_v1_pastebin_module_proto_rawDescGZIP(), []int{0}
}
func (x *PastebinServiceRecord) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *PastebinServiceRecord) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
func (x *PastebinServiceRecord) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (x *PastebinServiceRecord) GetContent() string {
if x != nil {
return x.Content
}
return ""
}
func (x *PastebinServiceRecord) GetCreatedAt() string {
if x != nil {
return x.CreatedAt
}
return ""
}
func (x *PastebinServiceRecord) GetExpiredAt() string {
if x != nil {
return x.ExpiredAt
}
return ""
}
func (x *PastebinServiceRecord) GetNeedPassword() bool {
if x != nil {
return x.NeedPassword
}
return false
}
func (x *PastebinServiceRecord) GetEditable() bool {
if x != nil {
return x.Editable
}
return false
}
func (x *PastebinServiceRecord) GetExpireLevel() ExpireLevel {
if x != nil {
return x.ExpireLevel
}
return ExpireLevel_Forever
}
func (x *PastebinServiceRecord) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
func (x *PastebinServiceRecord) GetLang() string {
if x != nil {
return x.Lang
}
return ""
}
func (x *PastebinServiceRecord) GetAuthor() string {
if x != nil {
return x.Author
}
return ""
}
type PastebinServiceListReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
PageSize int64 `protobuf:"varint,1,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` // 分页大小
CurrentPage int64 `protobuf:"varint,2,opt,name=current_page,json=currentPage,proto3" json:"current_page,omitempty"` // 当前页 从第一页开始
}
func (x *PastebinServiceListReq) Reset() {
*x = PastebinServiceListReq{}
if protoimpl.UnsafeEnabled {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PastebinServiceListReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PastebinServiceListReq) ProtoMessage() {}
func (x *PastebinServiceListReq) ProtoReflect() protoreflect.Message {
mi := &file_api_services_v1_pastebin_module_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 PastebinServiceListReq.ProtoReflect.Descriptor instead.
func (*PastebinServiceListReq) Descriptor() ([]byte, []int) {
return file_api_services_v1_pastebin_module_proto_rawDescGZIP(), []int{1}
}
func (x *PastebinServiceListReq) GetPageSize() int64 {
if x != nil {
return x.PageSize
}
return 0
}
func (x *PastebinServiceListReq) GetCurrentPage() int64 {
if x != nil {
return x.CurrentPage
}
return 0
}
type PastebinServiceListResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Items []*PastebinServiceRecord `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` // 列表
HasMore bool `protobuf:"varint,2,opt,name=has_more,json=hasMore,proto3" json:"has_more,omitempty"` // 是否有下一页
}
func (x *PastebinServiceListResp) Reset() {
*x = PastebinServiceListResp{}
if protoimpl.UnsafeEnabled {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PastebinServiceListResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PastebinServiceListResp) ProtoMessage() {}
func (x *PastebinServiceListResp) ProtoReflect() protoreflect.Message {
mi := &file_api_services_v1_pastebin_module_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 PastebinServiceListResp.ProtoReflect.Descriptor instead.
func (*PastebinServiceListResp) Descriptor() ([]byte, []int) {
return file_api_services_v1_pastebin_module_proto_rawDescGZIP(), []int{2}
}
func (x *PastebinServiceListResp) GetItems() []*PastebinServiceRecord {
if x != nil {
return x.Items
}
return nil
}
func (x *PastebinServiceListResp) GetHasMore() bool {
if x != nil {
return x.HasMore
}
return false
}
type PastebinServiceAddReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Record *PastebinServiceRecord `protobuf:"bytes,1,opt,name=record,proto3" json:"record,omitempty"`
}
func (x *PastebinServiceAddReq) Reset() {
*x = PastebinServiceAddReq{}
if protoimpl.UnsafeEnabled {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PastebinServiceAddReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PastebinServiceAddReq) ProtoMessage() {}
func (x *PastebinServiceAddReq) ProtoReflect() protoreflect.Message {
mi := &file_api_services_v1_pastebin_module_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 PastebinServiceAddReq.ProtoReflect.Descriptor instead.
func (*PastebinServiceAddReq) Descriptor() ([]byte, []int) {
return file_api_services_v1_pastebin_module_proto_rawDescGZIP(), []int{3}
}
func (x *PastebinServiceAddReq) GetRecord() *PastebinServiceRecord {
if x != nil {
return x.Record
}
return nil
}
type PastebinServiceAddResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *PastebinServiceAddResp) Reset() {
*x = PastebinServiceAddResp{}
if protoimpl.UnsafeEnabled {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PastebinServiceAddResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PastebinServiceAddResp) ProtoMessage() {}
func (x *PastebinServiceAddResp) ProtoReflect() protoreflect.Message {
mi := &file_api_services_v1_pastebin_module_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 PastebinServiceAddResp.ProtoReflect.Descriptor instead.
func (*PastebinServiceAddResp) Descriptor() ([]byte, []int) {
return file_api_services_v1_pastebin_module_proto_rawDescGZIP(), []int{4}
}
type PastebinServiceUpdateReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Record *PastebinServiceRecord `protobuf:"bytes,1,opt,name=record,proto3" json:"record,omitempty"`
}
func (x *PastebinServiceUpdateReq) Reset() {
*x = PastebinServiceUpdateReq{}
if protoimpl.UnsafeEnabled {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PastebinServiceUpdateReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PastebinServiceUpdateReq) ProtoMessage() {}
func (x *PastebinServiceUpdateReq) ProtoReflect() protoreflect.Message {
mi := &file_api_services_v1_pastebin_module_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 PastebinServiceUpdateReq.ProtoReflect.Descriptor instead.
func (*PastebinServiceUpdateReq) Descriptor() ([]byte, []int) {
return file_api_services_v1_pastebin_module_proto_rawDescGZIP(), []int{5}
}
func (x *PastebinServiceUpdateReq) GetRecord() *PastebinServiceRecord {
if x != nil {
return x.Record
}
return nil
}
type PastebinServiceUpdateResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *PastebinServiceUpdateResp) Reset() {
*x = PastebinServiceUpdateResp{}
if protoimpl.UnsafeEnabled {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PastebinServiceUpdateResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PastebinServiceUpdateResp) ProtoMessage() {}
func (x *PastebinServiceUpdateResp) ProtoReflect() protoreflect.Message {
mi := &file_api_services_v1_pastebin_module_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 PastebinServiceUpdateResp.ProtoReflect.Descriptor instead.
func (*PastebinServiceUpdateResp) Descriptor() ([]byte, []int) {
return file_api_services_v1_pastebin_module_proto_rawDescGZIP(), []int{6}
}
type PastebinServiceGetReq 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 *PastebinServiceGetReq) Reset() {
*x = PastebinServiceGetReq{}
if protoimpl.UnsafeEnabled {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PastebinServiceGetReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PastebinServiceGetReq) ProtoMessage() {}
func (x *PastebinServiceGetReq) ProtoReflect() protoreflect.Message {
mi := &file_api_services_v1_pastebin_module_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 PastebinServiceGetReq.ProtoReflect.Descriptor instead.
func (*PastebinServiceGetReq) Descriptor() ([]byte, []int) {
return file_api_services_v1_pastebin_module_proto_rawDescGZIP(), []int{7}
}
func (x *PastebinServiceGetReq) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
func (x *PastebinServiceGetReq) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
type PastebinServiceGetResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Record *PastebinServiceRecord `protobuf:"bytes,1,opt,name=record,proto3" json:"record,omitempty"`
}
func (x *PastebinServiceGetResp) Reset() {
*x = PastebinServiceGetResp{}
if protoimpl.UnsafeEnabled {
mi := &file_api_services_v1_pastebin_module_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PastebinServiceGetResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PastebinServiceGetResp) ProtoMessage() {}
func (x *PastebinServiceGetResp) ProtoReflect() protoreflect.Message {
mi := &file_api_services_v1_pastebin_module_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 PastebinServiceGetResp.ProtoReflect.Descriptor instead.
func (*PastebinServiceGetResp) Descriptor() ([]byte, []int) {
return file_api_services_v1_pastebin_module_proto_rawDescGZIP(), []int{8}
}
func (x *PastebinServiceGetResp) GetRecord() *PastebinServiceRecord {
if x != nil {
return x.Record
}
return nil
}
var File_api_services_v1_pastebin_module_proto protoreflect.FileDescriptor
var file_api_services_v1_pastebin_module_proto_rawDesc = []byte{
0x0a, 0x25, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x76,
0x31, 0x2f, 0x70, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c,
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x61, 0x70, 0x69, 0x5f, 0x73, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x22, 0xf1, 0x02, 0x0a, 0x15, 0x50, 0x61, 0x73,
0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x63, 0x6f,
0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02,
0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20,
0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f,
0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e,
0x74, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f,
0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65,
0x64, 0x41, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x61,
0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64,
0x41, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x65, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77,
0x6f, 0x72, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6e, 0x65, 0x65, 0x64, 0x50,
0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x64, 0x69, 0x74, 0x61,
0x62, 0x6c, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x65, 0x64, 0x69, 0x74, 0x61,
0x62, 0x6c, 0x65, 0x12, 0x3f, 0x0a, 0x0c, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x5f, 0x6c, 0x65,
0x76, 0x65, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x5f,
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x69,
0x72, 0x65, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x0b, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x4c,
0x65, 0x76, 0x65, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64,
0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64,
0x12, 0x12, 0x0a, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x6c, 0x61, 0x6e, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x18, 0x0d,
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x22, 0x58, 0x0a, 0x16,
0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c,
0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73,
0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53,
0x69, 0x7a, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x70,
0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65,
0x6e, 0x74, 0x50, 0x61, 0x67, 0x65, 0x22, 0x72, 0x0a, 0x17, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62,
0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73,
0x70, 0x12, 0x3c, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 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, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x12,
0x19, 0x0a, 0x08, 0x68, 0x61, 0x73, 0x5f, 0x6d, 0x6f, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x08, 0x52, 0x07, 0x68, 0x61, 0x73, 0x4d, 0x6f, 0x72, 0x65, 0x22, 0x57, 0x0a, 0x15, 0x50, 0x61,
0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x41, 0x64, 0x64,
0x52, 0x65, 0x71, 0x12, 0x3e, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 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, 0x22, 0x18, 0x0a, 0x16, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x70, 0x22, 0x5a, 0x0a,
0x18, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x3e, 0x0a, 0x06, 0x72, 0x65, 0x63,
0x6f, 0x72, 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, 0x22, 0x1b, 0x0a, 0x19, 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, 0x22, 0x45, 0x0a, 0x15, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62,
0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x47, 0x65, 0x74, 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, 0x58, 0x0a,
0x16, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3e, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72,
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,
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,
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,
}
var (
file_api_services_v1_pastebin_module_proto_rawDescOnce sync.Once
file_api_services_v1_pastebin_module_proto_rawDescData = file_api_services_v1_pastebin_module_proto_rawDesc
)
func file_api_services_v1_pastebin_module_proto_rawDescGZIP() []byte {
file_api_services_v1_pastebin_module_proto_rawDescOnce.Do(func() {
file_api_services_v1_pastebin_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_services_v1_pastebin_module_proto_rawDescData)
})
return file_api_services_v1_pastebin_module_proto_rawDescData
}
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_goTypes = []interface{}{
(ExpireLevel)(0), // 0: api_services.v1.ExpireLevel
(*PastebinServiceRecord)(nil), // 1: api_services.v1.PastebinServiceRecord
(*PastebinServiceListReq)(nil), // 2: api_services.v1.PastebinServiceListReq
(*PastebinServiceListResp)(nil), // 3: api_services.v1.PastebinServiceListResp
(*PastebinServiceAddReq)(nil), // 4: api_services.v1.PastebinServiceAddReq
(*PastebinServiceAddResp)(nil), // 5: api_services.v1.PastebinServiceAddResp
(*PastebinServiceUpdateReq)(nil), // 6: api_services.v1.PastebinServiceUpdateReq
(*PastebinServiceUpdateResp)(nil), // 7: api_services.v1.PastebinServiceUpdateResp
(*PastebinServiceGetReq)(nil), // 8: api_services.v1.PastebinServiceGetReq
(*PastebinServiceGetResp)(nil), // 9: api_services.v1.PastebinServiceGetResp
}
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
}
func init() { file_api_services_v1_pastebin_module_proto_init() }
func file_api_services_v1_pastebin_module_proto_init() {
if File_api_services_v1_pastebin_module_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_api_services_v1_pastebin_module_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PastebinServiceRecord); 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[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PastebinServiceListReq); 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[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PastebinServiceListResp); 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[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PastebinServiceAddReq); 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[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PastebinServiceAddResp); 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[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PastebinServiceUpdateReq); 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[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PastebinServiceUpdateResp); 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[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PastebinServiceGetReq); 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[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PastebinServiceGetResp); 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_api_services_v1_pastebin_module_proto_rawDesc,
NumEnums: 1,
NumMessages: 9,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_api_services_v1_pastebin_module_proto_goTypes,
DependencyIndexes: file_api_services_v1_pastebin_module_proto_depIdxs,
EnumInfos: file_api_services_v1_pastebin_module_proto_enumTypes,
MessageInfos: file_api_services_v1_pastebin_module_proto_msgTypes,
}.Build()
File_api_services_v1_pastebin_module_proto = out.File
file_api_services_v1_pastebin_module_proto_rawDesc = nil
file_api_services_v1_pastebin_module_proto_goTypes = nil
file_api_services_v1_pastebin_module_proto_depIdxs = nil
}

View File

@ -0,0 +1,87 @@
syntax = "proto3";
package api_services.v1;
option go_package = "./;api_servicesv1";
// @route_group: true
// @base_url: /v1/pastebin
// @gen_to: ./api_services/v1/pastebin_controller.go
service PastebinService {
// @desc:
// @author: Young Xu
// @method: GET
// @api: /list
rpc List (PastebinServiceListReq) returns (PastebinServiceListResp);
// @desc:
// @author: Young Xu
// @method: PUT
// @api: /add
rpc Add (PastebinServiceAddReq) returns (PastebinServiceAddResp);
// @desc:
// @author: Young Xu
// @method: POST
// @api: /update
rpc Update (PastebinServiceUpdateReq) returns (PastebinServiceUpdateResp);
// @desc:
// @author: Young Xu
// @method: GET
// @api: /get
rpc Get (PastebinServiceGetReq) returns (PastebinServiceGetResp);
}
enum ExpireLevel {
Forever = 0;
Day = 1;
Week = 2;
Month = 3;
Year = 4;
}
message PastebinServiceRecord {
int64 id = 1; // ID
string key = 2; //
string title = 3; //
string content = 5; //
string created_at = 6; //
string expired_at = 7; //
bool need_password = 8; //
bool editable = 9; //
ExpireLevel expire_level = 10; //
string password = 11; // 访
string lang = 12; //
string author = 13; //
}
message PastebinServiceListReq {
int64 page_size = 1; //
int64 current_page = 2; //
}
message PastebinServiceListResp {
repeated PastebinServiceRecord items = 1; //
bool has_more = 2; //
}
message PastebinServiceAddReq {
PastebinServiceRecord record = 1;
}
message PastebinServiceAddResp {}
message PastebinServiceUpdateReq {
PastebinServiceRecord record = 1;
}
message PastebinServiceUpdateResp {}
message PastebinServiceGetReq {
string key = 1;
string password = 2;
}
message PastebinServiceGetResp {
PastebinServiceRecord record = 1;
}

19
buf.gen.yaml Normal file
View File

@ -0,0 +1,19 @@
version: v1
managed:
enabled: true
go_package_prefix:
default: pastebin/api_services
plugins:
- plugin: buf.build/protocolbuffers/go
out: .
opt: paths=source_relative
- plugin: coco
out: .
# opt: paths=source_relative,disable_mongodb_model=true
opt: paths=source_relative
- plugin: buf.build/community/stephenh-ts-proto
out: ./webui/src/gen
opt:
- paths=source_relative
- snakeToCamel=json
- esModuleInterop=true

9
buf.yaml Normal file
View File

@ -0,0 +1,9 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT
except:
- MINIMAL

21
cmd/api.go Normal file
View File

@ -0,0 +1,21 @@
package cmd
import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"pastebin/register"
)
var (
apiServerCommand = &cobra.Command{
Use: "api",
Short: "start api server",
Long: "start api server",
Run: func(cmd *cobra.Command, args []string) {
router := register.NewRouter()
if err := router.Register(); err != nil {
logrus.Errorf("register router failed: %v", err)
}
},
}
)

41
cmd/exec.go Normal file
View File

@ -0,0 +1,41 @@
package cmd
import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"gitter.top/common/lormatter"
"pastebin/config"
)
var (
rootCmd = &cobra.Command{}
cfgFile string
)
func Execute() {
// 预加载配置文件
loadConfig()
if err := rootCmd.Execute(); err != nil {
logrus.Fatalf("exec command failed: %v", err)
}
}
func init() {
var formatter = lormatter.Formatter{
ShowTime: true,
ShowFile: true,
}
formatter.Register()
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "config_dev.yaml", "config file")
rootCmd.AddCommand(apiServerCommand) // API服务
}
func loadConfig() {
// 初始化配置文件
config.New(cfgFile)
conf := config.Get()
if err := conf.Load(); err != nil {
panic(err)
}
}

13
common/random.go Normal file
View File

@ -0,0 +1,13 @@
package common
import (
"github.com/sqids/sqids-go"
)
func UniqID(unix int64) string {
s, _ := sqids.New(sqids.Options{
MinLength: 8,
})
id, _ := s.Encode([]uint64{uint64(unix)})
return id
}

7
common/time.go Normal file
View File

@ -0,0 +1,7 @@
package common
import "time"
func Unix2Datetime(t int64) string {
return time.Unix(t, 0).Format(time.DateTime)
}

64
config/config.go Normal file
View File

@ -0,0 +1,64 @@
package config
import (
"os"
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
)
type SqliteConfig struct {
Dbname string `yaml:"dbname"`
Debug bool `yaml:"debug"`
}
type ServerConfig struct {
ServerName string `yaml:"server-name"`
ServerListen string `yaml:"server-listen"`
Environment string `yaml:"environment"`
DBConfig SqliteConfig `yaml:"db"`
}
type ServerConf struct {
ConfigFile string
ServerConfig `yaml:",inline"`
}
var conf *ServerConf
func New(fileName string) {
conf = new(ServerConf)
conf.ConfigFile = fileName
if err := conf.Load(); err != nil {
logrus.Fatalf("read config file failed: %v", err)
}
}
func Get() *ServerConf {
if conf == nil {
panic("config file not initialized")
}
return conf
}
func (receiver *ServerConf) Load() error {
data, err := os.ReadFile(receiver.ConfigFile)
if err != nil && !os.IsNotExist(err) {
return err
}
if err := yaml.Unmarshal(data, receiver); err != nil {
return err
}
return nil
}
func (receiver *ServerConf) Rewrite() error {
data, err := yaml.Marshal(receiver)
if err != nil {
return err
}
if err := os.WriteFile(receiver.ConfigFile, data, os.ModePerm); err != nil {
return err
}
return nil
}

6
config_dev.yaml Normal file
View File

@ -0,0 +1,6 @@
server-name: pastebin
server-listen: 0.0.0.0:38080
environment: dev
db:
dbname: pastebin.db
debug: true

6
config_prod.yaml Normal file
View File

@ -0,0 +1,6 @@
server-name: pastebin
server-listen: 0.0.0.0:38080
environment: prod
db:
dbname: pastebin.db
debug: true

11
docker-compose.yaml Normal file
View File

@ -0,0 +1,11 @@
version: "3"
services:
server:
image: xuthus5/pastebin:latest
container_name: pastebin
restart: always
volumes:
- /data/containers/pastebin:/app/data
ports:
- "30001:38080"

60
go.mod Normal file
View File

@ -0,0 +1,60 @@
module pastebin
go 1.21.0
require (
github.com/alecthomas/chroma v0.10.0
github.com/gin-gonic/gin v1.9.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/sqids/sqids-go v0.4.1
gitter.top/coco/coco v0.0.0-20230903142509-eaab943a68bc
gitter.top/common/lormatter v0.0.0-20230910075849-28d49dccd03a
gitter.top/drivers/sdbc v0.0.0-20230929063242-b4baa9aa7ff8
google.golang.org/protobuf v1.31.0
gopkg.in/yaml.v3 v3.0.1
)
require (
github.com/bytedance/sonic v1.10.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/dlclark/regexp2 v1.10.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/glebarez/go-sqlite v1.21.2 // indirect
github.com/glebarez/sqlite v1.9.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.15.3 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/gorilla/schema v1.2.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
gitter.top/common/goref v0.0.0-20230916075900-7b64840146ae // indirect
golang.org/x/arch v0.5.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
gorm.io/gorm v1.25.4 // indirect
modernc.org/libc v1.24.1 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
modernc.org/sqlite v1.25.0 // indirect
)

View File

View File

@ -0,0 +1,30 @@
package repositories
import (
"gitter.top/drivers/sdbc"
"pastebin/config"
modelv1 "pastebin/model/v1"
"time"
)
var (
driver *sdbc.Driver
pastebinOperator sdbc.Operator
)
func GetPastebin() sdbc.Operator {
if driver == nil {
cfg := config.Get()
driver = sdbc.NewSDBC(&sdbc.Config{
Dbname: cfg.DBConfig.Dbname,
MaxIdleConn: 20,
MaxOpenConn: 200,
MaxLifetime: time.Hour,
Debug: cfg.DBConfig.Debug,
})
}
if pastebinOperator == nil {
pastebinOperator = driver.BindModel(&modelv1.ModelPastebin{})
}
return pastebinOperator
}

View File

@ -0,0 +1,55 @@
// Code generated by protoc-gen-coco. DO NOT EDIT.
// source: model/v1/pastebin_model.proto
// generate at: 2023-09-30 21:44:38
package modelv1
const TableNameModelPastebin = "pastebin"
func (t *ModelPastebin) TableName() string {
return "pastebin"
}
func (m *ModelPastebin) GetIdField() string {
return "_id"
}
func (m *ModelPastebin) GetCreatedAtField() string {
return "created_at"
}
func (m *ModelPastebin) GetExpiredAtField() string {
return "expired_at"
}
func (m *ModelPastebin) GetShortIdField() string {
return "short_id"
}
func (m *ModelPastebin) GetTitleField() string {
return "title"
}
func (m *ModelPastebin) GetAuthorField() string {
return "author"
}
func (m *ModelPastebin) GetContentField() string {
return "content"
}
func (m *ModelPastebin) GetLangField() string {
return "lang"
}
func (m *ModelPastebin) GetPasswordField() string {
return "password"
}
func (m *ModelPastebin) GetNeedPasswordField() string {
return "need_password"
}
func (m *ModelPastebin) GetEditableField() string {
return "editable"
}

View File

@ -0,0 +1,249 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc (unknown)
// source: model/v1/pastebin_model.proto
package modelv1
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)
)
// @table_name: pastebin
type ModelPastebin struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // ID
CreatedAt int64 `protobuf:"varint,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // 创建时间
ExpiredAt int64 `protobuf:"varint,3,opt,name=expired_at,json=expiredAt,proto3" json:"expired_at,omitempty"` // 过期时间
ShortId string `protobuf:"bytes,4,opt,name=short_id,json=shortId,proto3" json:"short_id,omitempty"` // ID别名
Title string `protobuf:"bytes,5,opt,name=title,proto3" json:"title,omitempty"` // 标题
Author string `protobuf:"bytes,6,opt,name=author,proto3" json:"author,omitempty"` // 作者
Content string `protobuf:"bytes,7,opt,name=content,proto3" json:"content,omitempty"` // 内容
Lang string `protobuf:"bytes,8,opt,name=lang,proto3" json:"lang,omitempty"` // 语言
Password string `protobuf:"bytes,9,opt,name=password,proto3" json:"password,omitempty"` // 是否需要密码
NeedPassword bool `protobuf:"varint,10,opt,name=need_password,json=needPassword,proto3" json:"need_password,omitempty"` // 是否需要密码
Editable bool `protobuf:"varint,11,opt,name=editable,proto3" json:"editable,omitempty"` // 是否可以修改
}
func (x *ModelPastebin) Reset() {
*x = ModelPastebin{}
if protoimpl.UnsafeEnabled {
mi := &file_model_v1_pastebin_model_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ModelPastebin) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ModelPastebin) ProtoMessage() {}
func (x *ModelPastebin) ProtoReflect() protoreflect.Message {
mi := &file_model_v1_pastebin_model_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 ModelPastebin.ProtoReflect.Descriptor instead.
func (*ModelPastebin) Descriptor() ([]byte, []int) {
return file_model_v1_pastebin_model_proto_rawDescGZIP(), []int{0}
}
func (x *ModelPastebin) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *ModelPastebin) GetCreatedAt() int64 {
if x != nil {
return x.CreatedAt
}
return 0
}
func (x *ModelPastebin) GetExpiredAt() int64 {
if x != nil {
return x.ExpiredAt
}
return 0
}
func (x *ModelPastebin) GetShortId() string {
if x != nil {
return x.ShortId
}
return ""
}
func (x *ModelPastebin) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (x *ModelPastebin) GetAuthor() string {
if x != nil {
return x.Author
}
return ""
}
func (x *ModelPastebin) GetContent() string {
if x != nil {
return x.Content
}
return ""
}
func (x *ModelPastebin) GetLang() string {
if x != nil {
return x.Lang
}
return ""
}
func (x *ModelPastebin) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
func (x *ModelPastebin) GetNeedPassword() bool {
if x != nil {
return x.NeedPassword
}
return false
}
func (x *ModelPastebin) GetEditable() bool {
if x != nil {
return x.Editable
}
return false
}
var File_model_v1_pastebin_model_proto protoreflect.FileDescriptor
var file_model_v1_pastebin_model_proto_rawDesc = []byte{
0x0a, 0x1d, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x73, 0x74, 0x65,
0x62, 0x69, 0x6e, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
0x08, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x22, 0xb1, 0x02, 0x0a, 0x0d, 0x4d, 0x6f,
0x64, 0x65, 0x6c, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63,
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x78,
0x70, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09,
0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64, 0x41, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x68, 0x6f,
0x72, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x68, 0x6f,
0x72, 0x74, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x05, 0x20,
0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x75,
0x74, 0x68, 0x6f, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x75, 0x74, 0x68,
0x6f, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x07, 0x20,
0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04,
0x6c, 0x61, 0x6e, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x61, 0x6e, 0x67,
0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x09, 0x20, 0x01,
0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x23, 0x0a, 0x0d,
0x6e, 0x65, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x0a, 0x20,
0x01, 0x28, 0x08, 0x52, 0x0c, 0x6e, 0x65, 0x65, 0x64, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72,
0x64, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x64, 0x69, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x0b, 0x20,
0x01, 0x28, 0x08, 0x52, 0x08, 0x65, 0x64, 0x69, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x42, 0x8b, 0x01,
0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x76, 0x31, 0x42, 0x12,
0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x50, 0x72, 0x6f,
0x74, 0x6f, 0x50, 0x01, 0x5a, 0x26, 0x70, 0x61, 0x73, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x2f, 0x61,
0x70, 0x69, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65,
0x6c, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x4d,
0x58, 0x58, 0xaa, 0x02, 0x08, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08,
0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x14, 0x4d, 0x6f, 0x64, 0x65, 0x6c,
0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea,
0x02, 0x09, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
file_model_v1_pastebin_model_proto_rawDescOnce sync.Once
file_model_v1_pastebin_model_proto_rawDescData = file_model_v1_pastebin_model_proto_rawDesc
)
func file_model_v1_pastebin_model_proto_rawDescGZIP() []byte {
file_model_v1_pastebin_model_proto_rawDescOnce.Do(func() {
file_model_v1_pastebin_model_proto_rawDescData = protoimpl.X.CompressGZIP(file_model_v1_pastebin_model_proto_rawDescData)
})
return file_model_v1_pastebin_model_proto_rawDescData
}
var file_model_v1_pastebin_model_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_model_v1_pastebin_model_proto_goTypes = []interface{}{
(*ModelPastebin)(nil), // 0: model.v1.ModelPastebin
}
var file_model_v1_pastebin_model_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_model_v1_pastebin_model_proto_init() }
func file_model_v1_pastebin_model_proto_init() {
if File_model_v1_pastebin_model_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_model_v1_pastebin_model_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ModelPastebin); 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_model_v1_pastebin_model_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_model_v1_pastebin_model_proto_goTypes,
DependencyIndexes: file_model_v1_pastebin_model_proto_depIdxs,
MessageInfos: file_model_v1_pastebin_model_proto_msgTypes,
}.Build()
File_model_v1_pastebin_model_proto = out.File
file_model_v1_pastebin_model_proto_rawDesc = nil
file_model_v1_pastebin_model_proto_goTypes = nil
file_model_v1_pastebin_model_proto_depIdxs = nil
}

View File

@ -0,0 +1,21 @@
syntax = "proto3";
package model.v1;
option go_package = "./;modelv1";
// @table_name: pastebin
message ModelPastebin {
int64 id = 1; // ID
int64 created_at = 2; //
int64 expired_at = 3; //
string short_id = 4; // ID别名
string title = 5; //
string author = 6; //
string content = 7; //
string lang = 8; //
string password = 9; //
bool need_password = 10; //
bool editable = 11; //
}

7
pastebin.go Normal file
View File

@ -0,0 +1,7 @@
package main
import "pastebin/cmd"
func main() {
cmd.Execute()
}

37
register/router.go Normal file
View File

@ -0,0 +1,37 @@
package register
import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"gitter.top/coco/coco/core"
"pastebin/api_services/v1"
"pastebin/config"
)
type Router struct{}
func NewRouter() *Router {
return &Router{}
}
// Register 注册路由
func (receiver *Router) Register() error {
cfg := config.Get()
// 从这里开始实例化路由注册器
var register = core.NewRegister()
register.DefaultRouter(core.WithListenAddress(cfg.ServerListen),
core.WithGinMode(gin.ReleaseMode), core.WithCors(), core.WithRecovery())
register.RegisterStruct(api_servicesv1.AutoGenPastebinServiceRouterMap, &api_servicesv1.PastebinService{})
_ = register.PreRun(func() error {
engine := register.RawEngine()
engine.Static("/assets", "./webui/dist/assets")
engine.NoRoute(func(ctx *gin.Context) {
ctx.File("./webui/dist/index.html")
})
return nil
})
logrus.Infof("api server: http://%s", cfg.ServerListen)
register.Run()
return nil
}

0
rpc_services/.gitkeep Normal file
View File

21
webui/.eslintrc.cjs Normal file
View File

@ -0,0 +1,21 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
module.exports = {
root: true,
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript',
'@vue/eslint-config-prettier/skip-formatting'
],
parserOptions: {
ecmaVersion: 'latest'
},
env: {
browser: true,
amd: true,
node: true,
es2022: true,
}
}

28
webui/.gitignore vendored Normal file
View File

@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

8
webui/.prettierrc.json Normal file
View File

@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}

8
webui/.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,8 @@
{
"recommendations": [
"Vue.volar",
"Vue.vscode-typescript-vue-plugin",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}

46
webui/README.md Normal file
View File

@ -0,0 +1,46 @@
# pastebin
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Type Support for `.vue` Imports in TS
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
1. Disable the built-in TypeScript Extension
1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Type-Check, Compile and Minify for Production
```sh
npm run build
```
### Lint with [ESLint](https://eslint.org/)
```sh
npm run lint
```

1
webui/env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="vite/client" />

13
webui/index.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>粘贴箱 - Pastebin</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

4531
webui/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

45
webui/package.json Normal file
View File

@ -0,0 +1,45 @@
{
"name": "pastebin",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@codemirror/lang-javascript": "github:codemirror/lang-javascript",
"@codemirror/lang-json": "github:codemirror/lang-json",
"@codemirror/lang-markdown": "github:codemirror/lang-markdown",
"@codemirror/theme-one-dark": "github:codemirror/theme-one-dark",
"@kyvg/vue3-notification": "^3.0.2",
"axios": "^1.5.1",
"codemirror": "^6.0.1",
"pinia": "^2.1.6",
"ts-proto": "^1.158.0",
"vue": "^3.3.4",
"vue-codemirror": "^6.1.1",
"vue-router": "^4.2.4",
"vue3-highlightjs": "^1.0.5"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.3.3",
"@tsconfig/node18": "^18.2.2",
"@types/node": "^18.17.17",
"@vitejs/plugin-vue": "^4.3.4",
"@vue/eslint-config-prettier": "^8.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/tsconfig": "^0.4.0",
"autoprefixer": "^10.4.16",
"daisyui": "^3.7.7",
"eslint": "^8.49.0",
"eslint-plugin-vue": "^9.17.0",
"npm-run-all2": "^6.0.6",
"postcss": "^8.4.30",
"prettier": "^3.0.3",
"tailwindcss": "^3.3.3",
"typescript": "~5.2.0",
"vite": "^4.4.9",
"vue-tsc": "^1.8.11"
}
}

6
webui/postcss.config.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

BIN
webui/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

25
webui/src/App.vue Normal file
View File

@ -0,0 +1,25 @@
<script setup lang="ts">
import { RouterLink, RouterView } from 'vue-router'
import {usePageStore} from "@/stores/counter";
const pager = usePageStore()
</script>
<template>
<div class="hero bg-base-200">
<div class="hero-content text-center">
<div class="max-w-md">
<h1 class="text-5xl font-bold">Pastebin!</h1>
<p class="py-6">本网站旨在用作各方之间粘贴信息的短期交换提交的数据不保证是永久性的并且可能随时被删除</p>
<RouterLink :to="{name: pager.reversal()}" class="btn btn-primary">
<span v-if="pager.reversal() === 'home'">首页</span>
<span v-else>列表</span>
</RouterLink>
</div>
</div>
</div>
<notifications />
<RouterView />
</template>

View File

@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>

After

Width:  |  Height:  |  Size: 276 B

View File

@ -0,0 +1,41 @@
<script setup lang="ts">
defineProps<{
msg: string
}>()
</script>
<template>
<div class="greetings">
<h1 class="green">{{ msg }}</h1>
<h3>
Youve successfully created a project with
<a href="https://vitejs.dev/" target="_blank" rel="noopener">Vite</a> +
<a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>. What's next?
</h3>
</div>
</template>
<style scoped>
h1 {
font-weight: 500;
font-size: 2.6rem;
position: relative;
top: -10px;
}
h3 {
font-size: 1.2rem;
}
.greetings h1,
.greetings h3 {
text-align: center;
}
@media (min-width: 1024px) {
.greetings h1,
.greetings h3 {
text-align: left;
}
}
</style>

View File

@ -0,0 +1,88 @@
<script setup lang="ts">
import WelcomeItem from './WelcomeItem.vue'
import DocumentationIcon from './icons/IconDocumentation.vue'
import ToolingIcon from './icons/IconTooling.vue'
import EcosystemIcon from './icons/IconEcosystem.vue'
import CommunityIcon from './icons/IconCommunity.vue'
import SupportIcon from './icons/IconSupport.vue'
</script>
<template>
<WelcomeItem>
<template #icon>
<DocumentationIcon />
</template>
<template #heading>Documentation</template>
Vues
<a href="https://vuejs.org/" target="_blank" rel="noopener">official documentation</a>
provides you with all information you need to get started.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<ToolingIcon />
</template>
<template #heading>Tooling</template>
This project is served and bundled with
<a href="https://vitejs.dev/guide/features.html" target="_blank" rel="noopener">Vite</a>. The
recommended IDE setup is
<a href="https://code.visualstudio.com/" target="_blank" rel="noopener">VSCode</a> +
<a href="https://github.com/johnsoncodehk/volar" target="_blank" rel="noopener">Volar</a>. If
you need to test your components and web pages, check out
<a href="https://www.cypress.io/" target="_blank" rel="noopener">Cypress</a> and
<a href="https://on.cypress.io/component" target="_blank" rel="noopener"
>Cypress Component Testing</a
>.
<br />
More instructions are available in <code>README.md</code>.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<EcosystemIcon />
</template>
<template #heading>Ecosystem</template>
Get official tools and libraries for your project:
<a href="https://pinia.vuejs.org/" target="_blank" rel="noopener">Pinia</a>,
<a href="https://router.vuejs.org/" target="_blank" rel="noopener">Vue Router</a>,
<a href="https://test-utils.vuejs.org/" target="_blank" rel="noopener">Vue Test Utils</a>, and
<a href="https://github.com/vuejs/devtools" target="_blank" rel="noopener">Vue Dev Tools</a>. If
you need more resources, we suggest paying
<a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">Awesome Vue</a>
a visit.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<CommunityIcon />
</template>
<template #heading>Community</template>
Got stuck? Ask your question on
<a href="https://chat.vuejs.org" target="_blank" rel="noopener">Vue Land</a>, our official
Discord server, or
<a href="https://stackoverflow.com/questions/tagged/vue.js" target="_blank" rel="noopener"
>StackOverflow</a
>. You should also subscribe to
<a href="https://news.vuejs.org" target="_blank" rel="noopener">our mailing list</a> and follow
the official
<a href="https://twitter.com/vuejs" target="_blank" rel="noopener">@vuejs</a>
twitter account for latest news in the Vue world.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<SupportIcon />
</template>
<template #heading>Support Vue</template>
As an independent project, Vue relies on community backing for its sustainability. You can help
us by
<a href="https://vuejs.org/sponsor/" target="_blank" rel="noopener">becoming a sponsor</a>.
</WelcomeItem>
</template>

View File

@ -0,0 +1,87 @@
<template>
<div class="item">
<i>
<slot name="icon"></slot>
</i>
<div class="details">
<h3>
<slot name="heading"></slot>
</h3>
<slot></slot>
</div>
</div>
</template>
<style scoped>
.item {
margin-top: 2rem;
display: flex;
position: relative;
}
.details {
flex: 1;
margin-left: 1rem;
}
i {
display: flex;
place-items: center;
place-content: center;
width: 32px;
height: 32px;
color: var(--color-text);
}
h3 {
font-size: 1.2rem;
font-weight: 500;
margin-bottom: 0.4rem;
color: var(--color-heading);
}
@media (min-width: 1024px) {
.item {
margin-top: 0;
padding: 0.4rem 0 1rem calc(var(--section-gap) / 2);
}
i {
top: calc(50% - 25px);
left: -26px;
position: absolute;
border: 1px solid var(--color-border);
background: var(--color-background);
border-radius: 8px;
width: 50px;
height: 50px;
}
.item:before {
content: ' ';
border-left: 1px solid var(--color-border);
position: absolute;
left: 0;
bottom: calc(50% + 25px);
height: calc(50% - 25px);
}
.item:after {
content: ' ';
border-left: 1px solid var(--color-border);
position: absolute;
left: 0;
top: calc(50% + 25px);
height: calc(50% - 25px);
}
.item:first-of-type:before {
display: none;
}
.item:last-of-type:after {
display: none;
}
}
</style>

View File

@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor">
<path
d="M15 4a1 1 0 1 0 0 2V4zm0 11v-1a1 1 0 0 0-1 1h1zm0 4l-.707.707A1 1 0 0 0 16 19h-1zm-4-4l.707-.707A1 1 0 0 0 11 14v1zm-4.707-1.293a1 1 0 0 0-1.414 1.414l1.414-1.414zm-.707.707l-.707-.707.707.707zM9 11v-1a1 1 0 0 0-.707.293L9 11zm-4 0h1a1 1 0 0 0-1-1v1zm0 4H4a1 1 0 0 0 1.707.707L5 15zm10-9h2V4h-2v2zm2 0a1 1 0 0 1 1 1h2a3 3 0 0 0-3-3v2zm1 1v6h2V7h-2zm0 6a1 1 0 0 1-1 1v2a3 3 0 0 0 3-3h-2zm-1 1h-2v2h2v-2zm-3 1v4h2v-4h-2zm1.707 3.293l-4-4-1.414 1.414 4 4 1.414-1.414zM11 14H7v2h4v-2zm-4 0c-.276 0-.525-.111-.707-.293l-1.414 1.414C5.42 15.663 6.172 16 7 16v-2zm-.707 1.121l3.414-3.414-1.414-1.414-3.414 3.414 1.414 1.414zM9 12h4v-2H9v2zm4 0a3 3 0 0 0 3-3h-2a1 1 0 0 1-1 1v2zm3-3V3h-2v6h2zm0-6a3 3 0 0 0-3-3v2a1 1 0 0 1 1 1h2zm-3-3H3v2h10V0zM3 0a3 3 0 0 0-3 3h2a1 1 0 0 1 1-1V0zM0 3v6h2V3H0zm0 6a3 3 0 0 0 3 3v-2a1 1 0 0 1-1-1H0zm3 3h2v-2H3v2zm1-1v4h2v-4H4zm1.707 4.707l.586-.586-1.414-1.414-.586.586 1.414 1.414z"
/>
</svg>
</template>

View File

@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" fill="currentColor">
<path
d="M11 2.253a1 1 0 1 0-2 0h2zm-2 13a1 1 0 1 0 2 0H9zm.447-12.167a1 1 0 1 0 1.107-1.666L9.447 3.086zM1 2.253L.447 1.42A1 1 0 0 0 0 2.253h1zm0 13H0a1 1 0 0 0 1.553.833L1 15.253zm8.447.833a1 1 0 1 0 1.107-1.666l-1.107 1.666zm0-14.666a1 1 0 1 0 1.107 1.666L9.447 1.42zM19 2.253h1a1 1 0 0 0-.447-.833L19 2.253zm0 13l-.553.833A1 1 0 0 0 20 15.253h-1zm-9.553-.833a1 1 0 1 0 1.107 1.666L9.447 14.42zM9 2.253v13h2v-13H9zm1.553-.833C9.203.523 7.42 0 5.5 0v2c1.572 0 2.961.431 3.947 1.086l1.107-1.666zM5.5 0C3.58 0 1.797.523.447 1.42l1.107 1.666C2.539 2.431 3.928 2 5.5 2V0zM0 2.253v13h2v-13H0zm1.553 13.833C2.539 15.431 3.928 15 5.5 15v-2c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM5.5 15c1.572 0 2.961.431 3.947 1.086l1.107-1.666C9.203 13.523 7.42 13 5.5 13v2zm5.053-11.914C11.539 2.431 12.928 2 14.5 2V0c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM14.5 2c1.573 0 2.961.431 3.947 1.086l1.107-1.666C18.203.523 16.421 0 14.5 0v2zm3.5.253v13h2v-13h-2zm1.553 12.167C18.203 13.523 16.421 13 14.5 13v2c1.573 0 2.961.431 3.947 1.086l1.107-1.666zM14.5 13c-1.92 0-3.703.523-5.053 1.42l1.107 1.666C11.539 15.431 12.928 15 14.5 15v-2z"
/>
</svg>
</template>

View File

@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="20" fill="currentColor">
<path
d="M11.447 8.894a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm0 1.789a1 1 0 1 0 .894-1.789l-.894 1.789zM7.447 7.106a1 1 0 1 0-.894 1.789l.894-1.789zM10 9a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0H8zm9.447-5.606a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm2 .789a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zM18 5a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0h-2zm-5.447-4.606a1 1 0 1 0 .894-1.789l-.894 1.789zM9 1l.447-.894a1 1 0 0 0-.894 0L9 1zm-2.447.106a1 1 0 1 0 .894 1.789l-.894-1.789zm-6 3a1 1 0 1 0 .894 1.789L.553 4.106zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zm-2-.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 2.789a1 1 0 1 0 .894-1.789l-.894 1.789zM2 5a1 1 0 1 0-2 0h2zM0 7.5a1 1 0 1 0 2 0H0zm8.553 12.394a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 1a1 1 0 1 0 .894 1.789l-.894-1.789zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zM8 19a1 1 0 1 0 2 0H8zm2-2.5a1 1 0 1 0-2 0h2zm-7.447.394a1 1 0 1 0 .894-1.789l-.894 1.789zM1 15H0a1 1 0 0 0 .553.894L1 15zm1-2.5a1 1 0 1 0-2 0h2zm12.553 2.606a1 1 0 1 0 .894 1.789l-.894-1.789zM17 15l.447.894A1 1 0 0 0 18 15h-1zm1-2.5a1 1 0 1 0-2 0h2zm-7.447-5.394l-2 1 .894 1.789 2-1-.894-1.789zm-1.106 1l-2-1-.894 1.789 2 1 .894-1.789zM8 9v2.5h2V9H8zm8.553-4.894l-2 1 .894 1.789 2-1-.894-1.789zm.894 0l-2-1-.894 1.789 2 1 .894-1.789zM16 5v2.5h2V5h-2zm-4.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zm-2.894-1l-2 1 .894 1.789 2-1L8.553.106zM1.447 5.894l2-1-.894-1.789-2 1 .894 1.789zm-.894 0l2 1 .894-1.789-2-1-.894 1.789zM0 5v2.5h2V5H0zm9.447 13.106l-2-1-.894 1.789 2 1 .894-1.789zm0 1.789l2-1-.894-1.789-2 1 .894 1.789zM10 19v-2.5H8V19h2zm-6.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zM2 15v-2.5H0V15h2zm13.447 1.894l2-1-.894-1.789-2 1 .894 1.789zM18 15v-2.5h-2V15h2z"
/>
</svg>
</template>

View File

@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor">
<path
d="M10 3.22l-.61-.6a5.5 5.5 0 0 0-7.666.105 5.5 5.5 0 0 0-.114 7.665L10 18.78l8.39-8.4a5.5 5.5 0 0 0-.114-7.665 5.5 5.5 0 0 0-7.666-.105l-.61.61z"
/>
</svg>
</template>

View File

@ -0,0 +1,19 @@
<!-- This icon is from <https://github.com/Templarian/MaterialDesign>, distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license-->
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
aria-hidden="true"
role="img"
class="iconify iconify--mdi"
width="24"
height="24"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 24 24"
>
<path
d="M20 18v-4h-3v1h-2v-1H9v1H7v-1H4v4h16M6.33 8l-1.74 4H7v-1h2v1h6v-1h2v1h2.41l-1.74-4H6.33M9 5v1h6V5H9m12.84 7.61c.1.22.16.48.16.8V18c0 .53-.21 1-.6 1.41c-.4.4-.85.59-1.4.59H4c-.55 0-1-.19-1.4-.59C2.21 19 2 18.53 2 18v-4.59c0-.32.06-.58.16-.8L4.5 7.22C4.84 6.41 5.45 6 6.33 6H7V5c0-.55.18-1 .57-1.41C7.96 3.2 8.44 3 9 3h6c.56 0 1.04.2 1.43.59c.39.41.57.86.57 1.41v1h.67c.88 0 1.49.41 1.83 1.22l2.34 5.39z"
fill="currentColor"
></path>
</svg>
</template>

View File

@ -0,0 +1,965 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "api_services.v1";
export enum ExpireLevel {
Forever = 0,
Day = 1,
Week = 2,
Month = 3,
Year = 4,
UNRECOGNIZED = -1,
}
export function expireLevelFromJSON(object: any): ExpireLevel {
switch (object) {
case 0:
case "Forever":
return ExpireLevel.Forever;
case 1:
case "Day":
return ExpireLevel.Day;
case 2:
case "Week":
return ExpireLevel.Week;
case 3:
case "Month":
return ExpireLevel.Month;
case 4:
case "Year":
return ExpireLevel.Year;
case -1:
case "UNRECOGNIZED":
default:
return ExpireLevel.UNRECOGNIZED;
}
}
export function expireLevelToJSON(object: ExpireLevel): string {
switch (object) {
case ExpireLevel.Forever:
return "Forever";
case ExpireLevel.Day:
return "Day";
case ExpireLevel.Week:
return "Week";
case ExpireLevel.Month:
return "Month";
case ExpireLevel.Year:
return "Year";
case ExpireLevel.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
export interface PastebinServiceRecord {
/** 记录ID */
id: number;
/** 记录别名 */
key: string;
/** 记录标题 */
title: string;
/** 记录渲染后内容 */
content: string;
/** 记录创建时间 */
created_at: string;
/** 过期时间 */
expired_at: string;
/** 是否需要密码 */
need_password: boolean;
/** 是否可以修订 */
editable: boolean;
/** 指定记录有效期 */
expire_level: ExpireLevel;
/** 指定需要密码访问 */
password: string;
/** 指定语言 */
lang: string;
/** 作者 */
author: string;
}
export interface PastebinServiceListReq {
/** 分页大小 */
page_size: number;
/** 当前页 从第一页开始 */
current_page: number;
}
export interface PastebinServiceListResp {
/** 列表 */
items: PastebinServiceRecord[];
/** 是否有下一页 */
has_more: boolean;
}
export interface PastebinServiceAddReq {
record: PastebinServiceRecord | undefined;
}
export interface PastebinServiceAddResp {
}
export interface PastebinServiceUpdateReq {
record: PastebinServiceRecord | undefined;
}
export interface PastebinServiceUpdateResp {
}
export interface PastebinServiceGetReq {
key: string;
password: string;
}
export interface PastebinServiceGetResp {
record: PastebinServiceRecord | undefined;
}
function createBasePastebinServiceRecord(): PastebinServiceRecord {
return {
id: 0,
key: "",
title: "",
content: "",
created_at: "",
expired_at: "",
need_password: false,
editable: false,
expire_level: 0,
password: "",
lang: "",
author: "",
};
}
export const PastebinServiceRecord = {
encode(message: PastebinServiceRecord, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int64(message.id);
}
if (message.key !== "") {
writer.uint32(18).string(message.key);
}
if (message.title !== "") {
writer.uint32(26).string(message.title);
}
if (message.content !== "") {
writer.uint32(42).string(message.content);
}
if (message.created_at !== "") {
writer.uint32(50).string(message.created_at);
}
if (message.expired_at !== "") {
writer.uint32(58).string(message.expired_at);
}
if (message.need_password === true) {
writer.uint32(64).bool(message.need_password);
}
if (message.editable === true) {
writer.uint32(72).bool(message.editable);
}
if (message.expire_level !== 0) {
writer.uint32(80).int32(message.expire_level);
}
if (message.password !== "") {
writer.uint32(90).string(message.password);
}
if (message.lang !== "") {
writer.uint32(98).string(message.lang);
}
if (message.author !== "") {
writer.uint32(106).string(message.author);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): PastebinServiceRecord {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePastebinServiceRecord();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 8) {
break;
}
message.id = longToNumber(reader.int64() as Long);
continue;
case 2:
if (tag !== 18) {
break;
}
message.key = reader.string();
continue;
case 3:
if (tag !== 26) {
break;
}
message.title = reader.string();
continue;
case 5:
if (tag !== 42) {
break;
}
message.content = reader.string();
continue;
case 6:
if (tag !== 50) {
break;
}
message.created_at = reader.string();
continue;
case 7:
if (tag !== 58) {
break;
}
message.expired_at = reader.string();
continue;
case 8:
if (tag !== 64) {
break;
}
message.need_password = reader.bool();
continue;
case 9:
if (tag !== 72) {
break;
}
message.editable = reader.bool();
continue;
case 10:
if (tag !== 80) {
break;
}
message.expire_level = reader.int32() as any;
continue;
case 11:
if (tag !== 90) {
break;
}
message.password = reader.string();
continue;
case 12:
if (tag !== 98) {
break;
}
message.lang = reader.string();
continue;
case 13:
if (tag !== 106) {
break;
}
message.author = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): PastebinServiceRecord {
return {
id: isSet(object.id) ? Number(object.id) : 0,
key: isSet(object.key) ? String(object.key) : "",
title: isSet(object.title) ? String(object.title) : "",
content: isSet(object.content) ? String(object.content) : "",
created_at: isSet(object.createdAt) ? String(object.createdAt) : "",
expired_at: isSet(object.expiredAt) ? String(object.expiredAt) : "",
need_password: isSet(object.needPassword) ? Boolean(object.needPassword) : false,
editable: isSet(object.editable) ? Boolean(object.editable) : false,
expire_level: isSet(object.expireLevel) ? expireLevelFromJSON(object.expireLevel) : 0,
password: isSet(object.password) ? String(object.password) : "",
lang: isSet(object.lang) ? String(object.lang) : "",
author: isSet(object.author) ? String(object.author) : "",
};
},
toJSON(message: PastebinServiceRecord): unknown {
const obj: any = {};
if (message.id !== 0) {
obj.id = Math.round(message.id);
}
if (message.key !== "") {
obj.key = message.key;
}
if (message.title !== "") {
obj.title = message.title;
}
if (message.content !== "") {
obj.content = message.content;
}
if (message.created_at !== "") {
obj.createdAt = message.created_at;
}
if (message.expired_at !== "") {
obj.expiredAt = message.expired_at;
}
if (message.need_password === true) {
obj.needPassword = message.need_password;
}
if (message.editable === true) {
obj.editable = message.editable;
}
if (message.expire_level !== 0) {
obj.expireLevel = expireLevelToJSON(message.expire_level);
}
if (message.password !== "") {
obj.password = message.password;
}
if (message.lang !== "") {
obj.lang = message.lang;
}
if (message.author !== "") {
obj.author = message.author;
}
return obj;
},
create<I extends Exact<DeepPartial<PastebinServiceRecord>, I>>(base?: I): PastebinServiceRecord {
return PastebinServiceRecord.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<PastebinServiceRecord>, I>>(object: I): PastebinServiceRecord {
const message = createBasePastebinServiceRecord();
message.id = object.id ?? 0;
message.key = object.key ?? "";
message.title = object.title ?? "";
message.content = object.content ?? "";
message.created_at = object.created_at ?? "";
message.expired_at = object.expired_at ?? "";
message.need_password = object.need_password ?? false;
message.editable = object.editable ?? false;
message.expire_level = object.expire_level ?? 0;
message.password = object.password ?? "";
message.lang = object.lang ?? "";
message.author = object.author ?? "";
return message;
},
};
function createBasePastebinServiceListReq(): PastebinServiceListReq {
return { page_size: 0, current_page: 0 };
}
export const PastebinServiceListReq = {
encode(message: PastebinServiceListReq, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.page_size !== 0) {
writer.uint32(8).int64(message.page_size);
}
if (message.current_page !== 0) {
writer.uint32(16).int64(message.current_page);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): PastebinServiceListReq {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePastebinServiceListReq();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 8) {
break;
}
message.page_size = longToNumber(reader.int64() as Long);
continue;
case 2:
if (tag !== 16) {
break;
}
message.current_page = longToNumber(reader.int64() as Long);
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): PastebinServiceListReq {
return {
page_size: isSet(object.pageSize) ? Number(object.pageSize) : 0,
current_page: isSet(object.currentPage) ? Number(object.currentPage) : 0,
};
},
toJSON(message: PastebinServiceListReq): unknown {
const obj: any = {};
if (message.page_size !== 0) {
obj.pageSize = Math.round(message.page_size);
}
if (message.current_page !== 0) {
obj.currentPage = Math.round(message.current_page);
}
return obj;
},
create<I extends Exact<DeepPartial<PastebinServiceListReq>, I>>(base?: I): PastebinServiceListReq {
return PastebinServiceListReq.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<PastebinServiceListReq>, I>>(object: I): PastebinServiceListReq {
const message = createBasePastebinServiceListReq();
message.page_size = object.page_size ?? 0;
message.current_page = object.current_page ?? 0;
return message;
},
};
function createBasePastebinServiceListResp(): PastebinServiceListResp {
return { items: [], has_more: false };
}
export const PastebinServiceListResp = {
encode(message: PastebinServiceListResp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.items) {
PastebinServiceRecord.encode(v!, writer.uint32(10).fork()).ldelim();
}
if (message.has_more === true) {
writer.uint32(16).bool(message.has_more);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): PastebinServiceListResp {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePastebinServiceListResp();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.items.push(PastebinServiceRecord.decode(reader, reader.uint32()));
continue;
case 2:
if (tag !== 16) {
break;
}
message.has_more = reader.bool();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): PastebinServiceListResp {
return {
items: Array.isArray(object?.items) ? object.items.map((e: any) => PastebinServiceRecord.fromJSON(e)) : [],
has_more: isSet(object.hasMore) ? Boolean(object.hasMore) : false,
};
},
toJSON(message: PastebinServiceListResp): unknown {
const obj: any = {};
if (message.items?.length) {
obj.items = message.items.map((e) => PastebinServiceRecord.toJSON(e));
}
if (message.has_more === true) {
obj.hasMore = message.has_more;
}
return obj;
},
create<I extends Exact<DeepPartial<PastebinServiceListResp>, I>>(base?: I): PastebinServiceListResp {
return PastebinServiceListResp.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<PastebinServiceListResp>, I>>(object: I): PastebinServiceListResp {
const message = createBasePastebinServiceListResp();
message.items = object.items?.map((e) => PastebinServiceRecord.fromPartial(e)) || [];
message.has_more = object.has_more ?? false;
return message;
},
};
function createBasePastebinServiceAddReq(): PastebinServiceAddReq {
return { record: undefined };
}
export const PastebinServiceAddReq = {
encode(message: PastebinServiceAddReq, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.record !== undefined) {
PastebinServiceRecord.encode(message.record, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): PastebinServiceAddReq {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePastebinServiceAddReq();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.record = PastebinServiceRecord.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): PastebinServiceAddReq {
return { record: isSet(object.record) ? PastebinServiceRecord.fromJSON(object.record) : undefined };
},
toJSON(message: PastebinServiceAddReq): unknown {
const obj: any = {};
if (message.record !== undefined) {
obj.record = PastebinServiceRecord.toJSON(message.record);
}
return obj;
},
create<I extends Exact<DeepPartial<PastebinServiceAddReq>, I>>(base?: I): PastebinServiceAddReq {
return PastebinServiceAddReq.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<PastebinServiceAddReq>, I>>(object: I): PastebinServiceAddReq {
const message = createBasePastebinServiceAddReq();
message.record = (object.record !== undefined && object.record !== null)
? PastebinServiceRecord.fromPartial(object.record)
: undefined;
return message;
},
};
function createBasePastebinServiceAddResp(): PastebinServiceAddResp {
return {};
}
export const PastebinServiceAddResp = {
encode(_: PastebinServiceAddResp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): PastebinServiceAddResp {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePastebinServiceAddResp();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(_: any): PastebinServiceAddResp {
return {};
},
toJSON(_: PastebinServiceAddResp): unknown {
const obj: any = {};
return obj;
},
create<I extends Exact<DeepPartial<PastebinServiceAddResp>, I>>(base?: I): PastebinServiceAddResp {
return PastebinServiceAddResp.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<PastebinServiceAddResp>, I>>(_: I): PastebinServiceAddResp {
const message = createBasePastebinServiceAddResp();
return message;
},
};
function createBasePastebinServiceUpdateReq(): PastebinServiceUpdateReq {
return { record: undefined };
}
export const PastebinServiceUpdateReq = {
encode(message: PastebinServiceUpdateReq, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.record !== undefined) {
PastebinServiceRecord.encode(message.record, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): PastebinServiceUpdateReq {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePastebinServiceUpdateReq();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.record = PastebinServiceRecord.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): PastebinServiceUpdateReq {
return { record: isSet(object.record) ? PastebinServiceRecord.fromJSON(object.record) : undefined };
},
toJSON(message: PastebinServiceUpdateReq): unknown {
const obj: any = {};
if (message.record !== undefined) {
obj.record = PastebinServiceRecord.toJSON(message.record);
}
return obj;
},
create<I extends Exact<DeepPartial<PastebinServiceUpdateReq>, I>>(base?: I): PastebinServiceUpdateReq {
return PastebinServiceUpdateReq.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<PastebinServiceUpdateReq>, I>>(object: I): PastebinServiceUpdateReq {
const message = createBasePastebinServiceUpdateReq();
message.record = (object.record !== undefined && object.record !== null)
? PastebinServiceRecord.fromPartial(object.record)
: undefined;
return message;
},
};
function createBasePastebinServiceUpdateResp(): PastebinServiceUpdateResp {
return {};
}
export const PastebinServiceUpdateResp = {
encode(_: PastebinServiceUpdateResp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): PastebinServiceUpdateResp {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePastebinServiceUpdateResp();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(_: any): PastebinServiceUpdateResp {
return {};
},
toJSON(_: PastebinServiceUpdateResp): unknown {
const obj: any = {};
return obj;
},
create<I extends Exact<DeepPartial<PastebinServiceUpdateResp>, I>>(base?: I): PastebinServiceUpdateResp {
return PastebinServiceUpdateResp.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<PastebinServiceUpdateResp>, I>>(_: I): PastebinServiceUpdateResp {
const message = createBasePastebinServiceUpdateResp();
return message;
},
};
function createBasePastebinServiceGetReq(): PastebinServiceGetReq {
return { key: "", password: "" };
}
export const PastebinServiceGetReq = {
encode(message: PastebinServiceGetReq, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.key !== "") {
writer.uint32(10).string(message.key);
}
if (message.password !== "") {
writer.uint32(18).string(message.password);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): PastebinServiceGetReq {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePastebinServiceGetReq();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.key = reader.string();
continue;
case 2:
if (tag !== 18) {
break;
}
message.password = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): PastebinServiceGetReq {
return {
key: isSet(object.key) ? String(object.key) : "",
password: isSet(object.password) ? String(object.password) : "",
};
},
toJSON(message: PastebinServiceGetReq): unknown {
const obj: any = {};
if (message.key !== "") {
obj.key = message.key;
}
if (message.password !== "") {
obj.password = message.password;
}
return obj;
},
create<I extends Exact<DeepPartial<PastebinServiceGetReq>, I>>(base?: I): PastebinServiceGetReq {
return PastebinServiceGetReq.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<PastebinServiceGetReq>, I>>(object: I): PastebinServiceGetReq {
const message = createBasePastebinServiceGetReq();
message.key = object.key ?? "";
message.password = object.password ?? "";
return message;
},
};
function createBasePastebinServiceGetResp(): PastebinServiceGetResp {
return { record: undefined };
}
export const PastebinServiceGetResp = {
encode(message: PastebinServiceGetResp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.record !== undefined) {
PastebinServiceRecord.encode(message.record, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): PastebinServiceGetResp {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePastebinServiceGetResp();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.record = PastebinServiceRecord.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): PastebinServiceGetResp {
return { record: isSet(object.record) ? PastebinServiceRecord.fromJSON(object.record) : undefined };
},
toJSON(message: PastebinServiceGetResp): unknown {
const obj: any = {};
if (message.record !== undefined) {
obj.record = PastebinServiceRecord.toJSON(message.record);
}
return obj;
},
create<I extends Exact<DeepPartial<PastebinServiceGetResp>, I>>(base?: I): PastebinServiceGetResp {
return PastebinServiceGetResp.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<PastebinServiceGetResp>, I>>(object: I): PastebinServiceGetResp {
const message = createBasePastebinServiceGetResp();
message.record = (object.record !== undefined && object.record !== null)
? PastebinServiceRecord.fromPartial(object.record)
: undefined;
return message;
},
};
/**
* @route_group: true
* @base_url: /v1/pastebin
* @gen_to: ./api_services/v1/pastebin_controller.go
*/
export interface PastebinService {
/**
* @desc:
* @author: Young Xu
* @method: GET
* @api: /list
*/
List(request: PastebinServiceListReq): Promise<PastebinServiceListResp>;
/**
* @desc:
* @author: Young Xu
* @method: PUT
* @api: /add
*/
Add(request: PastebinServiceAddReq): Promise<PastebinServiceAddResp>;
/**
* @desc:
* @author: Young Xu
* @method: POST
* @api: /update
*/
Update(request: PastebinServiceUpdateReq): Promise<PastebinServiceUpdateResp>;
/**
* @desc:
* @author: Young Xu
* @method: GET
* @api: /get
*/
Get(request: PastebinServiceGetReq): Promise<PastebinServiceGetResp>;
}
export const PastebinServiceServiceName = "api_services.v1.PastebinService";
export class PastebinServiceClientImpl implements PastebinService {
private readonly rpc: Rpc;
private readonly service: string;
constructor(rpc: Rpc, opts?: { service?: string }) {
this.service = opts?.service || PastebinServiceServiceName;
this.rpc = rpc;
this.List = this.List.bind(this);
this.Add = this.Add.bind(this);
this.Update = this.Update.bind(this);
this.Get = this.Get.bind(this);
}
List(request: PastebinServiceListReq): Promise<PastebinServiceListResp> {
const data = PastebinServiceListReq.encode(request).finish();
const promise = this.rpc.request(this.service, "List", data);
return promise.then((data) => PastebinServiceListResp.decode(_m0.Reader.create(data)));
}
Add(request: PastebinServiceAddReq): Promise<PastebinServiceAddResp> {
const data = PastebinServiceAddReq.encode(request).finish();
const promise = this.rpc.request(this.service, "Add", data);
return promise.then((data) => PastebinServiceAddResp.decode(_m0.Reader.create(data)));
}
Update(request: PastebinServiceUpdateReq): Promise<PastebinServiceUpdateResp> {
const data = PastebinServiceUpdateReq.encode(request).finish();
const promise = this.rpc.request(this.service, "Update", data);
return promise.then((data) => PastebinServiceUpdateResp.decode(_m0.Reader.create(data)));
}
Get(request: PastebinServiceGetReq): Promise<PastebinServiceGetResp> {
const data = PastebinServiceGetReq.encode(request).finish();
const promise = this.rpc.request(this.service, "Get", data);
return promise.then((data) => PastebinServiceGetResp.decode(_m0.Reader.create(data)));
}
}
interface Rpc {
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
}
declare const self: any | undefined;
declare const window: any | undefined;
declare const global: any | undefined;
const tsProtoGlobalThis: any = (() => {
if (typeof globalThis !== "undefined") {
return globalThis;
}
if (typeof self !== "undefined") {
return self;
}
if (typeof window !== "undefined") {
return window;
}
if (typeof global !== "undefined") {
return global;
}
throw "Unable to locate global object";
})();
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
export type DeepPartial<T> = T extends Builtin ? T
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin ? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
function longToNumber(long: Long): number {
if (long.gt(Number.MAX_SAFE_INTEGER)) {
throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
}
return long.toNumber();
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}

View File

@ -0,0 +1,298 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "model.v1";
/** @table_name: pastebin */
export interface ModelPastebin {
/** ID */
id: number;
/** 创建时间 */
created_at: number;
/** 过期时间 */
expired_at: number;
/** ID别名 */
short_id: string;
/** 标题 */
title: string;
/** 作者 */
author: string;
/** 内容 */
content: string;
/** 语言 */
lang: string;
/** 是否需要密码 */
password: string;
/** 是否需要密码 */
need_password: boolean;
/** 是否可以修改 */
editable: boolean;
}
function createBaseModelPastebin(): ModelPastebin {
return {
id: 0,
created_at: 0,
expired_at: 0,
short_id: "",
title: "",
author: "",
content: "",
lang: "",
password: "",
need_password: false,
editable: false,
};
}
export const ModelPastebin = {
encode(message: ModelPastebin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int64(message.id);
}
if (message.created_at !== 0) {
writer.uint32(16).int64(message.created_at);
}
if (message.expired_at !== 0) {
writer.uint32(24).int64(message.expired_at);
}
if (message.short_id !== "") {
writer.uint32(34).string(message.short_id);
}
if (message.title !== "") {
writer.uint32(42).string(message.title);
}
if (message.author !== "") {
writer.uint32(50).string(message.author);
}
if (message.content !== "") {
writer.uint32(58).string(message.content);
}
if (message.lang !== "") {
writer.uint32(66).string(message.lang);
}
if (message.password !== "") {
writer.uint32(74).string(message.password);
}
if (message.need_password === true) {
writer.uint32(80).bool(message.need_password);
}
if (message.editable === true) {
writer.uint32(88).bool(message.editable);
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ModelPastebin {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseModelPastebin();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 8) {
break;
}
message.id = longToNumber(reader.int64() as Long);
continue;
case 2:
if (tag !== 16) {
break;
}
message.created_at = longToNumber(reader.int64() as Long);
continue;
case 3:
if (tag !== 24) {
break;
}
message.expired_at = longToNumber(reader.int64() as Long);
continue;
case 4:
if (tag !== 34) {
break;
}
message.short_id = reader.string();
continue;
case 5:
if (tag !== 42) {
break;
}
message.title = reader.string();
continue;
case 6:
if (tag !== 50) {
break;
}
message.author = reader.string();
continue;
case 7:
if (tag !== 58) {
break;
}
message.content = reader.string();
continue;
case 8:
if (tag !== 66) {
break;
}
message.lang = reader.string();
continue;
case 9:
if (tag !== 74) {
break;
}
message.password = reader.string();
continue;
case 10:
if (tag !== 80) {
break;
}
message.need_password = reader.bool();
continue;
case 11:
if (tag !== 88) {
break;
}
message.editable = reader.bool();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): ModelPastebin {
return {
id: isSet(object.id) ? Number(object.id) : 0,
created_at: isSet(object.createdAt) ? Number(object.createdAt) : 0,
expired_at: isSet(object.expiredAt) ? Number(object.expiredAt) : 0,
short_id: isSet(object.shortId) ? String(object.shortId) : "",
title: isSet(object.title) ? String(object.title) : "",
author: isSet(object.author) ? String(object.author) : "",
content: isSet(object.content) ? String(object.content) : "",
lang: isSet(object.lang) ? String(object.lang) : "",
password: isSet(object.password) ? String(object.password) : "",
need_password: isSet(object.needPassword) ? Boolean(object.needPassword) : false,
editable: isSet(object.editable) ? Boolean(object.editable) : false,
};
},
toJSON(message: ModelPastebin): unknown {
const obj: any = {};
if (message.id !== 0) {
obj.id = Math.round(message.id);
}
if (message.created_at !== 0) {
obj.createdAt = Math.round(message.created_at);
}
if (message.expired_at !== 0) {
obj.expiredAt = Math.round(message.expired_at);
}
if (message.short_id !== "") {
obj.shortId = message.short_id;
}
if (message.title !== "") {
obj.title = message.title;
}
if (message.author !== "") {
obj.author = message.author;
}
if (message.content !== "") {
obj.content = message.content;
}
if (message.lang !== "") {
obj.lang = message.lang;
}
if (message.password !== "") {
obj.password = message.password;
}
if (message.need_password === true) {
obj.needPassword = message.need_password;
}
if (message.editable === true) {
obj.editable = message.editable;
}
return obj;
},
create<I extends Exact<DeepPartial<ModelPastebin>, I>>(base?: I): ModelPastebin {
return ModelPastebin.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<ModelPastebin>, I>>(object: I): ModelPastebin {
const message = createBaseModelPastebin();
message.id = object.id ?? 0;
message.created_at = object.created_at ?? 0;
message.expired_at = object.expired_at ?? 0;
message.short_id = object.short_id ?? "";
message.title = object.title ?? "";
message.author = object.author ?? "";
message.content = object.content ?? "";
message.lang = object.lang ?? "";
message.password = object.password ?? "";
message.need_password = object.need_password ?? false;
message.editable = object.editable ?? false;
return message;
},
};
declare const self: any | undefined;
declare const window: any | undefined;
declare const global: any | undefined;
const tsProtoGlobalThis: any = (() => {
if (typeof globalThis !== "undefined") {
return globalThis;
}
if (typeof self !== "undefined") {
return self;
}
if (typeof window !== "undefined") {
return window;
}
if (typeof global !== "undefined") {
return global;
}
throw "Unable to locate global object";
})();
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
export type DeepPartial<T> = T extends Builtin ? T
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin ? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
function longToNumber(long: Long): number {
if (long.gt(Number.MAX_SAFE_INTEGER)) {
throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
}
return long.toNumber();
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}

19
webui/src/main.ts Normal file
View File

@ -0,0 +1,19 @@
import './assets/base.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import Notifications from '@kyvg/vue3-notification'
import VueHighlightJS from 'vue3-highlightjs'
import 'vue3-highlightjs/styles/gruvbox-dark.css'
const app = createApp(App)
app.use(createPinia())
app.use(router)
app.use(Notifications)
app.use(VueHighlightJS)
app.mount('#app')

27
webui/src/request/api.ts Normal file
View File

@ -0,0 +1,27 @@
import axiosInstance from './request';
export interface ApiResult<T> {
err_code: number;
err_msg: string;
data: T;
}
export async function get<T>(url: string, params?: any): Promise<ApiResult<T>> {
const response = await axiosInstance.get<ApiResult<T>>(url, { params });
return response.data;
}
export async function post<T>(url: string, data?: any): Promise<ApiResult<T>> {
const response = await axiosInstance.post<ApiResult<T>>(url, data);
return response.data;
}
export async function put<T>(url: string, data?: any): Promise<ApiResult<T>> {
const response = await axiosInstance.put<ApiResult<T>>(url, data);
return response.data;
}
export async function del<T>(url: string, params?: any): Promise<ApiResult<T>> {
const response = await axiosInstance.delete<ApiResult<T>>(url, { params });
return response.data;
}

View File

@ -0,0 +1,32 @@
import axios, {type AxiosInstance, type AxiosResponse, type InternalAxiosRequestConfig} from 'axios';
const axiosInstance: AxiosInstance = axios.create({
baseURL: '/',
timeout: 5000,
});
// 添加请求拦截器
axiosInstance.interceptors.request.use(
(config: InternalAxiosRequestConfig) => {
// 在发送请求之前做些什么
return config;
},
(error: any) => {
// 处理请求错误
return Promise.reject(error);
},
);
// 添加响应拦截器
axiosInstance.interceptors.response.use(
(response: AxiosResponse) => {
// 对响应数据做点什么
return response;
},
(error: any) => {
// 处理响应错误
return Promise.reject(error);
},
);
export default axiosInstance;

24
webui/src/router/index.ts Normal file
View File

@ -0,0 +1,24 @@
import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: () => import('../views/HomeView.vue')
},
{
path: '/list',
name: 'list',
component: () => import('../views/ListView.vue')
},
{
path: '/view/:id',
name: 'view',
component: () => import('../views/DocumentView.vue')
}
]
})
export default router

View File

@ -0,0 +1,16 @@
import { ref } from 'vue'
import { defineStore } from 'pinia'
export const usePageStore = defineStore('page', () => {
const page = ref('home')
function change(pageName:string) {
page.value = pageName
}
function reversal() {
if (page.value === 'home') return 'list';
if (page.value === 'list') return 'home';
}
return { page, change,reversal }
})

View File

@ -0,0 +1,90 @@
<script setup lang="ts">
import {useRouter} from "vue-router";
const router = useRouter()
let doc_id = ref(router.currentRoute.value.params.id);
import {get} from "../request/api";
import {PastebinServiceGetResp, PastebinServiceRecord} from "@/gen/api_services/v1/pastebin_module.ts";
import {onMounted, reactive, ref} from "vue";
import {useNotification} from "@kyvg/vue3-notification";
const notification = useNotification()
let doc_proxy: PastebinServiceRecord = {}
let doc = reactive({instance: doc_proxy})
async function document() {
let response = await get<PastebinServiceGetResp>("/v1/pastebin/get?key=" + doc_id.value)
if (response.err_code != 0) {
notification.notify({
title: response.err_msg,
type: "error",
duration: 15000,
});
return
}
doc.instance = response.data.record
}
onMounted(async () => {
await document()
})
</script>
<template>
<div class="flex flex-row w-full">
<div class="basis-1/4"></div>
<div class="basis-1/2">
<div class="stats stats-vertical lg:stats-horizontal shadow">
<div class="stat">
<div class="stat-title">作者</div>
<div class="stat-value">{{ doc.instance.author }}</div>
</div>
<div class="stat">
<div class="stat-title">创建时间</div>
<div class="stat-value">{{ doc.instance.created_at }}</div>
</div>
<div class="stat">
<div class="stat-title">过期时间</div>
<div class="stat-value">{{ doc.instance.expired_at }}</div>
</div>
<div class="stat">
<div class="stat-title">使用语言</div>
<div class="stat-value">{{ doc.instance.lang }}</div>
</div>
</div>
<div class="divider"></div>
<div class="mockup-code">
<pre v-highlightjs="doc.instance.content"><code :class="doc.instance.lang"></code></pre>
</div>
<div class="divider"></div>
<div class="join grid grid-cols-2 content-center place-items-center mt-8">
<button class="join-item btn btn-neutral self-auto">查看原文</button>
<button class="join-item btn btn-neutral self-auto" v-if="doc.instance.editable">编辑原文</button>
<button class="join-item btn btn-neutral self-auto" v-else disabled>编辑原文</button>
</div>
</div>
<div class="basis-1/4"></div>
</div>
</template>
<style scoped>
.mockup-code pre {
padding-right: 0;
}
.mockup-code pre::before {
margin-right: 0;
}
</style>

View File

@ -0,0 +1,138 @@
<script setup lang="ts">
import { ref } from 'vue'
import { Codemirror } from 'vue-codemirror'
import { javascript } from '@codemirror/lang-javascript'
import { oneDark } from '@codemirror/theme-one-dark'
import { useRouter } from "vue-router";
const router = useRouter()
const extensions = [javascript(), oneDark]
import {usePageStore} from "@/stores/counter";
const pager = usePageStore()
pager.change('home')
import {put} from "../request/api";
import {
PastebinServiceAddReq,
PastebinServiceAddResp,
PastebinServiceRecord
} from "@/gen/api_services/v1/pastebin_module";
import { useNotification } from "@kyvg/vue3-notification";
const notification = useNotification()
let document = ref({
code: '',
title: '',
author: '',
password: '',
expire_level: 1,
lang: 'plaintext',
editable: false
})
async function add() {
let request:PastebinServiceAddReq = {}
let record:PastebinServiceRecord = {}
record.title = document.value.title
record.author = document.value.author
record.content = document.value.code
record.password = document.value.password
record.expire_level = Number(document.value.expire_level)
record.lang = document.value.lang
record.editable = Boolean(document.value.editable)
request.record = record
const response = await put<PastebinServiceAddResp>("/v1/pastebin/add", request)
console.log("add response: ", response)
if (response.err_code != 0) {
notification.notify({
title: response.err_msg,
type: "error",
duration: 15000,
});
return
}
await router.push({path: 'list'})
}
</script>
<template>
<div class="flex flex-col w-full">
<div class="basis-1/4"></div>
<div class="basis-1/2 m-auto">
<codemirror
v-model="document.code"
placeholder="Code goes here..."
:style="{ height: '500px', fontSize: '16px' }"
:autofocus="true"
:indent-with-tab="true"
:tab-size="2"
:extensions="extensions"
/>
<div class="flex flex-row w-full mt-2">
<div class="join">
<button class="btn join-item">标题</button>
<input class="input input-bordered join-item" v-model="document.title"/>
</div>
<div class="join">
<button class="btn join-item ml-2">作者</button>
<input class="input input-bordered join-item" v-model="document.author"/>
</div>
<div class="join">
<button class="btn join-item ml-2">需要密码</button>
<input class="input input-bordered join-item" v-model="document.password"/>
</div>
</div>
<div class="grid gap-4 grid-cols-3 mt-2">
<div class="join self-auto">
<button class="btn join-item">有效期?</button>
<select class="select select-bordered w-full max-w-xs join-item" v-model="document.expire_level">
<option value="1">1</option>
<option value="2">1</option>
<option value="3">1</option>
<option value="4">1</option>
<option value="0">永久</option>
</select>
</div>
<div class="join self-auto">
<button class="btn join-item">语言</button>
<select class="select select-bordered w-full max-w-xs join-item" v-model="document.lang">
<option value="plaintext">Plaintext</option>
<option value="markdown">Markdown</option>
<option value="bash">Bash</option>
<option value="go">Golang</option>
<option value="python">Python</option>
<option value="java">Java</option>
<option value="php">PHP</option>
<option value="lua">Lua</option>
<option value="javascript">Javascript</option>
<option value="typescript">Typescript</option>
<option value="html">HTML</option>
<option value="css">CSS</option>
<option value="sql">SQL</option>
<option value="protocol">ProtocolBuffer</option>
<option value="yaml">YAML</option>
<option value="json">JSON</option>
<option value="xml">XML</option>
<option value="toml">TOML</option>
</select>
</div>
<div class="join self-auto">
<button class="btn join-item">是否可编辑?</button>
<input class="join-item btn btn-ghost" type="radio" name="options" aria-label="" value="true" v-model="document.editable" />
<input class="join-item btn btn-ghost" type="radio" name="options" aria-label="" value="false" v-model="document.editable" />
</div>
</div>
<div class="grid content-center place-items-center mt-8">
<button class="btn btn-neutral" @click="add">提交</button>
</div>
</div>
<div class="basis-1/4"></div>
</div>
</template>

View File

@ -0,0 +1,95 @@
<script setup lang="ts">
import {usePageStore} from "@/stores/counter";
const pager = usePageStore()
pager.change('list')
import {get} from "../request/api";
import {
PastebinServiceListResp,
PastebinServiceRecord
} from "@/gen/api_services/v1/pastebin_module";
import {onMounted, reactive, ref} from "vue";
import { useNotification } from "@kyvg/vue3-notification";
const notification = useNotification()
let items_proxy:PastebinServiceRecord[] = []
let pastebin_items = reactive({list: items_proxy})
let current_page = ref(1)
let pagination_next_disable = ref(false)
async function list() {
const response = await get<PastebinServiceListResp>("/v1/pastebin/list?current_page="+current_page.value)
if (response.err_code != 0) {
notification.notify({
title: response.err_msg,
type: "error",
duration: 15000,
});
return
}
pastebin_items.list = response.data.items
if (!response.data.has_more) {
pagination_next_disable.value = true
}
console.log("response: ", response)
}
async function paginationPrev() {
if (current_page.value <= 1) return
current_page.value--
pagination_next_disable.value = false
await list()
}
async function paginationNext() {
if (pagination_next_disable.value) return
current_page.value++
await list()
}
onMounted(async () => {
await list()
})
</script>
<template>
<div class="flex flex-row w-full">
<div class="basis-1/4"></div>
<div class="basis-1/2">
<table class="table">
<thead>
<tr>
<th>标题</th>
<th>作者</th>
<th>语言</th>
<th>ID</th>
<th>发布时间</th>
<th>过期时间</th>
</tr>
</thead>
<tbody>
<tr v-for="item in pastebin_items.list" :key="item.id">
<td>{{item.title}}</td>
<td>{{item.author}}</td>
<td>{{item.lang}}</td>
<td>{{item.key}}</td>
<td>{{item.created_at}}</td>
<td>{{item.expired_at}}</td>
</tr>
</tbody>
</table>
<div class="join grid content-center place-items-end mt-8">
<div>
<button class="join-item btn btn-outline self-auto" @click="paginationPrev" v-if="current_page != 1">Prev</button>
<button class="join-item btn btn-outline self-auto" @click="paginationPrev" disabled v-else>Prev</button>
<button class="join-item btn btn-outline self-auto" @click="paginationNext" v-if="!pagination_next_disable">Next</button>
<button class="join-item btn btn-outline self-auto" @click="paginationNext" disabled v-else>Next</button>
</div>
</div>
</div>
<div class="basis-1/4"></div>
</div>
</template>

12
webui/tailwind.config.js Normal file
View File

@ -0,0 +1,12 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./index.html",
"./src/**/*.{vue,js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [require("daisyui")],
}

26
webui/tsconfig.json Normal file
View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
"types": ["node"],
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}

10
webui/tsconfig.node.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

16
webui/vite.config.ts Normal file
View File

@ -0,0 +1,16 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})