Skip to content

Commit

Permalink
Spring API meeting 2 progress
Browse files Browse the repository at this point in the history
https: //github.com/acmcsufoss/i/issues/18
Co-Authored-By: Akanksh Jagadish <[email protected]>
Co-Authored-By: John Carlo Manuel <[email protected]>
  • Loading branch information
3 people committed Feb 21, 2024
1 parent f251d80 commit 31a0d6c
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 121 deletions.
6 changes: 4 additions & 2 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
swgui "github.com/swaggest/swgui/v5emb"

"github.com/acmcsufoss/api.acmcsuf.com/internal/api/services"
"github.com/acmcsufoss/api.acmcsuf.com/internal/api/services/events"
"github.com/acmcsufoss/api.acmcsuf.com/internal/api/services/resources"
"github.com/acmcsufoss/api.acmcsuf.com/internal/db/sqlite"
)

Expand Down Expand Up @@ -34,8 +36,8 @@ func New(q *sqlite.Queries) *web.Service {
}

func useAll(s *web.Service, q *sqlite.Queries) {
use("/resources", services.NewResourcesService(q), s)
use("/events", services.NewEventsService(q), s)
use("/resources", resources.New(q), s)
use("/events", events.New(q), s)
}

func use(path string, s services.Service, ss *web.Service) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
package services

import (
"github.com/swaggest/usecase"

"github.com/acmcsufoss/api.acmcsuf.com/internal/db/sqlite"
)

var _ Service = EventsService{}

type EventsService struct {
q *sqlite.Queries
}

func NewEventsService(q *sqlite.Queries) *EventsService {
return &EventsService{q}
}

func (s EventsService) Resources() usecase.IOInteractor {
panic("implement me")
}

func (s EventsService) PostResources() usecase.IOInteractor {
panic("implement me")
}

func (s EventsService) BatchPostResources() usecase.IOInteractor {
panic("implement me")
}

func (s EventsService) Resource() usecase.IOInteractor {
panic("implement me")
}

func (s EventsService) PostResource() usecase.IOInteractor {
panic("implement me")
}

func (s EventsService) BatchPostResource() usecase.IOInteractor {
panic("implement me")
}

func (s EventsService) DeleteResource() usecase.IOInteractor {
panic("implement me")
}
package events

import (
"github.com/swaggest/usecase"

"github.com/acmcsufoss/api.acmcsuf.com/internal/api/services"
"github.com/acmcsufoss/api.acmcsuf.com/internal/db/sqlite"
)

var _ services.Service = EventsService{}

type EventsService struct {
q *sqlite.Queries
}

func New(q *sqlite.Queries) *EventsService {
return &EventsService{q}
}

func (s EventsService) Resources() usecase.IOInteractor {
panic("implement me")
// s.q.GetResourceList(context.TODO(), "")
}

func (s EventsService) PostResources() usecase.IOInteractor {
panic("implement me")
}

func (s EventsService) BatchPostResources() usecase.IOInteractor {
panic("implement me")
}

func (s EventsService) Resource() usecase.IOInteractor {
panic("implement me")
}

func (s EventsService) PostResource() usecase.IOInteractor {
panic("implement me")
}

func (s EventsService) BatchPostResource() usecase.IOInteractor {
panic("implement me")
}

func (s EventsService) DeleteResource() usecase.IOInteractor {
panic("implement me")
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,74 +1,75 @@
package services

import (
"context"

"github.com/swaggest/usecase"
"github.com/swaggest/usecase/status"

"github.com/acmcsufoss/api.acmcsuf.com/internal/db/sqlite"
)

var _ Service = ResourcesService{}

type ResourcesService struct {
q *sqlite.Queries
}

func NewResourcesService(q *sqlite.Queries) *ResourcesService {
return &ResourcesService{q}
}

type resourceInput struct {
Title string `json:"title"`
ContentMd string `json:"content_md"`
ImageUrl string `json:"image_url"`
ResourceType string `json:"resource_type"`
ResourceListID string `json:"resource_list_id"`
}

type resourceOutput sqlite.Resource

func (s ResourcesService) Resources() usecase.IOInteractor {
panic("implement me")
}

func (s ResourcesService) PostResources() usecase.IOInteractor {
panic("implement me")
}

func (s ResourcesService) BatchPostResources() usecase.IOInteractor {
panic("implement me")
}

func (s ResourcesService) Resource() usecase.IOInteractor {
// Create use case interactor with references to input/output types and interaction function.
u := usecase.NewIOI(new(resourceInput), new(resourceOutput), func(ctx context.Context, input, output interface{}) error {
// var (
// in = input.(*resourceInput)
// out = output.(*resourceOutput)
// )

// TODO: Get resource by ID from database.

return nil
})

// Describe use case interactor.
u.SetTitle("GetResource")
u.SetDescription("Gets a single base resource.")
u.SetExpectedErrors(status.InvalidArgument)
return u
}

func (s ResourcesService) PostResource() usecase.IOInteractor {
panic("implement me")
}

func (s ResourcesService) BatchPostResource() usecase.IOInteractor {
panic("implement me")
}

func (s ResourcesService) DeleteResource() usecase.IOInteractor {
panic("implement me")
}
package resources

import (
"context"

"github.com/swaggest/usecase"
"github.com/swaggest/usecase/status"

"github.com/acmcsufoss/api.acmcsuf.com/internal/api/services"
"github.com/acmcsufoss/api.acmcsuf.com/internal/db/sqlite"
)

var _ services.Service = ResourcesService{}

type ResourcesService struct {
q *sqlite.Queries
}

func New(q *sqlite.Queries) *ResourcesService {
return &ResourcesService{q}
}

type resourceInput struct {
Title string `json:"title"`
ContentMd string `json:"content_md"`
ImageUrl string `json:"image_url"`
ResourceType string `json:"resource_type"`
ResourceListID string `json:"resource_list_id"`
}

type resourceOutput sqlite.Resource

func (s ResourcesService) Resources() usecase.IOInteractor {
panic("implement me")
}

func (s ResourcesService) PostResources() usecase.IOInteractor {
panic("implement me")
}

func (s ResourcesService) BatchPostResources() usecase.IOInteractor {
panic("implement me")
}

func (s ResourcesService) Resource() usecase.IOInteractor {
// Create use case interactor with references to input/output types and interaction function.
u := usecase.NewIOI(new(resourceInput), new(resourceOutput), func(ctx context.Context, input, output interface{}) error {
// var (
// in = input.(*resourceInput)
// out = output.(*resourceOutput)
// )

// TODO: Get resource by ID from database.

return nil
})

// Describe use case interactor.
u.SetTitle("GetResource")
u.SetDescription("Gets a single base resource.")
u.SetExpectedErrors(status.InvalidArgument)
return u
}

func (s ResourcesService) PostResource() usecase.IOInteractor {
panic("implement me")
}

func (s ResourcesService) BatchPostResource() usecase.IOInteractor {
panic("implement me")
}

func (s ResourcesService) DeleteResource() usecase.IOInteractor {
panic("implement me")
}

0 comments on commit 31a0d6c

Please sign in to comment.