package com.gci.boot.modules.basedata.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gci.boot.common.config.CancelConverter;
import com.gci.boot.common.dict.annotation.Dict;
import com.gci.boot.common.dict.excel.DictConverter;
import com.gci.boot.common.validated.SaveValidated;
import com.gci.boot.common.validated.UpdateValidated;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;

@Data
@TableName("tb_vehicle_supplier_archives")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="车辆供应商档案表对象", description="车辆供应商档案表对象")
public class TbVehicleSupplierArchives implements Serializable {
    private static final long serialVersionUID = 1L;
    /**主键id*/
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键id")
    @ExcelIgnore
    private String id;
    @NotBlank(message = "全称不能为空",groups = {SaveValidated.class, UpdateValidated.class})
    @Length(max = 128,groups = {SaveValidated.class,UpdateValidated.class},message = "全称长度不能超过128")
    @ApiModelProperty(value = "全称")
    @ExcelProperty(value = "全称",index = 1)
    @ColumnWidth(value = 30)
    private String name;
    @NotBlank(message = "简称不能为空",groups = {SaveValidated.class, UpdateValidated.class})
    @Length(max = 32,groups = {SaveValidated.class,UpdateValidated.class},message = "简称长度不能超过32")
    @ApiModelProperty(value = "简称")
    @ExcelProperty(value = "简称",index =2)
    @ColumnWidth(value = 15)
    private String shortened;
    @ApiModelProperty(value = "联系人")
    @NotBlank(message = "联系人不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @Length(max = 32,groups = {SaveValidated.class,UpdateValidated.class},message = "联系人长度不能超过32")
    @ExcelProperty(value = "联系人",index =3)
    @ColumnWidth(value = 15)
    private String contact;
    @ApiModelProperty(value = "联系电话")
    @NotBlank(message = "联系电话不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @Pattern(regexp = "^(?:(?:\\+|00)86)?1\\d{10}$",message = "联系电话格式错误!",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelProperty(value = "联系电话",index =4)
    @ColumnWidth(value = 15)
    private String phone;
    @ApiModelProperty(value = "地址")
    @NotBlank(message = "地址不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @Length(max = 128,groups = {SaveValidated.class,UpdateValidated.class},message = "地址长度不能超过128")
    @ExcelProperty(value = "地址",index =5)
    @ColumnWidth(value = 30)
    private String address;
    /**所属机构*/
    @ApiModelProperty(value = "所属部门")
    @ExcelIgnore
    private String sysOrgCode;
    /**创建日期*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建日期")
    @ExcelIgnore
    private Date createTime;
    /**更新日期*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新日期")
    @ExcelProperty(value = "更新时间",index =8)
    @com.alibaba.excel.annotation.format.DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ColumnWidth(value = 30)
    private Date updateTime;
    /**创建人*/
    @ApiModelProperty(value = "创建人")
    @ExcelIgnore
    private String createBy;
    /**更新人*/
    @ApiModelProperty(value = "更新人")
    @ExcelProperty(value = "更新人",converter = DictConverter.class,index = 7)
    @Dict(dictTable = "sys_user",dicCode = "username",dicText = "realname")
    @ColumnWidth(value = 15)
    private String updateBy;
    /**作废标志--默认0-正常，1-作废*/
    @ApiModelProperty(value = "作废标志")
    @ExcelProperty(value = "数据状态",index =8, converter = CancelConverter.class)
    @ColumnWidth(value = 15)
    private Integer cancelFlag;

    @NotBlank(message = "供应商类型不能为空",groups = {SaveValidated.class, UpdateValidated.class})
    @ColumnWidth(value = 15)
    @Dict(dicCode = "supplier_type")
    @ExcelProperty(value = "供应商类型",index = 0,converter = DictConverter.class)
    private String type;
    @Length(max = 256,groups = {SaveValidated.class,UpdateValidated.class},message = "备注长度不能超过256")
    @ApiModelProperty(value = "备注")
    @ExcelIgnore
    private String remark;
}
