package handler

import (
	"net/http"

	"github.com/gin-gonic/gin"

	"infogenie-backend/internal/middleware"
)

type UserHandler struct{}

func NewUserHandler() *UserHandler { return &UserHandler{} }

func (h *UserHandler) GetProfile(c *gin.Context) {
	authUser, exists := c.Get("auth_user")
	if !exists {
		c.JSON(http.StatusUnauthorized, gin.H{"success": false, "message": "未认证"})
		return
	}
	user := authUser.(*middleware.AuthCenterUser)

	c.JSON(http.StatusOK, gin.H{
		"success": true,
		"data": gin.H{
			"account":       user.Account,
			"username":      user.Username,
			"email":         user.Email,
			"avatar":        user.AvatarURL,
			"level":         user.Level,
			"sprout_coins":  user.SproutCoins,
			"checkin_days":  user.CheckInDays,
			"checkin_streak": user.CheckInStreak,
		},
	})
}
