Backend: List repo query gains name (ILIKE with wildcard escaping on
name + synonym LEFT JOIN, SELECT DISTINCT) and types (ANY cast) params;
handler parses ?name= and ?type=, resolves combined-type aliases from
domain.FruitTypeAliases, validates plain types against validFruitTypes
to prevent Postgres enum cast errors. ORDER BY f.name, f.id for stable
pagination.
Frontend: listFruits gains optional {name, type} params; fruitStore adds
searchName/searchType state and setSearch action (resets offset, refetches);
FruitList.vue wires text input (debounced 300 ms + Enter) and flat type
dropdown (17 enum values + 4 aliases per spec §5 order); debounce timer
cleared on unmount.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
49 lines
1.5 KiB
Go
49 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"`
|
|
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"`
|
|
}
|