refactor(backend/models): separate core, item and full models

This commit is contained in:
Masahiko AMANO 2025-07-03 18:02:46 +03:00
parent ec17dfb0ce
commit 27184bf17a

View File

@ -1,6 +1,7 @@
package models package models
import ( import (
"encoding/json"
"time" "time"
"github.com/jackc/pgx/v5/pgtype" "github.com/jackc/pgx/v5/pgtype"
@ -16,43 +17,83 @@ type MIME struct {
Extension string `json:"extension"` Extension string `json:"extension"`
} }
type Category struct { type (
ID string `json:"id"` CategoryCore struct {
Name string `json:"name"` ID string `json:"id"`
Color pgtype.Text `json:"color"` Name string `json:"name"`
CreatedAt time.Time `json:"created_at"` Color pgtype.Text `json:"color"`
Creator User `json:"creator"` }
} CategoryItem struct {
CategoryCore
}
CategoryFull struct {
CategoryCore
CreatedAt time.Time `json:"created_at"`
Creator User `json:"creator"`
Notes pgtype.Text `json:"notes"`
}
)
type File struct { type (
ID string `json:"id"` FileCore struct {
Name pgtype.Text `json:"name"` ID string `json:"id"`
MIME MIME `json:"mime"` Name pgtype.Text `json:"name"`
CreatedAt time.Time `json:"created_at"` MIME MIME `json:"mime"`
Creator User `json:"creator"` }
} FileItem struct {
FileCore
CreatedAt time.Time `json:"created_at"`
Creator User `json:"creator"`
}
FileFull struct {
FileCore
CreatedAt time.Time `json:"created_at"`
Creator User `json:"creator"`
Notes pgtype.Text `json:"notes"`
Metadata *json.RawMessage `json:"metadata"`
}
)
type Tag struct { type (
ID string `json:"id"` TagCore struct {
Name string `json:"name"` ID string `json:"id"`
Color pgtype.Text `json:"color"` Name string `json:"name"`
Category Category `json:"category"` Color pgtype.Text `json:"color"`
CreatedAt time.Time `json:"created_at"` }
Creator User `json:"creator"` TagItem struct {
} TagCore
Category CategoryCore `json:"category"`
}
TagFull struct {
TagCore
Category CategoryCore `json:"category"`
CreatedAt time.Time `json:"created_at"`
Creator User `json:"creator"`
Notes pgtype.Text `json:"notes"`
}
)
type Autotag struct { type Autotag struct {
TriggerTag Tag `json:"trigger_tag"` TriggerTag TagCore `json:"trigger_tag"`
AddTag Tag `json:"add_tag"` AddTag TagCore `json:"add_tag"`
IsActive bool `json:"is_active"` IsActive bool `json:"is_active"`
} }
type Pool struct { type (
ID string `json:"id"` PoolCore struct {
Name string `json:"name"` ID string `json:"id"`
CreatedAt time.Time `json:"created_at"` Name string `json:"name"`
Creator User `json:"creator"` }
} PoolItem struct {
PoolCore
}
PoolFull struct {
PoolCore
CreatedAt time.Time `json:"created_at"`
Creator User `json:"creator"`
Notes pgtype.Text `json:"notes"`
}
)
type Session struct { type Session struct {
ID int `json:"id"` ID int `json:"id"`