<?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.ylx.massage.mapper.TCommentUserMapper">

    <resultMap type="com.ylx.massage.domain.TCommentUser" id="TCommentUserMap">
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="text" column="text" jdbcType="VARCHAR"/>
        <result property="orderNo" column="order_no" jdbcType="VARCHAR"/>
        <result property="jsId" column="js_id" jdbcType="VARCHAR"/>
        <result property="openId" column="open_id" jdbcType="VARCHAR"/>
        <result property="commentTime" column="comment_time" jdbcType="TIMESTAMP"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="isDelete" column="is_delete" jdbcType="INTEGER"/>
    </resultMap>

    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into ry-vue.t_comment_user(textorder_nojs_idopen_idcomment_timenamecreate_timeupdate_timeis_delete)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.text}#{entity.orderNo}#{entity.jsId}#{entity.openId}#{entity.commentTime}#{entity.name}#{entity.createTime}#{entity.updateTime}#{entity.isDelete})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into ry-vue.t_comment_user(textorder_nojs_idopen_idcomment_timenamecreate_timeupdate_timeis_delete)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.text}#{entity.orderNo}#{entity.jsId}#{entity.openId}#{entity.commentTime}#{entity.name}#{entity.createTime}#{entity.updateTime}#{entity.isDelete})
        </foreach>
        on duplicate key update
        text = values(text) order_no = values(order_no) js_id = values(js_id) open_id = values(open_id) comment_time =
        values(comment_time) name = values(name) create_time = values(create_time) update_time = values(update_time)
        is_delete = values(is_delete)
    </insert>

    <!-- 分页查询用户评论 -->
    <select id="selectAll" resultType="com.ylx.massage.domain.TCommentUser">
        SELECT
            tcu.id as id,
            tcu.nick_name as nickName,
            tcu.text as text,
            tcu.star as star,
            tcu.comment_time as commentTime,
            tcu.js_id as jsId,
            tcu.name as name,
            tcu.sensitive_word as sensitiveWord,
            tcua.audit_status as auditStatus
        FROM
            t_comment_user tcu
                LEFT JOIN t_comment_user_audit tcua ON tcu.id = tcua.comment_id
        WHERE
            tcu.is_delete = 0
          AND tcua.is_delete = 0
          <!-- 技师姓名查询 -->
        <if test="tCommentUser.name != null and tCommentUser.name != ''">
            AND tcu.name = #{tCommentUser.name}
        </if>
        <!--敏感词查询-->
        <if test="tCommentUser.sensitiveWord != null">
            AND tcu.sensitive_word = #{tCommentUser.sensitiveWord}
        </if>
        <!-- 审核状态查询 -->
        <if test="tCommentUser.auditStatus != null">
            AND tcua.audit_status = #{tCommentUser.auditStatus}
        </if>
    </select>

</mapper>

