package mq

import (
	"mtp20access/global"
	"mtp20access/model/common/response"
	"mtp20access/model/mq/request"
	"mtp20access/service/mq"

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

// SendNtfToMQ 发送总线通知信息
// @Summary 总线通知
// @accept  application/json
// @Produce application/json
// @Param   data body     request.MQNtfReq              true "入参"
// @Success 200  {object} response.Response{msg=string} "出参"
// @Router  /MQ/SendNtfToMQ [post]
// @Tags    总线业务
func SendNtfToMQ(c *gin.Context) {
	req := request.MQNtfReq{}
	if err := c.ShouldBindJSON(&req); err != nil {
		response.FailWithMessage("入参不正确", c)
		return
	} else {
		global.M2A_LOG.Info("[C->S]", zap.Any("req", req.FunCode), zap.Any("data", req.Data))
	}

	if err := mq.SendNtfMQ(&req, 0); err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}

	response.OkWithMessage("发送成功", c)
}
