diff --git a/internal/db/seeders/user_seeder.go b/internal/db/seeders/user_seeder.go index 559ed8f..074ab85 100644 --- a/internal/db/seeders/user_seeder.go +++ b/internal/db/seeders/user_seeder.go @@ -15,7 +15,7 @@ func NewUserSeeder(db *gorm.DB) *UserSeeder { } func (userSeeder *UserSeeder) SetUsers() { - users := map[int]map[string]string{ + users := map[int64]map[string]string{ 1: { "email": "user1@example.com", "name": "user1", @@ -33,7 +33,7 @@ func (userSeeder *UserSeeder) SetUsers() { userSeeder.DB.First(&user, key) if user.ID == 0 { - user.ID = uint(key) + user.ID = key user.Email = value["email"] user.Name = value["name"] user.Password = value["password"] diff --git a/internal/models/post.go b/internal/models/post.go index ba49de0..0dfb184 100644 --- a/internal/models/post.go +++ b/internal/models/post.go @@ -6,6 +6,6 @@ type Post struct { gorm.Model Title string `json:"title" gorm:"type:text"` Content string `json:"content" gorm:"type:text"` - UserID uint + UserID int64 User User `gorm:"foreignkey:UserID"` } diff --git a/internal/responses/posts_response.go b/internal/responses/posts_response.go index dc597a4..3bf1dec 100644 --- a/internal/responses/posts_response.go +++ b/internal/responses/posts_response.go @@ -8,7 +8,7 @@ type PostResponse struct { Title string `json:"title" example:"Echo"` Content string `json:"content" example:"Echo is nice!"` Username string `json:"username" example:"John Doe"` - ID uint `json:"id" example:"1"` + ID int64 `json:"id" example:"1"` } func NewPostResponse(posts []models.Post) *[]PostResponse { diff --git a/internal/services/token/create_access_token.go b/internal/services/token/create_access_token.go index 4393ecb..a6e19f2 100644 --- a/internal/services/token/create_access_token.go +++ b/internal/services/token/create_access_token.go @@ -10,9 +10,9 @@ import ( func (tokenService *Service) CreateAccessToken(user *models.User) (t string, expired int64, err error) { exp := time.Now().Add(time.Hour * ExpireCount) claims := &JwtCustomClaims{ - user.Name, - user.ID, - jwt.RegisteredClaims{ + Name: user.Name, + ID: user.ID, + RegisteredClaims: jwt.RegisteredClaims{ ExpiresAt: jwt.NewNumericDate(exp), }, } diff --git a/internal/services/token/service.go b/internal/services/token/service.go index 0b1e55e..b78d94b 100644 --- a/internal/services/token/service.go +++ b/internal/services/token/service.go @@ -12,12 +12,12 @@ const ExpireRefreshCount = 168 type JwtCustomClaims struct { Name string `json:"name"` - ID uint `json:"id"` + ID int64 `json:"id"` jwt.RegisteredClaims } type JwtCustomRefreshClaims struct { - ID uint `json:"id"` + ID int64 `json:"id"` jwt.RegisteredClaims }