Restructure project
This commit is contained in:
parent
e44e7caa11
commit
16b2f17301
46 changed files with 1744 additions and 1265 deletions
51
internal/controller/routesTable.go
Normal file
51
internal/controller/routesTable.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// @Schemes
|
||||
// @Summary get all active tables
|
||||
// @Description gets all active tables as array
|
||||
// @Tags tables
|
||||
// @Produce json
|
||||
// @Success 200 {array} Table
|
||||
// @Router /tables [get]
|
||||
func (c *Controller) GetTables(ctx echo.Context) error {
|
||||
return ctx.JSON(http.StatusOK, c.GetAllTables())
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary create new table
|
||||
// @Description creates a new table and returns it
|
||||
// @Tags tables
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 201 {object} Table "Table has been created"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /tables [post]
|
||||
func (c *Controller) CreateTable(ctx echo.Context) error {
|
||||
table, err := c.CreateNewTable()
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
return ctx.JSON(http.StatusCreated, table)
|
||||
}
|
||||
|
||||
// @Schemes
|
||||
// @Summary delete the latest table
|
||||
// @Description deletes the latest table from the database
|
||||
// @Tags tables
|
||||
// @Produce json
|
||||
// @Success 200 "OK"
|
||||
// @Failure 500 "Internal Server Error"
|
||||
// @Router /tables [delete]
|
||||
func (c *Controller) DeleteTable(ctx echo.Context) error {
|
||||
err := c.DeleteLatestTable()
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
return ctx.NoContent(http.StatusOK)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue