package com.caliverse.admin.global.common.utils;

import com.caliverse.admin.domain.RabbitMq.message.MailItem;
import com.caliverse.admin.dynamodb.entity.SystemMessage;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

@Component
@RequiredArgsConstructor
public class JsonUtils {
    private static final Logger logger = LoggerFactory.getLogger(CommonUtils.class);
    private static final ObjectMapper objectMapper = new ObjectMapper();

    public static ObjectNode createSystemMessage(SystemMessage message) {
        ObjectNode node = objectMapper.createObjectNode();
        node.put("LanguageType", message.getLanguageType());
        node.put("Text", message.getText());
        return node;
    }

    public static ObjectNode createMAilItem(MailItem mailItem) {
        ObjectNode node = objectMapper.createObjectNode();
        node.put("ItemId", mailItem.getItemId());
        node.put("Count", mailItem.getCount());
        node.put("ProductId", 0);
        node.put("isRepeatProduct", false);
        return node;
    }
}
