Fix swagger deps
This commit is contained in:
parent
28f068c890
commit
f63210272d
28 changed files with 307 additions and 310 deletions
|
@ -6,19 +6,18 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"gitlab.unjx.de/flohoss/cafe-plaetschwiesle/internal/types"
|
||||
)
|
||||
|
||||
// @Schemes
|
||||
// @Summary get all orders
|
||||
// @Description gets all orders as array
|
||||
// @Tags orders
|
||||
// @Produce json
|
||||
// @Param table query int false "Table ID"
|
||||
// @Param grouping query bool false "grouping"
|
||||
// @Param filter query string false "filter"
|
||||
// @Success 200 {array} Order
|
||||
// @Router /orders [get]
|
||||
// @Schemes
|
||||
// @Summary get all orders
|
||||
// @Description gets all orders as array
|
||||
// @Tags orders
|
||||
// @Produce json
|
||||
// @Param table query int false "Table ID"
|
||||
// @Param grouping query bool false "grouping"
|
||||
// @Param filter query string false "filter"
|
||||
// @Success 200 {array} Order
|
||||
// @Router /orders [get]
|
||||
func (c *Controller) GetOrders(ctx echo.Context) error {
|
||||
table, _ := strconv.ParseUint(ctx.QueryParam("table"), 10, 64)
|
||||
grouping, _ := strconv.ParseBool(ctx.QueryParam("grouping"))
|
||||
|
@ -37,23 +36,23 @@ func (c *Controller) GetOrders(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusOK, orders)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary create new order
|
||||
// @Description creates a new order and returns it
|
||||
// @Tags orders
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param item query int true "OrderItem ID"
|
||||
// @Param table query int true "Table ID"
|
||||
// @Success 201 {object} Order
|
||||
// @Failure 400
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders [post]
|
||||
// @Schemes
|
||||
// @Summary create new order
|
||||
// @Description creates a new order and returns it
|
||||
// @Tags orders
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param item query int true "OrderItem ID"
|
||||
// @Param table query int true "Table ID"
|
||||
// @Success 201 {object} Order
|
||||
// @Failure 400
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders [post]
|
||||
func (c *Controller) CreateOrder(ctx echo.Context) error {
|
||||
table, err1 := strconv.ParseUint(ctx.QueryParam("table"), 10, 64)
|
||||
item, err2 := strconv.ParseUint(ctx.QueryParam("item"), 10, 64)
|
||||
if err1 != nil || err2 != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, types.MissingInformation.String())
|
||||
return echo.NewHTTPError(http.StatusBadRequest, MissingInformation.String())
|
||||
}
|
||||
order := Order{TableID: table, OrderItemID: item, IsServed: false}
|
||||
err := c.createOrder(&order)
|
||||
|
@ -63,22 +62,22 @@ func (c *Controller) CreateOrder(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusCreated, order)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary delete an order
|
||||
// @Description deletes an order from the database
|
||||
// @Tags orders
|
||||
// @Produce json
|
||||
// @Param item query int true "OrderItem ID"
|
||||
// @Param table query int true "Table ID"
|
||||
// @Success 200 "OK"
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders [delete]
|
||||
// @Schemes
|
||||
// @Summary delete an order
|
||||
// @Description deletes an order from the database
|
||||
// @Tags orders
|
||||
// @Produce json
|
||||
// @Param item query int true "OrderItem ID"
|
||||
// @Param table query int true "Table ID"
|
||||
// @Success 200 "OK"
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders [delete]
|
||||
func (c *Controller) DeleteOrder(ctx echo.Context) error {
|
||||
item := ctx.QueryParam("item")
|
||||
table := ctx.QueryParam("table")
|
||||
if table == "" || item == "" {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, types.MissingInformation.String())
|
||||
return echo.NewHTTPError(http.StatusBadRequest, MissingInformation.String())
|
||||
}
|
||||
err := c.deleteOrder(table, item)
|
||||
if err != nil {
|
||||
|
@ -87,18 +86,18 @@ func (c *Controller) DeleteOrder(ctx echo.Context) error {
|
|||
return ctx.NoContent(http.StatusOK)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary update an order
|
||||
// @Description updates an order with provided information
|
||||
// @Tags orders
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param order body Order true "updated Order"
|
||||
// @Success 200 {object} Order
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders [put]
|
||||
// @Schemes
|
||||
// @Summary update an order
|
||||
// @Description updates an order with provided information
|
||||
// @Tags orders
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param order body Order true "updated Order"
|
||||
// @Success 200 {object} Order
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders [put]
|
||||
func (c *Controller) UpdateOrder(ctx echo.Context) error {
|
||||
var newOrder Order
|
||||
err := ctx.Bind(&newOrder)
|
||||
|
@ -116,33 +115,33 @@ func (c *Controller) UpdateOrder(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusOK, newOrder)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary get all orderItems
|
||||
// @Description gets all orderItems as array
|
||||
// @Tags orderItems
|
||||
// @Produce json
|
||||
// @Param type query int true "ItemType"
|
||||
// @Success 200 {array} OrderItem
|
||||
// @Router /orders/items [get]
|
||||
// @Schemes
|
||||
// @Summary get all orderItems
|
||||
// @Description gets all orderItems as array
|
||||
// @Tags orderItems
|
||||
// @Produce json
|
||||
// @Param type query int true "ItemType"
|
||||
// @Success 200 {array} OrderItem
|
||||
// @Router /orders/items [get]
|
||||
func (c *Controller) GetOrderItems(ctx echo.Context) error {
|
||||
orderType := ctx.QueryParam("type")
|
||||
if orderType == "" {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, types.MissingInformation.String())
|
||||
return echo.NewHTTPError(http.StatusBadRequest, MissingInformation.String())
|
||||
}
|
||||
return ctx.JSON(http.StatusOK, c.getOrderItemsForType(orderType))
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary create new orderItem
|
||||
// @Description creates a new orderItem and returns it
|
||||
// @Tags orderItems
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param order body OrderItem true "OrderItem ID"
|
||||
// @Success 201 {object} OrderItem
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders/items [post]
|
||||
// @Schemes
|
||||
// @Summary create new orderItem
|
||||
// @Description creates a new orderItem and returns it
|
||||
// @Tags orderItems
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param order body OrderItem true "OrderItem ID"
|
||||
// @Success 201 {object} OrderItem
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders/items [post]
|
||||
func (c *Controller) CreateOrderItem(ctx echo.Context) error {
|
||||
var orderItem OrderItem
|
||||
err := ctx.Bind(&orderItem)
|
||||
|
@ -156,18 +155,18 @@ func (c *Controller) CreateOrderItem(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusCreated, orderItem)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary update a orderItem
|
||||
// @Description updates a orderItem with provided information
|
||||
// @Tags orderItems
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param orderItem body OrderItem true "updated OrderItem"
|
||||
// @Success 200 {object} OrderItem
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders/items [put]
|
||||
// @Schemes
|
||||
// @Summary update a orderItem
|
||||
// @Description updates a orderItem with provided information
|
||||
// @Tags orderItems
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param orderItem body OrderItem true "updated OrderItem"
|
||||
// @Success 200 {object} OrderItem
|
||||
// @Failure 400 "Bad Request"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders/items [put]
|
||||
func (c *Controller) UpdateOrderItem(ctx echo.Context) error {
|
||||
var newOrderItem OrderItem
|
||||
err := ctx.Bind(&newOrderItem)
|
||||
|
@ -185,16 +184,16 @@ func (c *Controller) UpdateOrderItem(ctx echo.Context) error {
|
|||
return ctx.JSON(http.StatusOK, newOrderItem)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary delete an orderItem
|
||||
// @Description deletes an orderItem from the database
|
||||
// @Tags orderItems
|
||||
// @Produce json
|
||||
// @Param id path int true "OrderItem ID"
|
||||
// @Success 200 "OK"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders/items/{id} [delete]
|
||||
// @Schemes
|
||||
// @Summary delete an orderItem
|
||||
// @Description deletes an orderItem from the database
|
||||
// @Tags orderItems
|
||||
// @Produce json
|
||||
// @Param id path int true "OrderItem ID"
|
||||
// @Success 200 "OK"
|
||||
// @Failure 404 "Not Found"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /orders/items/{id} [delete]
|
||||
func (c *Controller) DeleteOrderItem(ctx echo.Context) error {
|
||||
id := ctx.Param("id")
|
||||
orderItem, err := c.doesOrderItemExist(id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue