Adds a new endpoint GET /api/tasks/templates/by-region/?zip= that resolves ZIP codes to IECC climate regions and returns relevant home maintenance task templates. Includes climate region model, region lookup service with tests, seed data for all 8 climate zones with 50+ templates, and OpenAPI spec. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
24 lines
1.3 KiB
Go
24 lines
1.3 KiB
Go
package models
|
|
|
|
// TaskTemplate represents a predefined task template that users can select when creating tasks
|
|
type TaskTemplate struct {
|
|
BaseModel
|
|
Title string `gorm:"column:title;size:200;not null" json:"title"`
|
|
Description string `gorm:"column:description;type:text" json:"description"`
|
|
CategoryID *uint `gorm:"column:category_id;index" json:"category_id"`
|
|
Category *TaskCategory `gorm:"foreignKey:CategoryID" json:"category,omitempty"`
|
|
FrequencyID *uint `gorm:"column:frequency_id;index" json:"frequency_id"`
|
|
Frequency *TaskFrequency `gorm:"foreignKey:FrequencyID" json:"frequency,omitempty"`
|
|
IconIOS string `gorm:"column:icon_ios;size:100" json:"icon_ios"`
|
|
IconAndroid string `gorm:"column:icon_android;size:100" json:"icon_android"`
|
|
Tags string `gorm:"column:tags;type:text" json:"tags"` // Comma-separated tags for search
|
|
DisplayOrder int `gorm:"column:display_order;default:0" json:"display_order"`
|
|
IsActive bool `gorm:"column:is_active;default:true;index" json:"is_active"`
|
|
Regions []ClimateRegion `gorm:"many2many:task_tasktemplate_regions;" json:"regions,omitempty"`
|
|
}
|
|
|
|
// TableName returns the table name for GORM
|
|
func (TaskTemplate) TableName() string {
|
|
return "task_tasktemplate"
|
|
}
|