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

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.huimv.employment.service.common.jackson.FlexibleLocalDateTimeDeserializer;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

/**
 * 任务发布时单个工种的计划起止时间。
 * <p>匹配优先级：{@code id} → {@code group_no} → {@code job_type}。</p>
 */
@Schema(description = "任务发布用工明细（工种起止时间）")
public class TaskPublishWorkItemRequest {

    @JsonProperty("id")
    @JsonAlias({"work_item_id", "workItemId"})
    @Schema(description = "fe_order_work_item.id，优先匹配")
    private Long id;

    @JsonProperty("group_no")
    @JsonAlias({"groupNo"})
    @Schema(description = "用工分组号，其次匹配")
    private String groupNo;

    @JsonProperty("job_type")
    @JsonAlias({"jobType"})
    @Schema(description = "工种名称，再次匹配")
    private String jobType;

    @NotNull(message = "work_start_date 不能为空")
    @JsonProperty("work_start_date")
    @JsonAlias({"workStartDate"})
    @JsonDeserialize(using = FlexibleLocalDateTimeDeserializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "计划开工时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2026-08-01 08:00:00")
    private LocalDateTime workStartDate;

    @NotNull(message = "work_end_date 不能为空")
    @JsonProperty("work_end_date")
    @JsonAlias({"workEndDate"})
    @JsonDeserialize(using = FlexibleLocalDateTimeDeserializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "计划结束时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2026-08-10 18:00:00")
    private LocalDateTime workEndDate;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getGroupNo() {
        return groupNo;
    }

    public void setGroupNo(String groupNo) {
        this.groupNo = groupNo;
    }

    public String getJobType() {
        return jobType;
    }

    public void setJobType(String jobType) {
        this.jobType = jobType;
    }

    public LocalDateTime getWorkStartDate() {
        return workStartDate;
    }

    public void setWorkStartDate(LocalDateTime workStartDate) {
        this.workStartDate = workStartDate;
    }

    public LocalDateTime getWorkEndDate() {
        return workEndDate;
    }

    public void setWorkEndDate(LocalDateTime workEndDate) {
        this.workEndDate = workEndDate;
    }
}
