package com.lesingle.edu.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * 冲突检测结果
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "冲突检测结果")
public class ConflictCheckResult {

    @Schema(description = "是否有冲突")
    private Boolean hasConflict;

    @Schema(description = "冲突信息列表")
    private List<ConflictInfo> conflicts;

    /**
     * 冲突信息
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(description = "冲突信息")
    public static class ConflictInfo {

        @Schema(description = "冲突类型：CLASS-班级冲突，TEACHER-教师冲突")
        private String type;

        @Schema(description = "冲突描述")
        private String message;

        @Schema(description = "冲突的排课 ID")
        private Long conflictScheduleId;

        @Schema(description = "冲突的班级名称")
        private String className;

        @Schema(description = "冲突的教师名称")
        private String teacherName;

        @Schema(description = "冲突时间")
        private String conflictTime;
    }

    /**
     * 无冲突结果
     */
    public static ConflictCheckResult noConflict() {
        return ConflictCheckResult.builder()
                .hasConflict(false)
                .conflicts(new ArrayList<>())
                .build();
    }

    /**
     * 有冲突结果
     */
    public static ConflictCheckResult withConflicts(List<ConflictInfo> conflicts) {
        return ConflictCheckResult.builder()
                .hasConflict(true)
                .conflicts(conflicts)
                .build();
    }
}