package api

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

func ChatReportList(c *gin.Context) {
	var req forms.ChatReportListReq
	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.ChatReport.List(c, &req))
}

func ChatLogList(c *gin.Context) {
	var req forms.ChatLogListReq
	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.ChatReport.LogList(c, &req))
}

func DownloadChatLog(c *gin.Context) {
	var req forms.DownloadChatLogReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(403, ErrorResponse(err))
		return
	}
	if err := forms.ParseParams(&req); err != nil {
		c.JSON(403, ErrorResponse(err))
		return
	}
	service.ChatReport.DownloadLog(c, &req)
}

func ChatMsgList(c *gin.Context) {
	var req forms.ChatMsgListReq
	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.ChatReport.ChatMsgList(c, &req))
}
