package com.fxy.realm;

import android.os.Parcel;
import android.os.Parcelable;

import com.fxy.baselibrary.util.JsonUtil;
import com.fxy.detection.bean.DealDiffBean;
import com.luck.picture.lib.entity.LocalMedia;

import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;

public class AsyncUploadRealm extends RealmObject implements Parcelable {
    @PrimaryKey // 必须要有一个主键
    private String id ;//
    private String uploadType = "" ;// 上传类型（作用于区分不同的功能）
    private String notifyKey = "" ; // 分组KEY(作用于一个页面多个图片)
    private String uniqueTag = ""; //唯一标识
    private String notifyUrl = ""; // 通知地址
    private String notifyParam = ""; //通知参数
    private String ossUrl ="";//OSS文件路径
    private String scanDate = ""; //扫描时间
    private Integer isDelete = 0; //是否删除
    private Integer pushStatus = 0; // 推送到oss状态 0 -未推送 1 - 推送失败;  2 - 推送成功
    private Integer rePush = 0; //重推次数
    private Integer isFinish=0; // 是否完成 0未完成【】  1已完成 【已上传】 2上传失败
    private Long createTime;
    private String localMediaStr = "";
    public AsyncUploadRealm() {
    }

    protected AsyncUploadRealm(Parcel in) {
        id = in.readString();
        uploadType = in.readString();
        notifyKey = in.readString();
        uniqueTag = in.readString();
        notifyUrl = in.readString();
        notifyParam = in.readString();
        ossUrl = in.readString();
        scanDate = in.readString();
        if (in.readByte() == 0) {
            isDelete = null;
        } else {
            isDelete = in.readInt();
        }
        if (in.readByte() == 0) {
            pushStatus = null;
        } else {
            pushStatus = in.readInt();
        }
        if (in.readByte() == 0) {
            rePush = null;
        } else {
            rePush = in.readInt();
        }
        if (in.readByte() == 0) {
            isFinish = null;
        } else {
            isFinish = in.readInt();
        }
        if (in.readByte() == 0) {
            createTime = null;
        } else {
            createTime = in.readLong();
        }
        localMediaStr = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(uploadType);
        dest.writeString(notifyKey);
        dest.writeString(uniqueTag);
        dest.writeString(notifyUrl);
        dest.writeString(notifyParam);
        dest.writeString(ossUrl);
        dest.writeString(scanDate);
        if (isDelete == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(isDelete);
        }
        if (pushStatus == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(pushStatus);
        }
        if (rePush == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(rePush);
        }
        if (isFinish == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(isFinish);
        }
        if (createTime == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeLong(createTime);
        }
        dest.writeString(localMediaStr);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<AsyncUploadRealm> CREATOR = new Creator<AsyncUploadRealm>() {
        @Override
        public AsyncUploadRealm createFromParcel(Parcel in) {
            return new AsyncUploadRealm(in);
        }

        @Override
        public AsyncUploadRealm[] newArray(int size) {
            return new AsyncUploadRealm[size];
        }
    };

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUploadType() {
        return uploadType;
    }

    public void setUploadType(String uploadType) {
        this.uploadType = uploadType;
    }

    public String getNotifyKey() {
        return notifyKey;
    }

    public void setNotifyKey(String notifyKey) {
        this.notifyKey = notifyKey;
    }

    public String getUniqueTag() {
        return uniqueTag;
    }

    public void setUniqueTag(String uniqueTag) {
        this.uniqueTag = uniqueTag;
    }

    public String getNotifyUrl() {
        return notifyUrl;
    }

    public void setNotifyUrl(String notifyUrl) {
        this.notifyUrl = notifyUrl;
    }

    public String getNotifyParam() {
        return notifyParam;
    }

    public void setNotifyParam(String notifyParam) {
        this.notifyParam = notifyParam;
    }

    public String getOssUrl() {
        return ossUrl;
    }

    public void setOssUrl(String ossUrl) {
        this.ossUrl = ossUrl;
    }

    public String getScanDate() {
        return scanDate;
    }

    public void setScanDate(String scanDate) {
        this.scanDate = scanDate;
    }

    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    public Integer getPushStatus() {
        return pushStatus;
    }

    public void setPushStatus(Integer pushStatus) {
        this.pushStatus = pushStatus;
    }

    public Integer getRePush() {
        return rePush;
    }

    public void setRePush(Integer rePush) {
        this.rePush = rePush;
    }

    public Integer getIsFinish() {
        return isFinish;
    }

    public void setIsFinish(Integer isFinish) {
        this.isFinish = isFinish;
    }

    public Long getCreateTime() {
        return createTime;
    }

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

    public String getLocalMediaStr() {
        return localMediaStr;
    }

    public void setLocalMediaStr(String localMediaStr) {
        this.localMediaStr = localMediaStr;
    }

    public LocalMedia getLocalMedia() {
        return JsonUtil.jsonString2Bean(this.localMediaStr, LocalMedia.class);
    }
}
