26 lines
445 B
Go
26 lines
445 B
Go
//go:build ignore
|
|
|
|
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
"xboard-go/internal/database"
|
|
"xboard-go/internal/model"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func UserInfo(c *gin.Context) {
|
|
userID, _ := c.Get("user_id")
|
|
|
|
var user model.User
|
|
if err := database.DB.Preload("Plan").First(&user, userID).Error; err != nil {
|
|
c.JSON(http.StatusNotFound, gin.H{"message": "用户不存在"})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"data": user,
|
|
})
|
|
}
|