forked from mtusi2026/mtusi2026lab5
chore(migrate) moved codebase from lab4
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
// 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"`
|
||||
AttachmentIDs []uuid.UUID `json:"attachment_ids"`
|
||||
}
|
||||
|
||||
func (m Message) GetID() uuid.UUID { return m.ID }
|
||||
func (m Message) GetCreatedAt() time.Time { return time.Time(m.CreatedAt) }
|
||||
|
||||
type Attachment struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
ChatID uuid.UUID `json:"chat_id"`
|
||||
OwnerID uuid.UUID `json:"owner_id"`
|
||||
Filename string `json:"filename"`
|
||||
ContentType string `json:"content_type"`
|
||||
SizeBytes int64 `json:"size_bytes"`
|
||||
SHA256 string `json:"sha256"`
|
||||
Status string `json:"status"`
|
||||
Variants []Variant `json:"variants"`
|
||||
ErrorCode *string `json:"error_code"`
|
||||
CreatedAt common.RFCFormTime `json:"created_at"`
|
||||
UpdatedAt common.RFCFormTime `json:"updated_at"`
|
||||
|
||||
// ObjectKey is internal and never serialized.
|
||||
ObjectKey string `json:"-"`
|
||||
}
|
||||
|
||||
func (a Attachment) GetID() uuid.UUID { return a.ID }
|
||||
func (a Attachment) GetCreatedAt() time.Time { return time.Time(a.CreatedAt) }
|
||||
|
||||
type Variant struct {
|
||||
Name string `json:"name"`
|
||||
ContentType string `json:"content_type"`
|
||||
SizeBytes int64 `json:"size_bytes"`
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
SHA256 string `json:"sha256"`
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
Token string `json:"token"`
|
||||
TokenType string `json:"token_type"`
|
||||
ExpiresAt common.RFCFormTime `json:"expires_at"`
|
||||
User User `json:"user"`
|
||||
}
|
||||
Reference in New Issue
Block a user