package app import ( "net/http" "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() } //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) } func UserListHandler(c *gin.Context) { } func FeeListHandler(c *gin.Context) { }