package cn.estsh.i3plus.pojo.model.softswitch;

import cn.estsh.i3plus.pojo.base.annotation.XStreamCDATA;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.softswitch.bean.BsSuitRecord;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
import io.swagger.annotations.ApiParam;
import lombok.Data;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * @Description :
 * @Reference :
 * @Author : wei.peng
 * @CreateDate : 19-9-5 下午7:30
 * @Modify:
 **/
@Data
@XStreamAlias("server")
@XmlRootElement(name = "server")
@XmlAccessorType(XmlAccessType.NONE)
public class SuitServerModel implements Serializable {

    private static final long serialVersionUID = 3501193688956575386L;
    // 执行方法命令
    @XmlElement
    @ApiParam(value = "适配器code")
    private String suitCaseCode;
    /* 认证使用 以后使用 */
    private String token;

    // 请求ID
    private String requestId;

    // 调用方自定义标识
    private String suitSid;

    // 重试记录id
    private Long retryRecordId;

    // 传输单对象
    @XmlElement(name = "data")
    @XStreamAlias("data")
    private Object obj;
    // 传输集合
    private List list;
    // 传输键值对
    private Map<String, Object> map;
    // 传输 JSON 数据
    private String json;

    /**
     * 适配结果信息
     */
//    @XStreamImplicit
    @XStreamCDATA
    @XmlElement
    private String suitMessage;

    /**
     * 适配状态码
     */
//    @XStreamImplicit
    private String suitCaseStatusCode = ResourceEnumUtil.MESSAGE.SUCCESS.getCode();

    /**
     * 适配结果
     */
//    @XStreamImplicit
    private boolean suitSuccess = true;

    /**
     * 适配记录
     */
    @XStreamOmitField
    private BsSuitRecord bsSuitRecord;

    /**
     * 适配器信息
     */
    @XStreamOmitField
    private BsSuitCaseModel bsSuitCaseModel;

    /**
     * 适配发送报文信息
     */
    @XStreamOmitField
    private String suitSendMessage;


    /**
     * 请求来源
     */
//    @XStreamImplicit
    private Integer requestSource;

    /**
     * 适配方式
     */
//    @XStreamImplicit
    private Integer suitMethodId;

    public int getSuitMethodIdVal() {
        if (suitMethodId == null) {
            return -1;
        }
        return suitMethodId.intValue();
    }

    //    @XStreamImplicit
    private String analyzeMessage;

    public SuitServerModel(){
    }
    public SuitServerModel(SuitModel suitModel){
        this.suitCaseCode = suitModel.getSuitCaseCode();
        this.requestSource = suitModel.getRequestSource();
        this.suitSid= suitModel.getSuitSid();
        this.retryRecordId = suitModel.getRetryRecordId();
        this.obj = suitModel.getParamXml();
    }
}
