rubbishclass-srv/app/user-handler.go

53 lines
897 B
Go
Raw Permalink Normal View History

2020-03-24 07:12:31 +00:00
package app
2020-03-30 13:28:58 +00:00
import (
"net/http"
2020-03-24 07:12:31 +00:00
2020-03-30 13:28:58 +00:00
"github.com/gin-gonic/gin"
"yyjishu.com/rubbish-class/user"
)
func UserCheckHandler(c *gin.Context) {
token := c.GetHeader("token")
userService := user.NewService()
r, err := userService.CheckSession(&token)
if err != nil {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
"err": err.Error(),
})
return
}
if !r {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
"err": "无效token!",
})
return
}
c.Next()
}
2020-03-24 07:12:31 +00:00
2020-03-30 13:28:58 +00:00
//UserInfoHandler 用户信息获取及变更
func UserInfoHandler(c *gin.Context) {
if c.Request.Method == "GET" {
c.JSON(http.StatusOK, gin.H{
"method": "get",
})
return
}
if c.Request.Method == "PUT" {
c.JSON(http.StatusOK, gin.H{
"method": "put",
})
return
}
c.JSON(http.StatusMethodNotAllowed, nil)
2020-03-24 07:12:31 +00:00
}
func UserListHandler(c *gin.Context) {
}
func FeeListHandler(c *gin.Context) {
}