- Auto-crop thumbnails on image upload (Go stdlib, no external deps): find non-background bounding box, pad 5px, scale to ≤300px, encode JPEG - Add thumbnail_data BYTEA column to fruit_images and publication_fruit_images - New GET /api/v1/fruits/:id/images/:imageId/thumbnail endpoint (fallback to full data) - New GET /api/v1/publications/:id/fruit-images/:imgId/thumbnail endpoint - New POST /api/v1/admin/backfill-thumbnails to retroactively generate thumbnails - ListFruits response now includes synonyms and thumbnail_url per fruit - Replace FruitList table with responsive FruitCard grid (thumbnail + name + OSDB ID + type + synonyms) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
package domain
|
|
|
|
import "time"
|
|
|
|
// FruitTypeAliases maps combined-type alias labels to the enum values they expand to.
|
|
var FruitTypeAliases = map[string][]string{
|
|
"Birnen- und Quittensorten": {"Birnensorten", "Quittensorten"},
|
|
"Aprikosen und Pfirsiche": {"Aprikosen", "Pfirsiche"},
|
|
"Mirabellen und Reineclauden": {"Mirabellen", "Renekloden"},
|
|
"Pflaumen und Zwetschen": {"Pflaumen", "Zwetschen"},
|
|
}
|
|
|
|
type Fruit struct {
|
|
ID int `json:"id"`
|
|
Name string `json:"name"`
|
|
OSDBNumber string `json:"osdb_number"`
|
|
Comment *string `json:"comment"`
|
|
FruitType string `json:"fruit_type"`
|
|
Synonyms []string `json:"synonyms"`
|
|
Images []FruitImage `json:"images"`
|
|
ThumbnailURL *string `json:"thumbnail_url"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type FruitImage struct {
|
|
ID int `json:"id"`
|
|
FruitID int `json:"fruit_id"`
|
|
Filename *string `json:"filename"`
|
|
ImageType string `json:"image_type"`
|
|
Title *string `json:"title"`
|
|
URL string `json:"url"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type FruitWriteDTO struct {
|
|
Name string `json:"name"`
|
|
OSDBNumber string `json:"osdb_number"`
|
|
Comment *string `json:"comment"`
|
|
FruitType string `json:"fruit_type"`
|
|
Synonyms []string `json:"synonyms"`
|
|
}
|
|
|
|
type FruitListResponse struct {
|
|
Items []Fruit `json:"items"`
|
|
Total int `json:"total"`
|
|
Limit int `json:"limit"`
|
|
Offset int `json:"offset"`
|
|
}
|