package com.qmth.distributed.print.business.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.teachcloud.common.base.BaseEntity;
import com.qmth.teachcloud.common.contant.SystemConstant;
import com.qmth.teachcloud.common.enums.PushTypeEnum;
import com.qmth.teachcloud.common.enums.TaskResultEnum;
import com.qmth.teachcloud.common.enums.TaskStatusEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

/**
 * <p>
 * 同步任务表
 * </p>
 */
@ApiModel(value = "TBSyncTask对象", description = "同步任务表")
public class TBSyncTask extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "学校id")
    @JsonSerialize(using = ToStringSerializer.class)
    @TableField("school_id")
    private Long schoolId;

    @ApiModelProperty(value = "机构id")
    @JsonSerialize(using = ToStringSerializer.class)
    @TableField(value = "org_id", updateStrategy = FieldStrategy.IGNORED)
    private Long orgId;

    @ApiModelProperty(value = "推送类型，USER_PUSH：用户推送")
    @TableField(value = "type")
    private PushTypeEnum type;

    @ApiModelProperty(value = "第三方关联id")
    @JsonSerialize(using = ToStringSerializer.class)
    @TableField("third_relate_id")
    private Long thirdRelateId;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "对象id")
    @TableField(value = "object_id")
    private Long objectId;

    @ApiModelProperty(value = "任务状态，INIT：未开始，RUNNING：进行中，FINISH：已完成")
    @TableField(value = "status")
    private TaskStatusEnum status;

    @ApiModelProperty(value = "实时摘要信息")
    @TableField(value = "summary")
    private String summary;

    @ApiModelProperty(value = "数据结果，SUCCESS：成功，ERROR：失败")
    @TableField(value = "result")
    private TaskResultEnum result;

    @ApiModelProperty(value = "备注")
    @TableField(value = "remark")
    private String remark;

    @ApiModelProperty(value = "重试次数")
    @TableField(value = "reset_count")
    private int resetCount;

    @ApiModelProperty(value = "错误原因")
    @TableField(value = "error_message", updateStrategy = FieldStrategy.IGNORED)
    private String errorMessage;

    @ApiModelProperty(value = "报告路径")
    @TableField(value = "report_file_path")
    private String reportFilePath;

    public TBSyncTask() {
    }

    public TBSyncTask(PushTypeEnum type, TaskStatusEnum status, Long createId, Long schoolId) {
        setId(SystemConstant.getDbUuid());
        this.type = type;
        this.status = status;
        setCreateId(createId);
        setCreateTime(System.currentTimeMillis());
        this.schoolId = schoolId;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public Long getThirdRelateId() {
        return thirdRelateId;
    }

    public void setThirdRelateId(Long thirdRelateId) {
        this.thirdRelateId = thirdRelateId;
    }

    public Long getSchoolId() {
        return schoolId;
    }

    public void setSchoolId(Long schoolId) {
        this.schoolId = schoolId;
    }

    public Long getObjectId() {
        return objectId;
    }

    public void setObjectId(Long objectId) {
        this.objectId = objectId;
    }

    public TaskStatusEnum getStatus() {
        return status;
    }

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

    public String getSummary() {
        return summary;
    }

    public void setSummary(String summary) {
        this.summary = summary;
    }

    public TaskResultEnum getResult() {
        return result;
    }

    public void setResult(TaskResultEnum result) {
        this.result = result;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public int getResetCount() {
        return resetCount;
    }

    public void setResetCount(int resetCount) {
        this.resetCount = resetCount;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public PushTypeEnum getType() {
        return type;
    }

    public void setType(PushTypeEnum type) {
        this.type = type;
    }

    public String getReportFilePath() {
        return reportFilePath;
    }

    public void setReportFilePath(String reportFilePath) {
        this.reportFilePath = reportFilePath;
    }
}
