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

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gci.boot.annotation.Query.OrderQuery;
import com.gci.boot.annotation.Query.SelectQuery;
import com.gci.boot.annotation.repeat.FieldRepeat;
import com.gci.boot.annotation.repeat.TableRepeat;
import com.gci.boot.common.dict.annotation.Dict;
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.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

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

/**
 * <p>
 * 超速阈值设置
 * </p>
 *
 * @author 2464
 * @since 2023-12-25
 */
@Getter
@Setter
@TableName("tb_gis_speeding_threshold")
@ApiModel(value = "TbGisSpeedingThreshold对象", description = "超速阈值设置")
@TableRepeat(aClass = TbGisSpeedingThreshold.class,groups = {SaveValidated.class,UpdateValidated.class})
public class TbGisSpeedingThreshold implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("主键id")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @NotBlank(message = "id不能为空！",groups = {UpdateValidated.class})
    private String id;

    @ApiModelProperty("所属机构")
    private String sysOrgCode;

    @ApiModelProperty("创建时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @OrderQuery()
    private Date createTime;

    @ApiModelProperty("更新时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @ApiModelProperty("创建人")
    private String createBy;

    @ApiModelProperty("更新人")
    @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname")
    private String updateBy;

    @ApiModelProperty("所属项目")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    @Dict(dictTable = "tb_projects", dicText = "project_name", dicCode = "id")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    private String projectId;

    @ApiModelProperty("车辆种类")
    @Dict(dicCode = "vehicle_type")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    private String vehicleType;

    @ApiModelProperty("阈值规则类型")
    @Dict(dicCode = "threshold_type")
    @NotBlank(message = "规则类型不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    private String thresholdType;

    @ApiModelProperty("阈值速度 km/h")
    @NotNull(message = "阈值速度不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @Range(min = 1,max = 220,message = "阈值速度必须在1到220区间内！",groups = {SaveValidated.class,UpdateValidated.class})
    private Integer thresholdSpeed;

    @ApiModelProperty("阈值规则名称")
    @NotBlank(message = "名称不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @SelectQuery()
    @Length(message = "规则名称不能超过64字符",max = 64,groups = {SaveValidated.class,UpdateValidated.class})
    @FieldRepeat(message = "规则名称不能重复！")
    private String thresholdName;

    @ApiModelProperty("是否启用")
    @Dict(dicCode = "yes_no")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    private Integer isValid;
}
