entity

package
v0.0.0-...-f349414 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIDIsRequired   = errors.New("id is required")
	ErrInvalidID      = errors.New("invalid id")
	ErrNameIsRequired = errors.New("name is required")
)
View Source
var (
	ErrChatroomIDIsRequired = errors.New("chatroom_id is required")
	ErrInvalidChatroomID    = errors.New("invalid chatroom_id")
	ErrUserIDIsRequired     = errors.New("user_id is required")
	ErrInvalidUserID        = errors.New("invalid user_id")
)

Functions

This section is empty.

Types

type Chatroom

type Chatroom struct {
	ID          entity.ID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"created_at"`
}

func NewChatRoom

func NewChatRoom(name string, description string) (*Chatroom, error)

func (*Chatroom) Validate

func (p *Chatroom) Validate() error

type Message

type Message struct {
	ID         entity.ID `json:"id"`
	ChatroomID entity.ID `json:"chatroom_id"`
	Chatroom   Chatroom  `json:"chatroom"`
	UserID     entity.ID `json:"user_id"`
	User       User      `json:"user"`
	Content    string    `json:"content"`
	CreatedAt  time.Time `json:"created_at"`
}

func NewMessage

func NewMessage(chatroomID entity.ID, userID entity.ID, content string) (*Message, error)

func (*Message) Validate

func (m *Message) Validate() error

type User

type User struct {
	ID       entity.ID `json:"id"`
	Name     string    `json:"name"`
	Email    string    `json:"email"`
	Password string    `json:"-"`
	Type     UserType  `json:"type" gorm:"type:varchar(4);default:'USER'"` // USER or BOT
}

func NewUser

func NewUser(name, email, password string, tp UserType) (*User, error)

func (*User) ValidatePassword

func (u *User) ValidatePassword(password string) bool

type UserType

type UserType string
const (
	BOT  UserType = "BOT"
	USER UserType = "USER"
)

Jump to

Keyboard shortcuts

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