package com.njcn.gather.aireport.clientunit.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 lombok.Data;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 委托单位展示对象。
 */
@Data
public class ClientUnitVO implements Serializable {
    private static final long serialVersionUID = 8924649462626990262L;
    private static final String DEFAULT_EMPTY_DISPLAY = "-";

    private String id;
    private String name;
    private String contactName;
    private String phonenumber;
    private String address;
    private String createBy;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime createTime;
    private String updateBy;
    @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 getContactName() {
        return defaultDisplay(contactName);
    }

    public String getPhonenumber() {
        return defaultDisplay(phonenumber);
    }

    public String getAddress() {
        return defaultDisplay(address);
    }

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

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

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