Ajouter décompte
This commit is contained in:
parent
7351f970f7
commit
6c09f1fa65
9 changed files with 126 additions and 1 deletions
|
@ -13,6 +13,8 @@ import (
|
|||
func DeclareRoutes(e *echo.Echo, h *WebHandler) {
|
||||
e.GET("/", h.IndexGET)
|
||||
e.POST("/scan/", h.ScanPOST)
|
||||
e.GET("/decompte/", h.DecompteGET)
|
||||
e.GET("/nothing/", h.NothingGET)
|
||||
}
|
||||
|
||||
type WebHandler struct {
|
||||
|
@ -31,6 +33,19 @@ func (w *WebHandler) IndexGET(c echo.Context) error {
|
|||
r.Message = "foo"
|
||||
r.StatusCode = http.StatusOK
|
||||
|
||||
/*
|
||||
decompteResponse, err := w.APIClient.GetDecompte()
|
||||
if err != nil {
|
||||
r.Error = err.Error()
|
||||
r.Message = "Impossible d'obtenir le décompte"
|
||||
r.StatusCode = http.StatusInternalServerError
|
||||
|
||||
return c.Render(r.StatusCode, "index-html", r)
|
||||
}
|
||||
|
||||
r.Data.Decompte = decompteResponse.Data.Decompte
|
||||
*/
|
||||
|
||||
return c.Render(r.StatusCode, "index-html", r)
|
||||
}
|
||||
|
||||
|
@ -44,6 +59,19 @@ func (w *WebHandler) ScanPOST(c echo.Context) error {
|
|||
|
||||
r.StatusCode = http.StatusOK
|
||||
|
||||
/*
|
||||
decompteResponse, err := w.APIClient.GetDecompte()
|
||||
if err != nil {
|
||||
r.Error = err.Error()
|
||||
r.Message = "Impossible d'obtenir le décompte"
|
||||
r.StatusCode = http.StatusInternalServerError
|
||||
|
||||
return c.Render(r.StatusCode, "index-html", r)
|
||||
}
|
||||
|
||||
r.Data.Decompte = decompteResponse.Data.Decompte
|
||||
*/
|
||||
|
||||
scanResponse, err := w.APIClient.Scan(membreID)
|
||||
r.Error = scanResponse.Error
|
||||
if err != nil {
|
||||
|
@ -54,3 +82,27 @@ func (w *WebHandler) ScanPOST(c echo.Context) error {
|
|||
|
||||
return c.Render(r.StatusCode, "scan-html", r)
|
||||
}
|
||||
|
||||
func (w *WebHandler) DecompteGET(c echo.Context) error {
|
||||
var r webresponse.DecompteGET
|
||||
|
||||
decompteResponse, err := w.APIClient.GetDecompte()
|
||||
if err != nil {
|
||||
r.Error = err.Error()
|
||||
r.Message = "Impossible d'obtenir le décompte"
|
||||
r.StatusCode = http.StatusInternalServerError
|
||||
|
||||
return c.Render(r.StatusCode, "decompte-html", r)
|
||||
}
|
||||
|
||||
r.Data.Decompte = decompteResponse.Data.Decompte
|
||||
|
||||
r.StatusCode = http.StatusOK
|
||||
r.Message = "ok"
|
||||
|
||||
return c.Render(r.StatusCode, "decompte-html", r)
|
||||
}
|
||||
|
||||
func (w *WebHandler) NothingGET(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, nil)
|
||||
}
|
||||
|
|
Reference in a new issue