forked from mtusi2026/mtusi2026lab2
48 lines
1.8 KiB
Go
48 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gitflic.ru/project/bulla-max/mtusi2026lab2/internal/common"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type User struct {
|
|
ID uuid.UUID `json:"id" validate:"required"`
|
|
Username string `json:"username" validate:"required"`
|
|
DisplayName string `json:"display_name" validate:"required"`
|
|
PasswordHash string `json:"-"`
|
|
CreatedAt common.RFCFormTime `json:"created_at" validate:"required"`
|
|
}
|
|
|
|
func (u User) GetID() uuid.UUID { return u.ID }
|
|
func (u User) GetCreatedAt() time.Time { return time.Time(u.CreatedAt) }
|
|
|
|
type Chat struct {
|
|
ID uuid.UUID `json:"id" validate:"required"`
|
|
Title string `json:"title" validate:"required"`
|
|
MemberIDs []uuid.UUID `json:"member_ids" validate:"required"`
|
|
CreatedAt common.RFCFormTime `json:"created_at" validate:"required"`
|
|
}
|
|
|
|
func (c Chat) GetID() uuid.UUID { return c.ID }
|
|
func (c Chat) GetCreatedAt() time.Time { return time.Time(c.CreatedAt) }
|
|
|
|
type Message struct {
|
|
ID uuid.UUID `json:"id" validate:"required"`
|
|
ChatID uuid.UUID `json:"chat_id" validate:"required"`
|
|
SenderID uuid.UUID `json:"sender_id" validate:"required"`
|
|
Text string `json:"text" validate:"required"`
|
|
CreatedAt common.RFCFormTime `json:"created_at" validate:"required"`
|
|
}
|
|
|
|
func (m Message) GetID() uuid.UUID { return m.ID }
|
|
func (m Message) GetCreatedAt() time.Time { return time.Time(m.CreatedAt) }
|
|
|
|
type Session struct {
|
|
Token string `json:"token" validate:"required"`
|
|
TokenType string `json:"token_type" validate:"required"`
|
|
ExpiresAt common.RFCFormTime `json:"expires_at" validate:"required"`
|
|
User User `json:"user" validate:"required"`
|
|
}
|