Implémenter page web de scan de présence
Voir diff pour détails
This commit is contained in:
parent
c6f3a52f91
commit
c218860e33
10 changed files with 139 additions and 10 deletions
|
@ -2,21 +2,27 @@
|
|||
package webhandler
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"git.agecem.com/agecem/bottin-ag/apiclient"
|
||||
"git.agecem.com/agecem/bottin-ag/webresponse"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func DeclareRoutes(e *echo.Echo, h *WebHandler) {
|
||||
e.GET("/", h.IndexGET)
|
||||
e.POST("/scan/", h.ScanPOST)
|
||||
}
|
||||
|
||||
type WebHandler struct {
|
||||
APIClient *apiclient.APIClient
|
||||
}
|
||||
|
||||
func New() WebHandler {
|
||||
return WebHandler{}
|
||||
func New(apiClient *apiclient.APIClient) WebHandler {
|
||||
return WebHandler{
|
||||
APIClient: apiClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WebHandler) IndexGET(c echo.Context) error {
|
||||
|
@ -27,3 +33,24 @@ func (w *WebHandler) IndexGET(c echo.Context) error {
|
|||
|
||||
return c.Render(r.StatusCode, "index-html", r)
|
||||
}
|
||||
|
||||
func (w *WebHandler) ScanPOST(c echo.Context) error {
|
||||
var r webresponse.ScanPOST
|
||||
|
||||
membreID := c.FormValue("membre_id")
|
||||
|
||||
//TODO
|
||||
log.Println("membreID:", membreID)
|
||||
|
||||
r.StatusCode = http.StatusOK
|
||||
|
||||
scanResponse, err := w.APIClient.Scan(membreID)
|
||||
r.Error = scanResponse.Error
|
||||
if err != nil {
|
||||
r.Error = err.Error()
|
||||
}
|
||||
|
||||
r.Message = scanResponse.Message
|
||||
|
||||
return c.Render(r.StatusCode, "scan-html", r)
|
||||
}
|
||||
|
|
Reference in a new issue