Initial commit: MyCrib API in Go
Complete rewrite of Django REST API to Go with: - Gin web framework for HTTP routing - GORM for database operations - GoAdmin for admin panel - Gorush integration for push notifications - Redis for caching and job queues Features implemented: - User authentication (login, register, logout, password reset) - Residence management (CRUD, sharing, share codes) - Task management (CRUD, kanban board, completions) - Contractor management (CRUD, specialties) - Document management (CRUD, warranties) - Notifications (preferences, push notifications) - Subscription management (tiers, limits) Infrastructure: - Docker Compose for local development - Database migrations and seed data - Admin panel for data management 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
53
internal/models/contractor.go
Normal file
53
internal/models/contractor.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package models
|
||||
|
||||
// ContractorSpecialty represents the task_contractorspecialty table
|
||||
type ContractorSpecialty struct {
|
||||
BaseModel
|
||||
Name string `gorm:"column:name;size:50;not null" json:"name"`
|
||||
Description string `gorm:"column:description;type:text" json:"description"`
|
||||
Icon string `gorm:"column:icon;size:50" json:"icon"`
|
||||
DisplayOrder int `gorm:"column:display_order;default:0" json:"display_order"`
|
||||
}
|
||||
|
||||
// TableName returns the table name for GORM
|
||||
func (ContractorSpecialty) TableName() string {
|
||||
return "task_contractorspecialty"
|
||||
}
|
||||
|
||||
// Contractor represents the task_contractor table
|
||||
type Contractor struct {
|
||||
BaseModel
|
||||
ResidenceID uint `gorm:"column:residence_id;index;not null" json:"residence_id"`
|
||||
Residence Residence `gorm:"foreignKey:ResidenceID" json:"-"`
|
||||
CreatedByID uint `gorm:"column:created_by_id;index;not null" json:"created_by_id"`
|
||||
CreatedBy User `gorm:"foreignKey:CreatedByID" json:"created_by,omitempty"`
|
||||
|
||||
Name string `gorm:"column:name;size:200;not null" json:"name"`
|
||||
Company string `gorm:"column:company;size:200" json:"company"`
|
||||
Phone string `gorm:"column:phone;size:20" json:"phone"`
|
||||
Email string `gorm:"column:email;size:254" json:"email"`
|
||||
Website string `gorm:"column:website;size:200" json:"website"`
|
||||
Notes string `gorm:"column:notes;type:text" json:"notes"`
|
||||
|
||||
// Address
|
||||
StreetAddress string `gorm:"column:street_address;size:255" json:"street_address"`
|
||||
City string `gorm:"column:city;size:100" json:"city"`
|
||||
StateProvince string `gorm:"column:state_province;size:100" json:"state_province"`
|
||||
PostalCode string `gorm:"column:postal_code;size:20" json:"postal_code"`
|
||||
|
||||
// Specialties (many-to-many)
|
||||
Specialties []ContractorSpecialty `gorm:"many2many:task_contractor_specialties;" json:"specialties,omitempty"`
|
||||
|
||||
// Rating and favorites
|
||||
Rating *float64 `gorm:"column:rating;type:decimal(2,1)" json:"rating"`
|
||||
IsFavorite bool `gorm:"column:is_favorite;default:false" json:"is_favorite"`
|
||||
IsActive bool `gorm:"column:is_active;default:true;index" json:"is_active"`
|
||||
|
||||
// Tasks associated with this contractor
|
||||
Tasks []Task `gorm:"foreignKey:ContractorID" json:"tasks,omitempty"`
|
||||
}
|
||||
|
||||
// TableName returns the table name for GORM
|
||||
func (Contractor) TableName() string {
|
||||
return "task_contractor"
|
||||
}
|
||||
Reference in New Issue
Block a user