package api

import (
	"gadmin/internal/admin/forms"
	"gadmin/internal/admin/service"

	"github.com/gin-gonic/gin"
)

func PlayerAttrGet(c *gin.Context) {
	var req forms.PlayerAttrGetReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.PlayerAttr.Get(c, req))
}

func PlayerAttrGetAll(c *gin.Context) {
	var req forms.PlayerAttrGetAllReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.PlayerAttr.GetAll(c, req))
}

func LevelRanking(c *gin.Context) {
	var req forms.LevelRankingReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.PlayerAttr.LevelRanking(c, req))
}

func AdvRanking(c *gin.Context) {
	var req forms.AdvRankingReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.AdvertisementLog.AdvRanking(c, req))
}

func LoginRanking(c *gin.Context) {
	var req forms.LoginRankingReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.LoginLog.Ranking(c, req))
}

func LoginList(c *gin.Context) {
	var req forms.LoginLogListReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	if err := forms.ParseParams(&req); err != nil {
		c.JSON(200, ErrorResponse(err))
		return
	}

	c.JSON(200, service.LoginLog.List(c, req))
}
