package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.leave;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

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

import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;

@Data
public class CalculateAndVerifyLeaveDTO {

    @Schema(description = "假期设置id", requiredMode = Schema.RequiredMode.REQUIRED, example = "阅读芋道源码")
    @NotNull(message = "假期设置id")
    private Long holidaySettingId;

    @Schema(description = "请假的开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "开始时间不能为空")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
    private LocalDate startTime;

    @Schema(description = "请假的结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "结束时间不能为空")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
    private LocalDate endTime;

    @Schema(description = "开始时间额外字段 根据请假最小单位来 1按天则为空 2按半天则1为上午 2为下午 3按小时则 格式为 HH:mm", requiredMode = Schema.RequiredMode.REQUIRED, example = "阅读芋道源码")
    private String startTimeExtraFields;

    @Schema(description = "结束时间额外字段 根据请假最小单位来 1按天则为空 2按半天则1为上午 2为下午 3按小时则 格式为 HH:mm", requiredMode = Schema.RequiredMode.REQUIRED, example = "阅读芋道源码")
    private String endTimeExtraFields;

    @Schema(description = "请假最小单位 1按天 2按半天 3按小时", requiredMode = Schema.RequiredMode.REQUIRED, example = "阅读芋道源码")
    @NotNull(message = "请假最小单位 1按天 2按半天 3按小时")
    private Integer minUnit;

    @Schema(description = "用户id (前端不用传)", requiredMode = Schema.RequiredMode.REQUIRED, example = "阅读芋道源码")
    private Long userId;

    public LocalDateTime getStartTime() {
        return this.startTime.atStartOfDay();
    }

    public LocalDateTime getEndTime() {
        return this.endTime.atStartOfDay();
    }
}

