<?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.guosen.helpRecord.mapper.HelpRecordMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="helpRecordResultMap" type="org.springblade.modules.guosen.helpRecord.entity.HelpRecord">
        <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="product_id" property="productId"/>
        <result column="sender_id" property="senderId"/>
        <result column="receiver_id" property="receiverId"/>
        <result column="present_id" property="presentId"/>
        <result column="type" property="type"/>
        <result column="hot_value" property="hotValue"/>
    </resultMap>


    <select id="selectHelpRecordPage" resultMap="helpRecordResultMap">
        select * from cyzh_help_record where is_deleted = 0
    </select>

    <select id="selectHelpRecordVoPage"  resultType="org.springblade.modules.guosen.helpRecord.vo.HelpRecordVO">
        select a.*,b.nick_name as nickName,b.avatar
        from cyzh_help_record as a
        left join cyzh_login_user as b on a.sender_id=b.id
        where a.is_deleted = 0
        <if test="helpRecord!=null">
            <if test="helpRecord.receiverId != null and helpRecord.receiverId != ''">
                AND a.receiver_id = #{helpRecord.receiverId}
            </if>
            <if test="helpRecord.senderId != null and helpRecord.senderId != ''">
                AND a.sender_id = #{helpRecord.senderId}
            </if>
            <if test="helpRecord.productId != null and helpRecord.productId != ''">
                AND a.product_id = #{helpRecord.productId}
            </if>
        </if>
        ORDER BY a.create_time desc

    </select>

</mapper>
