package com.njcn.gather.aireport.reportmodel.pojo.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.time.LocalDateTime;

/**
 * Report model view object.
 */
@Data
public class ReportModelVO {
    private static final String DEFAULT_EMPTY_DISPLAY = "-";

    @ApiModelProperty("Template ID")
    private String id;
    @ApiModelProperty("Template name")
    private String name;
    @ApiModelProperty("Template state")
    private String state;
    @ApiModelProperty("Auditor ID")
    private String checkId;
    @ApiModelProperty("Auditor display name")
    private String checkerName;
    @ApiModelProperty("Audit time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime checkTime;
    @ApiModelProperty("Audit comment")
    private String checkResult;
    @ApiModelProperty("Template file path")
    private String path;
    @ApiModelProperty("Template document file name")
    private String fileName;
    @ApiModelProperty("Logical status")
    private Integer status;
    @ApiModelProperty("Creator display name")
    private String createBy;
    @ApiModelProperty("Create time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime createTime;
    @ApiModelProperty("Editor display name")
    private String updateBy;
    @ApiModelProperty("Editor display name")
    private String editorName;
    @ApiModelProperty("Update time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime updateTime;

    public String getId() {
        return defaultDisplay(id);
    }

    public String getName() {
        return defaultDisplay(name);
    }

    public String getState() {
        return defaultDisplay(state);
    }

    public String getCheckId() {
        return defaultDisplay(checkId);
    }

    public String getCheckerName() {
        return defaultDisplay(checkerName);
    }

    public String getCheckResult() {
        return defaultDisplay(checkResult);
    }

    public String getPath() {
        return defaultDisplay(path);
    }

    public String getFileName() {
        return defaultDisplay(fileName);
    }

    public String getCreateBy() {
        return defaultDisplay(createBy);
    }

    public String getUpdateBy() {
        return defaultDisplay(updateBy);
    }

    public String getEditorName() {
        return defaultDisplay(editorName);
    }

    private String defaultDisplay(String value) {
        return StringUtils.hasText(value) ? value : DEFAULT_EMPTY_DISPLAY;
    }
}
