Cleanup of user model
Cette révision appartient à :
Parent
254bf42ffb
révision
5d57233882
1 fichiers modifiés avec 16 ajouts et 16 suppressions
|
@ -4,9 +4,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// omit is the bool type for omitting a field of struct.
|
|
||||||
type omit bool
|
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
Id uint `gorm:"column:user_id;primary_key"`
|
Id uint `gorm:"column:user_id;primary_key"`
|
||||||
Username string `gorm:"column:username"`
|
Username string `gorm:"column:username"`
|
||||||
|
@ -15,19 +12,18 @@ type User struct {
|
||||||
Status int `gorm:"column:status"`
|
Status int `gorm:"column:status"`
|
||||||
CreatedAt time.Time `gorm:"column:created_at"`
|
CreatedAt time.Time `gorm:"column:created_at"`
|
||||||
UpdatedAt time.Time `gorm:"column:updated_at"`
|
UpdatedAt time.Time `gorm:"column:updated_at"`
|
||||||
/*Api*/Token string `gorm:"column:api_token"`
|
Token string `gorm:"column:api_token"`
|
||||||
//ApiTokenExpiry
|
|
||||||
|
|
||||||
// Liking
|
|
||||||
LikingCount int `json:"likingCount"`
|
|
||||||
LikedCount int `json:"likedCount"`
|
|
||||||
Likings []User `gorm:"foreignkey:userId;associationforeignkey:follower_id;many2many:users_followers;"`
|
|
||||||
Liked []User `gorm:"foreignkey:follower_id;associationforeignkey:userId;many2many:users_followers;"`
|
|
||||||
|
|
||||||
Md5 string `json:"md5"`
|
|
||||||
TokenExpiration time.Time `gorm:"column:api_token_expiry"`
|
TokenExpiration time.Time `gorm:"column:api_token_expiry"`
|
||||||
Language string `gorm:"column:language"`
|
Language string `gorm:"column:language"`
|
||||||
Torrents []Torrents `gorm:"ForeignKey:UploaderId"`
|
|
||||||
|
// TODO: move this to PublicUser
|
||||||
|
LikingCount int `json:"likingCount" gorm:"-"`
|
||||||
|
LikedCount int `json:"likedCount" gorm:"-"`
|
||||||
|
Likings []User `gorm:"foreignkey:userId;associationforeignkey:follower_id;many2many:users_followers;"`
|
||||||
|
Liked []User `gorm:"foreignkey:follower_id;associationforeignkey:userId;many2many:users_followers;"`
|
||||||
|
|
||||||
|
Md5 string `json:"md5" gorm:"-"`
|
||||||
|
Torrents []Torrents `gorm:"ForeignKey:UploaderId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PublicUser struct {
|
type PublicUser struct {
|
||||||
|
@ -36,6 +32,10 @@ type PublicUser struct {
|
||||||
|
|
||||||
// UsersFollowers is a relation table to relate users each other.
|
// UsersFollowers is a relation table to relate users each other.
|
||||||
type UsersFollowers struct {
|
type UsersFollowers struct {
|
||||||
UserID uint `gorm:"column:userId"`
|
UserID uint `gorm:"column:user_id"`
|
||||||
FollowerID uint `gorm:"column:follower_id"`
|
FollowerID uint `gorm:"column:following"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c UsersFollowers) TableName() string {
|
||||||
|
return "user_follows"
|
||||||
}
|
}
|
||||||
|
|
Référencer dans un nouveau ticket