models

package
v0.0.0-...-a36a601 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	ID    int     `json:"id" gorm:"primaryKey" example:"1"`
	Type  string  `json:"type" example:"private"` // private, group
	Users []*User `json:"users,omitempty" gorm:"many2many:chat_users"`
}

type ChatRepository

type ChatRepository interface {
	FindByID(id int) (*Chat, error)
	FindByUserID(id int) (*[]Chat, error)
	FindPrivateChatByUsersArray(users []*User) (*Chat, error)
	Create(chat *Chat) error
	Update(chat *Chat) error
	Delete(chat *Chat) error
}

type Device

type Device struct {
	ID        int       `json:"id" gorm:"primaryKey" example:"1"`
	UserID    int       `json:"userId" example:"1"`
	Type      string    `json:"type" example:"web"` // web, android, ios
	Name      string    `json:"name" example:"Chrome 90.0.4430.212 (Linux x86_64)"`
	Token     string    `` /* 186-byte string literal not displayed */
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

type Message

type Message struct {
	ID        int    `json:"id" gorm:"primaryKey" example:"1"`
	Type      string `json:"type" example:"text"` // text, error, system
	ChatID    int    `json:"chatId,omitempty" gorm:"foreignKey:ChatID" example:"1"`
	Content   string `json:"content" example:"bla-bla-bla"`
	SenderID  int    `json:"senderId,omitempty" gorm:"foreignKey:SenderID" example:"2"`
	Sender    User   `json:"sender,omitempty"`
	Status    string `json:"status,omitempty" example:"sent"` // sent, delivered, read
	CreatedAt int64  `json:"createdAt,omitempty" example:"1620000000"`
}

type MessageRepository

type MessageRepository interface {
	FindByID(id int) (*Message, error)
	FindAll() (*[]Message, error)
	Create(message *Message) error
	Update(message *Message) error
	GetMessages(chatID, from, limit int) (*[]Message, error)
}

type User

type User struct {
	ID            int       `json:"id" gorm:"primaryKey" example:"1"`
	Username      string    `json:"username" gorm:"unique" example:"username"`
	Password      string    `json:"-"`
	Image         string    `json:"image" example:"image.png"`
	FollowedUsers []*User   `json:"followedUsers,omitempty" gorm:"many2many:followed_users"`
	BlockedUsers  []*User   `json:"blockedUsers,omitempty" gorm:"many2many:blocked_users"`
	Chats         []*Chat   `json:"chats,omitempty" gorm:"many2many:chat_users"`
	Devices       []*Device `json:"devices,omitempty"`
	IsOnline      bool      `json:"isOnline,omitempty" gorm:"default:false" example:"true"`
	CreatedAt     time.Time `json:"-"`
	UpdatedAt     time.Time `json:"updatedAt,omitempty" example:"2024-01-01T12:00:00.000Z"`
}

type UserRepository

type UserRepository interface {
	FindAll() (*[]User, error)
	FindByID(id int) (*User, error)
	FindByUsername(username string) (*User, error)
	FindArrayByPartUsername(username string, order string, limit int) (*[]User, error)
	Create(user *User) error
	Update(user *User) error
	UpdateWithAssociations(user *User) error
	Delete(user *User) error
	ReplaceFollowedUsers(user *User, followedUsers []*User) error
	ReplaceBlockedUsers(user *User, blockedUsers []*User) error
	ResetPassword(user *User, password string) error
	PasswordMatches(user *User, plainText string) (bool, error)
}

Jump to

Keyboard shortcuts

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