string

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StringController

type StringController struct {
	Interactor StringInteractor
	Logger     logging.Logger
}

StringController is the api object that allows for http requests into our application

func (*StringController) CreateOne

func (s *StringController) CreateOne(c *gin.Context)

CreateOne creates a single string object

func (*StringController) DeleteById

func (s *StringController) DeleteById(c *gin.Context)

DeleteById deletes a string by a string uuid passed as part of the req uri path

func (*StringController) FindAll

func (s *StringController) FindAll(c *gin.Context)

FindAll fetches all strings or all strings associated with a certain thread if you pass a uuid as a `thread` query param

func (*StringController) RegisterRoutes

func (s *StringController) RegisterRoutes(router *gin.RouterGroup)

RegisterRoutes creates a gin route grouping for the `/string` routes

func (*StringController) UpdateName

func (s *StringController) UpdateName(c *gin.Context)

UpdateName takes a string `id` and `name` as query params to update the name of that string.

func (*StringController) UpdateOrder

func (s *StringController) UpdateOrder(c *gin.Context)

UpdateOrder takes a list of id and order values and updates the strings

type StringInteractor

type StringInteractor interface {
	FindAll() ([]core.String, error)
	FindAllByThread(threadId uuid.UUID) ([]core.String, error)
	CreateOne(core.String) (core.String, error)
	UpdateName(stringId uuid.UUID, name string) error
	UpdateOrder(stringOrders []core.StringOrder) error
	DeleteById(id uuid.UUID) error
}

StringInteractor defines the service interface the controller will usee

type StringOrderDTO

type StringOrderDTO struct {
	Id    string `json:"id" binding:"required"`
	Order int    `json:"order"`
}

StringOrderDTO is needed to bind the request body. The core.StringOrder struct defines `Id` as an uuid.UUID which gin cannot bind. So I needed to create a DTO struct to bind to and then convert to the core struct

type StringRepository

type StringRepository struct {
	DB     api.PgxConn
	Logger logging.Logger
}

func (*StringRepository) CreateOne

func (s *StringRepository) CreateOne(coreString core.String) (core.String, error)

func (*StringRepository) DeleteAllByThread

func (s *StringRepository) DeleteAllByThread(threadId uuid.UUID) error

func (*StringRepository) DeleteById

func (s *StringRepository) DeleteById(id uuid.UUID) error

func (*StringRepository) FindAll

func (s *StringRepository) FindAll() ([]core.String, error)

func (*StringRepository) FindAllByThread

func (s *StringRepository) FindAllByThread(threadId uuid.UUID) ([]core.String, error)

func (*StringRepository) UpdateName

func (s *StringRepository) UpdateName(stringId uuid.UUID, name string) error

func (*StringRepository) UpdateOrder

func (s *StringRepository) UpdateOrder(stringOrders []core.StringOrder) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL