package zapx

import (
	"encoding/json"

	amqp "github.com/rabbitmq/amqp091-go"
)

// 设置日志记录消息
func SetLogPublishBody(p *amqp.Publishing, record LogRecord) error {
	bs, err := json.Marshal(record)
	if err != nil {
		return err
	}

	p.ContentType = "application/json"
	p.Body = bs
	return nil
}

// 设置日志记录消息
func WriteLogPublishBody(p *amqp.Publishing, bs []byte) error {
	p.ContentType = "application/json"
	p.Body = bs
	return nil
}

// 设置操作记录消息
func SetOperatePublishBody(p *amqp.Publishing, record OperateRecord) error {
	bs, err := json.Marshal(record)
	if err != nil {
		return err
	}

	p.ContentType = "application/json"
	p.Body = bs
	return nil
}
