package handlers import ( "bugulma/backend/internal/domain" "gorm.io/gorm" ) // geographicalFeatureHandler implements EntityHandler for GeographicalFeature entities type geographicalFeatureHandler struct{} func NewGeographicalFeatureHandler() domain.EntityHandler[*domain.GeographicalFeature] { return &geographicalFeatureHandler{} } func (h *geographicalFeatureHandler) GetEntityID(entity *domain.GeographicalFeature) string { return entity.ID } func (h *geographicalFeatureHandler) GetFieldValue(entity *domain.GeographicalFeature, field string) string { switch field { case "name": return entity.Name case "properties": // For properties JSON field, return it as string for potential translation // In practice, individual properties within the JSON might be translatable return string(entity.Properties) default: return "" } } func (h *geographicalFeatureHandler) GetLocalizableFields() []string { return []string{"name", "properties"} } func (h *geographicalFeatureHandler) LoadEntities(db *gorm.DB, options domain.EntityLoadOptions) ([]*domain.GeographicalFeature, error) { var features []*domain.GeographicalFeature if err := db.Find(&features).Error; err != nil { return nil, err } return features, nil } func (h *geographicalFeatureHandler) BuildFieldQuery(db *gorm.DB, field, value string) *gorm.DB { switch field { case "name": return db.Where("name = ?", value) case "properties": // For JSON field, we might need to use JSON operators // For now, use simple text search return db.Where("properties::text LIKE ?", "%"+value+"%") default: return db } } func (h *geographicalFeatureHandler) GetEntityType() string { return "geographical_feature" }