Skip to content

Commit 8b0f75f

Browse files
authored
code polish (#124)
1 parent a19dc19 commit 8b0f75f

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

internal/core/openapi/context.go

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ import (
2525
"github.com/gin-gonic/gin"
2626
)
2727

28+
const (
29+
requestIdHeader = "x-envcd-request-id"
30+
// tokenHeader
31+
tokenHeader = "x-envcd-token"
32+
)
33+
2834
// buildContext build plugin context
2935
// @param params params
3036
// @return *context.Context context

internal/core/openapi/openapi.go

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ import (
3333
"github.com/gin-gonic/gin"
3434
)
3535

36-
var requestIdHeader = "x-envcd-request-id"
37-
3836
type PageListVO struct {
3937
Page int64 `json:"page"`
4038
PageSize int64 `json:"pageSize"`

internal/core/openapi/token.go

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import (
3232
const (
3333
// hmacSecret secret
3434
hmacSecret = "9C035514A15F78"
35-
// tokenHeader
36-
tokenHeader = "token"
3735
)
3836

3937
// authorizationClaims claims

internal/core/openapi/user.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ func (openapi *Openapi) login(ginCtx *gin.Context) {
9292
return result.InternalFailure(err)
9393
}
9494

95-
users, err := dao.New(openapi.storage).SelectUser(entity.User{
95+
daoAction := dao.New(openapi.storage)
96+
users, err := daoAction.SelectUser(entity.User{
9697
Name: param.Username,
9798
})
9899
if err != nil {
@@ -114,7 +115,6 @@ func (openapi *Openapi) login(ginCtx *gin.Context) {
114115
if err != nil {
115116
return result.InternalFailure(err)
116117
}
117-
daoAction := dao.New(openapi.storage)
118118
user.UserSession = token
119119
if _, err := daoAction.UpdateUser(user); err != nil {
120120
return result.InternalFailure(err)

0 commit comments

Comments
 (0)