package jnpf.model.certificate.vo.app;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

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

/**
 * 健康证明细。
 */
@Data
@NoArgsConstructor
public class HealthCertificateDetailVO implements Serializable {

    private static final long serialVersionUID = 1L;

    public HealthCertificateDetailVO(String userId, String certificateInstanceId, String certificateImage, Date issueDate, Date expireDate, Integer status) {
        this.userId = userId;
        this.certificateInstanceId = certificateInstanceId;
        if(Objects.isNull(certificateImage)){
            certificateImage = "[]";
        }
        this.certificateImage = certificateImage;
        this.issueDate = issueDate;
        this.expireDate = expireDate;
        this.status = status;
    }

    /**
     * 员工用户ID。
     */
    private String userId;
    /**
     * 证照实例ID。
     */
    private String certificateInstanceId;

    /**
     * 健康证图片。
     */
    private String certificateImage;

    /**
     * 发证日期。格式为时间戳
     */
    @JSONField(format = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date issueDate;

    /**
     * 到期日期。格式为时间戳
     */
    @JSONField(format = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date expireDate;

    /**
     * 状态：1-缺失，2-过期，3-临期，4-正常。
     */
    private Integer status;

    /**
     * 状态描述。
    */
    public String getStatusDesc() {
        if (status == null) {
            return "";
        }
        switch (status) {
            case 1:
                return "缺失";
            case 2:
                return "过期";
            case 3:
                return "临期";
            default:
                return "正常";
        }
    }

}

