models

package
v0.0.0-...-501be23 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const PAGE_SIZE = 50

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	Id        int    `json:"id"`
	Title     string `json:"title"`
	CreatorId int    `json:"creatorId"`
	CreatedAt string `json:"createdAt"`
}

type ChatDTO

type ChatDTO struct {
	Title     string `json:"title"`
	CreatorId int    `json:"creatorId"`
}

type ChatFromRequest

type ChatFromRequest struct {
	Title string `json:"title"`
}

type ChatStorer

type ChatStorer struct {
	DB *sql.DB
}

func NewChatStorer

func NewChatStorer(db *sql.DB) ChatStorer

func (ChatStorer) Begin

func (cs ChatStorer) Begin() (*sql.Tx, error)

func (ChatStorer) Create

func (cs ChatStorer) Create(dto ChatDTO) (*Chat, error)

func (ChatStorer) CreateInTx

func (cs ChatStorer) CreateInTx(tx *sql.Tx, dto ChatDTO) (*Chat, error)

func (ChatStorer) Delete

func (cs ChatStorer) Delete(id int) (*Chat, error)

func (ChatStorer) GetOne

func (cs ChatStorer) GetOne(id int) (*Chat, error)

func (ChatStorer) GetUserChats

func (cs ChatStorer) GetUserChats(userId int) ([]Chat, error)

func (ChatStorer) Update

func (cs ChatStorer) Update(chat Chat) (*Chat, error)

type ChatUser

type ChatUser struct {
	Participant
	Name string `json:"name"`
}

type IChatStorer

type IChatStorer interface {
	Begin() (*sql.Tx, error)
	Create(dto ChatDTO) (*Chat, error)
	CreateInTx(tx *sql.Tx, dto ChatDTO) (*Chat, error)
	GetOne(id int) (*Chat, error)
	GetUserChats(userId int) ([]Chat, error)
	Update(chat Chat) (*Chat, error)
	Delete(id int) (*Chat, error)
}

type IMessageStorer

type IMessageStorer interface {
	Create(tdo MessageDTO) (*Message, error)
	GetOne(id int) (*Message, error)
	GetChatMessages(chatId, page int) ([]Message, error)
	Update(message Message) (*Message, error)
	Delete(id int) (*Message, error)
	DeleteAll(chatId int) (sql.Result, error)
}

type IParticipantStorer

type IParticipantStorer interface {
	Create(participant Participant) (*Participant, error)
	CreateInTx(tx *sql.Tx, participant Participant) (*Participant, error)
	GetOne(userId, chatId int) (*Participant, error)
	GetChatUsers(chatId int) ([]ChatUser, error)
	Update(participant Participant) (*Participant, error)
	Delete(participant Participant) (*Participant, error)
	DeleteAll(chatId int) (sql.Result, error)
}

type IUserStorer

type IUserStorer interface {
	GetOne(id int) (*User, error)
	Update(user User) (*User, error)
	Delete(id int) (*User, error)
}

type Message

type Message struct {
	Id        int    `json:"id"`
	SenderId  int    `json:"senderId"`
	ChatId    int    `json:"chatId"`
	Type      string `json:"type"`
	Content   string `json:"content"`
	CreatedAt string `json:"createdAt"`
}

type MessageDTO

type MessageDTO struct {
	SenderId int    `json:"senderId"`
	ChatId   int    `json:"chatId"`
	Type     string `json:"type"`
	Content  string `json:"content"`
}

type MessageFromRequest

type MessageFromRequest struct {
	ChatId  int    `json:"chatId"`
	Type    string `json:"type"`
	Content string `json:"content"`
}

type MessageStorer

type MessageStorer struct {
	DB *sql.DB
}

func NewMessageStorer

func NewMessageStorer(db *sql.DB) MessageStorer

func (MessageStorer) Create

func (cs MessageStorer) Create(tdo MessageDTO) (*Message, error)

func (MessageStorer) Delete

func (cs MessageStorer) Delete(id int) (*Message, error)

func (MessageStorer) DeleteAll

func (cs MessageStorer) DeleteAll(chatId int) (sql.Result, error)

func (MessageStorer) GetChatMessages

func (cs MessageStorer) GetChatMessages(chatId, page int) ([]Message, error)

func (MessageStorer) GetOne

func (cs MessageStorer) GetOne(id int) (*Message, error)

func (MessageStorer) Update

func (cs MessageStorer) Update(message Message) (*Message, error)

type Participant

type Participant struct {
	UserId int    `json:"userId"`
	ChatId int    `json:"chatId"`
	Role   string `json:"role"`
}

type ParticipantFromRequest

type ParticipantFromRequest struct {
	UserId int `json:"userId"`
	ChatId int `json:"chatId"`
}

type ParticipantStorer

type ParticipantStorer struct {
	DB *sql.DB
}

func NewParticipantStorer

func NewParticipantStorer(db *sql.DB) ParticipantStorer

func (ParticipantStorer) Create

func (ps ParticipantStorer) Create(participant Participant) (*Participant, error)

func (ParticipantStorer) CreateInTx

func (ps ParticipantStorer) CreateInTx(tx *sql.Tx, participant Participant) (*Participant, error)

func (ParticipantStorer) Delete

func (ps ParticipantStorer) Delete(participant Participant) (*Participant, error)

func (ParticipantStorer) DeleteAll

func (ps ParticipantStorer) DeleteAll(chatId int) (sql.Result, error)

func (ParticipantStorer) GetChatUsers

func (ps ParticipantStorer) GetChatUsers(chatId int) ([]ChatUser, error)

func (ParticipantStorer) GetOne

func (ps ParticipantStorer) GetOne(userId, chatId int) (*Participant, error)

func (ParticipantStorer) Update

func (ps ParticipantStorer) Update(participant Participant) (*Participant, error)

type User

type User struct {
	Id          int    `json:"id"`
	Tag         string `json:"tag"`
	Name        string `json:"name"`
	Password    string `json:"password"`
	Description string `json:"description"`
}

type UserDTO

type UserDTO struct {
	Tag         string `json:"tag"`
	Name        string `json:"name"`
	Password    string `json:"password"`
	Description string `json:"description"`
}

type UserStorer

type UserStorer struct {
	DB *sql.DB
}

func NewUserStorer

func NewUserStorer(db *sql.DB) UserStorer

func (UserStorer) Delete

func (us UserStorer) Delete(id int) (*User, error)

func (UserStorer) GetOne

func (us UserStorer) GetOne(id int) (*User, error)

func (UserStorer) Update

func (us UserStorer) Update(user User) (*User, error)

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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