spaceship

package
v0.0.0-...-e812b8c Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeEndpointCreate

func MakeEndpointCreate(s Service) endpoint.Endpoint

@BasePath / Create godoc @Description Create new spaceship. @Tags Spaceship @Accept json @Produce json @Param request body createRequest true "Request body (JSON)" @Success 201 @Failure 500 @Router /spaceship [post]

func MakeEndpointDeleteByID

func MakeEndpointDeleteByID(s Service) endpoint.Endpoint

@BasePath / Delete godoc @Description Delete existing spaceship by a specific ID. @Tags Spaceship @Produce json @Param id path string true "Spaceship ID (integer)" @Success 200 @Failure 400 @Failure 500 @Router /spaceship/{id} [delete]

func MakeEndpointGetAll

func MakeEndpointGetAll(s Service) endpoint.Endpoint

@BasePath / GetAll godoc @Description Get all spaceships. @Tags Spaceship @Produce json @Success 200 @Failure 500 @Router /spaceship [get]

func MakeEndpointGetByID

func MakeEndpointGetByID(s Service) endpoint.Endpoint

@BasePath / GetByID godoc @Description Fetch existing spaceship by a specific ID. @Tags Spaceship @Produce json @Param id path string true "Spaceship ID (integer)" @Success 200 @Failure 400 @Failure 500 @Router /spaceship/{id} [get]

func MakeEndpointUpdate

func MakeEndpointUpdate(s Service) endpoint.Endpoint

@BasePath / Update godoc @Description Update existing spaceship by a specific ID. @Tags Spaceship @Accept json @Produce json @Param id path string true "Spaceship ID (integer)" @Param request body updateRequest true "Request body (JSON)" @Success 200 @Failure 400 @Failure 500 @Router /spaceship/{id} [patch]

func NewService

func NewService(repo SpaceShipRepository, logger log.Logger) *service

func RegisterRoutes

func RegisterRoutes(router *httprouter.Router, s Service)

Types

type CreateRequestModel

type CreateRequestModel struct {
	Name      string
	Class     string
	Crew      int64
	Image     string
	Value     float64
	Status    string
	Armaments []armamentReqModel
}

func (CreateRequestModel) ToEntity

func (r CreateRequestModel) ToEntity() entity.SpaceShip

type CreateResponseModel

type CreateResponseModel struct {
	Success bool
}

type DeleteByIDRequestModel

type DeleteByIDRequestModel struct {
	ID int64
}

type DeleteByIDResponseModel

type DeleteByIDResponseModel struct {
	Success bool
}

type GetAllRequestModel

type GetAllRequestModel struct {
	Name   string
	Class  string
	Status string
}

func (GetAllRequestModel) ToEntity

func (r GetAllRequestModel) ToEntity() entity.SpaceShip

type GetAllResponseModel

type GetAllResponseModel struct {
	SpaceShip []entity.SpaceShip
}

type GetByIDRequestModel

type GetByIDRequestModel struct {
	ID int64
}

type GetByIDResponseModel

type GetByIDResponseModel struct {
	SpaceShip entity.SpaceShip
}

type Service

type Service interface {
	Create(ctx context.Context, req entity.SpaceShip) error
	GetByID(ctx context.Context, id int64) (entity.SpaceShip, error)
	Update(ctx context.Context, id int64, req entity.SpaceShip) error
	Delete(ctx context.Context, id int64) error
	GetAll(ctx context.Context, req entity.SpaceShip) ([]entity.SpaceShip, error)
}

type SpaceShipRepository

type SpaceShipRepository interface {
	Insert(ctx context.Context, req entity.SpaceShip) error
	GetByID(ctx context.Context, id int64) (entity.SpaceShip, error)
	Update(ctx context.Context, id int64, req entity.SpaceShip) error
	Delete(ctx context.Context, id int64) error
	GetAll(ctx context.Context, req entity.SpaceShip) ([]entity.SpaceShip, error)
	DeleteArmaments(ctx context.Context, spaceshipID int64) error
}

type UpdateRequestModel

type UpdateRequestModel struct {
	ID        int64
	Name      string
	Class     string
	Crew      int64
	Image     string
	Value     float64
	Status    string
	Armaments []armamentReqModel
}

func (UpdateRequestModel) ToEntity

func (r UpdateRequestModel) ToEntity() entity.SpaceShip

type UpdateResponseModel

type UpdateResponseModel struct {
	Success bool
}

Jump to

Keyboard shortcuts

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