gogmagog/models/plan.go
Deepak 8ca7858069
All checks were successful
gitea-deepak/gogmagog/pipeline/head This commit looks good
Adds update plan method
2021-02-07 15:11:44 -06:00

35 lines
1.1 KiB
Go

package models
// Plan represents a single day's agenda of actions.
type Plan struct {
PlanID int64 `json:"plan_id"`
PlanDescription string `json:"plan_description"`
UserID int64 `json:"user_id"`
}
// Plans returns all plans in the model.
func (m *Model) Plans(userID int) ([]*Plan, error) {
return m.SelectPlans(userID)
}
// Plan returns a single plan from the store by plan_id.
func (m *Model) Plan(id int, userID int) (*Plan, error) {
plan, err := m.SelectPlanByID(id, userID)
return plan, wrapNotFound(err)
}
// AddPlan inserts a given plan into the store, returning the generated PlanID. The provided PlanID is ignored.
func (m *Model) AddPlan(plan *Plan, userID int) (int, error) {
return m.InsertPlan(plan, userID)
}
// SavePlan saves and updates a plan.
func (m *Model) SavePlan(plan *Plan, userID int) error {
return m.UpdatePlan(plan, userID)
}
// GetActions returns the actions associated with a particular plan.
func (m *Model) GetActions(plan *Plan, userID int) ([]*Action, error) {
return m.SelectActionsByPlanID(plan, userID)
}