package com.huimv.employment.service.order.dto;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * 任务发布请求：按工种写入计划起止日，推进至任务已发布并生成结算单。
 */
@Schema(description = "任务发布请求")
public class TaskPublishRequest {

    @NotEmpty(message = "work_items 不能为空")
    @Valid
    @JsonProperty("work_items")
    @JsonAlias({"workItems"})
    @Schema(description = "各工种计划起止日期列表", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<TaskPublishWorkItemRequest> workItems;

    /** true=允许已就绪人数 &lt; 计划人数时仍发布任务并结算 */
    @JsonProperty("allow_understaffed")
    @JsonAlias({"allowUnderstaffed"})
    @Schema(description = "已加入人数少于计划人数时是否仍允许发布；默认 false")
    private Boolean allowUnderstaffed;

    public List<TaskPublishWorkItemRequest> getWorkItems() {
        return workItems;
    }

    public void setWorkItems(List<TaskPublishWorkItemRequest> workItems) {
        this.workItems = workItems;
    }

    public Boolean getAllowUnderstaffed() {
        return allowUnderstaffed;
    }

    public void setAllowUnderstaffed(Boolean allowUnderstaffed) {
        this.allowUnderstaffed = allowUnderstaffed;
    }

    public boolean isAllowUnderstaffed() {
        return Boolean.TRUE.equals(allowUnderstaffed);
    }
}
