27 lines
467 B
Go
27 lines
467 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"myschools.me/xixi.xv/hello/model"
|
|
"myschools.me/xixi.xv/hello/service"
|
|
)
|
|
|
|
// user login
|
|
func UserLogin(c *gin.Context) {
|
|
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)
|
|
}
|