<?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.ruoyi.model.mapper.AppMyEvaluateMapper">
    
    <resultMap type="AppMyEvaluate" id="AppMyEvaluateResult">
        <result property="id"    column="id"    />
        <result property="uid"    column="uid"    />
        <result property="petId"    column="pet_id"    />
        <result property="evaluateText"    column="evaluate_text"    />
        <result property="evaluateTime"    column="evaluate_time"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectAppMyEvaluateVo">
        select id, uid, pet_id, evaluate_text, evaluate_time, remark, create_time, create_by, update_time, update_by, del_flag from app_my_evaluate
    </sql>

    <select id="selectAppMyEvaluateList" parameterType="AppMyEvaluate" resultMap="AppMyEvaluateResult">
        <include refid="selectAppMyEvaluateVo"/>
        <where>  
            <if test="uid != null "> and uid = #{uid}</if>
            <if test="petId != null "> and pet_id = #{petId}</if>
            <if test="evaluateText != null  and evaluateText != ''"> and evaluate_text = #{evaluateText}</if>
            <if test="evaluateTime != null "> and evaluate_time = #{evaluateTime}</if>
        </where>
    </select>
    
    <select id="selectAppMyEvaluateById" parameterType="Long" resultMap="AppMyEvaluateResult">
        <include refid="selectAppMyEvaluateVo"/>
        where id = #{id}
    </select>
    <select id="getAppMyEvaluateByPetId" resultType="com.ruoyi.model.domain.AppMyEvaluate">
        <include refid="selectAppMyEvaluateVo"/> where pet_id = #{petId} and del_flag = 0;
    </select>

    <insert id="insertAppMyEvaluate" parameterType="AppMyEvaluate">
        insert into app_my_evaluate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="uid != null">uid,</if>
            <if test="petId != null">pet_id,</if>
            <if test="evaluateText != null">evaluate_text,</if>
            <if test="evaluateTime != null">evaluate_time,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="uid != null">#{uid},</if>
            <if test="petId != null">#{petId},</if>
            <if test="evaluateText != null">#{evaluateText},</if>
            <if test="evaluateTime != null">#{evaluateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateAppMyEvaluate" parameterType="AppMyEvaluate">
        update app_my_evaluate
        <trim prefix="SET" suffixOverrides=",">
            <if test="uid != null">uid = #{uid},</if>
            <if test="petId != null">pet_id = #{petId},</if>
            <if test="evaluateText != null">evaluate_text = #{evaluateText},</if>
            <if test="evaluateTime != null">evaluate_time = #{evaluateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppMyEvaluateById" parameterType="Long">
        delete from app_my_evaluate where id = #{id}
    </delete>

    <delete id="deleteAppMyEvaluateByIds" parameterType="String">
        delete from app_my_evaluate where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>