All checks were successful
gitea-deepak/gogmagog/pipeline/head This commit looks good
33 lines
835 B
Go
33 lines
835 B
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Plan represents a single day's agenda of actions.
|
|
type Plan struct {
|
|
PlanID int64 `json:"plan_id"`
|
|
PlanDate *time.Time `json:"plan_date"`
|
|
}
|
|
|
|
// Plans returns all plans in the model.
|
|
func (m *Model) Plans() ([]*Plan, error) {
|
|
return m.SelectPlans()
|
|
}
|
|
|
|
// Plan returns a single plan from the store by plan_id.
|
|
func (m *Model) Plan(id int) (*Plan, error) {
|
|
plan, err := m.SelectPlanByID(id)
|
|
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) (int, error) {
|
|
return m.InsertPlan(plan)
|
|
}
|
|
|
|
// GetActions returns the actions associated with a particular plan.
|
|
func (m *Model) GetActions(plan *Plan) ([]*Action, error) {
|
|
return m.SelectActionsByPlanID(plan)
|
|
}
|