package com.mortals.xhx.common.model;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.SignAlgorithm;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.common.code.MessageProtocolEnum;
import com.mortals.xhx.queue.TbQueueMsgHeaders;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 默认消息头
 *
 * @author: zxfei
 * @date: 2021/11/22 11:14
 */
public class DefaultTbQueueMsgHeaders implements TbQueueMsgHeaders {

    @Setter
    protected  Map<String, String> data = new HashMap<>();

    public DefaultTbQueueMsgHeaders() {
        data.put(MessageHeader.TIMESTAMP, String.valueOf(new Date().getTime()));
       // data.put(MessageHeader.MESSAGESIGN, new String(SecureUtil.sign(SignAlgorithm.SHA256withRSA).sign(data.get(MessageHeader.TIMESTAMP).getBytes())));
        // TODO: 2022/4/15
        data.put(MessageHeader.MESSAGESIGN, "abcd1234");
        data.put(MessageHeader.MESSAGEPROTOCOL, MessageProtocolEnum.JSON.getValue());
      //  data.put(MessageHeader.TOPIC, "");
       // data.put(MessageHeader.QOS, "0");

    }

    @Override
    public void put(String key, String value) {
        data.put(key, value);
    }

    @Override
    public String get(String key) {
        return data.get(key);
    }

    @Override
    public Map<String, String> getData() {
        return data;
    }
}
