package com.ematou.wxservice.mp.message;

import com.alibaba.fastjson.annotation.JSONField;
import com.ematou.wxservice.common.utils.XStreamTransformer;
import com.ematou.wxservice.common.xml.converter.XStreamCDataConverter;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;

import java.io.InputStream;
import java.io.Serializable;

/**
 * 用户发过来的消息
 * @author lhm
 * @version 1.0
 * 2021-05-11 16:08
 */
@XStreamAlias("xml")
public class WeChatMessage implements Serializable {
    private static final long serialVersionUID = -3586245291677274914L;

    @JSONField(name = "Encrypt")
    @XStreamAlias("Encrypt")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String encrypt;

    @JSONField(name = "ToUserName")
    @XStreamAlias("ToUserName")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String toUser;

    @JSONField(name = "FromUserName")
    @XStreamAlias("FromUserName")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String fromUser;

    @JSONField(name = "CreateTime")
    @XStreamAlias("CreateTime")
    private Integer createTime;

    @JSONField(name = "MsgType")
    @XStreamAlias("MsgType")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String msgType;

    @JSONField(name = "MsgDataFormat")
    @XStreamAlias("MsgDataFormat")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String msgDataFormat;

    @JSONField(name = "Content")
    @XStreamAlias("Content")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String content;

    @JSONField(name = "MsgId")
    @XStreamAlias("MsgId")
    private Long msgId;

    @JSONField(name = "PicUrl")
    @XStreamAlias("PicUrl")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String picUrl;

    @JSONField(name = "MediaId")
    @XStreamAlias("MediaId")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String mediaId;

    @JSONField(name = "Event")
    @XStreamAlias("Event")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String event;

    @JSONField(name = "EventKey")
    @XStreamAlias("EventKey")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String eventKey;

    @JSONField(name = "Title")
    @XStreamAlias("Title")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String title;

    @JSONField(name = "AppId")
    @XStreamAlias("AppId")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String appId;

    @JSONField(name = "PagePath")
    @XStreamAlias("PagePath")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String pagePath;

    @JSONField(name = "ThumbUrl")
    @XStreamAlias("ThumbUrl")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String thumbUrl;

    @JSONField(name = "ThumbMediaId")
    @XStreamAlias("ThumbMediaId")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String thumbMediaId;

    @JSONField(name = "SessionFrom")
    @XStreamAlias("SessionFrom")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String sessionFrom;

    /**
     * 以下是异步校验图片/音频是否含有违法违规内容的异步检测结果推送报文中的参数
     */
    @JSONField(name = "isrisky")
    @XStreamAlias("isrisky")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String isRisky;

    @JSONField(name = "extra_info_json")
    @XStreamAlias("extra_info_json")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String extraInfoJson;

    @JSONField(name = "appid")
    @XStreamAlias("appid")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String appid;

    @JSONField(name = "trace_id")
    @XStreamAlias("trace_id")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String traceId;

    @JSONField(name = "status_code")
    @XStreamAlias("status_code")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String statusCode;

    @JSONField(name = "Status")
    @XStreamAlias("Status")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String status;

    @JSONField(name = "Scene")
    @XStreamAlias("Scene")
    private Integer scene;

    @JSONField(name = "Query")
    @XStreamAlias("Query")
    @XStreamConverter(value = XStreamCDataConverter.class)
    private String query;


    public static WeChatMessage fromXml(String xml) {
        return XStreamTransformer.fromXml(WeChatMessage.class, xml);
    }

    public static WeChatMessage fromXml(InputStream is) {
        return XStreamTransformer.fromXml(WeChatMessage.class, is);
    }


    public String getEncrypt() {
        return encrypt;
    }

    public void setEncrypt(String encrypt) {
        this.encrypt = encrypt;
    }

    public String getToUser() {
        return toUser;
    }

    public void setToUser(String toUser) {
        this.toUser = toUser;
    }

    public String getFromUser() {
        return fromUser;
    }

    public void setFromUser(String fromUser) {
        this.fromUser = fromUser;
    }

    public Integer getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Integer createTime) {
        this.createTime = createTime;
    }

    public String getMsgType() {
        return msgType;
    }

    public void setMsgType(String msgType) {
        this.msgType = msgType;
    }

    public String getMsgDataFormat() {
        return msgDataFormat;
    }

    public void setMsgDataFormat(String msgDataFormat) {
        this.msgDataFormat = msgDataFormat;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Long getMsgId() {
        return msgId;
    }

    public void setMsgId(Long msgId) {
        this.msgId = msgId;
    }

    public String getPicUrl() {
        return picUrl;
    }

    public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
    }

    public String getMediaId() {
        return mediaId;
    }

    public void setMediaId(String mediaId) {
        this.mediaId = mediaId;
    }

    public String getEvent() {
        return event;
    }

    public void setEvent(String event) {
        this.event = event;
    }

    public String getEventKey() {
        return eventKey;
    }

    public void setEventKey(String eventKey) {
        this.eventKey = eventKey;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getPagePath() {
        return pagePath;
    }

    public void setPagePath(String pagePath) {
        this.pagePath = pagePath;
    }

    public String getThumbUrl() {
        return thumbUrl;
    }

    public void setThumbUrl(String thumbUrl) {
        this.thumbUrl = thumbUrl;
    }

    public String getThumbMediaId() {
        return thumbMediaId;
    }

    public void setThumbMediaId(String thumbMediaId) {
        this.thumbMediaId = thumbMediaId;
    }

    public String getSessionFrom() {
        return sessionFrom;
    }

    public void setSessionFrom(String sessionFrom) {
        this.sessionFrom = sessionFrom;
    }

    public String getIsRisky() {
        return isRisky;
    }

    public void setIsRisky(String isRisky) {
        this.isRisky = isRisky;
    }

    public String getExtraInfoJson() {
        return extraInfoJson;
    }

    public void setExtraInfoJson(String extraInfoJson) {
        this.extraInfoJson = extraInfoJson;
    }

    public String getAppid() {
        return appid;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    public String getTraceId() {
        return traceId;
    }

    public void setTraceId(String traceId) {
        this.traceId = traceId;
    }

    public String getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(String statusCode) {
        this.statusCode = statusCode;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Integer getScene() {
        return scene;
    }

    public void setScene(Integer scene) {
        this.scene = scene;
    }

    public String getQuery() {
        return query;
    }

    public void setQuery(String query) {
        this.query = query;
    }
}
