Skip to content

Commit

Permalink
Remove BaseModel
Browse files Browse the repository at this point in the history
  • Loading branch information
David Zhang committed Aug 23, 2024
1 parent 47321fd commit 8c54485
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 7 additions & 7 deletions app/models/base_model.go → app/models/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (

type IdType int64

type BaseModel struct {
ID IdType `gorm:"primarykey" json:"id"`
// type BaseModel struct {
// ID IdType `gorm:"primarykey" json:"id"`

CreatedAt Timestamp `json:"created_at"`
UpdatedAt Timestamp `json:"updated_at"`
// CreatedAt Timestamp `json:"created_at"`
// UpdatedAt Timestamp `json:"updated_at"`

// Disable `DeletedAt` by default
// DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
// // Disable `DeletedAt` by default
// // DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
// }

type PolyModel interface {
PolyId() IdType
Expand Down
5 changes: 4 additions & 1 deletion app/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

type User struct {
BaseModel
ID IdType `gorm:"primarykey" json:"id"`

Nickname string `json:"nickname"`
Username string `json:"username"`
Expand All @@ -16,6 +16,9 @@ type User struct {
APIToken string `json:"api_token"`
EncryptedPassword string `json:"-"`
Balance services.PriceCent `json:"balance"`

CreatedAt Timestamp `json:"created_at"`
UpdatedAt Timestamp `json:"updated_at"`
}

func (u User) TableName() string { return "users" }
Expand Down

0 comments on commit 8c54485

Please sign in to comment.