Skip to content

Commit

Permalink
fix: Change the type of user_id from string to int32
Browse files Browse the repository at this point in the history
  • Loading branch information
ckappgit authored Jul 14, 2024
1 parent 2a1edf7 commit b023e97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 5 additions & 5 deletions internal/service/user/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type ProfileResponse struct {
Private bool `json:"private"`
Roles []string `json:"roles,omitempty"`
Signature string `json:"signature"`
UserID int `json:"user_id"`
UserID int32 `json:"user_id"`
Username string `json:"username"`
}

Expand Down Expand Up @@ -59,7 +59,7 @@ func ProfileMe(c *gin.Context) {
Private: user.Private,
Roles: roles,
Signature: user.Signature,
UserID: int(user.UserID),
UserID: int32(user.UserID),

Check failure on line 62 in internal/service/user/profile.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary conversion (unconvert)
Username: user.Username,
})

Expand Down Expand Up @@ -98,7 +98,7 @@ func ProfileOthers(c *gin.Context) {
log.Logger.Info("Failed to get user roles: " + err.Error())
roles = []string{}
}
// 判断是否为隐私账号 1==1为谷歌编程规范
// 判断是否为隐私账号
if user.Private {
// 只显示最基础信息
util.OKWithData(c, ProfileResponse{
Expand All @@ -112,7 +112,7 @@ func ProfileOthers(c *gin.Context) {
Private: user.Private,
Roles: []string{},
Signature: "",
UserID: int(user.UserID),
UserID: user.UserID,
Username: user.Username,
})
} else {
Expand All @@ -129,7 +129,7 @@ func ProfileOthers(c *gin.Context) {
Private: user.Private,
Roles: roles,
Signature: user.Signature,
UserID: int(user.UserID),
UserID: user.UserID,
Username: user.Username,
})
}
Expand Down
5 changes: 2 additions & 3 deletions internal/service/user/register.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package user

import (
"strconv"
"time"

"github.com/TensoRaws/NuxBT-Backend/dal/model"
Expand All @@ -24,7 +23,7 @@ type RegisterRequest struct {

type RegisterDataResponse struct {
Email string `json:"email"`
UserID string `json:"user_id"`
UserID int32 `json:"user_id"`
Username string `json:"username"`
}

Expand Down Expand Up @@ -77,7 +76,7 @@ func Register(c *gin.Context) {

util.OKWithData(c, RegisterDataResponse{
Email: user.Email,
UserID: strconv.FormatInt(int64(user.UserID), 10),
UserID: user.UserID,
Username: user.Username,
})
log.Logger.Info("register success: " + util.StructToString(user))
Expand Down

0 comments on commit b023e97

Please sign in to comment.