package com.yida.data.user.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yida.data.common.core.entity.user.EduStudent;
import com.yida.data.common.core.entity.user.EduTeacherDept;
import com.yida.data.school.dto.transaction.ListBuyStudentDTO;
import com.yida.data.user.dto.ListStudentDTO;
import com.yida.data.user.dto.OutPageStudentDTO;
import com.yida.data.user.dto.PageStudentDTO;
import com.yida.data.user.dto.PageStudentDormDTO;
import com.yida.data.user.excel.SelectStudentDormExportData;
import com.yida.data.user.vo.ListParentByStudentIdsVO;
import com.yida.data.user.vo.OutPageStudentVO;
import com.yida.data.user.vo.StudentClassInfoVO;
import com.yida.data.user.vo.StudentDormInfoVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface EduStudentMapper extends BaseMapper<EduStudent> {

    /**
     * 查询学生列表数据
     */
    @InterceptorIgnore(tenantLine = "true")
    IPage<EduStudent> selectStudentPage(Page page, @Param("dto") PageStudentDTO dto);

    @InterceptorIgnore(tenantLine = "true")
    List<EduStudent> selectStudent(@Param("dto") PageStudentDTO dto);

    EduStudent getStudentWithParent(@Param("studentId") Long studentId, @Param("wxId") String wxId,
                                    @Param("schoolId") Long schoolId);


    List<EduStudent> getStudentListWithParent(@Param("studentIdList") List<Long> studentIdList, @Param("wxId") String wxId,
        @Param("schoolId") Long schoolId);


    List<EduStudent> listStudentByParent(Long parentId);

    StudentClassInfoVO getStudentInfo(@Param("studentId") Long studentId,
                                      @Param("parentMobile") String parentMobile);

    List<String> getParentByPhoneAndSchoolId(@Param("phone") List<String> phone, @Param("schoolId") Long schoolId);

    /**
     * 查询位购买该商品的学生
     *
     * @param dto
     * @return
     */
    Page<EduStudent> listNotBuyStudent(@Param("page") Page page, @Param("dto") ListBuyStudentDTO dto);

    /**
     * 查询位购买该商品的学生
     *
     * @param dto
     * @return
     */
    List<EduStudent> listNotBuyStudent(@Param("dto") ListBuyStudentDTO dto);

    /**
     * 通过学生id查询家长WxId
     *
     * @param studentIds
     * @return
     */
    List<String> findParentWxId(@Param("studentIds") List<Long> studentIds);

    /**
     * 通过学生们查询家长和学生信息
     *
     * @param studentIds
     * @return
     */
    List<ListParentByStudentIdsVO> listParentByStudentIds(@Param("studentIds") List<Long> studentIds);

    /**
     * 查询学生列表  带家长
     *
     * @param dto
     * @return
     */
    List<EduStudent> listStudent(@Param("dto") ListStudentDTO dto);


    List<EduStudent> listStudentByCondition(ListStudentDTO listStudentDTO);


    /**
     * 分页查询住宿学生列表
     *
     * @param dto
     * @return
     */
    IPage<StudentDormInfoVO> listStudentDormPage(Page page,
                                                 @Param("dormRoomIds") List<Long> dormRoomIds,
                                                 @Param("dto") PageStudentDormDTO dto);

    List<EduStudent> listStudentDorm(@Param("dormRoomIds") List<Long> dormRoomIds,
                                         @Param("dto") SelectStudentDormExportData selectStudentDormExportData);

    /**
     * 查询学生对应教师
     *
     * @param classId
     * @return
     */
    List<EduTeacherDept> listTeacherByStudentId(@Param("classId") Long classId);

    /**
     * 根据学生表字段查询学生id信息
     *
     * @param eduStudent 查询条件
     * @return java.util.List<java.lang.Long>
     * @author ZYJ
     * @date 2022/3/29 9:33
     */
    List<Long> listBaseStudentIds(EduStudent eduStudent);

    /**
     * 根据学生表字段查询学生列表信息
     *
     * @param eduStudent 查询条件
     * @return java.util.List<com.yida.data.common.core.entity.user.EduStudent>
     * @author ZYJ
     * @date 2022/3/29 13:59
     */
    List<EduStudent> listBaseStudent(EduStudent eduStudent);


    List<Long> listDormIdsByDeptId(ListStudentDTO dto);

    List<EduStudent> listBaseStudentNoJoin(EduStudent eduStudent);

    IPage<OutPageStudentVO> listStudentOutPage(Page page,
                                               @Param("dto") OutPageStudentDTO dto);

    /**
     * 查询年级人数
     *
     * @param gradeId 年级id
     * @return long
     * @author ZYJ
     * @date 2023/4/25 11:47
     */
    long selectGradeStudentNumber(@Param("gradeId") Long gradeId);
}
