package api

import (
	"gadmin/internal/admin/forms"
	"gadmin/internal/admin/service"
	"github.com/gin-gonic/gin"
)

func DiamondRanking(c *gin.Context) {
	var req forms.DiamondRankingReq
	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.ChangedLogs.DiamondRanking(c, req))
}

func ItemRanking(c *gin.Context) {
	var req forms.ItemRankingReq
	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.ChangedLogs.ItemRanking(c, req))
}

func ChangedLogsList(c *gin.Context) {
	var req forms.ChangedLogsListReq
	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.ChangedLogs.List(c, req))
}

func ConsumptionStatistics(c *gin.Context) {
	var req forms.ConsumptionStatisticsReq
	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.ChangedLogs.Statistics(c, req))
}
