models

package
v0.0.0-...-d6be14c Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	gorm.Model
	UUID            string `gorm:"unique; not null;"`
	Email           string `gorm:"unique; not null;"`
	Password        string
	IsEmailVerified bool `gorm:"default:false;"`
}

func (*Account) Create

func (account *Account) Create() *gorm.DB

func (Account) DeleteByIDs

func (Account) DeleteByIDs(ids []interface{}) *gorm.DB

func (*Account) ReadByEmail

func (account *Account) ReadByEmail() *gorm.DB

func (Account) ReadByEmails

func (Account) ReadByEmails(emails []interface{}, list *[]Account) *gorm.DB

func (*Account) ReadByUUID

func (account *Account) ReadByUUID() *gorm.DB

func (*Account) UpdateByEmailAndUUID

func (account *Account) UpdateByEmailAndUUID(m map[string]interface{}) *gorm.DB

func (*Account) UpdateIsEmailVerifiedToTrueByAccountUUID

func (account *Account) UpdateIsEmailVerifiedToTrueByAccountUUID() *gorm.DB

func (*Account) UpdatePasswordByEmail

func (account *Account) UpdatePasswordByEmail(password string) *gorm.DB

type AccountOauthInfo

type AccountOauthInfo struct {
	gorm.Model
	AccountID   uint   `gorm:"not null"`
	AccountUUID string `gorm:"not null"`
	Provider    string `gorm:"not null"`
	Email       string `gorm:"not null"`
}

func (*AccountOauthInfo) Create

func (accountOAuthInfo *AccountOauthInfo) Create() *gorm.DB

func (AccountOauthInfo) DeleteByAccountIDs

func (AccountOauthInfo) DeleteByAccountIDs(ids []interface{}) *gorm.DB

func (AccountOauthInfo) ReadAllByAccountUUID

func (a AccountOauthInfo) ReadAllByAccountUUID(accountUUID string, list *[]AccountOauthInfo) *gorm.DB

func (*AccountOauthInfo) ReadByEmailAndProvider

func (accountOAuthInfo *AccountOauthInfo) ReadByEmailAndProvider() *gorm.DB

type AccountProfile

type AccountProfile struct {
	gorm.Model
	AccountID   uint   `gorm:"unique; not null;"`
	AccountUUID string `gorm:"unique; not null;"`
	Avatar      string
	Banner      string
	Signature   string
}

func (*AccountProfile) Create

func (accountProfile *AccountProfile) Create() *gorm.DB

func (AccountProfile) DeleteByAccountIDs

func (AccountProfile) DeleteByAccountIDs(ids []interface{}) *gorm.DB

func (AccountProfile) ReadAllByAccountUUIDs

func (AccountProfile) ReadAllByAccountUUIDs(accountUuids []interface{}, list *[]AccountProfile) *gorm.DB

func (*AccountProfile) ReadByAccountUUID

func (accountProfile *AccountProfile) ReadByAccountUUID() *gorm.DB

func (*AccountProfile) UpdateByAccountUUID

func (accountProfile *AccountProfile) UpdateByAccountUUID(m map[string]interface{}) *gorm.DB

type AccountProfileSocialMedia

type AccountProfileSocialMedia struct {
	ID          uint   `gorm:"primarykey"`
	AccountID   uint   `gorm:"not null"`
	AccountUUID string `gorm:"not null"`
	Provider    string `gorm:"not null"`
	UserName    string `gorm:"not null"`
}

func (AccountProfileSocialMedia) DeleteByAccountIDs

func (AccountProfileSocialMedia) DeleteByAccountIDs(ids []interface{}) *gorm.DB

func (AccountProfileSocialMedia) ReadAllByAccountUUID

func (a AccountProfileSocialMedia) ReadAllByAccountUUID(accountUUID string, list *[]AccountProfileSocialMedia) *gorm.DB

func (*AccountProfileSocialMedia) UpdateOrCreateByAccountUUIDAndProvider

func (accountProfileSocialMedia *AccountProfileSocialMedia) UpdateOrCreateByAccountUUIDAndProvider(m map[string]interface{}) *gorm.DB

type AccountSetting

type AccountSetting struct {
	gorm.Model
	AccountID   uint   `gorm:"unique; not null;"`
	AccountUUID string `gorm:"unique; not null;"`
	Name        string
	Locale      string
}

func (*AccountSetting) Create

func (accountSetting *AccountSetting) Create() *gorm.DB

func (AccountSetting) DeleteByAccountIDs

func (AccountSetting) DeleteByAccountIDs(ids []interface{}) *gorm.DB

func (AccountSetting) ReadAllByAccountUUIDs

func (AccountSetting) ReadAllByAccountUUIDs(accountUuids []interface{}, list *[]AccountSetting) *gorm.DB

func (*AccountSetting) ReadByAccountUUID

func (accountSetting *AccountSetting) ReadByAccountUUID() *gorm.DB

func (*AccountSetting) UpdateByAccountUUID

func (accountSetting *AccountSetting) UpdateByAccountUUID(m map[string]interface{}) *gorm.DB

type AccountSettingNotification

type AccountSettingNotification struct {
	ID                      uint   `gorm:"primarykey"`
	AccountID               uint   `gorm:"unique; not null;"`
	AccountUUID             string `gorm:"unique; not null;"`
	FollowOrOwnArticleReply uint   `gorm:"default:1"`
	CommentTagged           bool   `gorm:"default:true"`
	ArticleTweet            bool   `gorm:"default:true"`
	CommentTweet            bool   `gorm:"default:true"`
	InterestRecommendation  bool   `gorm:"default:true"`
	Chat                    bool   `gorm:"default:true"`
	Followed                bool   `gorm:"default:true"`
}

func (*AccountSettingNotification) Create

func (accountSettingNotification *AccountSettingNotification) Create() *gorm.DB

func (AccountSettingNotification) DeleteByAccountIDs

func (AccountSettingNotification) DeleteByAccountIDs(ids []interface{}) *gorm.DB

func (*AccountSettingNotification) ReadByAccountUUID

func (accountSettingNotification *AccountSettingNotification) ReadByAccountUUID() *gorm.DB

func (*AccountSettingNotification) UpdateByAccountUUID

func (accountSettingNotification *AccountSettingNotification) UpdateByAccountUUID(m map[string]interface{}) *gorm.DB

type AuthAccountEmailVerification

type AuthAccountEmailVerification struct {
	AccountUUID string
	Token       string
	Code        string
	Result      string
}

Redis

func (*AuthAccountEmailVerification) Create

func (aaev *AuthAccountEmailVerification) Create() error

func (*AuthAccountEmailVerification) Delete

func (aaev *AuthAccountEmailVerification) Delete() error

func (*AuthAccountEmailVerification) IsMatch

func (aaev *AuthAccountEmailVerification) IsMatch() bool

func (*AuthAccountEmailVerification) Read

func (aaev *AuthAccountEmailVerification) Read() error

func (*AuthAccountEmailVerification) Update

func (aaev *AuthAccountEmailVerification) Update() error

type AuthAccountResetPassword

type AuthAccountResetPassword struct {
	AccountUUID string
	Token       string
	Code        string
	Result      string
}

Redis

func (*AuthAccountResetPassword) Create

func (aarp *AuthAccountResetPassword) Create() error

func (*AuthAccountResetPassword) Delete

func (aarp *AuthAccountResetPassword) Delete() error

func (*AuthAccountResetPassword) IsMatch

func (aarp *AuthAccountResetPassword) IsMatch() bool

func (*AuthAccountResetPassword) Read

func (aarp *AuthAccountResetPassword) Read() error

func (*AuthAccountResetPassword) Update

func (aarp *AuthAccountResetPassword) Update() error

type AuthCaptcha

type AuthCaptcha struct {
	UUID string
	Code string
}

Redis

func (*AuthCaptcha) Create

func (ac *AuthCaptcha) Create() error

func (*AuthCaptcha) Delete

func (ac *AuthCaptcha) Delete() error

func (*AuthCaptcha) ReadByUUID

func (ac *AuthCaptcha) ReadByUUID() error

func (*AuthCaptcha) UpdateByUUID

func (ac *AuthCaptcha) UpdateByUUID() error

type AuthChatWS

type AuthChatWS struct {
	AccountUUID string
	Token       string
}

func (*AuthChatWS) Create

func (acws *AuthChatWS) Create() error

func (*AuthChatWS) Delete

func (acws *AuthChatWS) Delete() error

func (*AuthChatWS) Read

func (acws *AuthChatWS) Read() error

type ChatMessage

type ChatMessage struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	From      string
	To        uint
	Type      string
	Content   string
	Timestamp time.Time
}

func (ChatMessage) FindByTo

func (ChatMessage) FindByTo(to uint) ([]*ChatMessage, error)

func (*ChatMessage) InsertOne

func (m *ChatMessage) InsertOne() (*mongo.InsertOneResult, error)

type ChatRoom

type ChatRoom struct {
	gorm.Model
	Type             string `gorm:"not null;"`
	MaximumMemberNum int    `gorm:"default:50;not null;"`
	Emoji            string
	Name             string
	Avatar           string
}

func (*ChatRoom) Create

func (cr *ChatRoom) Create() *gorm.DB

func (ChatRoom) ReadAllByIDs

func (ChatRoom) ReadAllByIDs(ids []interface{}, list *[]ChatRoom) *gorm.DB

func (*ChatRoom) UpdateByID

func (cr *ChatRoom) UpdateByID(m map[string]interface{}) *gorm.DB

type ChatRoomInviteCode

type ChatRoomInviteCode struct {
	Code       string
	ChatRoomID uint
}

Redis

func (*ChatRoomInviteCode) Create

func (cric *ChatRoomInviteCode) Create() error

func (*ChatRoomInviteCode) Read

func (cric *ChatRoomInviteCode) Read() error

type ChatRoomMember

type ChatRoomMember struct {
	ID                  uint   `gorm:"primarykey"`
	ChatRoomID          uint   `gorm:"not null;"`
	AccountUUID         string `gorm:"not null;"`
	Theme               string
	EnabledNotification bool `gorm:"default:true; not null;"`
	LastSeenAt          time.Time
}

func (*ChatRoomMember) Create

func (acr *ChatRoomMember) Create() *gorm.DB

func (ChatRoomMember) ReadAllByAccountUUID

func (acr ChatRoomMember) ReadAllByAccountUUID(accountUUID string, list *[]ChatRoomMember) *gorm.DB

func (ChatRoomMember) ReadAllByChatRoomID

func (acr ChatRoomMember) ReadAllByChatRoomID(chatRoomID uint, list *[]ChatRoomMember) *gorm.DB

func (ChatRoomMember) ReadAllByChatRoomIDs

func (acr ChatRoomMember) ReadAllByChatRoomIDs(ids []interface{}, list *[]ChatRoomMember) *gorm.DB

func (*ChatRoomMember) ReadByChatRoomIDAndAccountUUID

func (acr *ChatRoomMember) ReadByChatRoomIDAndAccountUUID() *gorm.DB

func (*ChatRoomMember) UpdateByChatRoomIDAndAccountUUID

func (acr *ChatRoomMember) UpdateByChatRoomIDAndAccountUUID(m map[string]interface{}) *gorm.DB

type Forum

type Forum struct {
	MongoDBModel  `bson:",inline"`
	Name          string
	Icon          string
	Banner        string
	Rule          string
	Description   string
	PopularTopics []string `bson:"popular_topics"`
}

func (Forum) Find

func (Forum) Find() ([]Forum, error)

func (*Forum) FindOneByID

func (f *Forum) FindOneByID() error

func (*Forum) FindOneByName

func (f *Forum) FindOneByName() error

func (*Forum) InsertOne

func (f *Forum) InsertOne() (*mongo.InsertOneResult, error)

func (*Forum) UpdateByID

func (f *Forum) UpdateByID(bsonM bson.M) error

type JWTToken

type JWTToken struct {
	AccountID   uint
	AccountUUID string
	Email       string
	jwt.StandardClaims
}

func ParseJWTToken

func ParseJWTToken(tk string) (*JWTToken, error)

func (*JWTToken) Generate

func (tk *JWTToken) Generate() (string, error)

type MongoDBModel

type MongoDBModel struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	CreatedAt time.Time          `bson:"created_at"`
	UpdatedAt time.Time          `bson:"updated_at"`
	DeletedAt *time.Time         `bson:"deleted_at"`
}

作為匿名 nested struct 到各個 struct 時,該 struct 名稱不能是 package level (小寫開頭),要大寫開頭才能正常運作 若該 nested struct 要和其他 struct 同層級的話,要加上 bson inline tag 例如:

type TestingStruct struct {
	MongoDBModel `bson:",inline"`
	Name         string `bson:"name"`
}

type Post

type Post struct {
	MongoDBModel  `bson:",inline"`
	AccountID     uint               `bson:"account_id"`
	IsAnonymous   bool               `bson:"is_anonymous"`
	ForumID       primitive.ObjectID `bson:"forum_id"`
	Type          string
	Title         string
	Content       string
	Thumbnail     string
	MasterVision  string `bson:"master_vision"`
	CommentCount  int    `bson:"comment_count"`
	Topics        []string
	ReactionStats map[string]int `bson:"reaction_stats"`
}

func (*Post) InsertOne

func (p *Post) InsertOne() (*mongo.InsertOneResult, error)

type PostComment

type PostComment struct {
	MongoDBModel `bson:",inline"`
	PostID       primitive.ObjectID `bson:"post_id"`
	AccountID    uint               `bson:"account_id"`
	LikeCount    int                `bson:"like_count"`
	Content      string
}

type PostFavorite

type PostFavorite struct {
	MongoDBModel `bson:",inline"`
	PostID       primitive.ObjectID `bson:"post_id"`
	AccountID    uint               `bson:"account_id"`
}

type PostFollowed

type PostFollowed struct {
	MongoDBModel `bson:",inline"`
	PostID       primitive.ObjectID `bson:"post_id"`
	AccountID    uint               `bson:"account_id"`
}

type PostReaction

type PostReaction struct {
	MongoDBModel `bson:",inline"`
	AccountID    uint               `bson:"account_id"`
	PostID       primitive.ObjectID `bson:"post_id"`
	Type         string
}

type Session

type Session struct {
	AccountID   uint
	AccountUUID string
	Email       string
	Token       string
}

Redis

func (*Session) Create

func (s *Session) Create() error

func (*Session) Delete

func (s *Session) Delete() error

func (*Session) ReadByAccount

func (s *Session) ReadByAccount() error

func (*Session) ReadByToken

func (s *Session) ReadByToken() error

type Topic

type Topic struct {
	MongoDBModel  `bson:",inline"`
	Name          string
	PostCount     int `bson:"post_count"`
	FollowedCount int `bson:"followed_count"`
}

type TopicFollowed

type TopicFollowed struct {
	MongoDBModel `bson:",inline"`
	TopicID      primitive.ObjectID `bson:"topic_id"`
	AccountID    uint               `bson:"account_id"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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