<?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="org.springblade.modules.ldt.activityjoinrecord.mapper.ActivityJoinRecordMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="activityJoinRecordResultMap" type="org.springblade.modules.ldt.activityjoinrecord.entity.ActivityJoinRecord">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="activity_id" property="activityId"/>
        <result column="join_type" property="joinType"/>
        <result column="join_id" property="joinId"/>
        <result column="init_supply_price" property="initSupplyPrice"/>
        <result column="append_supply_price" property="appendSupplyPrice"/>
        <result column="final_supply_price" property="finalSupplyPrice"/>
        <result column="join_pic" property="joinPic"/>
        <result column="join_name" property="joinName"/>
    </resultMap>

    <resultMap id="activityJoinRecordResultMapVO"
               type="org.springblade.modules.ldt.activityjoinrecord.vo.ActivityJoinRecordVO"
               extends="activityJoinRecordResultMap">
        <result column="activity_name" property="activityName"/>
        <result column="sponsor_name" property="sponsorName"/>
    </resultMap>


    <select id="selectActivityJoinRecordPage" resultMap="activityJoinRecordResultMapVO">
        select
            lajr.* ,la.title as activity_name,la.sponsor_name as sponsor_name
         from
            ldt_activity_join_record lajr, ldt_activity la
         where
            lajr.is_deleted = 0 and lajr.activity_id = la.id
         <if test="activityJoinRecord != null">
             <if test="activityJoinRecord.activityName != null">
                 and la.title like "%${activityJoinRecord.activityName}%"
             </if>
             <if test="activityJoinRecord.sponsorName != null">
                 and la.sponsor_name like "%${activityJoinRecord.sponsorName}%"
             </if>
             <if test="activityJoinRecord.joinType != null">
                 and lajr.join_type = ${activityJoinRecord.joinType}
             </if>
             <if test="activityJoinRecord.joinName != null">
                 and lajr.join_name like "%${activityJoinRecord.joinName}%"
             </if>

         </if>
    </select>

</mapper>
