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

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

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.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 javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;

/**
 * <p>
 * 巡检模板表
 * </p>
 *
 * @author 2464
 * @since 2023-09-09
 */
@Data
@TableName("tb_inspection_template")
@ApiModel(value = "TbInspectionTemplate对象", description = "巡检模板表")
@TableRepeat(aClass = TbInspectionTemplate.class,groups = {SaveValidated.class, UpdateValidated.class})
public class TbInspectionTemplate 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("模板名称")
    @NotBlank(message = "模板名称不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @FieldRepeat(message = "模板名称不能重复！")
    @Size(max = 64,message = "模板名称不能超过64位！",groups = {SaveValidated.class,UpdateValidated.class})
    @SelectQuery
    @Excel(name = "模板名称",needMerge = true)
    private String name;

    @ApiModelProperty("车辆种类")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @Dict(dicCode = "vehicle_type")
    @Excel(name = "车辆种类",needMerge = true,dict = "vehicle_type")
    private String vehicleType;

    @ApiModelProperty("备注")
    @Size(max = 500,message = "模板备注不能超过500位！",groups = {SaveValidated.class,UpdateValidated.class})
    @Excel(name = "备注",needMerge = true)
    private String remark;

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

    @ExcelIgnore
    @ApiModelProperty("创建时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @OrderQuery(sort = 1)
    @com.alibaba.excel.annotation.format.DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    private Date createTime;

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

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

    /**
     * 关联的项目
     */
    @TableField(exist = false)
    @Valid
    @NotEmpty(message = "巡检项目不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelCollection(name = "巡检项目")
    private List<TbInspectionTemplateProject> projectList;

}
