<?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.ActivityImageMapper">
    <resultMap type="com.template.model.vo.ActivityImageApplyVo" id="ActivityImagePageMap">
        <result property="id" column="id"/>
        <result property="image" column="image"/>
        <result property="isPass" column="is_pass"/>
        <result property="applyUserName" column="apply_user_name"/>
        <result property="theme" column="theme"/>
    </resultMap>
    <select id="activityImagePageDatas" resultType="com.template.model.vo.ActivityImageApplyVo" resultMap="ActivityImagePageMap">
        select ai.id,ai.image,ai.is_pass,ai.apply_user_name,aa.theme from activity_image ai
        left join alumni_activity aa on aa.deleted = 0 and aa.id = ai.activity_id
        where ai.deleted = 0
        and FIND_IN_SET(${userId},ai.apply_user)
        order by ai.create_time desc
    </select>

    <resultMap type="com.template.model.vo.ActivityMyImageApplyVo" id="ActivityMyImagePageMap">
        <result property="id" column="id"/>
        <result property="image" column="image"/>
        <result property="isPass" column="is_pass"/>
        <result property="applyUserName" column="apply_user_name"/>
        <result property="theme" column="theme"/>
        <result property="createTime" column="create_time"/>
    </resultMap>
    <select id="activityMyImagePageDatas" resultType="com.template.model.vo.ActivityMyImageApplyVo" resultMap="ActivityMyImagePageMap">
        select ai.id,ai.image,ai.is_pass,ai.apply_user_name,aa.theme,ai.create_time
        from activity_image ai
        inner join alumni_activity aa on aa.deleted = 0 and aa.id = ai.activity_id
        <if test="name != null and name != 0">
            and aa.theme like '%' #{name} '%'
        </if>
        where ai.deleted = 0
        <if test="userId != null and userId != 0">
            and ai.create_user =#{userId}
        </if>
        order by ai.create_time desc
    </select>

    <select id="activityApproveImagePageDatas" resultType="com.template.model.vo.ActivityMyImageApplyVo" resultMap="ActivityMyImagePageMap">
        select ai.id,ai.image,ai.is_pass,ai.apply_user_name,aa.theme,ai.create_time
        from activity_image ai
        inner join alumni_activity aa on aa.deleted = 0 and aa.id = ai.activity_id
        <if test="name != null and name != 0">
            and aa.theme like '%' #{name} '%'
        </if>
        where ai.deleted = 0 and ai.is_pass = 1
        <if test="userId != null and userId != 0">
            and FIND_IN_SET(${userId},ai.apply_user)
        </if>
        order by ai.create_time desc
    </select>
</mapper>
