package plant

import (
	"sundynix-go/global"
	"sundynix-go/model/commom/response"
	plantRes "sundynix-go/model/plant/response"

	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
)

type CallbackApi struct{}

// MediaCheckCallback 微信内容安全回调接口
func (a *CallbackApi) MediaCheckCallback(c *gin.Context) {
	var cb plantRes.WeChatCheckResultCallback
	if err := c.ShouldBindJSON(&cb); err != nil {
		global.Logger.Error("解析微信回调JSON失败", zap.Error(err))
		response.FailWithMsg("解析失败", c)
		return
	}

	if err := callbackService.HandleMediaCheckCallback(cb); err != nil {
		global.Logger.Error("处理微信回调失败", zap.Error(err))
		response.FailWithMsg("处理失败", c)
		return
	}

	response.OkWithMsg("success", c)
}
