package com.seer.teach.admin.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 教材响应参数
 * </p>
 *
 * @author ZS
 * @since 2025-10-22
 */
@Data
@Schema(description = "教材响应参数")
public class MaterialResp {

    @Schema(description = "教材ID")
    private Integer id;

    @Schema(description = "版本ID")
    private Integer versionId;

    @Schema(description = "版本名称")
    private String versionName;

    @Schema(description = "年级ID")
    private Integer gradeId;

    @Schema(description = "年级名称")
    private String gradeName;

    @Schema(description = "学科ID")
    private Integer subjectId;

    @Schema(description = "学科名称")
    private String subjectName;

    @Schema(description = "册别（0上册 1下册）")
    private Integer volume;

    @Schema(description = "教材名称")
    private String bookName;

    @Schema(description = "教材文档ID")
    private Integer docId;

    @Schema(description = "教材文档URL")
    private String docUrl;

    @Schema(description = "是否已检查 0-未检查 1-已检查")
    private Integer isChecked;

    @Schema(description = "评分")
    private Integer score;

    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    private String updateBy;

    private String updateByName;
    
    // 忽略 volumeName 字段的 getter 和 setter 方法
    @Getter(lombok.AccessLevel.NONE)
    @Setter(lombok.AccessLevel.NONE)
    @Schema(description = "册别名称")
    private String volumeName;
    
    // 册别名称映射表
    private static final Map<Integer, String> VOLUME_NAME_MAP;
    
    static {
        Map<Integer, String> map = new HashMap<>();
        map.put(0, "上册");
        map.put(1, "下册");
        map.put(2, "必修第一册");
        map.put(3, "必修第二册");
        map.put(4, "必修第三册");
        map.put(5, "必修第四册");
        map.put(6, "选择性必修第一册");
        map.put(7, "选择性必修第二册");
        map.put(8, "选择性必修第三册");
        map.put(9, "选择性必修第四册");
        VOLUME_NAME_MAP = Collections.unmodifiableMap(map);
    }
    
    public String getVolumeName() {
        return VOLUME_NAME_MAP.getOrDefault(this.volume, "未知册别");
    }
}