hello/handler/user-handler.go

27 lines
467 B
Go
Raw Normal View History

2024-07-10 08:07:44 +00:00
package handler
import (
"net/http"
"github.com/gin-gonic/gin"
"myschools.me/xixi.xv/hello/model"
"myschools.me/xixi.xv/hello/service"
)
2024-07-11 01:21:33 +00:00
// user login
func UserLogin(c *gin.Context) {
2024-07-10 08:07:44 +00:00
data := &model.User{}
if err := c.ShouldBindJSON(data); err != nil {
c.AbortWithStatus(http.StatusBadRequest)
return
}
ret, err := service.UserLogin(data)
if err != nil {
c.AbortWithStatus(http.StatusInternalServerError)
return
}
c.JSON(http.StatusOK, ret)
}