Add Plan page with day planner
This commit is contained in:
@ -16,22 +16,47 @@ import (
|
||||
|
||||
|
||||
|
||||
// DefaultApiRouter defines the required methods for binding the api requests to a responses for the DefaultApi
|
||||
// The DefaultApiRouter implementation should parse necessary information from the http request,
|
||||
// pass the data to a DefaultApiServicer to perform the required actions, then write the service results to the http response.
|
||||
type DefaultApiRouter interface {
|
||||
// JournalApiRouter defines the required methods for binding the api requests to a responses for the JournalApi
|
||||
// The JournalApiRouter implementation should parse necessary information from the http request,
|
||||
// pass the data to a JournalApiServicer to perform the required actions, then write the service results to the http response.
|
||||
type JournalApiRouter interface {
|
||||
DeleteJournalEntryForDate(http.ResponseWriter, *http.Request)
|
||||
GetJournalEntryForDate(http.ResponseWriter, *http.Request)
|
||||
WriteJournalEntry(http.ResponseWriter, *http.Request)
|
||||
}
|
||||
// PlanApiRouter defines the required methods for binding the api requests to a responses for the PlanApi
|
||||
// The PlanApiRouter implementation should parse necessary information from the http request,
|
||||
// pass the data to a PlanApiServicer to perform the required actions, then write the service results to the http response.
|
||||
type PlanApiRouter interface {
|
||||
GetPlanDayForDate(http.ResponseWriter, *http.Request)
|
||||
GetPlanMonthForDate(http.ResponseWriter, *http.Request)
|
||||
GetPlanWeekForDate(http.ResponseWriter, *http.Request)
|
||||
SavePlanForDay(http.ResponseWriter, *http.Request)
|
||||
SavePlanForMonth(http.ResponseWriter, *http.Request)
|
||||
SavePlanForWeek(http.ResponseWriter, *http.Request)
|
||||
}
|
||||
|
||||
|
||||
// DefaultApiServicer defines the api actions for the DefaultApi service
|
||||
// JournalApiServicer defines the api actions for the JournalApi service
|
||||
// This interface intended to stay up to date with the openapi yaml used to generate it,
|
||||
// while the service implementation can be ignored with the .openapi-generator-ignore file
|
||||
// and updated with the logic required for the API.
|
||||
type DefaultApiServicer interface {
|
||||
type JournalApiServicer interface {
|
||||
DeleteJournalEntryForDate(context.Context, string) (ImplResponse, error)
|
||||
GetJournalEntryForDate(context.Context, string) (ImplResponse, error)
|
||||
WriteJournalEntry(context.Context, JournalEntry) (ImplResponse, error)
|
||||
}
|
||||
|
||||
|
||||
// PlanApiServicer defines the api actions for the PlanApi service
|
||||
// This interface intended to stay up to date with the openapi yaml used to generate it,
|
||||
// while the service implementation can be ignored with the .openapi-generator-ignore file
|
||||
// and updated with the logic required for the API.
|
||||
type PlanApiServicer interface {
|
||||
GetPlanDayForDate(context.Context, string) (ImplResponse, error)
|
||||
GetPlanMonthForDate(context.Context, string) (ImplResponse, error)
|
||||
GetPlanWeekForDate(context.Context, string) (ImplResponse, error)
|
||||
SavePlanForDay(context.Context, PlanDay) (ImplResponse, error)
|
||||
SavePlanForMonth(context.Context, PlanMonth) (ImplResponse, error)
|
||||
SavePlanForWeek(context.Context, PlanWeek) (ImplResponse, error)
|
||||
}
|
||||
|
||||
@ -17,25 +17,25 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// DefaultApiController binds http requests to an api service and writes the service results to the http response
|
||||
type DefaultApiController struct {
|
||||
service DefaultApiServicer
|
||||
// JournalApiController binds http requests to an api service and writes the service results to the http response
|
||||
type JournalApiController struct {
|
||||
service JournalApiServicer
|
||||
errorHandler ErrorHandler
|
||||
}
|
||||
|
||||
// DefaultApiOption for how the controller is set up.
|
||||
type DefaultApiOption func(*DefaultApiController)
|
||||
// JournalApiOption for how the controller is set up.
|
||||
type JournalApiOption func(*JournalApiController)
|
||||
|
||||
// WithDefaultApiErrorHandler inject ErrorHandler into controller
|
||||
func WithDefaultApiErrorHandler(h ErrorHandler) DefaultApiOption {
|
||||
return func(c *DefaultApiController) {
|
||||
// WithJournalApiErrorHandler inject ErrorHandler into controller
|
||||
func WithJournalApiErrorHandler(h ErrorHandler) JournalApiOption {
|
||||
return func(c *JournalApiController) {
|
||||
c.errorHandler = h
|
||||
}
|
||||
}
|
||||
|
||||
// NewDefaultApiController creates a default api controller
|
||||
func NewDefaultApiController(s DefaultApiServicer, opts ...DefaultApiOption) Router {
|
||||
controller := &DefaultApiController{
|
||||
// NewJournalApiController creates a default api controller
|
||||
func NewJournalApiController(s JournalApiServicer, opts ...JournalApiOption) Router {
|
||||
controller := &JournalApiController{
|
||||
service: s,
|
||||
errorHandler: DefaultErrorHandler,
|
||||
}
|
||||
@ -47,8 +47,8 @@ func NewDefaultApiController(s DefaultApiServicer, opts ...DefaultApiOption) Rou
|
||||
return controller
|
||||
}
|
||||
|
||||
// Routes returns all the api routes for the DefaultApiController
|
||||
func (c *DefaultApiController) Routes() Routes {
|
||||
// Routes returns all the api routes for the JournalApiController
|
||||
func (c *JournalApiController) Routes() Routes {
|
||||
return Routes{
|
||||
{
|
||||
"DeleteJournalEntryForDate",
|
||||
@ -72,7 +72,7 @@ func (c *DefaultApiController) Routes() Routes {
|
||||
}
|
||||
|
||||
// DeleteJournalEntryForDate -
|
||||
func (c *DefaultApiController) DeleteJournalEntryForDate(w http.ResponseWriter, r *http.Request) {
|
||||
func (c *JournalApiController) DeleteJournalEntryForDate(w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
dateParam := params["date"]
|
||||
|
||||
@ -88,7 +88,7 @@ func (c *DefaultApiController) DeleteJournalEntryForDate(w http.ResponseWriter,
|
||||
}
|
||||
|
||||
// GetJournalEntryForDate -
|
||||
func (c *DefaultApiController) GetJournalEntryForDate(w http.ResponseWriter, r *http.Request) {
|
||||
func (c *JournalApiController) GetJournalEntryForDate(w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
dateParam := params["date"]
|
||||
|
||||
@ -104,7 +104,7 @@ func (c *DefaultApiController) GetJournalEntryForDate(w http.ResponseWriter, r *
|
||||
}
|
||||
|
||||
// WriteJournalEntry -
|
||||
func (c *DefaultApiController) WriteJournalEntry(w http.ResponseWriter, r *http.Request) {
|
||||
func (c *JournalApiController) WriteJournalEntry(w http.ResponseWriter, r *http.Request) {
|
||||
journalEntryParam := JournalEntry{}
|
||||
d := json.NewDecoder(r.Body)
|
||||
d.DisallowUnknownFields()
|
||||
@ -15,21 +15,21 @@ import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
// DefaultApiService is a service that implements the logic for the DefaultApiServicer
|
||||
// This service should implement the business logic for every endpoint for the DefaultApi API.
|
||||
// JournalApiService is a service that implements the logic for the JournalApiServicer
|
||||
// This service should implement the business logic for every endpoint for the JournalApi API.
|
||||
// Include any external packages or services that will be required by this service.
|
||||
type DefaultApiService struct {
|
||||
type JournalApiService struct {
|
||||
}
|
||||
|
||||
// NewDefaultApiService creates a default api service
|
||||
func NewDefaultApiService() DefaultApiServicer {
|
||||
return &DefaultApiService{}
|
||||
// NewJournalApiService creates a default api service
|
||||
func NewJournalApiService() JournalApiServicer {
|
||||
return &JournalApiService{}
|
||||
}
|
||||
|
||||
// DeleteJournalEntryForDate -
|
||||
func (s *DefaultApiService) DeleteJournalEntryForDate(ctx context.Context, date string) (ImplResponse, error) {
|
||||
func (s *JournalApiService) DeleteJournalEntryForDate(ctx context.Context, date string) (ImplResponse, error) {
|
||||
// TODO - update DeleteJournalEntryForDate with the required logic for this service method.
|
||||
// Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
// Add api_journal_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
|
||||
//TODO: Uncomment the next line to return response Response(200, {}) or use other options such as http.Ok ...
|
||||
//return Response(200, nil),nil
|
||||
@ -38,9 +38,9 @@ func (s *DefaultApiService) DeleteJournalEntryForDate(ctx context.Context, date
|
||||
}
|
||||
|
||||
// GetJournalEntryForDate -
|
||||
func (s *DefaultApiService) GetJournalEntryForDate(ctx context.Context, date string) (ImplResponse, error) {
|
||||
func (s *JournalApiService) GetJournalEntryForDate(ctx context.Context, date string) (ImplResponse, error) {
|
||||
// TODO - update GetJournalEntryForDate with the required logic for this service method.
|
||||
// Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
// Add api_journal_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
|
||||
//TODO: Uncomment the next line to return response Response(200, JournalEntry{}) or use other options such as http.Ok ...
|
||||
//return Response(200, JournalEntry{}), nil
|
||||
@ -49,9 +49,9 @@ func (s *DefaultApiService) GetJournalEntryForDate(ctx context.Context, date str
|
||||
}
|
||||
|
||||
// WriteJournalEntry -
|
||||
func (s *DefaultApiService) WriteJournalEntry(ctx context.Context, journalEntry JournalEntry) (ImplResponse, error) {
|
||||
func (s *JournalApiService) WriteJournalEntry(ctx context.Context, journalEntry JournalEntry) (ImplResponse, error) {
|
||||
// TODO - update WriteJournalEntry with the required logic for this service method.
|
||||
// Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
// Add api_journal_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
|
||||
//TODO: Uncomment the next line to return response Response(200, {}) or use other options such as http.Ok ...
|
||||
//return Response(200, nil),nil
|
||||
210
backend/dashapi/api_plan.go
Normal file
210
backend/dashapi/api_plan.go
Normal file
@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Dash API
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* API version: 0.1
|
||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||
*/
|
||||
|
||||
package dashapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// PlanApiController binds http requests to an api service and writes the service results to the http response
|
||||
type PlanApiController struct {
|
||||
service PlanApiServicer
|
||||
errorHandler ErrorHandler
|
||||
}
|
||||
|
||||
// PlanApiOption for how the controller is set up.
|
||||
type PlanApiOption func(*PlanApiController)
|
||||
|
||||
// WithPlanApiErrorHandler inject ErrorHandler into controller
|
||||
func WithPlanApiErrorHandler(h ErrorHandler) PlanApiOption {
|
||||
return func(c *PlanApiController) {
|
||||
c.errorHandler = h
|
||||
}
|
||||
}
|
||||
|
||||
// NewPlanApiController creates a default api controller
|
||||
func NewPlanApiController(s PlanApiServicer, opts ...PlanApiOption) Router {
|
||||
controller := &PlanApiController{
|
||||
service: s,
|
||||
errorHandler: DefaultErrorHandler,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(controller)
|
||||
}
|
||||
|
||||
return controller
|
||||
}
|
||||
|
||||
// Routes returns all the api routes for the PlanApiController
|
||||
func (c *PlanApiController) Routes() Routes {
|
||||
return Routes{
|
||||
{
|
||||
"GetPlanDayForDate",
|
||||
strings.ToUpper("Get"),
|
||||
"/api/v1/plan/day/entry/{date}",
|
||||
c.GetPlanDayForDate,
|
||||
},
|
||||
{
|
||||
"GetPlanMonthForDate",
|
||||
strings.ToUpper("Get"),
|
||||
"/api/v1/plan/month/entry/{date}",
|
||||
c.GetPlanMonthForDate,
|
||||
},
|
||||
{
|
||||
"GetPlanWeekForDate",
|
||||
strings.ToUpper("Get"),
|
||||
"/api/v1/plan/week/entry/{date}",
|
||||
c.GetPlanWeekForDate,
|
||||
},
|
||||
{
|
||||
"SavePlanForDay",
|
||||
strings.ToUpper("Post"),
|
||||
"/api/v1/plan/day/entry/",
|
||||
c.SavePlanForDay,
|
||||
},
|
||||
{
|
||||
"SavePlanForMonth",
|
||||
strings.ToUpper("Post"),
|
||||
"/api/v1/plan/month/entry/",
|
||||
c.SavePlanForMonth,
|
||||
},
|
||||
{
|
||||
"SavePlanForWeek",
|
||||
strings.ToUpper("Post"),
|
||||
"/api/v1/plan/week/entry/",
|
||||
c.SavePlanForWeek,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// GetPlanDayForDate -
|
||||
func (c *PlanApiController) GetPlanDayForDate(w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
dateParam := params["date"]
|
||||
|
||||
result, err := c.service.GetPlanDayForDate(r.Context(), dateParam)
|
||||
// If an error occurred, encode the error with the status code
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, err, &result)
|
||||
return
|
||||
}
|
||||
// If no error, encode the body and the result code
|
||||
EncodeJSONResponse(result.Body, &result.Code, w)
|
||||
|
||||
}
|
||||
|
||||
// GetPlanMonthForDate -
|
||||
func (c *PlanApiController) GetPlanMonthForDate(w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
dateParam := params["date"]
|
||||
|
||||
result, err := c.service.GetPlanMonthForDate(r.Context(), dateParam)
|
||||
// If an error occurred, encode the error with the status code
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, err, &result)
|
||||
return
|
||||
}
|
||||
// If no error, encode the body and the result code
|
||||
EncodeJSONResponse(result.Body, &result.Code, w)
|
||||
|
||||
}
|
||||
|
||||
// GetPlanWeekForDate -
|
||||
func (c *PlanApiController) GetPlanWeekForDate(w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
dateParam := params["date"]
|
||||
|
||||
result, err := c.service.GetPlanWeekForDate(r.Context(), dateParam)
|
||||
// If an error occurred, encode the error with the status code
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, err, &result)
|
||||
return
|
||||
}
|
||||
// If no error, encode the body and the result code
|
||||
EncodeJSONResponse(result.Body, &result.Code, w)
|
||||
|
||||
}
|
||||
|
||||
// SavePlanForDay -
|
||||
func (c *PlanApiController) SavePlanForDay(w http.ResponseWriter, r *http.Request) {
|
||||
planDayParam := PlanDay{}
|
||||
d := json.NewDecoder(r.Body)
|
||||
d.DisallowUnknownFields()
|
||||
if err := d.Decode(&planDayParam); err != nil {
|
||||
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
|
||||
return
|
||||
}
|
||||
if err := AssertPlanDayRequired(planDayParam); err != nil {
|
||||
c.errorHandler(w, r, err, nil)
|
||||
return
|
||||
}
|
||||
result, err := c.service.SavePlanForDay(r.Context(), planDayParam)
|
||||
// If an error occurred, encode the error with the status code
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, err, &result)
|
||||
return
|
||||
}
|
||||
// If no error, encode the body and the result code
|
||||
EncodeJSONResponse(result.Body, &result.Code, w)
|
||||
|
||||
}
|
||||
|
||||
// SavePlanForMonth -
|
||||
func (c *PlanApiController) SavePlanForMonth(w http.ResponseWriter, r *http.Request) {
|
||||
planMonthParam := PlanMonth{}
|
||||
d := json.NewDecoder(r.Body)
|
||||
d.DisallowUnknownFields()
|
||||
if err := d.Decode(&planMonthParam); err != nil {
|
||||
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
|
||||
return
|
||||
}
|
||||
if err := AssertPlanMonthRequired(planMonthParam); err != nil {
|
||||
c.errorHandler(w, r, err, nil)
|
||||
return
|
||||
}
|
||||
result, err := c.service.SavePlanForMonth(r.Context(), planMonthParam)
|
||||
// If an error occurred, encode the error with the status code
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, err, &result)
|
||||
return
|
||||
}
|
||||
// If no error, encode the body and the result code
|
||||
EncodeJSONResponse(result.Body, &result.Code, w)
|
||||
|
||||
}
|
||||
|
||||
// SavePlanForWeek -
|
||||
func (c *PlanApiController) SavePlanForWeek(w http.ResponseWriter, r *http.Request) {
|
||||
planWeekParam := PlanWeek{}
|
||||
d := json.NewDecoder(r.Body)
|
||||
d.DisallowUnknownFields()
|
||||
if err := d.Decode(&planWeekParam); err != nil {
|
||||
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
|
||||
return
|
||||
}
|
||||
if err := AssertPlanWeekRequired(planWeekParam); err != nil {
|
||||
c.errorHandler(w, r, err, nil)
|
||||
return
|
||||
}
|
||||
result, err := c.service.SavePlanForWeek(r.Context(), planWeekParam)
|
||||
// If an error occurred, encode the error with the status code
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, err, &result)
|
||||
return
|
||||
}
|
||||
// If no error, encode the body and the result code
|
||||
EncodeJSONResponse(result.Body, &result.Code, w)
|
||||
|
||||
}
|
||||
93
backend/dashapi/api_plan_service.go
Normal file
93
backend/dashapi/api_plan_service.go
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Dash API
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* API version: 0.1
|
||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||
*/
|
||||
|
||||
package dashapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// PlanApiService is a service that implements the logic for the PlanApiServicer
|
||||
// This service should implement the business logic for every endpoint for the PlanApi API.
|
||||
// Include any external packages or services that will be required by this service.
|
||||
type PlanApiService struct {
|
||||
}
|
||||
|
||||
// NewPlanApiService creates a default api service
|
||||
func NewPlanApiService() PlanApiServicer {
|
||||
return &PlanApiService{}
|
||||
}
|
||||
|
||||
// GetPlanDayForDate -
|
||||
func (s *PlanApiService) GetPlanDayForDate(ctx context.Context, date string) (ImplResponse, error) {
|
||||
// TODO - update GetPlanDayForDate with the required logic for this service method.
|
||||
// Add api_plan_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
|
||||
//TODO: Uncomment the next line to return response Response(200, PlanDay{}) or use other options such as http.Ok ...
|
||||
//return Response(200, PlanDay{}), nil
|
||||
|
||||
return Response(http.StatusNotImplemented, nil), errors.New("GetPlanDayForDate method not implemented")
|
||||
}
|
||||
|
||||
// GetPlanMonthForDate -
|
||||
func (s *PlanApiService) GetPlanMonthForDate(ctx context.Context, date string) (ImplResponse, error) {
|
||||
// TODO - update GetPlanMonthForDate with the required logic for this service method.
|
||||
// Add api_plan_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
|
||||
//TODO: Uncomment the next line to return response Response(200, PlanMonth{}) or use other options such as http.Ok ...
|
||||
//return Response(200, PlanMonth{}), nil
|
||||
|
||||
return Response(http.StatusNotImplemented, nil), errors.New("GetPlanMonthForDate method not implemented")
|
||||
}
|
||||
|
||||
// GetPlanWeekForDate -
|
||||
func (s *PlanApiService) GetPlanWeekForDate(ctx context.Context, date string) (ImplResponse, error) {
|
||||
// TODO - update GetPlanWeekForDate with the required logic for this service method.
|
||||
// Add api_plan_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
|
||||
//TODO: Uncomment the next line to return response Response(200, PlanWeek{}) or use other options such as http.Ok ...
|
||||
//return Response(200, PlanWeek{}), nil
|
||||
|
||||
return Response(http.StatusNotImplemented, nil), errors.New("GetPlanWeekForDate method not implemented")
|
||||
}
|
||||
|
||||
// SavePlanForDay -
|
||||
func (s *PlanApiService) SavePlanForDay(ctx context.Context, planDay PlanDay) (ImplResponse, error) {
|
||||
// TODO - update SavePlanForDay with the required logic for this service method.
|
||||
// Add api_plan_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
|
||||
//TODO: Uncomment the next line to return response Response(200, {}) or use other options such as http.Ok ...
|
||||
//return Response(200, nil),nil
|
||||
|
||||
return Response(http.StatusNotImplemented, nil), errors.New("SavePlanForDay method not implemented")
|
||||
}
|
||||
|
||||
// SavePlanForMonth -
|
||||
func (s *PlanApiService) SavePlanForMonth(ctx context.Context, planMonth PlanMonth) (ImplResponse, error) {
|
||||
// TODO - update SavePlanForMonth with the required logic for this service method.
|
||||
// Add api_plan_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
|
||||
//TODO: Uncomment the next line to return response Response(200, {}) or use other options such as http.Ok ...
|
||||
//return Response(200, nil),nil
|
||||
|
||||
return Response(http.StatusNotImplemented, nil), errors.New("SavePlanForMonth method not implemented")
|
||||
}
|
||||
|
||||
// SavePlanForWeek -
|
||||
func (s *PlanApiService) SavePlanForWeek(ctx context.Context, planWeek PlanWeek) (ImplResponse, error) {
|
||||
// TODO - update SavePlanForWeek with the required logic for this service method.
|
||||
// Add api_plan_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
|
||||
|
||||
//TODO: Uncomment the next line to return response Response(200, {}) or use other options such as http.Ok ...
|
||||
//return Response(200, nil),nil
|
||||
|
||||
return Response(http.StatusNotImplemented, nil), errors.New("SavePlanForWeek method not implemented")
|
||||
}
|
||||
53
backend/dashapi/model_plan_day.go
Normal file
53
backend/dashapi/model_plan_day.go
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Dash API
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* API version: 0.1
|
||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||
*/
|
||||
|
||||
package dashapi
|
||||
|
||||
type PlanDay struct {
|
||||
|
||||
Date string `json:"date"`
|
||||
|
||||
Morning []string `json:"morning,omitempty"`
|
||||
|
||||
Midday []string `json:"midday,omitempty"`
|
||||
|
||||
Afternoon []string `json:"afternoon,omitempty"`
|
||||
|
||||
Evening []string `json:"evening,omitempty"`
|
||||
|
||||
Pleasant []string `json:"pleasant,omitempty"`
|
||||
|
||||
Reminders []string `json:"reminders,omitempty"`
|
||||
}
|
||||
|
||||
// AssertPlanDayRequired checks if the required fields are not zero-ed
|
||||
func AssertPlanDayRequired(obj PlanDay) error {
|
||||
elements := map[string]interface{}{
|
||||
"date": obj.Date,
|
||||
}
|
||||
for name, el := range elements {
|
||||
if isZero := IsZeroValue(el); isZero {
|
||||
return &RequiredError{Field: name}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AssertRecursePlanDayRequired recursively checks if required fields are not zero-ed in a nested slice.
|
||||
// Accepts only nested slice of PlanDay (e.g. [][]PlanDay), otherwise ErrTypeAssertionError is thrown.
|
||||
func AssertRecursePlanDayRequired(objSlice interface{}) error {
|
||||
return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
|
||||
aPlanDay, ok := obj.(PlanDay)
|
||||
if !ok {
|
||||
return ErrTypeAssertionError
|
||||
}
|
||||
return AssertPlanDayRequired(aPlanDay)
|
||||
})
|
||||
}
|
||||
43
backend/dashapi/model_plan_month.go
Normal file
43
backend/dashapi/model_plan_month.go
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Dash API
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* API version: 0.1
|
||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||
*/
|
||||
|
||||
package dashapi
|
||||
|
||||
type PlanMonth struct {
|
||||
|
||||
Date string `json:"date"`
|
||||
|
||||
Items []string `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
// AssertPlanMonthRequired checks if the required fields are not zero-ed
|
||||
func AssertPlanMonthRequired(obj PlanMonth) error {
|
||||
elements := map[string]interface{}{
|
||||
"date": obj.Date,
|
||||
}
|
||||
for name, el := range elements {
|
||||
if isZero := IsZeroValue(el); isZero {
|
||||
return &RequiredError{Field: name}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AssertRecursePlanMonthRequired recursively checks if required fields are not zero-ed in a nested slice.
|
||||
// Accepts only nested slice of PlanMonth (e.g. [][]PlanMonth), otherwise ErrTypeAssertionError is thrown.
|
||||
func AssertRecursePlanMonthRequired(objSlice interface{}) error {
|
||||
return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
|
||||
aPlanMonth, ok := obj.(PlanMonth)
|
||||
if !ok {
|
||||
return ErrTypeAssertionError
|
||||
}
|
||||
return AssertPlanMonthRequired(aPlanMonth)
|
||||
})
|
||||
}
|
||||
48
backend/dashapi/model_plan_week.go
Normal file
48
backend/dashapi/model_plan_week.go
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Dash API
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* API version: 0.1
|
||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||
*/
|
||||
|
||||
package dashapi
|
||||
|
||||
type PlanWeek struct {
|
||||
|
||||
Date string `json:"date"`
|
||||
|
||||
Items []PlanWeekItem `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
// AssertPlanWeekRequired checks if the required fields are not zero-ed
|
||||
func AssertPlanWeekRequired(obj PlanWeek) error {
|
||||
elements := map[string]interface{}{
|
||||
"date": obj.Date,
|
||||
}
|
||||
for name, el := range elements {
|
||||
if isZero := IsZeroValue(el); isZero {
|
||||
return &RequiredError{Field: name}
|
||||
}
|
||||
}
|
||||
|
||||
for _, el := range obj.Items {
|
||||
if err := AssertPlanWeekItemRequired(el); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AssertRecursePlanWeekRequired recursively checks if required fields are not zero-ed in a nested slice.
|
||||
// Accepts only nested slice of PlanWeek (e.g. [][]PlanWeek), otherwise ErrTypeAssertionError is thrown.
|
||||
func AssertRecursePlanWeekRequired(objSlice interface{}) error {
|
||||
return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
|
||||
aPlanWeek, ok := obj.(PlanWeek)
|
||||
if !ok {
|
||||
return ErrTypeAssertionError
|
||||
}
|
||||
return AssertPlanWeekRequired(aPlanWeek)
|
||||
})
|
||||
}
|
||||
45
backend/dashapi/model_plan_week_item.go
Normal file
45
backend/dashapi/model_plan_week_item.go
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Dash API
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* API version: 0.1
|
||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||
*/
|
||||
|
||||
package dashapi
|
||||
|
||||
type PlanWeekItem struct {
|
||||
|
||||
Item string `json:"item"`
|
||||
|
||||
NumTodos int32 `json:"numTodos,omitempty"`
|
||||
|
||||
NumDone int32 `json:"numDone,omitempty"`
|
||||
}
|
||||
|
||||
// AssertPlanWeekItemRequired checks if the required fields are not zero-ed
|
||||
func AssertPlanWeekItemRequired(obj PlanWeekItem) error {
|
||||
elements := map[string]interface{}{
|
||||
"item": obj.Item,
|
||||
}
|
||||
for name, el := range elements {
|
||||
if isZero := IsZeroValue(el); isZero {
|
||||
return &RequiredError{Field: name}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AssertRecursePlanWeekItemRequired recursively checks if required fields are not zero-ed in a nested slice.
|
||||
// Accepts only nested slice of PlanWeekItem (e.g. [][]PlanWeekItem), otherwise ErrTypeAssertionError is thrown.
|
||||
func AssertRecursePlanWeekItemRequired(objSlice interface{}) error {
|
||||
return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
|
||||
aPlanWeekItem, ok := obj.(PlanWeekItem)
|
||||
if !ok {
|
||||
return ErrTypeAssertionError
|
||||
}
|
||||
return AssertPlanWeekItemRequired(aPlanWeekItem)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user