package com.keao.edu.user.dao;

import com.keao.edu.common.dal.BaseDAO;
import com.keao.edu.user.dto.ExamOrganRegistDto;
import com.keao.edu.user.entity.ExamOrganizationRelation;
import com.keao.edu.user.entity.Organization;
import com.keao.edu.user.enums.YesOrNoEnum;
import org.apache.ibatis.annotations.Param;

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

public interface ExamOrganizationRelationDao extends BaseDAO<Long, ExamOrganizationRelation> {

    /**
     * @describe 批量插入考级项目与合作单位关联
     * @author Joburgess
     * @date 2020.06.18
     * @param examOrganizationRelations:
     * @return int
     */
    int batchInsert(@Param("examOrganizationRelations") List<ExamOrganizationRelation> examOrganizationRelations);

    /**
     * @describe 批量更新
     * @author Joburgess
     * @date 2020.06.29
     * @param examOrganizationRelations:
     * @return int
     */
    int batchUpdate(@Param("examOrganizationRelations") List<ExamOrganizationRelation> examOrganizationRelations);

    /**
     * @describe 批量更新合作单位的链接发送状态
     * @author Joburgess
     * @date 2020.06.18
     * @param examId: 考级项目编号
     * @param organIds: 合作单位编号列表
     * @param sendUrlFlag: 链接发送状态
     * @return int
     */
    int batchUpdateSendUrlFlag(@Param("examId") Integer examId,
                               @Param("organIds") List<Integer> organIds,
                               @Param("sendUrlFlag")YesOrNoEnum sendUrlFlag);

    /**
     * @describe 获取考级项目关联的合作单位
     * @author Joburgess
     * @date 2020.06.18
     * @param examId:
     * @return com.keao.edu.user.entity.ExamOrganizationRelation
     */
    List<ExamOrganizationRelation> getWithExam(@Param("examId") Integer examId);

    List<ExamOrganizationRelation> getWithExams(@Param("examIds") List<Integer> examIds);

    /**
     * @describe 获取考级项目关联的合作单位编号
     * @author Joburgess
     * @date 2020.06.18
     * @param examId:
     * @return java.util.Set<java.lang.Integer>
     */
    Set<Integer> getOrganIdsWithExam(@Param("examId") Integer examId);

    /**
     * @describe 统计指定考级项目与指定分布下的报名人数与累计收款
     * @author Joburgess
     * @date 2020.06.28
     * @param examId:
     * @param organIds:
     * @return java.util.List<com.keao.edu.user.entity.ExamOrganizationRelation>
     */
    List<ExamOrganizationRelation> countExamOrganStudentAndPayment(@Param("examId") Integer examId,
                                                                       @Param("organIds") List<Integer> organIds);

    /**
     * 是否有考试项目
     * @param organId
     * @return
     */
    Integer findByOrganId(@Param("organId") Integer organId);

    /**
     * @describe 获取未关联到考级项目的合作单位
     * @author Joburgess
     * @date 2020.07.03
     * @param params:
     * @return java.util.List<com.keao.edu.user.entity.Organization>
     */
    List<Organization> queryUnRelatedOrgans(Map<String, Object> params);
    int countUnRelatedOrgans(Map<String, Object> params);
}
