model

package
v0.0.0-...-dffa276 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 1 Imported by: 42

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Id              uint      `json:"id"`
	Name            string    `json:"name",sql:"size:255"`
	Key             string    `json:"name",sql:"size:255"`
	Token           string    `json:"token"`
	TokenExpiration time.Time `json:"tokenExperiation"`
}

type Article

type Article struct {
	Id             uint        `json:"id"`
	Title          string      `json:"title",sql:"size:255"`
	Url            string      `json:"url",sql:"size:512"`
	Content        string      `json:"content"`
	UserId         uint        `json:"userId"`
	Author         User        `json:"author"`
	ReferralId     uint        `json:"referralId"`
	ReferralUserId uint        `json:"referralUserId"`
	CategoryId     int         `json:"categoryId"`
	PrevId         uint        `json:"prevId"`
	NextId         uint        `json:"nextId"`
	LikingCount    int         `json:"likingCount"`
	CommentCount   int         `json:"commentCount"`
	SharingCount   int         `json:"sharingCount"`
	ImageName      string      `json:"imageName",sql:"size:512"`
	ThumbnailName  string      `json:"thumbnailName",sql:"size:512"`
	Activate       bool        `json:"active"`
	CreatedAt      time.Time   `json:"createdAt"`
	UpdatedAt      time.Time   `json:"updatedAt"`
	DeletedAt      *time.Time  `json:"deletedAt"`
	Comments       []Comment   `gorm:"many2many:articles_comments;association_autoupdate:false;association_autocreate:false"`
	CommentList    CommentList `json:"commentList"`
	Likings        []User      `gorm:"many2many:articles_users;association_autoupdate:false;association_autocreate:false"`
	LikingList     LikingList  `json:"likingList"`
}

Article is a article model.

type ArticleList

type ArticleList struct {
	Articles    []Article `json:"articles"`
	Category    int       `json:"category"`
	HasPrev     bool      `json:"hasPrev"`
	HasNext     bool      `json:"hasNext"`
	Count       int       `json:"count"`
	CurrentPage int       `json:"currentPage"`
	PerPage     int       `json:"perPage"`
}

ArticleList is list that contains articles and meta.

type Comment

type Comment struct {
	Id          uint       `json:"id"`
	Content     string     `json:"content"`
	UserId      uint       `json:"userId"`
	LikingCount int        `json:"likingCount"`
	CreatedAt   time.Time  `json:"createdAt"`
	UpdatedAt   time.Time  `json:"updatedAt"`
	DeletedAt   *time.Time `json:"deletedAt"`
	User        User       `json:"user"`
}

Comment is a comment model.

type CommentList

type CommentList struct {
	Comments    []Comment `json:"comments"`
	HasPrev     bool      `json:"hasPrev"`
	HasNext     bool      `json:"hasNext"`
	Count       int       `json:"count"`
	CurrentPage int       `json:"currentPage"`
}

CommentList is list that contains comments and meta.

type Connection

type Connection struct {
	Id             uint   `json:"id"`
	UserId         uint   `json:"userId"`
	ProviderId     uint   `gorm:"column:provider_id", json:"providerId"`
	ProviderUserId string `gorm:"column:provider_user_id", json:"providerUserId"`
	AccessToken    string `json:"accessToken"`
	ProfileUrl     string `gorm:"column:profile_url", json:"profileUrl"`
	ImageUrl       string `gorm:"column:image_url", json:"imageUrl"`
}

Connection is a connection model for oauth.

type ExpiredTokenLog

type ExpiredTokenLog struct {
	UserId     uint      `json:"userId"`
	AccessedAt time.Time `json:"activatedAt"`
}

type File

type File struct {
	Id        uint      `json:"id"`
	UserId    uint      `json:"userId"`
	Name      string    `json:"name",sql:"size:255"`
	Size      int       `json:"size",sql:"size:255"`
	CreatedAt time.Time `json:"createdAt"`
}

File is a file model that contains meta.

type Image

type Image struct {
	Id        uint      `json:"id"`
	Kind      int       `json:"kind"`
	Large     string    `json:"large"`
	Medium    string    `json:"medium"`
	Thumbnail string    `json:"thumbnail"`
	CreatedAt time.Time `json:"createdAt"`
}

Image is a image model.

type Language

type Language struct {
	Id   uint   `json:"id"`
	Name string `json:"name"`
}

Language is a language model.

type LikedList

type LikedList struct {
	Liked       []User `json:"liked"`
	HasPrev     bool   `json:"hasPrev"`
	HasNext     bool   `json:"hasNext"`
	Count       int    `json:"count"`
	CurrentPage int    `json:"currentPage"`
}

LikedList is list that contains liked and meta.

type LikingList

type LikingList struct {
	Likings     []User `json:"likings"`
	HasPrev     bool   `json:"hasPrev"`
	HasNext     bool   `json:"hasNext"`
	Count       int    `json:"count"`
	CurrentPage int    `json:"currentPage"`
	IsLiked     bool   `json:"isLiked"`
}

LikingList is list that contains likings and meta.

type Link struct {
	Id        uint      `json:"id"`
	Kind      int       `json:"kind"`
	Name      string    `json:"title",sql:"size:255"`
	Url       string    `json:"url",sql:"size:512"`
	CreatedAt time.Time `json:"createdAt"`
	Icon      string    `json:"icon",sql:"size:255"`
}

Link is a link model.

type PublicUser

type PublicUser struct {
	*User
	Email           omit `json:"email,omitempty",sql:"size:255;unique"`
	Password        omit `json:"password,omitempty",sql:"size:255"`
	Name            omit `json:"name,omitempty",sql:"size:255"`
	Birthday        omit `json:"birthday,omitempty"`
	Gender          omit `json:"gender,omitempty"`
	Token           omit `json:"token,omitempty"`
	TokenExpiration omit `json:"tokenExperiation,omitempty"`

	// admin
	Activation         omit `json:"activation,omitempty"`
	PasswordResetToken omit `json:"passwordResetToken,omitempty"`
	ActivationToken    omit `json:"activationToken,omitempty"`
	PasswordResetUntil omit `json:"passwordResetUntil,omitempty"`
	ActivateUntil      omit `json:"activateUntil,omitempty"`
	ActivatedAt        omit `json:"activatedAt,omitempty"`
	UpdatedAt          omit `json:"updatedAt,omitempty"`
	DeletedAt          omit `json:"deletedAt,omitempty"`
	LastLoginAt        omit `json:"lastLoginAt,omitempty"`
	CurrentLoginAt     omit `json:"currentLoginAt,omitempty"`
	LastLoginIp        omit `json:"lastLoginIp,omitempty",sql:"size:100"`
	CurrentLoginIp     omit `json:"currentLoginIp,omitempty",sql:"size:100"`

	Connections omit `json:"connections,omitempty"`
	Languages   omit `json:"languages,omitempty"`
	Roles       omit `json:"roles,omitempty"`
	Articles    omit `json:"articles,omitempty"`
}

PublicUser is a public user model that contains only a few information for everyone.

type Role

type Role struct {
	Id          uint   `json:"id"`
	Name        string `json:"name",sql:"size:255"`
	Description string `json:"description",sql:"size:255"`
}

Role is a role model for user permission.

type Tag

type Tag struct {
	Id   uint   `json:"id"`
	Name string `json:"name",sql:"size:255"`
}

Tag is a tag model.

type User

type User struct {
	Id              uint      `json:"id"`
	AppId           uint      `json:"appId"`
	Email           string    `json:"email",sql:"size:255;unique"`
	Password        string    `json:"password",sql:"size:255"`
	Name            string    `json:"name",sql:"size:255"`
	Username        string    `json:"username",sql:"size:255;unique"`
	Birthday        time.Time `json:"birthday"`
	Gender          int8      `json:"gender"`
	Description     string    `json:"description",sql:"size:100"`
	Token           string    `json:"token"`
	TokenExpiration time.Time `json:"tokenExperiation"`

	// email md5 for gravatar
	Md5 string `json:"md5"`

	// admin
	Activation         bool       `json:"activation"`
	PasswordResetToken string     `json:"passwordResetToken"`
	ActivationToken    string     `json:"activationToken"`
	PasswordResetUntil time.Time  `json:"passwordResetUntil"`
	ActivateUntil      time.Time  `json:"activateUntil"`
	ActivatedAt        time.Time  `json:"activatedAt"`
	CreatedAt          time.Time  `json:"createdAt"`
	UpdatedAt          time.Time  `json:"updatedAt"`
	DeletedAt          *time.Time `json:"deletedAt"`
	LastLoginAt        time.Time  `json:"lastLoginAt"`
	CurrentLoginAt     time.Time  `json:"currentLoginAt"`
	LastLoginIp        string     `json:"lastLoginIp",sql:"size:100"`
	CurrentLoginIp     string     `json:"currentLoginIp",sql:"size:100"`

	// Liking
	LikingCount int `json:"likingCount"`
	LikedCount  int `json:"likedCount"`
	// Likings     []User     `gorm:"foreignkey:userId;associationforeignkey:follower_id;many2many:users_followers;"`
	Likings []User
	Liked   []User
	// Liked   []User `gorm:"many2many:users_followers;foreignkey:follower_id;associationforeignkey:user_id;"`
	// Liked      []User     `gorm:"foreignkey:follower_id;associationforeignkey:userId;many2many:users_followers;"`
	LikingList LikingList `json:"likingList"`
	LikedList  LikedList  `json:"likedList"`

	Connections []Connection
	Languages   []Language `gorm:"many2many:user_languages;"` // Many To Many, user_languages is the join table
	Roles       []Role     `gorm:"many2many:users_roles;"`    // Many To Many, users_roles

}

User is a user model

type UsersFollowers

type UsersFollowers struct {
	UserID     uint `json:"user_id"`
	FollowerID uint `json:"follower_id"`
}

UsersFollowers is a relation table to relate users each other.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL