<?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.huiju.estateagents.sample.mapper.TaH5SampleMapper">

    <select id="listH5SampleByCondition" resultType="com.huiju.estateagents.sample.entity.TaH5Sample">
        SELECT
            t.*,
            t2.user_name addUserName,
            t3.user_name updateUserName
        FROM
            ta_h5_sample t
            LEFT JOIN sys_user t2 ON t.add_user = t2.user_id
            LEFT JOIN sys_user t3 ON t.update_user = t3.user_id
        WHERE
            t.`status` = 1
            <if test = "sampleName != null and sampleName != ''">
                AND t.sample_name LIKE concat('%',#{sampleName},'%')
            </if>
        ORDER BY
            t.order_no desc,
            t.create_date desc
    </select>

    <update id="batchUpdateStatus">
        UPDATE ta_h5_sample t
            SET t.`status` = - 1,
                t.update_user = #{userId},
                t.update_date = NOW( )
        WHERE
            t.sample_id IN ( SELECT t2.sample_id FROM ta_sample_contact t2 WHERE t2.contact_id IN
        <foreach collection="list" item="record" open="(" close=")" separator=",">
            #{record.contactId}
        </foreach>)
    </update>

</mapper>
