<?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.template.mapper.ActivityReportMapper">
    <resultMap type="com.template.model.vo.UserVo" id="ActivityReportMap">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="cardNumber" column="card_number"/>
    </resultMap>
    <select id="queryReportDatasByActivityId" resultType="com.template.model.vo.UserVo" resultMap="ActivityReportMap">
        select au.id,au.`name`,au.card_number from activity_report ar
        left join alumni_user au on au.deleted = 0 and au.id = ar.user_id
        where ar.deleted = 0 and ar.activity_id = #{activityId}
    </select>


    <resultMap type="com.template.model.vo.ActivityDetailExcelVo" id="ActivityDetailMap">
        <result property="theme" column="theme"/>
        <result property="name" column="name"/>
        <result property="collegeName" column="college_name"/>
        <result property="periodName" column="period_name"/>
        <result property="majorName" column="major_name"/>
        <result property="className" column="class_name"/>
        <result property="reportTime" column="report_time"/>
        <result property="signinTime" column="signin_time"/>
    </resultMap>
    <select id="activityDetailByActivityIds" resultType="com.template.model.vo.ActivityDetailExcelVo"
            resultMap="ActivityDetailMap">
        select aa.theme,au.name,au.college_name,au.period_name,au.major_name,au.class_name,ar.create_time as
        report_time,asd.create_time as signin_time
        from activity_report ar
        left join alumni_user au on au.deleted = 0 and au.id = ar.user_id
        left join alumni_activity aa on aa.deleted = 0 and aa.id = ar.activity_id
        left join activity_signin asd on asd.deleted = 0 and asd.activity_id = ar.activity_id and asd.user_id =
        ar.user_id
        where ar.deleted = 0
        <if test="activityIds != null and activityIds.size() > 0">
            and ar.activity_id in
            <foreach collection="activityIds" item="activityId" index="index" open="(" close=")" separator=",">
                ${activityId}
            </foreach>
        </if>
    </select>


    <resultMap type="com.template.model.vo.AlumniMyJoinActivityPageVo" id="MyJoinActivityMap">
        <result property="id" column="id"/>
        <result property="theme" column="theme"/>
        <result property="poster" column="poster"/>
        <result property="startTime" column="start_time"/>
        <result property="endTime" column="end_time"/>
        <result property="signsTime" column="signs_time"/>
        <result property="signeTime" column="signe_time"/>
        <result property="orgName" column="org_name"/>
    </resultMap>
    <select id="queryMyJoinActivityPages" resultType="com.template.model.vo.AlumniMyJoinActivityPageVo" resultMap="MyJoinActivityMap">
        select aa.id,aa.theme,aa.poster,aa.start_time,aa.end_time,aa.signs_time,aa.signe_time,au.org_name
        from activity_report ar
        left join alumni_user au on au.deleted = 0 and au.id = ar.user_id
        left join alumni_activity aa on aa.deleted = 0 and aa.id = ar.activity_id
        where ar.deleted = 0
        <if test="userId != null and userId != 0">
            and ar.user_id = #{userId}
        </if>
        order by ar.create_time desc
    </select>

</mapper>
