package com.sqx.modules.address.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.sqx.modules.address.validator.FullAddressGroup;
import com.sqx.modules.address.validator.InsideAddressGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.math.BigDecimal;

@Data
public class Address implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.AUTO)
    @ApiModelProperty("主键id")
    private Long addressId;

    @ApiModelProperty("用户id")
    private Long userId;

    @ApiModelProperty("用户姓名")
    @NotBlank(message = "用户姓名不能为空", groups = {FullAddressGroup.class, InsideAddressGroup.class})
    private String userName;

    @ApiModelProperty("用户电话")
    @NotBlank(message = "用户电话不能为空", groups = {FullAddressGroup.class, InsideAddressGroup.class})
    private String userPhone;

    @ApiModelProperty("用户地址")
    @NotBlank(message = "省份不能为空", groups = {FullAddressGroup.class})
    private String province;

    @ApiModelProperty("用户地址")
    @NotBlank(message = "城市不能为空", groups = {FullAddressGroup.class})
    private String city;

    @ApiModelProperty("用户地址")
    @NotBlank(message = "区县不能为空", groups = {FullAddressGroup.class})
    private String district;

    @ApiModelProperty("用户详细地址（用户手动输入的地址）")
    @NotBlank(message = "详细地址不能为空", groups = {FullAddressGroup.class})
    private String addressDetail;

    @ApiModelProperty("经度")
    @NotNull(message = "经度不能为空", groups = {FullAddressGroup.class})
    private Double lng;

    @ApiModelProperty("维度")
    @NotNull(message = "纬度不能为空", groups = {FullAddressGroup.class})
    private Double lat;

    @ApiModelProperty("内部地址id，当用户选择使用内部地址时，该字段不能为空")
    @NotNull(message = "内部地址id不能为空", groups = {InsideAddressGroup.class})
    private Long insideAddressId;

    @ApiModelProperty("创建时间")
    private String createTime;

    @ApiModelProperty("是否删除（0：未删除；1：删除）")
    private Integer deleteFlag;

    @ApiModelProperty("备注")
    private String remark;

    @ApiModelProperty("默认地址 0：非默认  1：默认")
    @NotNull(message = "默认地址不能为空", groups = {FullAddressGroup.class, InsideAddressGroup.class})
    @Pattern(regexp = "0|1", message = "默认地址只能为0或1")
    private Integer addressDefault;

    @ApiModelProperty("修改时间")
    private String updateTime;

    @ApiModelProperty("校内地址配送费")
    @TableField(exist = false)
    private BigDecimal insideDeliveryFee;

    @ApiModelProperty(name = "站点id")
    @TableField(exist = false)
    private Long stationId;
}