-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from YSTV/echo
Echo
- Loading branch information
Showing
24 changed files
with
1,917 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.env | ||
sqlboiler | ||
sqlboiler-psql | ||
sqlboiler.toml | ||
sqlboiler.toml | ||
swag |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package tables | ||
|
||
import ( | ||
"net/http" | ||
"strconv" | ||
|
||
"github.com/labstack/echo/v4" | ||
"github.com/ystv/web-api/models" | ||
"github.com/ystv/web-api/services" | ||
) | ||
|
||
// QuoteCreate Quote create API | ||
// @Summary Quote create API | ||
// @Description Create new quote | ||
// @Accept json | ||
// @Produce json | ||
// @Param body body models.Quote true "quote create parameter" | ||
// @Success 200 {object} models.Quote | ||
// @Router /v1/tables/quotes [post] | ||
func QuoteCreate(c echo.Context) error { | ||
q := new(models.Quote) | ||
err := c.Bind(q) | ||
if err != nil { | ||
return c.JSON(http.StatusBadRequest, err.Error()) | ||
} | ||
id, err := services.QuoteCreate(q) | ||
if err != nil { | ||
return c.JSON(http.StatusInternalServerError, err.Error()) | ||
} | ||
return c.JSON(http.StatusOK, id) | ||
} | ||
|
||
// QuoteList Quote list API | ||
// @Summary Quote list API | ||
// @Description list quotes | ||
// @Accept json | ||
// @Produce json | ||
// @Success 200 {object} models.QuoteSlice | ||
// @Router /v1/tables/quotes [get] | ||
func QuoteList(c echo.Context) error { | ||
res, err := services.QuoteList() | ||
if err != nil { | ||
return err | ||
} | ||
return c.JSON(http.StatusOK, res) | ||
} | ||
|
||
// QuoteFind Quote find API | ||
// @Summary Quote find API | ||
// @Description find quote | ||
// @Accept json | ||
// @Produce json | ||
// @Success 200 {object} models.Quote | ||
// @Router /v1/tables/quotes/{quote_id} [get] | ||
func QuoteFind(c echo.Context) error { | ||
id, err := strconv.Atoi(c.Param("id")) | ||
if err != nil { | ||
c.String(http.StatusBadRequest, "Number pls") | ||
} | ||
res, err := services.QuoteFind(id) | ||
if err != nil { | ||
return err | ||
} | ||
return c.JSON(http.StatusOK, res) | ||
} | ||
|
||
// QuoteUpdate Quote update API | ||
// @Summary Quote update API | ||
// @Description update quotes | ||
// @Accept json | ||
// @Produce json | ||
// @Param quote_id path int true "quote id parameter" | ||
// @Success 200 string string "" | ||
// @Router /v1/tables/quotes/{quote_id} [put] | ||
func QuoteUpdate(c echo.Context) error { | ||
// Check new quote will bind | ||
newQuote := new(models.Quote) | ||
err := c.Bind(newQuote) | ||
if err != nil { | ||
return c.JSON(http.StatusBadRequest, err.Error()) | ||
} | ||
// Finding quote to update | ||
id, err := strconv.Atoi(c.Param("id")) | ||
if err != nil { | ||
c.String(http.StatusBadRequest, "Number pls") | ||
} | ||
oldQuote, err := services.QuoteFind(id) | ||
if err != nil { | ||
return c.JSON(http.StatusNotFound, err.Error()) | ||
} | ||
// Update quote | ||
err = services.QuoteUpdate(oldQuote, newQuote) | ||
if err != nil { | ||
return c.JSON(http.StatusInternalServerError, err.Error()) | ||
} | ||
return c.JSON(http.StatusOK, oldQuote) | ||
} | ||
|
||
// QuoteDelete Quote delete API | ||
// @Summary Quote delete API | ||
// @Description delete quotes | ||
// @Accept json | ||
// @Produce json | ||
// @Param quote_id path int true "quote id parameter" | ||
// @Success 200 string string "" | ||
// @Router /v1/tables/quotes/{quote_id} [delete] | ||
func QuoteDelete(c echo.Context) error { | ||
id, err := strconv.Atoi(c.Param("id")) | ||
if err != nil { | ||
c.String(http.StatusBadRequest, "Number pls") | ||
} | ||
res, err := services.QuoteDelete(id) | ||
if err != nil { | ||
return err | ||
} | ||
return c.JSON(http.StatusOK, res) | ||
} |
2 changes: 1 addition & 1 deletion
2
controllers/videoboxes.go → controllers/v1/tables/videoboxes.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package controllers | ||
package tables | ||
|
||
import ( | ||
"context" | ||
|
2 changes: 1 addition & 1 deletion
2
controllers/videofiles.go → controllers/v1/tables/videofiles.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package controllers | ||
package tables | ||
|
||
import ( | ||
"context" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package tables | ||
|
||
import ( | ||
"net/http" | ||
"strconv" | ||
|
||
"github.com/labstack/echo/v4" | ||
"github.com/ystv/web-api/services" | ||
) | ||
|
||
// VideoCreate Video create API | ||
// @Summary Video create API | ||
// @Description create new video, there is more to videos! | ||
// @Accept json | ||
// @Produce json | ||
// @Param body body models.Video true "video create parameter" | ||
// @Success 200 {object} models.Video | ||
// @Router /v1/tables/videos [post] | ||
func VideoCreate(c echo.Context) error { | ||
return c.JSON(http.StatusOK, "update ok") | ||
} | ||
|
||
// VideoList Video list API | ||
// @Summary Video list API | ||
// @Description list videos | ||
// @Accept json | ||
// @Produce json | ||
// @Success 200 {object} models.VideoSlice | ||
// @Router /v1/tables/videos [get] | ||
func VideoList(c echo.Context) error { | ||
res, err := services.VideoList() | ||
if err != nil { | ||
return err | ||
} | ||
return c.JSON(http.StatusOK, res) | ||
} | ||
|
||
// VideoFind Video find API | ||
// @Summary Video find API | ||
// @Description find video | ||
// @Accept json | ||
// @Produce json | ||
// @Success 200 {object} models.Video | ||
// @Router /v1/tables/videos/{video_id} [get] | ||
func VideoFind(c echo.Context) error { | ||
id, err := strconv.Atoi(c.Param("id")) | ||
if err != nil { | ||
c.String(400, "Number pls") | ||
} | ||
res, err := services.VideoFind(id) | ||
if err != nil { | ||
return err | ||
} | ||
return c.JSON(http.StatusOK, res) | ||
} | ||
|
||
// VideoUpdate Video update API | ||
// @Summary Video update API | ||
// @Description update videos | ||
// @Accept json | ||
// @Produce json | ||
// @Param video_id path int true "video id parameter" | ||
// @Success 200 string string "" | ||
// @Router /v1/tables/videos/{video_id} [put] | ||
func VideoUpdate(c echo.Context) error { | ||
return c.JSON(http.StatusOK, "update ok") | ||
} | ||
|
||
// VideoDelete Video delete API | ||
// @Summary Video delete API | ||
// @Description delete videos | ||
// @Accept json | ||
// @Produce json | ||
// @Param video_id path int true "video id parameter" | ||
// @Success 200 string string "" | ||
// @Router /v1/tables/videos/{video_id} [delete] | ||
func VideoDelete(c echo.Context) error { | ||
return c.JSON(http.StatusOK, "delete ok") | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.