forked from mtusi2026/mtusi2026lab3
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
// Package model defines the JSON-facing domain types shared by handlers,
|
|
// storage and the public contract.
|
|
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gitflic.ru/project/bulla-max/mtusi2026lab/internal/common"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type User struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Username string `json:"username"`
|
|
DisplayName string `json:"display_name"`
|
|
PasswordHash string `json:"-"`
|
|
CreatedAt common.RFCFormTime `json:"created_at"`
|
|
}
|
|
|
|
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"`
|
|
Title string `json:"title"`
|
|
MemberIDs []uuid.UUID `json:"member_ids"`
|
|
CreatedAt common.RFCFormTime `json:"created_at"`
|
|
}
|
|
|
|
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"`
|
|
ChatID uuid.UUID `json:"chat_id"`
|
|
SenderID uuid.UUID `json:"sender_id"`
|
|
Text string `json:"text"`
|
|
CreatedAt common.RFCFormTime `json:"created_at"`
|
|
}
|
|
|
|
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"`
|
|
TokenType string `json:"token_type"`
|
|
ExpiresAt common.RFCFormTime `json:"expires_at"`
|
|
User User `json:"user"`
|
|
}
|