package cn.axzo.msg.center.domain.entity;

import cn.axzo.msg.center.domain.persistence.BaseOwnEntity;
import cn.axzo.trade.datasecurity.core.annotation.CryptField;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * <p>
 * 消息记录表
 * </p>
 *
 * @author zhaoyong
 * @since 2021-05-19
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("mns_message")
public class MNSMessage extends BaseOwnEntity<MNSMessage> {

    private static final long serialVersionUID=1L;

    /**
     * 应用no
     */
    @TableField("app_no")
    private String appNo;

    /**
     * APP请求号
     */
    @TableField("request_no")
    private String requestNo;

    /**
     * 批次号
     */
    @TableField("batch_no")
    private String batchNo;

    /**
     * 请求渠道号
     */
    @TableField("message_order_no")
    private String messageOrderNo;

    /**
     * 消息类型(M:邮件;S:短信)
     */
    @TableField("message_type")
    private String messageType;

    /**
     * 通知类型(REAL:实时发送;BATCH:批量发送;DELAY:延迟发送)
     */
    @TableField("notify_type")
    private String notifyType;

    /**
     * 状态(INIT:初始化;PROCESSING:处理中;EXCEPTION:处理异常;FAIL:处理失败;SUCCESS:成功)
     */
    @TableField("status")
    private String status;

    /**
     * 渠道码
     */
    @TableField("channel_code")
    private String channelCode;

    /**
     * 渠道名称
     */
    @TableField("channel_name")
    private String channelName;

    /**
     * 模板号
     */
    @TableField("template_no")
    private String templateNo;

    /**
     * 内容
     */
    @TableField("subject")
    @CryptField
    private String subject;

    /**
     * 通知地址
     */
    @TableField("target_address")
    @CryptField
    private String targetAddress;

    /**
     * 发送回执ID(阿里云)
     */
    @TableField("channel_biz_id")
    private String channelBizId;

    /**
     * 渠道响应请求 ID(阿里云)
     */
    @TableField("channel_request_id")
    private String channelRequestId;

    /**
     * 通知策略(30, 60, 120)
     */
    @TableField("notify_rule")
    private String notifyRule;

    /**
     * 备注
     */
    @TableField("remark")
    private String remark;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
