package com.qmth.distributed.print.business.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qmth.distributed.print.business.bean.params.AssignClazzParam;
import com.qmth.distributed.print.business.bean.params.TeachCourseSelectParam;
import com.qmth.distributed.print.business.bean.result.ClazzDistributedResult;
import com.qmth.distributed.print.business.bean.result.CourseWeightSettingStatusResult;
import com.qmth.distributed.print.business.bean.params.TeachCourseParams;
import com.qmth.distributed.print.business.bean.params.TeacherTeamParam;
import com.qmth.distributed.print.business.bean.result.DictionaryResult;
import com.qmth.distributed.print.business.bean.result.TeachCourseResult;
import com.qmth.distributed.print.business.entity.TeachCourse;
import com.qmth.distributed.print.business.enums.CourseSettingTypeEnum;
import com.qmth.teachcloud.common.bean.result.TeacherSelectResult;
import com.qmth.teachcloud.common.bean.result.TeacherTeamResult;
import com.qmth.teachcloud.common.entity.BasicCourse;
import com.qmth.teachcloud.common.entity.SysUser;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.Set;

/**
 * @Description: 教学课程服务类
 * @Author: CaoZixuan
 * @Date: 2022-02-07
 */
public interface TeachCourseService extends IService<TeachCourse> {

    /**
     * 分页查询教学课程列表
     *
     * @param examId     考试id
     * @param courseName 课程名称
     * @param pageNumber 分页参数
     * @param pageSize   分页容量
     * @return 教学课程分页结果
     */
    IPage<TeachCourseResult> teachCoursePage(Long examId, String courseName, int pageNumber, int pageSize);

    /**
     * 手动创建教学课程
     *
     * @param teachCourseParams 课程新增参数
     * @param requestUser       请求的用户
     * @return 创建结果
     */
    @Deprecated
    Boolean manualCreate(TeachCourseParams teachCourseParams, SysUser requestUser);

    /**
     * 选择课程表并创建教学课程
     *
     * @param teachCourseSelectParam 教学课程选择参数
     * @param requestUser            请求的用户
     */
    void selectCreate(TeachCourseSelectParam teachCourseSelectParam, SysUser requestUser);

    /**
     * 导入教学课程
     *
     * @param file        文件
     * @param requestUser 请求用户
     */
    @Deprecated
    void importTeachCourse(MultipartFile file, SysUser requestUser) throws IOException, NoSuchFieldException;

    /**
     * 根据用户id查询该用户所属机构下可以创建为教学课程的基础课程列表
     *
     * @param requestUser 请求的用户
     * @return 课程列表
     */
    List<DictionaryResult> findBasicCourseByUser(SysUser requestUser);

    /**
     * 根据教学课程id集合批量删除教学课程
     *
     * @param idList 教学课程idList
     */
    void deleteTeachCourseBatch(List<Long> idList);

    /**
     * 自动创建教师团队
     *
     * @param teacherTeamParam 教师团队参数
     * @param requestUser      请求的用户
     */
    void manualCreateTeacher(TeacherTeamParam teacherTeamParam, SysUser requestUser) throws IllegalAccessException;

    /**
     * 教师库添加教师团队
     *
     * @param teachCourseId 教学课程id
     * @param userIdList    用户id集合
     * @param requestUser   请求人
     */
    void selectCreateTeacher(Long teachCourseId, List<Long> userIdList, SysUser requestUser);

    /**
     * 导入教师团队
     *
     * @param file          文件
     * @param basicCourseId 基础课程id
     * @param requestUser   请求的用户
     */
    @Deprecated
    void importTeacherTeam(MultipartFile file, Long basicCourseId, SysUser requestUser) throws IOException, NoSuchFieldException, IllegalAccessException;

    /**
     * 分页查询教师团队
     *
     * @param teachCourseId 教学课程id
     * @param userInfo      教师信息
     * @param pageNumber    分页页数
     * @param pageSize      分页容量
     * @return 分页结果
     */
    IPage<TeacherTeamResult> findTeacherTeamPage(Long teachCourseId, String userInfo, int pageNumber, int pageSize);

    /**
     * 根据机构id查询用户
     *
     * @param orgId 机构id
     * @return 用户结果
     */
    List<TeacherSelectResult> findUserByOrgId(Long orgId);

    /**
     * 插入老师和课程关联表
     *
     * @param basicCourseId
     * @param teachIdSet
     */
    public void updateByCourseIdAndTeacherList(Long basicCourseId, Set<Long> teachIdSet);

    /**
     * 根据考试id，课程编号，教师id查询教学课程
     *
     * @param examId     考试id
     * @param courseCode 课程编号
     * @param userId     教师id
     * @return 教学课程
     */
    TeachCourse findByExamIdCourseCodeAndUserId(Long examId, String courseCode, Long userId);

    /**
     * 清除课程目标、评价、权重设置
     *
     * @param teachCourseId         教学课程id
     * @param courseSettingTypeEnum 课程设置类型
     */
    void clearCourseSetting(Long teachCourseId, CourseSettingTypeEnum courseSettingTypeEnum);

    /**
     * 查询课程权重设置状态
     *
     * @param teachCourseId         教学课程id
     * @return 课程权重设置状态
     */
    CourseWeightSettingStatusResult findCourseWeightSettingStatus(Long teachCourseId);

    /**
     * 查询班级分配情况
     *
     * @param teachCourseId 教学课程id
     * @param clazzName     班级名称
     * @return 分配情况结果
     */
    List<ClazzDistributedResult> findClazzDistributedStatus(Long teachCourseId, String clazzName);

    /**
     * 分配班级
     *
     * @param assignClazzParam 分配班级参数
     * @param requestUser      登录人
     */
    void assignClazz(AssignClazzParam assignClazzParam, SysUser requestUser);

    /**
     * 查询教师绑定课程关系
     *
     * @param userId 教师id
     * @return 课程集合
     */
    List<DictionaryResult> findTeacherCourseInfo(Long userId);
}
