63 lines
2.6 KiB
Go
63 lines
2.6 KiB
Go
/*
|
|
* 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 service
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"net/http"
|
|
|
|
"github.com/moustachioed/dash/backend/dashapi"
|
|
"github.com/moustachioed/dash/backend/database"
|
|
"github.com/moustachioed/dash/backend/mapping"
|
|
)
|
|
|
|
// 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.
|
|
// Include any external packages or services that will be required by this service.
|
|
type DefaultApiService struct {
|
|
db database.Database
|
|
mapper mapping.Mapper
|
|
}
|
|
|
|
// NewDefaultApiService creates a default api service
|
|
func NewDefaultApiService(db database.Database, mapper mapping.Mapper) dashapi.DefaultApiServicer {
|
|
return &DefaultApiService{}
|
|
}
|
|
|
|
// GetJournalEntryForDate -
|
|
func (s *DefaultApiService) GetJournalEntryForDate(ctx context.Context, date string) (dashapi.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.
|
|
|
|
//TODO: Uncomment the next line to return response Response(200, JournalEntry{}) or use other options such as http.Ok ...
|
|
//return Response(200, JournalEntry{}), nil
|
|
|
|
return dashapi.Response(http.StatusNotImplemented, nil), errors.New("GetJournalEntryForDate method not implemented")
|
|
}
|
|
|
|
// WriteJournalEntryForDate -
|
|
func (s *DefaultApiService) WriteJournalEntryForDate(ctx context.Context, date string, journalEntry dashapi.JournalEntry) (dashapi.ImplResponse, error) {
|
|
// TODO - update WriteJournalEntryForDate 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.
|
|
|
|
//TODO: Uncomment the next line to return response Response(200, {}) or use other options such as http.Ok ...
|
|
//return Response(200, nil),nil
|
|
journal := s.mapper.JournalApiToDb(journalEntry)
|
|
s.db.WriteJournalEntry(journal)
|
|
// log.Printf(journal.Thankful)
|
|
|
|
return dashapi.Response(http.StatusNotImplemented, nil), errors.New("WriteJournalEntryForDate method not implemented")
|
|
}
|
|
|
|
func (s *DefaultApiService) DeleteJournalEntryForDate(ctx context.Context, date string) (dashapi.ImplResponse, error) {
|
|
return dashapi.Response(http.StatusNotImplemented, nil), errors.New("DeleteJournalEntryForDate method not implemented")
|
|
}
|