diff --git a/backend/models/models.go b/backend/models/models.go index 3172d23..d411c99 100644 --- a/backend/models/models.go +++ b/backend/models/models.go @@ -1,6 +1,7 @@ package models import ( + "encoding/json" "time" "github.com/jackc/pgx/v5/pgtype" @@ -16,43 +17,83 @@ type MIME struct { Extension string `json:"extension"` } -type Category struct { - ID string `json:"id"` - Name string `json:"name"` - Color pgtype.Text `json:"color"` - CreatedAt time.Time `json:"created_at"` - Creator User `json:"creator"` -} +type ( + CategoryCore struct { + ID string `json:"id"` + Name string `json:"name"` + Color pgtype.Text `json:"color"` + } + CategoryItem struct { + CategoryCore + } + CategoryFull struct { + CategoryCore + CreatedAt time.Time `json:"created_at"` + Creator User `json:"creator"` + Notes pgtype.Text `json:"notes"` + } +) -type File struct { - ID string `json:"id"` - Name pgtype.Text `json:"name"` - MIME MIME `json:"mime"` - CreatedAt time.Time `json:"created_at"` - Creator User `json:"creator"` -} +type ( + FileCore struct { + ID string `json:"id"` + Name pgtype.Text `json:"name"` + MIME MIME `json:"mime"` + } + 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 { - ID string `json:"id"` - Name string `json:"name"` - Color pgtype.Text `json:"color"` - Category Category `json:"category"` - CreatedAt time.Time `json:"created_at"` - Creator User `json:"creator"` -} +type ( + TagCore struct { + ID string `json:"id"` + Name string `json:"name"` + Color pgtype.Text `json:"color"` + } + 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 { - TriggerTag Tag `json:"trigger_tag"` - AddTag Tag `json:"add_tag"` - IsActive bool `json:"is_active"` + TriggerTag TagCore `json:"trigger_tag"` + AddTag TagCore `json:"add_tag"` + IsActive bool `json:"is_active"` } -type Pool struct { - ID string `json:"id"` - Name string `json:"name"` - CreatedAt time.Time `json:"created_at"` - Creator User `json:"creator"` -} +type ( + PoolCore struct { + ID string `json:"id"` + Name string `json:"name"` + } + PoolItem struct { + PoolCore + } + PoolFull struct { + PoolCore + CreatedAt time.Time `json:"created_at"` + Creator User `json:"creator"` + Notes pgtype.Text `json:"notes"` + } +) type Session struct { ID int `json:"id"`