package com.xjrsoft.module.base.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseMapper;
import com.xjrsoft.module.base.dto.BaseClassCoursePageDto;
import com.xjrsoft.module.base.entity.BaseClassCourse;
import com.xjrsoft.module.base.entity.CourseBookInfo;
import com.xjrsoft.module.base.vo.BaseClassCoursePageVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
* @title: 班级课程
* @Author brealinxx
* @Date: 2024-06-04
* @Version 1.0
*/
@Mapper
public interface BaseClassCourseMapper extends MPJBaseMapper<BaseClassCourse> {
    Page<BaseClassCoursePageVo> getPage(Page<BaseClassCoursePageVo> page, BaseClassCoursePageDto dto);

    @Select("SELECT id, name FROM base_semester")
    List<Map<String, Object>> getAllSemesterNames();

    List<CourseBookInfo> getAllCourseBook(Long[] classIds, Long subjectGroupId, Long semester);
    List<CourseBookInfo> getSelectedCourseBook(Long[] classIds, Long semester);

    void updateAddClassCourseTextbooks(Long classId,Long courseId,Long textbookId);
    void updateRemoveClassCourseTextbooks(Long classId,Long courseId,Long textbookId);

    void markExistingRecordsAsDeleted(Long newClassId, Long sourceClassId);
    void insertClassCourseTextbookCombinations(Long newClassId, Long sourceClassId, Long semester);

    Long getClassIdByName(String name);
    Long getCourseIdByName(String name);
    Long getBookIdByName(String name);
    Long getBaseSemesterIdByName(String name);
    boolean checkExits(Long classId,Long courseId,Long textbookId);

    boolean checkExitsWithoutTextbook(Long classId, Long courseId);
}
