Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
李宇怀
Backend
Commits
7b23656d
You need to sign in or sign up before continuing.
Commit
7b23656d
authored
Sep 06, 2023
by
李宇怀
Browse files
修改了一些用语规范与方法实现
parent
75c47933
Changes
12
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
7b23656d
...
@@ -60,232 +60,6 @@ Design-Drive 的后端开发模式,先进行 API 和 model 设计,后进行
...
@@ -60,232 +60,6 @@ Design-Drive 的后端开发模式,先进行 API 和 model 设计,后进行
```
```
backend
backend
├─ .git
│ ├─ COMMIT_EDITMSG
│ ├─ config
│ ├─ description
│ ├─ FETCH_HEAD
│ ├─ HEAD
│ ├─ hooks
│ │ ├─ applypatch-msg.sample
│ │ ├─ commit-msg.sample
│ │ ├─ fsmonitor-watchman.sample
│ │ ├─ post-update.sample
│ │ ├─ pre-applypatch.sample
│ │ ├─ pre-commit.sample
│ │ ├─ pre-merge-commit.sample
│ │ ├─ pre-push.sample
│ │ ├─ pre-rebase.sample
│ │ ├─ pre-receive.sample
│ │ ├─ prepare-commit-msg.sample
│ │ ├─ push-to-checkout.sample
│ │ └─ update.sample
│ ├─ index
│ ├─ info
│ │ └─ exclude
│ ├─ logs
│ │ ├─ HEAD
│ │ └─ refs
│ │ ├─ heads
│ │ │ └─ main
│ │ └─ remotes
│ │ └─ origin
│ │ ├─ HEAD
│ │ └─ main
│ ├─ objects
│ │ ├─ 00
│ │ │ └─ 6319fab8cf9a282595606c542da250b0b20ee1
│ │ ├─ 01
│ │ │ ├─ 2a4dcda64e527a647b6d1541ece0c62e726ea2
│ │ │ └─ 75063ca25d9ad59dc8113ce6727db71d554d34
│ │ ├─ 07
│ │ │ ├─ 10d5ff187051d3c94f561e7d9938c4aa21b53e
│ │ │ └─ a0cc0fc69fdc13eda603a897b9116884ad9a61
│ │ ├─ 0a
│ │ │ └─ 0a0733abeede97558c13a5956964cdbf6e1e87
│ │ ├─ 0b
│ │ │ └─ a1b2ead2d3de3e2878caef6c83c558cf76e346
│ │ ├─ 0e
│ │ │ └─ d3d1798380e14a7bce3d737884f0eb33816afe
│ │ ├─ 10
│ │ │ └─ 3cc4dbc26e25fd27408617826584b79f9e278e
│ │ ├─ 14
│ │ │ ├─ 2f75e1c199927a90382b1f0d30634c04813c4a
│ │ │ └─ ba0cc6346ecd18a573993d08c04c891bd549a8
│ │ ├─ 15
│ │ │ └─ b8adf0a98eec267dbf3d827d7b198163c029b9
│ │ ├─ 18
│ │ │ └─ 9d75b1f9681c6db88ee5005b40c3b54fea21ca
│ │ ├─ 1b
│ │ │ └─ b1b7ca1a56c621a3b861a439ed94dd31a1e960
│ │ ├─ 1f
│ │ │ └─ 469bfbc611ca3182b79af1947656c6377058f2
│ │ ├─ 20
│ │ │ └─ defcf4d81434e76d046b58a45d4881185059de
│ │ ├─ 28
│ │ │ └─ 6d25917c9076bafa3bfc76815a12d6547ed135
│ │ ├─ 29
│ │ │ ├─ 420745339ade6960c24ea70f60c66b49c59620
│ │ │ └─ aa6594115743b934d9c257b715b8dee6fff3b7
│ │ ├─ 33
│ │ │ └─ 86b8a0d3bfc927794374c02378b7bd0f3cd0c5
│ │ ├─ 38
│ │ │ └─ f7cee1b6c59d41f84f9c6a2fb269b6c766d3ad
│ │ ├─ 39
│ │ │ ├─ b8bdf26334ff10ffdcd1d7334486705f93438e
│ │ │ └─ d632fbda60046b8233c0b2618dcb9db8cf0468
│ │ ├─ 3b
│ │ │ └─ 79ce5f78fd4f0b06ea06468394c4911802d48b
│ │ ├─ 3d
│ │ │ └─ faf1f15ac6f7ec2a029b356dedbad241e2bf1f
│ │ ├─ 3e
│ │ │ ├─ 74d6e97b9648d80369ce678a61bce8b316e5f4
│ │ │ └─ a64c89ca829a7867c70fe9baac059c5016ff86
│ │ ├─ 3f
│ │ │ └─ 396bcfd2b60f4590cb66f7c37bea2a3e2b2363
│ │ ├─ 41
│ │ │ └─ d3572e976d5463e6e1106de82553f2339abf02
│ │ ├─ 42
│ │ │ └─ acbe7c99e2fda7fee07be20ddb940a5ec795dc
│ │ ├─ 50
│ │ │ ├─ 323cc70c7f21584a24c36bb7318c1c550ed9bc
│ │ │ └─ ff8f9a44c43a352f6cbc26edbccff0b2006051
│ │ ├─ 53
│ │ │ └─ bd23cb8bcfe1f3687895d690a9858f825181a8
│ │ ├─ 55
│ │ │ └─ e9cffd6b08e1f2e22c87898c3a396654c7e195
│ │ ├─ 56
│ │ │ └─ e64cc19bf223b88933354ce793169e184f81ed
│ │ ├─ 58
│ │ │ └─ 2a77e41225a5b3043fba98d3cce0f9c01d2ad4
│ │ ├─ 5c
│ │ │ └─ 79327493adb151dada54670d92b95a2135a8b4
│ │ ├─ 61
│ │ │ └─ 513bd456fa6672511313628c75b1e39ac4c1a4
│ │ ├─ 66
│ │ │ └─ d513e8095630be2d8e0601d7eef1436a9ae99a
│ │ ├─ 6b
│ │ │ └─ e73fe9b46c8cdc62ad3e727be7dfdd0e14fc5b
│ │ ├─ 6c
│ │ │ └─ 6199e4827e8aa4984c0b626f9ea95bc6c64a0d
│ │ ├─ 70
│ │ │ └─ bfb48d0647ae659321092c694dc781c2eb2e52
│ │ ├─ 75
│ │ │ └─ 56e4c1221880b4c5966c12c76fde8613c4691d
│ │ ├─ 76
│ │ │ └─ 81ebd55ccc1f466c72d770e9ad276697d110bb
│ │ ├─ 79
│ │ │ └─ 41782b870066d871585040ab9a6843ac42ebdb
│ │ ├─ 7d
│ │ │ └─ c331ea568c9a25826aef5f1416fc8ac5f90bf5
│ │ ├─ 7e
│ │ │ └─ 1b53f3fb618991787e03407d9f47767095ad2a
│ │ ├─ 83
│ │ │ └─ f1cad9da365846ed3bb5b16cc8009c587027ce
│ │ ├─ 84
│ │ │ └─ f2f627e474893f4fb982e4688b802a4bc8324d
│ │ ├─ 86
│ │ │ └─ 067c38dd4c35053de1470a36b436f2117defa8
│ │ ├─ 8d
│ │ │ └─ ada3edaf50dbc082c9a125058f25def75e625a
│ │ ├─ 91
│ │ │ └─ 5d0bdcc9912c9503457486ecf5e076a4c3c99b
│ │ ├─ 93
│ │ │ └─ 2dd11c3b7730a20834c0cfb13c90a4fe252543
│ │ ├─ 95
│ │ │ └─ 5ed4ddad6979761061e03d54cfe6cce08ab7ff
│ │ ├─ 99
│ │ │ └─ 8c5eccd2fa0f2e24b8dc173e2c5c9b54b533ab
│ │ ├─ 9a
│ │ │ └─ 4c660072cb0d6cbbf1096f476b835640145ed0
│ │ ├─ 9c
│ │ │ └─ 01e6dc0ce14511234df8a9081af49013fc56cc
│ │ ├─ 9d
│ │ │ └─ b71614c4f79da3a86e4cb3ac0457c18f08b816
│ │ ├─ a4
│ │ │ └─ 2a85f804d81a3df20c9ab92fae09f4e09195f4
│ │ ├─ a6
│ │ │ ├─ 0f41078d17e307f34539d7b20a9b9cea051e47
│ │ │ └─ fe8ebcec220bc8efd300444d6a06d8594bb7cf
│ │ ├─ aa
│ │ │ └─ 59f9433f510b008d1f4cdd589cdecbc11ad10d
│ │ ├─ ab
│ │ │ └─ 15d552d629cc84918c516565ca93cdbf90facb
│ │ ├─ ad
│ │ │ └─ b78ea3dcbeb363a21bdf574b7861d3a2730fb1
│ │ ├─ ae
│ │ │ └─ ee0d910638e28b56062186f793d1bc71caad49
│ │ ├─ b1
│ │ │ └─ bd0de1b016312da0499130b3f69650c3ea27b7
│ │ ├─ b3
│ │ │ └─ 5cf6071d6f992c72c5e2681cea4baeef3682d9
│ │ ├─ b5
│ │ │ ├─ 792c006f4f3bea83c7fa5bf089e3176ac00b78
│ │ │ └─ f49b390d508201f0a55e6c2fdba174886e1f29
│ │ ├─ bd
│ │ │ └─ 0037542f9ec241f9aad55e67bc34b5b4979373
│ │ ├─ c3
│ │ │ ├─ 5e25661b8ce9f03b0eb81012c3b170dbd98481
│ │ │ └─ d76e5c374dc4cb1dc20c39a8143e0f0a6138d4
│ │ ├─ c4
│ │ │ └─ 054ded6ae13e566f42f2aea26c145ed3abc3e0
│ │ ├─ cb
│ │ │ ├─ 59bdc1dbe20143807bca1a9a065662e3f6243c
│ │ │ └─ ca8bb2da087fff7c945da8d5afaee17da50546
│ │ ├─ cc
│ │ │ ├─ 06c1f722bc8e02bc079c6c030beea20e183918
│ │ │ ├─ a4c4ea4be5a19dbcf19121fbabf7589d34d82b
│ │ │ └─ a99ee25f97fd9079b8b51bda6440c8be69ffda
│ │ ├─ d5
│ │ │ └─ 64d0bc3dd917926892c55e3706cc116d5b165e
│ │ ├─ d6
│ │ │ ├─ 32583e3a0584bf639acb32ff6fa52c096cb77c
│ │ │ └─ 44be469e0b8bd80d1ab1e90181cec693d86cef
│ │ ├─ da
│ │ │ └─ 6c7b812c4109a0062db924256f7ca396d53ff0
│ │ ├─ dc
│ │ │ ├─ 830b76af4204005a34e9fb59c44f8366699c8a
│ │ │ └─ 8b36de1a42fe92a0a4f1434c87e78d91ef6958
│ │ ├─ e1
│ │ │ └─ e3d567f337feb4b270dc0135da93ee81bb6512
│ │ ├─ e3
│ │ │ └─ 447117e430ac32335ea543158485c9d0da8efa
│ │ ├─ e4
│ │ │ └─ f2b97ad722c7991b1b09438a52b8cb2118aed0
│ │ ├─ e6
│ │ │ ├─ 5e639971c3fd2e41c8971bdbad3e12907959b0
│ │ │ └─ 9de29bb2d1d6434b8b29ae775ad8c2e48c5391
│ │ ├─ ea
│ │ │ ├─ 76d8938b7047b04b5b6d843b1d95e21a04a6fb
│ │ │ └─ ef0aaf44b79fb07ec5ad07f3910a39c8e37990
│ │ ├─ f0
│ │ │ └─ e8a56d238a199158d164ae6ec560a7a6575ffb
│ │ ├─ f1
│ │ │ ├─ 57a876207f7fb04fed98a4bb4e0a15c777eab1
│ │ │ └─ fc26815960cda87f65daef7a97e1520ec8f04c
│ │ ├─ f2
│ │ │ └─ 51489b316fac5c20a9126e16964dbfeb6afad8
│ │ ├─ f3
│ │ │ └─ 113e02b7fa60ed086708a9b1b05778e411f385
│ │ ├─ f6
│ │ │ └─ de5bdf4c5c0d7a1529025d119fee037af4372a
│ │ ├─ f8
│ │ │ └─ 8dfaf38c534f02225e13e3c32d16f98ef69f33
│ │ ├─ f9
│ │ │ └─ edc404cafe2884fed8e7f20de34be7c63e10d5
│ │ ├─ info
│ │ └─ pack
│ │ ├─ pack-a3e4badc67d264fdd23257998e97110d409579cf.idx
│ │ └─ pack-a3e4badc67d264fdd23257998e97110d409579cf.pack
│ ├─ packed-refs
│ └─ refs
│ ├─ heads
│ │ └─ main
│ ├─ remotes
│ │ └─ origin
│ │ ├─ HEAD
│ │ └─ main
│ └─ tags
├─ .gitignore
├─ .gitignore
├─ api
├─ api
│ ├─ dto
│ ├─ dto
...
...
api/dto/errcode.go
View file @
7b23656d
...
@@ -14,6 +14,6 @@ const (
...
@@ -14,6 +14,6 @@ const (
ErrShortLinkActive
=
8
// 短链被中断使用
ErrShortLinkActive
=
8
// 短链被中断使用
ErrShortLinkTime
=
9
// 不在可用时间范围
ErrShortLinkTime
=
9
// 不在可用时间范围
BadReq
e
ust
=
400
BadRequ
e
st
=
400
InternalError
=
500
InternalError
=
500
)
)
api/dto/link.go
View file @
7b23656d
...
@@ -12,7 +12,7 @@ type LinkCreateReq struct {
...
@@ -12,7 +12,7 @@ type LinkCreateReq struct {
}
}
type
LinkCreateResp
struct
{
type
LinkCreateResp
struct
{
Active
bool
`json:"active"`
// 服务状态
Active
null
.
Bool
`json:"active"`
// 服务状态
Comment
string
`json:"comment"`
// 备注信息
Comment
string
`json:"comment"`
// 备注信息
EndTime
null
.
Time
`json:"end_time"`
// 到期时间,UTC
EndTime
null
.
Time
`json:"end_time"`
// 到期时间,UTC
Origin
string
`json:"origin"`
// 原始链接
Origin
string
`json:"origin"`
// 原始链接
...
@@ -31,7 +31,7 @@ type GetLinkInfoReq struct { //Query Params
...
@@ -31,7 +31,7 @@ type GetLinkInfoReq struct { //Query Params
}
}
type
GetLinkInfoResp
struct
{
//Responses
type
GetLinkInfoResp
struct
{
//Responses
Active
bool
`json:"active"`
// 服务状态
Active
null
.
Bool
`json:"active"`
// 服务状态
Comment
string
`json:"comment"`
// 备注信息
Comment
string
`json:"comment"`
// 备注信息
EndTime
null
.
Time
`json:"end_time"`
// 到期时间,UTC
EndTime
null
.
Time
`json:"end_time"`
// 到期时间,UTC
Origin
string
`json:"origin"`
// 原始链接
Origin
string
`json:"origin"`
// 原始链接
...
@@ -41,7 +41,7 @@ type GetLinkInfoResp struct { //Responses
...
@@ -41,7 +41,7 @@ type GetLinkInfoResp struct { //Responses
// 更新短链接信息
// 更新短链接信息
type
LinkUpdateReq
struct
{
//Body Params
type
LinkUpdateReq
struct
{
//Body Params
Active
bool
`json:"active"`
// 服务状态
Active
null
.
Bool
`json:"active"`
// 服务状态
Comment
string
`json:"comment"`
// 备注信息
Comment
string
`json:"comment"`
// 备注信息
EndTime
null
.
Time
`json:"end_time"`
// 到期时间,UTC
EndTime
null
.
Time
`json:"end_time"`
// 到期时间,UTC
Origin
string
`json:"origin"`
// 原始链接
Origin
string
`json:"origin"`
// 原始链接
...
@@ -63,7 +63,7 @@ type GetLinkListResp struct {
...
@@ -63,7 +63,7 @@ type GetLinkListResp struct {
// Link
// Link
type
ShortLinkModel
struct
{
type
ShortLinkModel
struct
{
Active
bool
`json:"active"`
// 服务状态
Active
null
.
Bool
`json:"active"`
// 服务状态
Comment
string
`json:"comment"`
// 备注信息
Comment
string
`json:"comment"`
// 备注信息
EndTime
null
.
Time
`json:"end_time"`
// 到期时间,UTC
EndTime
null
.
Time
`json:"end_time"`
// 到期时间,UTC
Origin
string
`json:"origin"`
// 原始链接
Origin
string
`json:"origin"`
// 原始链接
...
...
api/route/route.go
View file @
7b23656d
...
@@ -17,20 +17,7 @@ func Ping(c *gin.Context) {
...
@@ -17,20 +17,7 @@ func Ping(c *gin.Context) {
func
SetupRouter
(
r
*
gin
.
RouterGroup
)
{
func
SetupRouter
(
r
*
gin
.
RouterGroup
)
{
r
.
GET
(
"/ping"
,
Ping
)
r
.
GET
(
"/ping"
,
Ping
)
r
.
POST
(
"/register"
,
Register
)
r
.
POST
(
"/login"
,
Login
)
setupUserController
(
r
)
setupUserController
(
r
)
}
setupLinkController
(
r
)
setupServerController
(
r
)
func
Register
(
ctx
*
gin
.
Context
)
{
// 注册
// ctx.JSON(http.StatusOK, dto.Resp{
// Code: http.StatusOK,
// Msg: "success",
// Data: "register success",)
}
func
Login
(
ctx
*
gin
.
Context
)
{
// 登录
}
}
go.mod
View file @
7b23656d
...
@@ -3,12 +3,17 @@ module go-svc-tpl
...
@@ -3,12 +3,17 @@ module go-svc-tpl
go 1.20
go 1.20
require (
require (
github.com/dchest/captcha
v1.0.0
github.com/dgrijalva/jwt-go
v3.2.0+incompatible
github.com/gin-contrib/sessions
v0.0.5
github.com/gin-gonic/gin
v1.9.1
github.com/gin-gonic/gin
v1.9.1
github.com/google/uuid
v1.3.1
github.com/palantir/stacktrace
v0.0.0-20161112013806-78658fd2d177
github.com/palantir/stacktrace
v0.0.0-20161112013806-78658fd2d177
github.com/sirupsen/logrus
v1.9.3
github.com/sirupsen/logrus
v1.9.3
github.com/spf13/cobra
v1.7.0
github.com/spf13/cobra
v1.7.0
github.com/spf13/viper
v1.16.0
github.com/spf13/viper
v1.16.0
github.com/stretchr/testify
v1.8.4
github.com/stretchr/testify
v1.8.4
golang.org/x/crypto
v0.9.0
gopkg.in/guregu/null.v4
v4.0.0
gopkg.in/guregu/null.v4
v4.0.0
gorm.io/driver/mysql
v1.5.1
gorm.io/driver/mysql
v1.5.1
gorm.io/gorm
v1.25.2
gorm.io/gorm
v1.25.2
...
@@ -18,11 +23,8 @@ require (
...
@@ -18,11 +23,8 @@ require (
github.com/bytedance/sonic
v1.9.1 // indirect
github.com/bytedance/sonic
v1.9.1 // indirect
github.com/chenzhuoyu/base64x
v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/chenzhuoyu/base64x
v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/davecgh/go-spew
v1.1.1 // indirect
github.com/davecgh/go-spew
v1.1.1 // indirect
github.com/dchest/captcha
v1.0.0 // indirect
github.com/dgrijalva/jwt-go
v3.2.0+incompatible // indirect
github.com/fsnotify/fsnotify
v1.6.0 // indirect
github.com/fsnotify/fsnotify
v1.6.0 // indirect
github.com/gabriel-vasile/mimetype
v1.4.2 // indirect
github.com/gabriel-vasile/mimetype
v1.4.2 // indirect
github.com/gin-contrib/sessions
v0.0.5 // indirect
github.com/gin-contrib/sse
v0.1.0 // indirect
github.com/gin-contrib/sse
v0.1.0 // indirect
github.com/go-playground/locales
v0.14.1 // indirect
github.com/go-playground/locales
v0.14.1 // indirect
github.com/go-playground/universal-translator
v0.18.1 // indirect
github.com/go-playground/universal-translator
v0.18.1 // indirect
...
@@ -50,13 +52,10 @@ require (
...
@@ -50,13 +52,10 @@ require (
github.com/spf13/cast
v1.5.1 // indirect
github.com/spf13/cast
v1.5.1 // indirect
github.com/spf13/jwalterweatherman
v1.1.0 // indirect
github.com/spf13/jwalterweatherman
v1.1.0 // indirect
github.com/spf13/pflag
v1.0.5 // indirect
github.com/spf13/pflag
v1.0.5 // indirect
github.com/stretchr/objx
v0.5.1 // indirect
github.com/subosito/gotenv
v1.4.2 // indirect
github.com/subosito/gotenv
v1.4.2 // indirect
github.com/swaggo/swag
v1.16.1 // indirect
github.com/twitchyliquid64/golang-asm
v0.15.1 // indirect
github.com/twitchyliquid64/golang-asm
v0.15.1 // indirect
github.com/ugorji/go/codec
v1.2.11 // indirect
github.com/ugorji/go/codec
v1.2.11 // indirect
golang.org/x/arch
v0.3.0 // indirect
golang.org/x/arch
v0.3.0 // indirect
golang.org/x/crypto
v0.9.0 // indirect
golang.org/x/net
v0.10.0 // indirect
golang.org/x/net
v0.10.0 // indirect
golang.org/x/sys
v0.8.0 // indirect
golang.org/x/sys
v0.8.0 // indirect
golang.org/x/text
v0.9.0 // indirect
golang.org/x/text
v0.9.0 // indirect
...
...
go.sum
View file @
7b23656d
...
@@ -38,12 +38,6 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f
...
@@ -38,12 +38,6 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f
dmitri.shuralyov.com/gpu/mtl
v0.0.0-20190408044501-666a987793e9/go.mod h1:
H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
dmitri.shuralyov.com/gpu/mtl
v0.0.0-20190408044501-666a987793e9/go.mod h1:
H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml
v0.3.1/go.mod h1:
xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml
v0.3.1/go.mod h1:
xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb
v0.0.0-20160522181843-27f122750802/go.mod h1:
IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/BurntSushi/xgb
v0.0.0-20160522181843-27f122750802/go.mod h1:
IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/KyleBanks/depth
v1.2.1 h1:
5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth
v1.2.1/go.mod h1:
jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/PuerkitoBio/purell
v1.1.1 h1:
WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
github.com/PuerkitoBio/purell
v1.1.1/go.mod h1:
c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc
v0.0.0-20170810143723-de5bf2ad4578 h1:
d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
github.com/PuerkitoBio/urlesc
v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:
uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/bytedance/sonic
v1.5.0/go.mod h1:
ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic
v1.5.0/go.mod h1:
ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic
v1.9.1 h1:
6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
github.com/bytedance/sonic
v1.9.1 h1:
6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
github.com/bytedance/sonic
v1.9.1/go.mod h1:
i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
github.com/bytedance/sonic
v1.9.1/go.mod h1:
i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
...
@@ -58,7 +52,6 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
...
@@ -58,7 +52,6 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
github.com/cncf/udpa/go
v0.0.0-20191209042840-269d4d468f6f/go.mod h1:
M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go
v0.0.0-20191209042840-269d4d468f6f/go.mod h1:
M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go
v0.0.0-20200629203442-efcf912fb354/go.mod h1:
WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/udpa/go
v0.0.0-20200629203442-efcf912fb354/go.mod h1:
WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/udpa/go
v0.0.0-20201120205902-5459f2c99403/go.mod h1:
WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/udpa/go
v0.0.0-20201120205902-5459f2c99403/go.mod h1:
WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cpuguy83/go-md2man/v2
v2.0.2 h1:
p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2
v2.0.2/go.mod h1:
tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2
v2.0.2/go.mod h1:
tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew
v1.1.0/go.mod h1:
J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew
v1.1.0/go.mod h1:
J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew
v1.1.1 h1:
vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew
v1.1.1 h1:
vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
...
@@ -87,14 +80,6 @@ github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SU
...
@@ -87,14 +80,6 @@ github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SU
github.com/go-gl/glfw
v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:
vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw
v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:
vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw
v0.0.0-20191125211704-12ad95a8df72/go.mod h1:
tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw
v0.0.0-20191125211704-12ad95a8df72/go.mod h1:
tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw
v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:
tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw
v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:
tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-openapi/jsonpointer
v0.19.5 h1:
gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
github.com/go-openapi/jsonpointer
v0.19.5/go.mod h1:
Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
github.com/go-openapi/jsonreference
v0.19.6 h1:
UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs=
github.com/go-openapi/jsonreference
v0.19.6/go.mod h1:
diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns=
github.com/go-openapi/spec
v0.20.4 h1:
O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M=
github.com/go-openapi/spec
v0.20.4/go.mod h1:
faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I=
github.com/go-openapi/swag
v0.19.15 h1:
D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM=
github.com/go-openapi/swag
v0.19.15/go.mod h1:
QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
github.com/go-playground/assert/v2
v2.2.0 h1:
JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2
v2.2.0 h1:
JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/locales
v0.14.1 h1:
EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales
v0.14.1 h1:
EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales
v0.14.1/go.mod h1:
hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/locales
v0.14.1/go.mod h1:
hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
...
@@ -161,6 +146,8 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe
...
@@ -161,6 +146,8 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe
github.com/google/pprof
v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:
kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof
v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:
kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio
v0.1.0/go.mod h1:
KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/renameio
v0.1.0/go.mod h1:
KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid
v1.1.2/go.mod h1:
TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid
v1.1.2/go.mod h1:
TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid
v1.3.1 h1:
KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid
v1.3.1/go.mod h1:
TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2
v2.0.4/go.mod h1:
0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2
v2.0.4/go.mod h1:
0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2
v2.0.5/go.mod h1:
DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/gax-go/v2
v2.0.5/go.mod h1:
DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/google-cloud-go-testing
v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:
dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
github.com/googleapis/google-cloud-go-testing
v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:
dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
...
@@ -182,8 +169,6 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
...
@@ -182,8 +169,6 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection
v1.0.0/go.mod h1:
h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/inflection
v1.0.0/go.mod h1:
h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now
v1.1.5 h1:
/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now
v1.1.5 h1:
/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now
v1.1.5/go.mod h1:
d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now
v1.1.5/go.mod h1:
d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/josharian/intern
v1.0.0 h1:
vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern
v1.0.0/go.mod h1:
5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go
v1.1.12 h1:
PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go
v1.1.12 h1:
PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go
v1.1.12/go.mod h1:
e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/json-iterator/go
v1.1.12/go.mod h1:
e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jstemmer/go-junit-report
v0.0.0-20190106144839-af01ea7f8024/go.mod h1:
6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report
v0.0.0-20190106144839-af01ea7f8024/go.mod h1:
6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
...
@@ -202,8 +187,6 @@ github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
...
@@ -202,8 +187,6 @@ github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn
v1.2.4/go.mod h1:
7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/leodido/go-urn
v1.2.4/go.mod h1:
7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/magiconair/properties
v1.8.7 h1:
IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties
v1.8.7 h1:
IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties
v1.8.7/go.mod h1:
Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/magiconair/properties
v1.8.7/go.mod h1:
Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mailru/easyjson
v0.7.6 h1:
8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
github.com/mailru/easyjson
v0.7.6/go.mod h1:
xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-isatty
v0.0.19 h1:
JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty
v0.0.19 h1:
JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty
v0.0.19/go.mod h1:
W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty
v0.0.19/go.mod h1:
W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mitchellh/mapstructure
v1.5.0 h1:
jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure
v1.5.0 h1:
jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
...
@@ -224,7 +207,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
...
@@ -224,7 +207,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prometheus/client_model
v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model
v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/go-internal
v1.3.0/go.mod h1:
M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal
v1.3.0/go.mod h1:
M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal
v1.9.0 h1:
73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal
v1.9.0 h1:
73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/russross/blackfriday/v2
v2.1.0 h1:
JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2
v2.1.0/go.mod h1:
+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2
v2.1.0/go.mod h1:
+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sirupsen/logrus
v1.9.3 h1:
dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus
v1.9.3 h1:
dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus
v1.9.3/go.mod h1:
naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sirupsen/logrus
v1.9.3/go.mod h1:
naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
...
@@ -243,8 +225,6 @@ github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1Fof
...
@@ -243,8 +225,6 @@ github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1Fof
github.com/stretchr/objx
v0.1.0/go.mod h1:
HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx
v0.1.0/go.mod h1:
HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx
v0.4.0/go.mod h1:
YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx
v0.4.0/go.mod h1:
YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx
v0.5.0/go.mod h1:
Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx
v0.5.0/go.mod h1:
Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx
v0.5.1 h1:
4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0=
github.com/stretchr/objx
v0.5.1/go.mod h1:
/iHQpkQwBD6DLUmQ4pE+s1TXdob1mORJ4/UFdrifcy0=
github.com/stretchr/testify
v1.2.2/go.mod h1:
a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify
v1.2.2/go.mod h1:
a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify
v1.3.0/go.mod h1:
M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify
v1.3.0/go.mod h1:
M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify
v1.4.0/go.mod h1:
j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify
v1.4.0/go.mod h1:
j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
...
@@ -259,14 +239,10 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
...
@@ -259,14 +239,10 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify
v1.8.4/go.mod h1:
sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify
v1.8.4/go.mod h1:
sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv
v1.4.2 h1:
X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
github.com/subosito/gotenv
v1.4.2 h1:
X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
github.com/subosito/gotenv
v1.4.2/go.mod h1:
ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/subosito/gotenv
v1.4.2/go.mod h1:
ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/swaggo/swag
v1.16.1 h1:
fTNRhKstPKxcnoKsytm4sahr8FaYzUcT7i1/3nd/fBg=
github.com/swaggo/swag
v1.16.1/go.mod h1:
9/LMvHycG3NFHfR6LwvikHv5iFvmPADQ359cKikGxto=
github.com/twitchyliquid64/golang-asm
v0.15.1 h1:
SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm
v0.15.1 h1:
SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm
v0.15.1/go.mod h1:
a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/twitchyliquid64/golang-asm
v0.15.1/go.mod h1:
a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec
v1.2.11 h1:
BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec
v1.2.11 h1:
BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec
v1.2.11/go.mod h1:
UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/ugorji/go/codec
v1.2.11/go.mod h1:
UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/urfave/cli/v2
v2.3.0 h1:
qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2
v2.3.0/go.mod h1:
LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/yuin/goldmark
v1.1.25/go.mod h1:
3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark
v1.1.25/go.mod h1:
3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark
v1.1.27/go.mod h1:
3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark
v1.1.27/go.mod h1:
3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark
v1.1.32/go.mod h1:
3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark
v1.1.32/go.mod h1:
3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
...
@@ -477,8 +453,6 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f
...
@@ -477,8 +453,6 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools
v0.0.0-20210105154028-b0ab187a4818/go.mod h1:
emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools
v0.0.0-20210105154028-b0ab187a4818/go.mod h1:
emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools
v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:
emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools
v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:
emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools
v0.1.0/go.mod h1:
xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools
v0.1.0/go.mod h1:
xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools
v0.7.0 h1:
W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
golang.org/x/tools
v0.7.0/go.mod h1:
4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
golang.org/x/xerrors
v0.0.0-20190717185122-a985d3407aa7/go.mod h1:
I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors
v0.0.0-20190717185122-a985d3407aa7/go.mod h1:
I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors
v0.0.0-20191011141410-1b5146add898/go.mod h1:
I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors
v0.0.0-20191011141410-1b5146add898/go.mod h1:
I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors
v0.0.0-20191204190536-9bdfabe68543/go.mod h1:
I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors
v0.0.0-20191204190536-9bdfabe68543/go.mod h1:
I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
...
@@ -583,8 +557,6 @@ gopkg.in/guregu/null.v4 v4.0.0/go.mod h1:YoQhUrADuG3i9WqesrCmpNRwm1ypAgSHYqoOcTu
...
@@ -583,8 +557,6 @@ gopkg.in/guregu/null.v4 v4.0.0/go.mod h1:YoQhUrADuG3i9WqesrCmpNRwm1ypAgSHYqoOcTu
gopkg.in/ini.v1
v1.67.0 h1:
Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1
v1.67.0 h1:
Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1
v1.67.0/go.mod h1:
pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1
v1.67.0/go.mod h1:
pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v2
v2.2.2/go.mod h1:
hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2
v2.2.2/go.mod h1:
hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2
v2.4.0 h1:
D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2
v2.4.0/go.mod h1:
RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3
v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:
K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3
v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:
K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3
v3.0.1 h1:
fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3
v3.0.1 h1:
fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3
v3.0.1/go.mod h1:
K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3
v3.0.1/go.mod h1:
K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
...
@@ -604,5 +576,3 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
...
@@ -604,5 +576,3 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
rsc.io/pdf
v0.1.1/go.mod h1:
n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
rsc.io/pdf
v0.1.1/go.mod h1:
n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
rsc.io/quote/v3
v3.1.0/go.mod h1:
yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/quote/v3
v3.1.0/go.mod h1:
yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler
v1.3.0/go.mod h1:
T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
rsc.io/sampler
v1.3.0/go.mod h1:
T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/yaml
v1.3.0 h1:
a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml
v1.3.0/go.mod h1:
GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
internal/controller/link.go
View file @
7b23656d
package
controller
package
controller
import
(
import
(
"fmt"
"go-svc-tpl/api/dto"
"go-svc-tpl/api/dto"
"go-svc-tpl/internal/dao"
"go-svc-tpl/internal/dao"
"go-svc-tpl/internal/dao/model"
"go-svc-tpl/internal/dao/model"
"go-svc-tpl/utils/stacktrace"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"gopkg.in/guregu/null.v4"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
const
USER_ID_KEY
=
"qwq"
const
LinkTable
=
"Links"
const
LinkTable
=
"Links"
// >>>>>>>>>>>>>>>>>> Interface >>>>>>>>>>>>>>>>>>
// >>>>>>>>>>>>>>>>>> Interface >>>>>>>>>>>>>>>>>>
...
@@ -32,7 +33,6 @@ var NewLinkController = func() *LinkController {
...
@@ -32,7 +33,6 @@ var NewLinkController = func() *LinkController {
}
}
type
LinkController
struct
{
type
LinkController
struct
{
db
*
gorm
.
DB
}
}
// create
// create
...
@@ -40,28 +40,32 @@ type LinkController struct {
...
@@ -40,28 +40,32 @@ type LinkController struct {
// short 如果为空字符串,则自动生成链接
// short 如果为空字符串,则自动生成链接
// 如果起止时间为 null 则表示不设置起止时间
// 如果起止时间为 null 则表示不设置起止时间
func
(
c
*
LinkController
)
Create
(
ctx
*
gin
.
Context
,
req
*
dto
.
LinkCreateReq
)
(
*
dto
.
LinkCreateResp
,
error
)
{
func
(
c
*
LinkController
)
Create
(
ctx
*
gin
.
Context
,
req
*
dto
.
LinkCreateReq
)
(
*
dto
.
LinkCreateResp
,
error
)
{
userID
:=
ctx
.
GetUint
(
USER_ID_KEY
)
userID
:=
ctx
.
GetUint
(
model
.
USER_ID_KEY
)
newLink
:=
&
model
.
Link
{
newLink
:=
&
model
.
Link
{
Short
:
req
.
Short
,
Short
:
req
.
Short
,
Comment
:
req
.
Comment
,
Comment
:
req
.
Comment
,
Origin
:
req
.
Origin
,
Origin
:
req
.
Origin
,
StartTime
:
req
.
StartTime
,
StartTime
:
req
.
StartTime
,
EndTime
:
req
.
EndTime
,
EndTime
:
req
.
EndTime
,
Active
:
true
,
Active
:
null
.
BoolFrom
(
true
)
,
OwnerID
:
userID
,
OwnerID
:
userID
,
}
}
err
:=
dao
.
DB
(
ctx
)
.
Create
(
newLink
)
.
Error
err
:=
dao
.
DB
(
ctx
)
.
Create
(
newLink
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
logrus
.
Fatal
(
err
)
return
nil
,
err
return
nil
,
err
}
}
var
link
model
.
Link
var
link
model
.
Link
err
=
dao
.
DB
(
ctx
)
.
First
(
&
link
,
"Short = ?"
,
newLink
.
Short
)
.
Error
err
=
dao
.
DB
(
ctx
)
.
Where
(
&
model
.
Link
{
Short
:
newLink
.
Short
})
.
First
(
&
link
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
// 没找到相关记录 说明不是短连接重复
if
err
==
gorm
.
ErrRecordNotFound
{
if
err
==
gorm
.
ErrRecordNotFound
{
fmt
.
Println
(
"Short is not duplicate. You can insert."
)
logrus
.
Fatal
(
err
)
return
nil
,
err
}
}
return
nil
,
err
return
nil
,
stacktrace
.
PropagateWithCode
(
nil
,
dto
.
ErrShortLinkExist
,
"ErrShortLinkExist"
)
}
}
return
&
dto
.
LinkCreateResp
{
return
&
dto
.
LinkCreateResp
{
Short
:
newLink
.
Short
,
Short
:
newLink
.
Short
,
...
@@ -75,20 +79,22 @@ func (c *LinkController) Create(ctx *gin.Context, req *dto.LinkCreateReq) (*dto.
...
@@ -75,20 +79,22 @@ func (c *LinkController) Create(ctx *gin.Context, req *dto.LinkCreateReq) (*dto.
// delete
// delete
func
(
c
*
LinkController
)
Delete
(
ctx
*
gin
.
Context
,
req
*
dto
.
LinkDeleteReq
)
error
{
func
(
c
*
LinkController
)
Delete
(
ctx
*
gin
.
Context
,
req
*
dto
.
LinkDeleteReq
)
error
{
userID
:=
ctx
.
GetUint
(
USER_ID_KEY
)
userID
:=
ctx
.
GetUint
(
model
.
USER_ID_KEY
)
deleteLink
:=
&
model
.
Link
{
deleteLink
:=
&
model
.
Link
{
Short
:
req
.
Short
,
Short
:
req
.
Short
,
OwnerID
:
userID
,
OwnerID
:
userID
,
}
}
err
:=
dao
.
DB
(
ctx
)
.
Delete
(
&
deleteLink
)
.
Error
err
:=
dao
.
DB
(
ctx
)
.
Delete
(
&
deleteLink
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
return
err
logrus
.
Fatal
(
err
)
return
stacktrace
.
PropagateWithCode
(
nil
,
dto
.
ErrNoShortLink
,
"ErrNoShortLink"
)
}
}
var
link
model
.
Link
var
link
model
.
Link
err
=
dao
.
DB
(
ctx
)
.
First
(
&
link
,
"Short = ?"
,
deleteLink
.
Short
)
.
Error
err
=
dao
.
DB
(
ctx
)
.
First
(
&
link
,
"Short = ?"
,
deleteLink
.
Short
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
if
err
==
gorm
.
ErrRecordNotFound
{
fmt
.
Println
(
"Short is not duplicate. You can insert."
)
logrus
.
Fatal
(
err
)
return
stacktrace
.
PropagateWithCode
(
nil
,
dto
.
ErrNoShortLink
,
"ErrNoShortLink"
)
}
}
return
err
return
err
}
}
...
@@ -97,7 +103,7 @@ func (c *LinkController) Delete(ctx *gin.Context, req *dto.LinkDeleteReq) error
...
@@ -97,7 +103,7 @@ func (c *LinkController) Delete(ctx *gin.Context, req *dto.LinkDeleteReq) error
// getinfo
// getinfo
func
(
c
*
LinkController
)
GetInfo
(
ctx
*
gin
.
Context
,
req
*
dto
.
GetLinkInfoReq
)
(
*
dto
.
GetLinkInfoResp
,
error
)
{
func
(
c
*
LinkController
)
GetInfo
(
ctx
*
gin
.
Context
,
req
*
dto
.
GetLinkInfoReq
)
(
*
dto
.
GetLinkInfoResp
,
error
)
{
userID
:=
ctx
.
GetUint
(
USER_ID_KEY
)
userID
:=
ctx
.
GetUint
(
model
.
USER_ID_KEY
)
getinfoLink
:=
&
model
.
Link
{
getinfoLink
:=
&
model
.
Link
{
Short
:
req
.
Short
,
Short
:
req
.
Short
,
OwnerID
:
userID
,
OwnerID
:
userID
,
...
@@ -107,7 +113,7 @@ func (c *LinkController) GetInfo(ctx *gin.Context, req *dto.GetLinkInfoReq) (*dt
...
@@ -107,7 +113,7 @@ func (c *LinkController) GetInfo(ctx *gin.Context, req *dto.GetLinkInfoReq) (*dt
err
:=
dao
.
DB
(
ctx
)
.
First
(
&
link
,
"Short = ?"
,
getinfoLink
.
Short
)
.
Error
err
:=
dao
.
DB
(
ctx
)
.
First
(
&
link
,
"Short = ?"
,
getinfoLink
.
Short
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
if
err
==
gorm
.
ErrRecordNotFound
{
fmt
.
Println
(
"Short is not duplicate. You can insert."
)
logrus
.
Fatal
(
err
)
}
}
return
nil
,
err
return
nil
,
err
}
}
...
@@ -124,7 +130,7 @@ func (c *LinkController) GetInfo(ctx *gin.Context, req *dto.GetLinkInfoReq) (*dt
...
@@ -124,7 +130,7 @@ func (c *LinkController) GetInfo(ctx *gin.Context, req *dto.GetLinkInfoReq) (*dt
// update
// update
func
(
c
*
LinkController
)
Update
(
ctx
*
gin
.
Context
,
req
*
dto
.
LinkUpdateReq
)
error
{
func
(
c
*
LinkController
)
Update
(
ctx
*
gin
.
Context
,
req
*
dto
.
LinkUpdateReq
)
error
{
userID
:=
ctx
.
GetUint
(
USER_ID_KEY
)
userID
:=
ctx
.
GetUint
(
model
.
USER_ID_KEY
)
updateLink
:=
&
model
.
Link
{
updateLink
:=
&
model
.
Link
{
Short
:
req
.
Short
,
Short
:
req
.
Short
,
Origin
:
req
.
Origin
,
Origin
:
req
.
Origin
,
...
@@ -143,7 +149,7 @@ func (c *LinkController) Update(ctx *gin.Context, req *dto.LinkUpdateReq) error
...
@@ -143,7 +149,7 @@ func (c *LinkController) Update(ctx *gin.Context, req *dto.LinkUpdateReq) error
err
=
dao
.
DB
(
ctx
)
.
First
(
&
link
,
"Short = ?"
,
updateLink
.
Short
)
.
Error
err
=
dao
.
DB
(
ctx
)
.
First
(
&
link
,
"Short = ?"
,
updateLink
.
Short
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
if
err
==
gorm
.
ErrRecordNotFound
{
fmt
.
Println
(
"Short is not duplicate. You can insert."
)
logrus
.
Fatal
(
err
)
}
}
return
err
return
err
}
}
...
...
internal/controller/server.go
View file @
7b23656d
...
@@ -3,6 +3,7 @@ package controller
...
@@ -3,6 +3,7 @@ package controller
import
(
import
(
"errors"
"errors"
"go-svc-tpl/api/dto"
"go-svc-tpl/api/dto"
"go-svc-tpl/internal/dao"
"go-svc-tpl/internal/dao/model"
"go-svc-tpl/internal/dao/model"
"net/http"
"net/http"
...
@@ -25,17 +26,15 @@ var NewServerController = func() *ServerController {
...
@@ -25,17 +26,15 @@ var NewServerController = func() *ServerController {
}
}
type
ServerController
struct
{
type
ServerController
struct
{
db
*
gorm
.
DB
}
}
// 重定向到相应链接
// 重定向到相应链接
// 当出现问题时,会按标准 response 返回,由前端显示相应页面
// 当出现问题时,会按标准 response 返回,由前端显示相应页面
func
(
c
*
ServerController
)
Link
(
ctx
*
gin
.
Context
,
req
*
dto
.
ServerLinkReq
)
error
{
func
(
c
*
ServerController
)
Link
(
ctx
*
gin
.
Context
,
req
*
dto
.
ServerLinkReq
)
error
{
shortLink
:=
req
.
Short
// 在数据库中查找对应的长链接
// 在数据库中查找对应的长链接
var
link
model
.
Link
var
link
model
.
Link
if
err
:=
c
.
db
.
Table
(
model
.
LinkTable
)
.
Where
(
"short = ?"
,
shortLink
)
.
First
(
&
link
)
.
Error
;
err
!=
nil
{
if
err
:=
dao
.
DB
(
ctx
)
.
Where
(
&
model
.
Link
{
Short
:
req
.
Short
})
.
First
(
&
link
)
.
Error
;
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
if
err
==
gorm
.
ErrRecordNotFound
{
// 如果找不到对应的长链接,返回404错误
// 如果找不到对应的长链接,返回404错误
ctx
.
JSON
(
http
.
StatusNotFound
,
gin
.
H
{
"error"
:
"Link not found"
})
ctx
.
JSON
(
http
.
StatusNotFound
,
gin
.
H
{
"error"
:
"Link not found"
})
...
...
internal/controller/user.go
View file @
7b23656d
package
controller
package
controller
import
(
import
(
"errors"
"fmt"
"go-svc-tpl/api/dto"
"go-svc-tpl/api/dto"
"go-svc-tpl/internal/dao"
"go-svc-tpl/internal/dao"
"go-svc-tpl/internal/dao/model"
"go-svc-tpl/internal/dao/model"
"net/http"
"regexp"
"regexp"
"go-svc-tpl/utils/stacktrace"
"bytes"
"path"
"strings"
"time"
"github.com/dchest/captcha"
"github.com/dchest/captcha"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"golang.org/x/crypto/bcrypt"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
// >>>>>>>>>>>>>>>>>> Interface >>>>>>>>>>>>>>>>>>
var
ID
uint
var
sessionID
string
type
IUserController
interface
{
//定义tag user 下的操作
type
IUserController
interface
{
//定义tag user 下的操作
Register
(
*
gin
.
Context
,
*
dto
.
UserRegisterReq
)
error
Register
(
*
gin
.
Context
,
*
dto
.
UserRegisterReq
)
error
GetVeri
(
*
gin
.
Context
)
(
*
dto
.
GetVeriResp
,
error
)
GetVeri
(
*
gin
.
Context
)
(
*
dto
.
GetVeriResp
,
error
)
...
@@ -22,6 +31,7 @@ type IUserController interface { //定义tag user 下的操作
...
@@ -22,6 +31,7 @@ type IUserController interface { //定义tag user 下的操作
GetInfo
(
*
gin
.
Context
)
(
*
dto
.
GetUserInfoResp
,
error
)
GetInfo
(
*
gin
.
Context
)
(
*
dto
.
GetUserInfoResp
,
error
)
ModifyInfo
(
*
gin
.
Context
,
*
dto
.
UserModifyInfoReq
)
error
ModifyInfo
(
*
gin
.
Context
,
*
dto
.
UserModifyInfoReq
)
error
ModifyPwd
(
*
gin
.
Context
,
*
dto
.
UserModifyPwdReq
)
error
ModifyPwd
(
*
gin
.
Context
,
*
dto
.
UserModifyPwdReq
)
error
Logout
(
*
gin
.
Context
)
error
}
}
var
_
IUserController
=
(
*
UserController
)(
nil
)
var
_
IUserController
=
(
*
UserController
)(
nil
)
...
@@ -31,101 +41,143 @@ var NewUserController = func() *UserController {
...
@@ -31,101 +41,143 @@ var NewUserController = func() *UserController {
}
}
type
UserController
struct
{
type
UserController
struct
{
db
*
gorm
.
DB
}
}
// Register
// Register
func
(
c
*
UserController
)
Register
(
ctx
*
gin
.
Context
,
req
*
dto
.
UserRegisterReq
)
error
{
func
(
c
*
UserController
)
Register
(
ctx
*
gin
.
Context
,
req
*
dto
.
UserRegisterReq
)
error
{
userID
:=
ctx
.
GetUint
(
USER_ID_KEY
)
userID
:=
ctx
.
GetUint
(
model
.
USER_ID_KEY
)
//验证邮箱格式
//验证邮箱格式
emailPattern
:=
`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$`
emailPattern
:=
`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$`
_
,
err
:=
regexp
.
MatchString
(
emailPattern
,
req
.
Email
)
_
,
err
:=
regexp
.
MatchString
(
emailPattern
,
req
.
Email
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
"wrong email pattern"
,
err
)
return
stacktrace
.
PropagateWithCode
(
err
,
dto
.
BadRequest
,
"Bad request."
)
return
err
}
//密码Hash处理
hashedBytes
,
err
:=
bcrypt
.
GenerateFromPassword
([]
byte
(
req
.
Password
),
bcrypt
.
DefaultCost
)
if
err
!=
nil
{
return
stacktrace
.
PropagateWithCode
(
err
,
dto
.
InternalError
,
"InternalError."
)
}
}
newUser
:=
&
model
.
User
{
newUser
:=
&
model
.
User
{
ID
:
userID
,
ID
:
userID
,
Email
:
req
.
Email
,
Email
:
req
.
Email
,
Name
:
req
.
Name
,
Name
:
req
.
Name
,
Password
:
req
.
Password
,
Password
:
string
(
hashedBytes
)
,
}
}
err
=
dao
.
DB
(
ctx
)
.
Create
(
newUser
)
.
Error
err
=
dao
.
DB
(
ctx
)
.
Model
(
&
model
.
User
{
ID
:
userID
})
.
Create
(
newUser
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
stacktrace
.
PropagateWithCode
(
err
,
dto
.
InternalError
,
"Internal Error."
)
}
}
//验证邮箱唯一性
//验证邮箱唯一性
var
user
model
.
User
var
user
model
.
User
err
=
dao
.
DB
(
ctx
)
.
First
(
&
user
,
"Email = ?"
,
newUser
.
Email
)
.
Error
err
=
dao
.
DB
(
ctx
)
.
Model
(
&
model
.
User
{
ID
:
userID
})
.
Where
(
&
model
.
User
{
Email
:
newUser
.
Email
})
.
First
(
&
user
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
if
err
==
gorm
.
ErrRecordNotFound
{
fmt
.
Println
(
"Email is not duplicate. You can inser
t."
)
return
stacktrace
.
PropagateWithCode
(
err
,
dto
.
ErrEmailExist
,
"ErrEmailExis
t."
)
}
}
return
err
return
stacktrace
.
PropagateWithCode
(
err
,
dto
.
InternalError
,
"Internal Error."
)
}
}
return
nil
return
nil
}
}
// GetVeri
// GetVeri
func
(
c
*
UserController
)
GetVeri
(
ctx
*
gin
.
Context
)
(
*
dto
.
GetVeriResp
,
error
)
{
func
(
c
*
UserController
)
GetVeri
(
ctx
*
gin
.
Context
)
(
*
dto
.
GetVeriResp
,
error
)
{
// 生成验证码ID
length
:=
captcha
.
DefaultLen
id
:=
captcha
.
New
()
captchaID
:=
captcha
.
NewLen
(
length
)
captchaURL
:=
"/captcha/"
+
captchaID
+
".png"
// 拼接验证码图片地址
url
:=
fmt
.
Sprintf
(
"/captcha/%s.png"
,
id
)
// 创建GetVeriResp结构体实例
resp
:=
&
dto
.
GetVeriResp
{
resp
:=
&
dto
.
GetVeriResp
{
CAPTCHAID
:
id
,
CAPTCHAID
:
captchaID
,
CAPTCHAURL
:
url
,
CAPTCHAURL
:
captchaURL
,
}
}
ServeHTTP
(
ctx
.
Writer
,
ctx
.
Request
)
// 返回响应结构体和nil
return
resp
,
nil
return
resp
,
nil
}
func
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
dir
,
file
:=
path
.
Split
(
r
.
URL
.
Path
)
ext
:=
path
.
Ext
(
file
)
id
:=
file
[
:
len
(
file
)
-
len
(
ext
)]
if
ext
==
""
||
id
==
""
{
http
.
NotFound
(
w
,
r
)
return
}
lang
:=
strings
.
ToLower
(
r
.
FormValue
(
"lang"
))
download
:=
path
.
Base
(
dir
)
==
"download"
if
Serve
(
w
,
r
,
id
,
ext
,
lang
,
download
,
captcha
.
StdWidth
,
captcha
.
StdHeight
)
==
captcha
.
ErrNotFound
{
http
.
NotFound
(
w
,
r
)
}
}
func
Serve
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
id
,
ext
,
lang
string
,
download
bool
,
width
,
height
int
)
error
{
w
.
Header
()
.
Set
(
"Cache-Control"
,
"no-cache, no-store, must-revalidate"
)
w
.
Header
()
.
Set
(
"Pragma"
,
"no-cache"
)
w
.
Header
()
.
Set
(
"Expires"
,
"0"
)
var
content
bytes
.
Buffer
switch
ext
{
case
".png"
:
w
.
Header
()
.
Set
(
"Content-Type"
,
"image/png"
)
captcha
.
WriteImage
(
&
content
,
id
,
width
,
height
)
default
:
return
captcha
.
ErrNotFound
}
if
download
{
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/octet-stream"
)
}
http
.
ServeContent
(
w
,
r
,
id
+
ext
,
time
.
Time
{},
bytes
.
NewReader
(
content
.
Bytes
()))
return
nil
}
}
// Login
// Login
func
(
c
*
UserController
)
Login
(
ctx
*
gin
.
Context
,
req
*
dto
.
UserLoginReq
)
error
{
func
(
c
*
UserController
)
Login
(
ctx
*
gin
.
Context
,
req
*
dto
.
UserLoginReq
)
error
{
// 验证用户输入的验证码是否正确
//验证码
if
!
captcha
.
VerifyString
(
req
.
CAPTCHAID
,
req
.
CAPTCHAValue
)
{
captchaId
:=
ctx
.
Param
(
"captcha_id"
)
return
errors
.
New
(
"invalid captcha value"
)
value
:=
ctx
.
Param
(
"captcha_value"
)
if
captchaId
==
""
||
value
==
""
{
return
stacktrace
.
PropagateWithCode
(
nil
,
dto
.
BadRequest
,
"BadRequest."
)
}
if
!
captcha
.
VerifyString
(
captchaId
,
value
)
{
return
stacktrace
.
PropagateWithCode
(
nil
,
dto
.
ErrCaptcha
,
"ErrCaptcha."
)
}
}
//找对应用户
var
user
model
.
User
err
:=
dao
.
DB
(
ctx
)
.
Model
(
&
model
.
User
{
Email
:
req
.
Email
})
.
Where
(
&
model
.
User
{
Email
:
req
.
Email
})
.
First
(
&
user
)
.
Error
if
err
!=
nil
{
return
stacktrace
.
PropagateWithCode
(
nil
,
dto
.
ErrUserNotFound
,
"ErrUserNotFound."
)
}
//密码
newUser
:=
&
model
.
User
{
newUser
:=
&
model
.
User
{
ID
:
user
.
ID
,
Email
:
req
.
Email
,
Email
:
req
.
Email
,
Password
:
req
.
Password
,
Password
:
req
.
Password
,
}
}
// 从数据库中查询用户信息
err
=
bcrypt
.
CompareHashAndPassword
([]
byte
(
user
.
Password
),
[]
byte
(
newUser
.
Password
))
var
user
model
.
User
err
:=
dao
.
DB
(
ctx
)
.
First
(
&
user
,
newUser
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
stacktrace
.
PropagateWithCode
(
nil
,
dto
.
ErrPassword
,
"ErrPassword."
)
fmt
.
Println
(
"Short is not duplicate. You can insert."
)
}
return
err
}
// 验证用户名和密码是否匹配
if
user
.
Password
!=
req
.
Password
{
return
errors
.
New
(
"invalid email or password"
)
}
}
//设置cookie
//ctx.SetCookie("id", strconv.FormatUint(uint64(userID), 10), 3600, "/", "localhost", false, true)
ID
=
user
.
ID
sessionID
=
uuid
.
New
()
.
String
()
ctx
.
SetCookie
(
"session_id"
,
sessionID
,
86400
,
"/"
,
"localhost"
,
false
,
true
)
return
nil
}
// 设置登录状态,生成并设置cookie
// Logout
session
:=
sessions
.
Default
(
ctx
)
func
(
c
*
UserController
)
Logout
(
ctx
*
gin
.
Context
)
error
{
session
.
Set
(
"user_id"
,
user
.
ID
)
ctx
.
SetCookie
(
"id"
,
""
,
-
1
,
"/"
,
"localhost"
,
false
,
true
)
session
.
Save
()
// 返回nil表示成功登录
return
nil
return
nil
}
}
// GetInfo
// GetInfo
func
(
c
*
UserController
)
GetInfo
(
ctx
*
gin
.
Context
)
(
*
dto
.
GetUserInfoResp
,
error
)
{
func
(
c
*
UserController
)
GetInfo
(
ctx
*
gin
.
Context
)
(
*
dto
.
GetUserInfoResp
,
error
)
{
userID
:=
ctx
.
GetUint
(
USER_ID_KEY
)
userID
:=
ctx
.
GetUint
(
model
.
USER_ID_KEY
)
var
user
model
.
User
var
user
model
.
User
err
:=
dao
.
DB
(
ctx
)
.
First
(
&
user
,
"ID = ?"
,
userID
)
.
Error
err
:=
dao
.
DB
(
ctx
)
.
Model
(
&
model
.
User
{
ID
:
userID
})
.
Where
(
&
model
.
User
{
ID
:
userID
})
.
First
(
&
user
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
stacktrace
.
PropagateWithCode
(
err
,
dto
.
ErrUserNotFound
,
"ErrUserNotFound."
)
}
}
return
&
dto
.
GetUserInfoResp
{
return
&
dto
.
GetUserInfoResp
{
ID
:
user
.
ID
,
ID
:
user
.
ID
,
...
@@ -136,43 +188,43 @@ func (c *UserController) GetInfo(ctx *gin.Context) (*dto.GetUserInfoResp, error)
...
@@ -136,43 +188,43 @@ func (c *UserController) GetInfo(ctx *gin.Context) (*dto.GetUserInfoResp, error)
// ModifyInfo
// ModifyInfo
func
(
c
*
UserController
)
ModifyInfo
(
ctx
*
gin
.
Context
,
req
*
dto
.
UserModifyInfoReq
)
error
{
func
(
c
*
UserController
)
ModifyInfo
(
ctx
*
gin
.
Context
,
req
*
dto
.
UserModifyInfoReq
)
error
{
userID
:=
ctx
.
GetUint
(
USER_ID_KEY
)
userID
:=
ctx
.
GetUint
(
model
.
USER_ID_KEY
)
//验证邮箱格式
//验证邮箱格式
emailPattern
:=
`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$`
emailPattern
:=
`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$`
_
,
err
:=
regexp
.
MatchString
(
emailPattern
,
req
.
Email
)
_
,
err
:=
regexp
.
MatchString
(
emailPattern
,
req
.
Email
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
"wrong email pattern"
,
err
)
return
stacktrace
.
PropagateWithCode
(
err
,
dto
.
ErrShortLinkExist
,
"ErrShortLinkExist."
)
return
err
}
}
newUser
:=
&
model
.
User
{
newUser
:=
&
model
.
User
{
ID
:
userID
,
ID
:
userID
,
Email
:
req
.
Email
,
Email
:
req
.
Email
,
Name
:
req
.
Name
,
Name
:
req
.
Name
,
}
}
err
=
dao
.
DB
(
ctx
)
.
Updates
(
&
newUser
)
.
Error
err
=
dao
.
DB
(
ctx
)
.
Model
(
&
model
.
User
{
ID
:
userID
})
.
Updates
(
&
newUser
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
stacktrace
.
PropagateWithCode
(
err
,
dto
.
InternalError
,
"Internal Error."
)
}
}
return
nil
return
nil
}
}
// ModifyPwd
// ModifyPwd
func
(
c
*
UserController
)
ModifyPwd
(
ctx
*
gin
.
Context
,
req
*
dto
.
UserModifyPwdReq
)
error
{
func
(
c
*
UserController
)
ModifyPwd
(
ctx
*
gin
.
Context
,
req
*
dto
.
UserModifyPwdReq
)
error
{
userID
:=
ctx
.
GetUint
(
USER_ID_KEY
)
userID
:=
ctx
.
GetUint
(
model
.
USER_ID_KEY
)
var
user
model
.
User
var
user
model
.
User
err
:=
dao
.
DB
(
ctx
)
.
First
(
&
user
,
"ID = ?"
,
userID
)
.
Error
err
:=
dao
.
DB
(
ctx
)
.
Model
(
&
model
.
User
{
ID
:
userID
})
.
Where
(
&
model
.
User
{
ID
:
userID
})
.
First
(
&
user
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
stacktrace
.
PropagateWithCode
(
err
,
dto
.
ErrUserNotFound
,
"ErrUserNotFound."
)
}
}
if
user
.
Password
!=
req
.
OldPwd
{
if
user
.
Password
!=
req
.
OldPwd
{
fmt
.
Println
(
"wrong p
assword"
)
return
stacktrace
.
PropagateWithCode
(
err
,
dto
.
ErrPassword
,
"ErrP
assword
.
"
)
}
}
newUser
:=
&
model
.
User
{
newUser
:=
&
model
.
User
{
Password
:
req
.
NewPwd
,
Password
:
req
.
NewPwd
,
}
}
err
=
dao
.
DB
(
ctx
)
.
Updates
(
&
newUser
)
.
Error
err
=
dao
.
DB
(
ctx
)
.
Model
(
&
model
.
User
{
ID
:
userID
})
.
Updates
(
&
newUser
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
stacktrace
.
PropagateWithCode
(
err
,
dto
.
InternalError
,
"Internal Error."
)
}
}
return
nil
return
nil
}
}
internal/dao/model/link.go
View file @
7b23656d
...
@@ -8,7 +8,7 @@ const LinkTable = "Links"
...
@@ -8,7 +8,7 @@ const LinkTable = "Links"
type
Link
struct
{
type
Link
struct
{
ID
uint
`json:"ID"`
//ID
ID
uint
`json:"ID"`
//ID
Active
bool
`json:"active"`
Active
null
.
Bool
`json:"active"`
Comment
string
`json:"comment"`
Comment
string
`json:"comment"`
EndTime
null
.
Time
`json:"end_time"`
EndTime
null
.
Time
`json:"end_time"`
Origin
string
`json:"origin"`
Origin
string
`json:"origin"`
...
...
internal/dao/model/user.go
View file @
7b23656d
package
model
package
model
const
USER_ID_KEY
=
"qwq"
const
UserTable
=
"Users"
const
UserTable
=
"Users"
type
User
struct
{
type
User
struct
{
...
...
test.go
deleted
100644 → 0
View file @
75c47933
package
main
import
(
"errors"
"go-svc-tpl/api/dto"
"go-svc-tpl/internal/controller"
"go-svc-tpl/internal/dao/model"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
"gorm.io/gorm"
)
func
TestUserController_Register
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
desc
string
req
*
dto
.
UserRegisterReq
expected
error
}{
{
desc
:
"success"
,
req
:
&
dto
.
UserRegisterReq
{
Email
:
"test@test.com"
,
Password
:
"password"
,
Name
:
"test"
,
},
expected
:
nil
,
},
{
desc
:
"invalid email"
,
req
:
&
dto
.
UserRegisterReq
{
Email
:
"test@test"
,
Password
:
"password"
,
Name
:
"test"
,
},
expected
:
errors
.
New
(
"wrong email pattern"
),
},
}
for
_
,
tC
:=
range
testCases
{
t
.
Run
(
tC
.
desc
,
func
(
t
*
testing
.
T
)
{
gin
.
SetMode
(
gin
.
TestMode
)
r
:=
gin
.
New
()
r
.
Use
(
func
(
c
*
gin
.
Context
)
{
c
.
Set
(
controller
.
USER_ID_KEY
,
uint
(
1
))
})
ctrl
:=
&
controller
.
UserController
{
db
:
&
gorm
.
DB
{},
}
_
=
model
.
Migrate
(
ctrl
.
db
)
ctrl
.
db
=
model
.
MockDB
()
var
resp
*
httptest
.
ResponseRecorder
if
data
,
err
:=
tC
.
req
.
ToJSON
();
err
!=
nil
{
t
.
Fatalf
(
"failed to marshal request to JSON: %v"
,
err
)
}
else
{
req
,
_
:=
http
.
NewRequest
(
http
.
MethodPost
,
"/register"
,
strings
.
NewReader
(
data
))
resp
=
httptest
.
NewRecorder
()
r
.
POST
(
"/register"
,
func
(
c
*
gin
.
Context
)
{
if
err
:=
ctrl
.
Register
(
c
,
tC
.
req
);
err
!=
nil
{
c
.
AbortWithStatus
(
http
.
StatusInternalServerError
)
}
c
.
AbortWithStatus
(
http
.
StatusOK
)
})
r
.
ServeHTTP
(
resp
,
req
)
}
assert
.
Equal
(
t
,
http
.
StatusOK
,
resp
.
Code
)
assert
.
Equal
(
t
,
tC
.
expected
,
nil
)
})
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment