Skip to content

Commit 82201df

Browse files
committed
feat: 完成粘贴板功能
1 parent 3b84c6b commit 82201df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+843
-388
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ public/newsCategories
2626
*.njsproj
2727
*.sln
2828
*.sw?
29+
pasteServer/paste/*
2930

pasteServer/.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* linguist-language=GO

pasteServer/.gitignore

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.buildpath
2+
.hgignore.swp
3+
.project
4+
.orig
5+
.swp
6+
.idea/
7+
.settings/
8+
.vscode/
9+
bin/
10+
**/.DS_Store
11+
gf
12+
main
13+
main.exe
14+
output/
15+
manifest/output/
16+
temp/
17+
temp.yaml
18+
bin
19+
**/config/config.yaml

pasteServer/Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ROOT_DIR = $(shell pwd)
2+
NAMESPACE = "default"
3+
DEPLOY_NAME = "template-single"
4+
DOCKER_NAME = "template-single"
5+
6+
include ./hack/hack.mk

pasteServer/README.MD

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# GoFrame Template For SingleRepo
2+
3+
Quick Start:
4+
- https://goframe.org/pages/viewpage.action?pageId=1114399

pasteServer/api/hello/hello.go

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pasteServer/api/hello/v1/hello.go

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package v1
2+
3+
import (
4+
"github.com/gogf/gf/v2/frame/g"
5+
)
6+
7+
type HelloReq struct {
8+
g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"`
9+
}
10+
type HelloRes struct {
11+
g.Meta `mime:"text/html" example:"string"`
12+
}

pasteServer/api/paste/paste.go

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pasteServer/api/paste/v1/paste.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package v1
2+
3+
import (
4+
"github.com/gogf/gf/v2/frame/g"
5+
"github.com/gogf/gf/v2/net/ghttp"
6+
)
7+
8+
type NewPasteReq struct {
9+
g.Meta `path:"/paste" tags:"Paste" method:"post" summary:"创建粘贴板"`
10+
Title string `v:"required" json:"title"`
11+
Language string `v:"required" json:"language"`
12+
Content string `v:"required" json:"content"`
13+
FileList *ghttp.UploadFiles `json:"fileList[]"`
14+
ExpDate string `v:"required" json:"expDate"`
15+
Password string `json:"password"`
16+
}
17+
type NewPasteRes struct {
18+
g.Meta `mime:"text/html" example:"string"`
19+
Id string `json:"id"`
20+
}
21+
22+
type PasteReq struct {
23+
g.Meta `path:"/paste" tags:"Paste" method:"get" summary:"获取粘贴板数据"`
24+
Id string `v:"required" json:"id"`
25+
Password string `json:"password"`
26+
}
27+
type PasteRes struct {
28+
g.Meta `mime:"text/html" example:"string"`
29+
Json string `v:"required" json:"json"`
30+
}

pasteServer/go.mod

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module pasteServer
2+
3+
go 1.18
4+
5+
require github.com/gogf/gf/v2 v2.5.2
6+
7+
require (
8+
github.com/BurntSushi/toml v1.2.0 // indirect
9+
github.com/clbanning/mxj/v2 v2.7.0 // indirect
10+
github.com/fatih/color v1.15.0 // indirect
11+
github.com/fsnotify/fsnotify v1.6.0 // indirect
12+
github.com/go-logr/logr v1.2.4 // indirect
13+
github.com/go-logr/stdr v1.2.2 // indirect
14+
github.com/google/uuid v1.6.0 // indirect
15+
github.com/gorilla/websocket v1.5.0 // indirect
16+
github.com/grokify/html-strip-tags-go v0.0.1 // indirect
17+
github.com/magiconair/properties v1.8.6 // indirect
18+
github.com/mattn/go-colorable v0.1.13 // indirect
19+
github.com/mattn/go-isatty v0.0.19 // indirect
20+
github.com/mattn/go-runewidth v0.0.15 // indirect
21+
github.com/olekukonko/tablewriter v0.0.5 // indirect
22+
github.com/rivo/uniseg v0.4.4 // indirect
23+
go.opentelemetry.io/otel v1.14.0 // indirect
24+
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
25+
go.opentelemetry.io/otel/trace v1.14.0 // indirect
26+
golang.org/x/net v0.12.0 // indirect
27+
golang.org/x/sys v0.10.0 // indirect
28+
golang.org/x/text v0.11.0 // indirect
29+
gopkg.in/yaml.v3 v3.0.1 // indirect
30+
)

pasteServer/go.sum

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
2+
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
3+
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
4+
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
5+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
6+
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
7+
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
8+
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
9+
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
10+
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
11+
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
12+
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
13+
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
14+
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
15+
github.com/gogf/gf/v2 v2.5.2 h1:fACJE7DJH6iTGHGhgiNY1uuZIZtr2IqQkJ52E+wBnt8=
16+
github.com/gogf/gf/v2 v2.5.2/go.mod h1:7yf5qp0BznfsYx7Sw49m3mQvBsHpwAjJk3Q9ZnKoUEc=
17+
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
18+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
19+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
20+
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
21+
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
22+
github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0=
23+
github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
24+
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
25+
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
26+
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
27+
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
28+
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
29+
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
30+
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
31+
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
32+
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
33+
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
34+
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
35+
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
36+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
37+
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
38+
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
39+
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
40+
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
41+
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
42+
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
43+
go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY=
44+
go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM=
45+
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
46+
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
47+
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
48+
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
49+
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
50+
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
51+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
52+
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
53+
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
54+
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
55+
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
56+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
57+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
58+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
59+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

pasteServer/hack/config.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# CLI tool, only in development environment.
3+
# https://goframe.org/pages/viewpage.action?pageId=3673173
4+
gfcli:
5+
docker:
6+
build: "-a amd64 -s linux -p temp -ew"
7+
tagPrefixes:
8+
- my.image.pub/my-app

pasteServer/hack/hack-cli.mk

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
# Install/Update to the latest CLI tool.
3+
.PHONY: cli
4+
cli:
5+
@set -e; \
6+
wget -O gf https://github.com/gogf/gf/releases/latest/download/gf_$(shell go env GOOS)_$(shell go env GOARCH) && \
7+
chmod +x gf && \
8+
./gf install -y && \
9+
rm ./gf
10+
11+
12+
# Check and install CLI tool.
13+
.PHONY: cli.install
14+
cli.install:
15+
@set -e; \
16+
gf -v > /dev/null 2>&1 || if [[ "$?" -ne "0" ]]; then \
17+
echo "GoFame CLI is not installed, start proceeding auto installation..."; \
18+
make cli; \
19+
fi;

pasteServer/hack/hack.mk

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
include ./hack/hack-cli.mk
2+
3+
# Update GoFrame and its CLI to latest stable version.
4+
.PHONY: up
5+
up: cli.install
6+
@gf up -a
7+
8+
# Build binary using configuration from hack/config.yaml.
9+
.PHONY: build
10+
build: cli.install
11+
@gf build -ew
12+
13+
# Parse api and generate controller/sdk.
14+
.PHONY: ctrl
15+
ctrl: cli.install
16+
@gf gen ctrl
17+
18+
# Generate Go files for DAO/DO/Entity.
19+
.PHONY: dao
20+
dao: cli.install
21+
@gf gen dao
22+
23+
# Parse current project go files and generate enums go file.
24+
.PHONY: enums
25+
enums: cli.install
26+
@gf gen enums
27+
28+
# Generate Go files for Service.
29+
.PHONY: service
30+
service: cli.install
31+
@gf gen service
32+
33+
34+
# Build docker image.
35+
.PHONY: image
36+
image: cli.install
37+
$(eval _TAG = $(shell git describe --dirty --always --tags --abbrev=8 --match 'v*' | sed 's/-/./2' | sed 's/-/./2'))
38+
ifneq (, $(shell git status --porcelain 2>/dev/null))
39+
$(eval _TAG = $(_TAG).dirty)
40+
endif
41+
$(eval _TAG = $(if ${TAG}, ${TAG}, $(_TAG)))
42+
$(eval _PUSH = $(if ${PUSH}, ${PUSH}, ))
43+
@gf docker ${_PUSH} -tn $(DOCKER_NAME):${_TAG};
44+
45+
46+
# Build docker image and automatically push to docker repo.
47+
.PHONY: image.push
48+
image.push:
49+
@make image PUSH=-p;
50+
51+
52+
# Deploy image and yaml to current kubectl environment.
53+
.PHONY: deploy
54+
deploy:
55+
$(eval _TAG = $(if ${TAG}, ${TAG}, develop))
56+
57+
@set -e; \
58+
mkdir -p $(ROOT_DIR)/temp/kustomize;\
59+
cd $(ROOT_DIR)/manifest/deploy/kustomize/overlays/${_ENV};\
60+
kustomize build > $(ROOT_DIR)/temp/kustomize.yaml;\
61+
kubectl apply -f $(ROOT_DIR)/temp/kustomize.yaml; \
62+
if [ $(DEPLOY_NAME) != "" ]; then \
63+
kubectl patch -n $(NAMESPACE) deployment/$(DEPLOY_NAME) -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"$(shell date +%s)\"}}}}}"; \
64+
fi;
65+
66+
67+
# Parsing protobuf files and generating go files.
68+
.PHONY: pb
69+
pb: cli.install
70+
@gf gen pb
71+
72+
# Generate protobuf files for database tables.
73+
.PHONY: pbentity
74+
pbentity: cli.install
75+
@gf gen pbentity

pasteServer/internal/cmd/cmd.go

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package cmd
2+
3+
import (
4+
"context"
5+
6+
"github.com/gogf/gf/v2/frame/g"
7+
"github.com/gogf/gf/v2/net/ghttp"
8+
"github.com/gogf/gf/v2/os/gcmd"
9+
10+
"pasteServer/internal/controller/hello"
11+
"pasteServer/internal/controller/paste"
12+
)
13+
14+
var (
15+
Main = gcmd.Command{
16+
Name: "main",
17+
Usage: "main",
18+
Brief: "start http server",
19+
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
20+
s := g.Server()
21+
s.Group("/", func(group *ghttp.RouterGroup) {
22+
group.Middleware(ghttp.MiddlewareHandlerResponse)
23+
group.Bind(
24+
hello.NewV1(),
25+
26+
paste.NewV1(),
27+
)
28+
})
29+
s.Run()
30+
return nil
31+
},
32+
}
33+
)

pasteServer/internal/consts/consts.go

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package consts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// =================================================================================
2+
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
3+
// =================================================================================
4+
5+
package hello

pasteServer/internal/controller/hello/hello_new.go

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package hello
2+
3+
import (
4+
"context"
5+
"github.com/gogf/gf/v2/frame/g"
6+
7+
"pasteServer/api/hello/v1"
8+
)
9+
10+
func (c *ControllerV1) Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) {
11+
g.RequestFromCtx(ctx).Response.Writeln("Hello World!")
12+
return
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// =================================================================================
2+
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
3+
// =================================================================================
4+
5+
package paste

0 commit comments

Comments
 (0)