package com.njcn.rdms.module.project.controller.admin.project.task.vo;

import com.njcn.rdms.module.project.dal.dataobject.attachment.AttachmentItem;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.time.LocalDate;
import java.util.List;

@Schema(description = "管理后台 - 任务保存 Request VO")
@Data
public class ProjectTaskSaveReqVO {

    @Schema(description = "任务编号", example = "9001")
    private Long id;

    @Schema(description = "父任务编号")
    private Long parentTaskId;

    @Schema(description = "任务标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "接口联调任务")
    @NotBlank(message = "任务标题不能为空")
    @Size(max = 300, message = "任务标题长度不能超过300个字符")
    private String taskTitle;

    @Schema(description = "任务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "feature")
    @NotBlank(message = "任务类型不能为空")
    @Size(max = 32, message = "任务类型长度不能超过32个字符")
    private String type;

    @Schema(description = "任务负责人用户编号；子任务不传时继承父任务负责人", example = "3002")
    private Long ownerId;

    @Schema(description = "计划开始日期")
    private LocalDate plannedStartDate;

    @Schema(description = "计划结束日期")
    private LocalDate plannedEndDate;

    @Schema(description = "任务说明（接受 HTML 富文本，图片走 URL 引用；后端经全局 XSS Safelist 自动净化）",
            example = "完成接口联调")
    @Size(max = 200000, message = "任务说明长度不能超过200000个字符")
    private String taskDesc;

    @Schema(description = "优先级字典 rdms_req_priority 值，0=P0(最高) / 1=P1 / 2=P2 / 3=P3(最低)",
            requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @NotBlank(message = "优先级不能为空")
    @Size(max = 8, message = "优先级长度不能超过8个字符")
    private String priority;

    @Schema(description = "初始协办人用户编号列表；仅在创建任务时生效，编辑任务时静默忽略。"
            + "协办人通过独立接口管理，详见 /tasks/{id}/assignees")
    private List<Long> assigneeUserIds;

    @Schema(description = "附件列表；规则与限制详见 AttachmentValidator（数量上限、扩展名白/黑名单、URL 协议）")
    @Valid
    private List<AttachmentItem> attachments;

}

