package com.qmth.paper.library.business.bean.result;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.paper.library.common.util.ServletUtil;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

/**
 * @Description: 新增/更新返回值
 * @Author: CaoZixuan
 * @Date: 2021-03-22
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class EditResult implements Serializable {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "主键")
    private Long id;

    @ApiModelProperty(value = "更新时间")
    Long updateTime;

    @ApiModelProperty(value = "成功状态")
    Boolean success;

    @ApiModelProperty(value = "附件url")
    String url;

    @ApiModelProperty(value = "pdf总页数")
    Integer pages;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public Long getId() {
        return id;
    }

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

    public Integer getPages() {
        return pages;
    }

    public void setPages(Integer pages) {
        this.pages = pages;
    }

    public Long getUpdateTime() {
        if (Objects.isNull(updateTime)) {
            return System.currentTimeMillis();
        } else {
            return updateTime;
        }
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    public EditResult(Long id) {
        this.id = id;
        ServletUtil.setRequestId(Arrays.asList(id));
    }

    public EditResult(Boolean success) {
        this.success = success;
    }

    public EditResult(Long id, String url) {
        this.id = id;
        this.url = url;
    }

    public EditResult(Long id, String url, Integer pages) {
        this.id = id;
        this.url = url;
        this.pages = pages;
    }

    public EditResult(String url) {
        this.url = url;
    }

    public EditResult() {
    }
}
