package com.izouma.dingdong.domain.user;

import com.izouma.dingdong.domain.BaseEntity;
import com.izouma.dingdong.enums.AddressTag;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.Column;
import javax.persistence.Entity;
import java.io.Serializable;

@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Builder
//@JsonIgnoreProperties(value = {"hibernateLazyInitializer"})
@ApiModel(value = "Address", description = "收获地址记录")
public class Address extends BaseEntity implements Serializable {
    @ApiModelProperty(value = "用户Id", name = "userId")
    private Long userId;

    @ApiModelProperty(value = "联系人", name = "name")
    private String name;

    @ApiModelProperty(value = "女士/先生", name = "sex")
    private String sex;

    @ApiModelProperty(value = "电话", name = "phone")
    private String phone;

    @ApiModelProperty(value = "详细地址", name = "addressName")
    private String addressName;

    @ApiModelProperty(value = "门牌号", name = "number")
    private String number;

    @ApiModelProperty(value = "标签", name = "addressTag")
    private AddressTag addressTag;

    @ApiModelProperty("是否选为默认地址")
    private Boolean isDefault;

    @ApiModelProperty(value = "经度", name = "longitude")
    private Double longitude;

    @ApiModelProperty(value = "纬度",name = "latitude")
    private Double latitude;

    @Column(nullable = false)
    private Boolean enabled = true;

    public String getAddressInfo() {
        return name + "," + phone + "," + addressName + number;
    }
}
