You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package models
import ( "context" "time" )
type Goal struct { ID string `json:"id" db:"goal_id"` UserID string `json:"-" db:"user_id"` GroupID string `json:"groupId" db:"group_id"` StartTime time.Time `json:"startTime" db:"start_time"` EndTime time.Time `json:"endTime" db:"end_time"` Amount int `json:"amount" db:"amount"` Name string `json:"name" db:"name"` Description string `json:"description" db:"description"` }
func (goal *Goal) Update(update GoalUpdate) { if update.Amount != nil { goal.Amount = *update.Amount } if update.StartTime != nil { goal.StartTime = *update.StartTime } if update.EndTime != nil { goal.EndTime = *update.EndTime } if update.Name != nil { goal.Name = *update.Name } if update.Description != nil { goal.Description = *update.Description } }
type GoalUpdate struct { StartTime *time.Time `json:"startTime"` EndTime *time.Time `json:"endTime"` Amount *int `json:"amount"` Name *string `json:"name"` Description *string `json:"description"` }
type GoalResult struct { Goal Group *Group `json:"group"` Items []*GoalResultItem `json:"items"` Logs []*LogResult `json:"logs"` CompletedAmount int `json:"completedAmount"` }
type GoalResultItem struct { Item CompletedAmount int `json:"completedAmount"` }
type GoalFilter struct { UserID string GroupIDs []string IncludesTime *time.Time MinTime *time.Time MaxTime *time.Time IDs []string }
type GoalRepository interface { Find(ctx context.Context, id string) (*Goal, error) List(ctx context.Context, filter GoalFilter) ([]*Goal, error) Insert(ctx context.Context, goal Goal) error Update(ctx context.Context, goal Goal) error Delete(ctx context.Context, goal Goal) error }
|