mirror of
https://github.com/sigmasternchen/threadule
synced 2025-03-15 08:09:01 +00:00
fix: models now have sensible json names
This commit is contained in:
parent
87aab8b23b
commit
4d5fb6098f
6 changed files with 36 additions and 36 deletions
|
@ -4,16 +4,16 @@ import uuid "github.com/satori/go.uuid"
|
|||
|
||||
type Account struct {
|
||||
BaseModel
|
||||
UserID uuid.UUID
|
||||
User *User
|
||||
UserID uuid.UUID `json:"-"`
|
||||
User *User `json:"-"`
|
||||
|
||||
ScreenName string
|
||||
TwitterHandle string
|
||||
TwitterID *int64
|
||||
AvatarURL string
|
||||
ScreenName string `json:"screen_name"`
|
||||
TwitterHandle string `json:"twitter_handle"`
|
||||
TwitterID *int64 `json:"twitter_id"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
|
||||
RequestToken *string
|
||||
RequestSecret *string
|
||||
AccessToken *string
|
||||
AccessTokenSecret *string
|
||||
RequestToken *string `json:"-"`
|
||||
RequestSecret *string `json:"-"`
|
||||
AccessToken *string `json:"-"`
|
||||
AccessTokenSecret *string `json:"-"`
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ import (
|
|||
)
|
||||
|
||||
type BaseModel struct {
|
||||
ID uuid.UUID `gorm:"type:char(36);primary_key;"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
ID uuid.UUID `gorm:"type:char(36);primary_key;" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"-"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
func (b *BaseModel) BeforeCreate(_ *gorm.DB) error {
|
||||
|
|
|
@ -4,14 +4,14 @@ type Group struct {
|
|||
BaseModel
|
||||
Users []*User `gorm:"many2many:user_groups;"`
|
||||
|
||||
Name string
|
||||
DisplayName string
|
||||
AdminGroup bool
|
||||
ManageUsers bool
|
||||
ManageGroups bool
|
||||
LimitAccounts uint
|
||||
LimitThreads uint
|
||||
LimitTweets uint
|
||||
Name string `json:"name"`
|
||||
DisplayName string `json:"display_name"`
|
||||
AdminGroup bool `json:"admin_group"`
|
||||
ManageUsers bool `json:"manage_users"`
|
||||
ManageGroups bool `json:"manage_groups"`
|
||||
LimitAccounts uint `json:"limit_accounts"`
|
||||
LimitThreads uint `json:"limit_threads"`
|
||||
LimitTweets uint `json:"limit_tweets"`
|
||||
}
|
||||
|
||||
func GetDefaultAdminGroup() *Group {
|
||||
|
|
|
@ -16,11 +16,11 @@ const (
|
|||
|
||||
type Thread struct {
|
||||
BaseModel
|
||||
AccountID uuid.UUID
|
||||
Account *Account
|
||||
Tweets []Tweet
|
||||
AccountID uuid.UUID `json:"-"`
|
||||
Account *Account `json:"-"`
|
||||
Tweets []Tweet `json:"tweets"`
|
||||
|
||||
ScheduledFor time.Time
|
||||
Status ThreadStatus
|
||||
Error *string
|
||||
ScheduledFor time.Time `json:"scheduled_for"`
|
||||
Status ThreadStatus `json:"status"`
|
||||
Error *string `json:"error"`
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ const (
|
|||
|
||||
type Tweet struct {
|
||||
BaseModel
|
||||
ThreadID uuid.UUID
|
||||
ThreadID uuid.UUID `json:"-"`
|
||||
|
||||
Text string
|
||||
Ordinal int
|
||||
Status TweetStatus
|
||||
TweetID *int64
|
||||
Error *string
|
||||
Text string `json:"text"`
|
||||
Ordinal int `json:"ordinal"`
|
||||
Status TweetStatus `json:"status"`
|
||||
TweetID *int64 `json:"tweet_id"`
|
||||
Error *string `json:"error"`
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ type User struct {
|
|||
BaseModel
|
||||
Groups []*Group `gorm:"many2many:user_groups;"`
|
||||
|
||||
Username string
|
||||
Password string
|
||||
Username string `json:"username"`
|
||||
Password string `json:"-"`
|
||||
}
|
||||
|
||||
func GetDefaultAdminUser() *User {
|
||||
|
|
Loading…
Reference in a new issue