package com.chushang.inspection.project.dto;

import cn.hutool.core.date.DatePattern;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.chushang.common.core.validator.Create;
import com.chushang.common.core.validator.Update;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.*;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TaskDTO implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @NotNull(message = "任务所属项目id不能为空", groups = {Create.class, Update.class})
    private Long projectId;

    /**
     * 上级ID
     */
    @Builder.Default
    private Long parentId = 0L;

    /**
     * 任务名称
     */
    @NotBlank(message = "任务名称不能为空", groups = Create.class)
    @Size(max = 255, message = "任务名称不能超过255个字符", groups = {Create.class, Update.class})
    private String name;

    /**
     * 联系人
     */
    @Size(max = 32, message = "联系人不能超过32个字符", groups = {Create.class, Update.class})
    private String contact;

    /**
     * 联系电话
     */
    @Size(max = 11, message = "联系电话不能超过11个字符", groups = {Create.class, Update.class})
    private String phone;

    /**
     * 项目开始时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(DatePattern.NORM_DATETIME_MS_PATTERN)
    private LocalDateTime startTime;

    /**
     * 项目结束时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(DatePattern.NORM_DATETIME_MS_PATTERN)
    private LocalDateTime endTime;

    /**
     * 负责的部门 -- 为空时 取当前用户部门id
     */
    @NotNull(message = "必须指定负责的部门", groups = {Create.class})
    private Long deptId;

    /**
     * 状态
     */
    @Range(min = 0, max = 1, message = "是否启用格式不正确", groups = {Create.class, Update.class})
    private Integer enabled;

    /**
     * 是否有电子巡检单(默认0  没有)
     */
    @Range(min = 0, max = 1, message = "是否有电子巡检单格式不正确", groups = {Create.class, Update.class})
    private Integer isInspection;

    /**
     * 派单方式
     */
    @Range(min = 0, max = 10, message = "派单方式格式不正确", groups = {Create.class, Update.class})
    private Integer dispatchMethod;

    /**
     * 审核方式
     */
    @Range(min = 1, max = 3, message = "审核方式格式不正确", groups = {Create.class, Update.class})
    private Integer reviewMethod;

    /**
     * 是否重复派单
     */
    @Range(min = 0, max = 1, message = "是否重复派单格式不正确", groups = {Create.class, Update.class})
    private Integer isRepeat;

    /**
     * 银行编号
     */
    @Size(max = 63, message = "编号不能超过63个字符", groups = {Create.class, Update.class})
    private String number;
}
