<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xjrsoft.module.activity.mapper.ActivityEnrollRangeMapper">
    <select id="getActivityInfoIds" parameterType="com.xjrsoft.module.activity.dto.AddActivityEnrollRangeDto" resultType="java.lang.Long">
        SELECT activity_info_id FROM activity_enroll_range WHERE delete_mark = 0 AND (
                user_id = #{dto.userId}
                OR class_id IN (SELECT class_id FROM base_student_school_roll WHERE delete_mark = 0 AND user_id = #{dto.userId})
                OR dept_id IN (SELECT dept_id FROM xjr_user_dept_relation WHERE user_id = #{dto.userId})
        ) AND activity_info_id IS NOT NULL
    </select>
</mapper>