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

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
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.fasterxml.jackson.annotation.JsonPropertyDescription;
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 lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

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-10-11
 */
@Data
@TableName("tb_customer_follow_template")
@ApiModel(value = "TbCustomerFollowTemplate对象", description = "客户回访模板")
@TableRepeat(aClass = TbCustomerFollowTemplate.class,groups = {SaveValidated.class, UpdateValidated.class})
public class TbCustomerFollowTemplate 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("模板名称")
    @FieldRepeat(message = "模板名称不能重复！")
    @NotBlank(message = "模板名称不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @Length(max = 64,message = "模板名称不能超过64位字符！",groups = {SaveValidated.class,UpdateValidated.class})
    @SelectQuery(Type = SelectQuery.SelectType.LIKE)
    @Excel(name = "模板名称",needMerge = true)
    private String name;

    @ApiModelProperty("备注")
    @Excel(name = "备注",needMerge = true)
    private String remark;

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

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

    @ExcelIgnore
    @ApiModelProperty("创建时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @OrderQuery
    @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("更新时间")
    @Excel(name = "更新时间",needMerge = true,exportFormat = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @TableField(exist = false)
    @Valid
    @NotEmpty(message = "回访信息不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelCollection(name = "回访信息")
    private List<TbCustomerFollowTemplatePart> partList;
}
