<?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.huijy.management.mapper.MemberEvaluateMapper">
    
    <resultMap type="MemberEvaluate" id="MemberEvaluateResult">
        <result property="memberEvaluateId"    column="member_evaluate_id"    />
        <result property="memberId"    column="member_id"    />
        <result property="objectId"    column="object_id"    />
        <result property="objectType"    column="object_type"    />
        <result property="evaluateStar"    column="evaluate_star"    />
        <result property="content"    column="content"    />
        <result property="createTime"    column="create_time"    />
        <result property="isShow"    column="is_show"    />
    </resultMap>

    <sql id="selectMemberEvaluateVo">
        select member_evaluate_id, member_id, object_id, object_type, evaluate_star, content, create_time, is_show from t_member_evaluate
    </sql>

    <select id="selectMemberEvaluateList" parameterType="MemberEvaluate" resultMap="MemberEvaluateResult">
        <include refid="selectMemberEvaluateVo"/>
        <where>  
            <if test="objectType != null  and objectType != ''"> and object_type = #{objectType}</if>
            <if test="isShow != null  and isShow != ''"> and is_show = #{isShow}</if>
        </where>
    </select>
    
    <select id="selectMemberEvaluateByMemberEvaluateId" parameterType="Long" resultMap="MemberEvaluateResult">
        <include refid="selectMemberEvaluateVo"/>
        where member_evaluate_id = #{memberEvaluateId}
    </select>
        
    <insert id="insertMemberEvaluate" parameterType="MemberEvaluate">
        insert into t_member_evaluate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="memberEvaluateId != null">member_evaluate_id,</if>
            <if test="memberId != null">member_id,</if>
            <if test="objectId != null">object_id,</if>
            <if test="objectType != null">object_type,</if>
            <if test="evaluateStar != null">evaluate_star,</if>
            <if test="content != null">content,</if>
            <if test="createTime != null">create_time,</if>
            <if test="isShow != null">is_show,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="memberEvaluateId != null">#{memberEvaluateId},</if>
            <if test="memberId != null">#{memberId},</if>
            <if test="objectId != null">#{objectId},</if>
            <if test="objectType != null">#{objectType},</if>
            <if test="evaluateStar != null">#{evaluateStar},</if>
            <if test="content != null">#{content},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="isShow != null">#{isShow},</if>
         </trim>
    </insert>

    <update id="updateMemberEvaluate" parameterType="MemberEvaluate">
        update t_member_evaluate
        <trim prefix="SET" suffixOverrides=",">
            <if test="memberId != null">member_id = #{memberId},</if>
            <if test="objectId != null">object_id = #{objectId},</if>
            <if test="objectType != null">object_type = #{objectType},</if>
            <if test="evaluateStar != null">evaluate_star = #{evaluateStar},</if>
            <if test="content != null">content = #{content},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="isShow != null">is_show = #{isShow},</if>
        </trim>
        where member_evaluate_id = #{memberEvaluateId}
    </update>

    <delete id="deleteMemberEvaluateByMemberEvaluateId" parameterType="Long">
        delete from t_member_evaluate where member_evaluate_id = #{memberEvaluateId}
    </delete>

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