Spaces:
Sleeping
Sleeping
| package models | |
| import ( | |
| "time" | |
| "github.com/google/uuid" | |
| "gorm.io/gorm" | |
| ) | |
| type MoodEntry struct { | |
| ID uuid.UUID `json:"id" gorm:"type:char(36);primaryKey"` | |
| UserID uuid.UUID `json:"user_id" gorm:"type:char(36);index"` | |
| Mood string `json:"mood" gorm:"type:enum('happy','sad','tired','angry','anxious','neutral')"` | |
| Note string `json:"note" gorm:"type:text"` | |
| IsFlagged bool `json:"is_flagged" gorm:"default:false"` | |
| IsPrivate bool `json:"is_private" gorm:"default:false"` | |
| Tags string `json:"tags" gorm:"type:text"` // JSON array as string | |
| LocationLat float64 `json:"location_lat"` | |
| LocationLng float64 `json:"location_lng"` | |
| CreatedAt time.Time `json:"created_at"` | |
| // Virtual field for support count | |
| SupportCount int `json:"support_count" gorm:"-"` | |
| } | |
| func (m *MoodEntry) BeforeCreate(tx *gorm.DB) error { | |
| if m.ID == uuid.Nil { | |
| m.ID = uuid.New() | |
| } | |
| return nil | |
| } | |
| type MoodEntryRequest struct { | |
| UserID string `json:"user_id" validate:"required,uuid"` | |
| Mood string `json:"mood" validate:"required,oneof=happy sad tired angry anxious neutral"` | |
| Note string `json:"note"` | |
| LocationLat float64 `json:"location_lat"` | |
| LocationLng float64 `json:"location_lng"` | |
| } | |
| type FeedResponse struct { | |
| ID uuid.UUID `json:"id"` | |
| Mood string `json:"mood"` | |
| Note string `json:"note"` | |
| CreatedAt time.Time `json:"created_at"` | |
| SupportCount int `json:"support_count"` | |
| } |