<?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.younike.system.mapper.GoodsCommentResourceMapper">


    <resultMap id="GoodsCommentResourceResult" type="com.younike.system.domain.GoodsCommentResource">

        <result column="recource_id" property="recourceId"/>

        <result column="comment_id" property="commentId"/>

        <result column="merchant_id" property="merchantId"/>

        <result column="type" property="type"/>

        <result column="url" property="url"/>

        <result column="face_img" property="faceImg"/>

        <result column="is_del" property="isDel"/>

        <result column="create_time" property="createTime"/>

        <result column="update_time" property="updateTime"/>

        <result column="version" property="version"/>

    </resultMap>

    <sql id="selectGoodsCommentResourceVo">select recource_id, comment_id, merchant_id, type, url, face_img, is_del, create_time, update_time, version from goods_comment_resource </sql>


    <select id="selectGoodsCommentResourceList" resultMap="GoodsCommentResourceResult"
            parameterType="com.younike.system.domain.GoodsCommentResource">

        <include refid="selectGoodsCommentResourceVo"/>


        <where>

            <if test="commentId != null ">and comment_id = #{commentId}</if>

            <if test="merchantId != null ">and merchant_id = #{merchantId}</if>

            <if test="type != null and type != ''">and type = #{type}</if>

            <if test="url != null and url != ''">and url = #{url}</if>

            <if test="faceImg != null and faceImg != ''">and face_img = #{faceImg}</if>

            <if test="isDel != null ">and is_del = #{isDel}</if>

            <if test="version != null ">and version = #{version}</if>

        </where>

    </select>


    <select id="selectGoodsCommentResourceByRecourceId" resultMap="GoodsCommentResourceResult" parameterType="Long">

        <include refid="selectGoodsCommentResourceVo"/>
        where recource_id = #{recourceId}
    </select>


    <insert id="insertGoodsCommentResource" parameterType="com.younike.system.domain.GoodsCommentResource" useGeneratedKeys="true" keyProperty="recourceId">
        insert into goods_comment_resource

        <trim suffixOverrides="," suffix=")" prefix="(">

            <if test="recourceId != null">recource_id,</if>

            <if test="commentId != null">comment_id,</if>

            <if test="merchantId != null">merchant_id,</if>

            <if test="type != null and type != ''">type,</if>

            <if test="url != null and url != ''">url,</if>

            <if test="faceImg != null">face_img,</if>

            <if test="isDel != null">is_del,</if>

            <if test="createTime != null">create_time,</if>

            <if test="updateTime != null">update_time,</if>

            <if test="version != null">version,</if>

        </trim>


        <trim suffixOverrides="," suffix=")" prefix="values (">

            <if test="recourceId != null">#{recourceId},</if>

            <if test="commentId != null">#{commentId},</if>

            <if test="merchantId != null">#{merchantId},</if>

            <if test="type != null and type != ''">#{type},</if>

            <if test="url != null and url != ''">#{url},</if>

            <if test="faceImg != null">#{faceImg},</if>

            <if test="isDel != null">#{isDel},</if>

            <if test="createTime != null">#{createTime},</if>

            <if test="updateTime != null">#{updateTime},</if>

            <if test="version != null">#{version},</if>

        </trim>

    </insert>


    <update id="updateGoodsCommentResource" parameterType="com.younike.system.domain.GoodsCommentResource">
        update goods_comment_resource

        <trim suffixOverrides="," prefix="SET">

            <if test="commentId != null">comment_id = #{commentId},</if>

            <if test="merchantId != null">merchant_id = #{merchantId},</if>

            <if test="type != null and type != ''">type = #{type},</if>

            <if test="url != null and url != ''">url = #{url},</if>

            <if test="faceImg != null">face_img = #{faceImg},</if>

            <if test="isDel != null">is_del = #{isDel},</if>

            <if test="createTime != null">create_time = #{createTime},</if>

            <if test="updateTime != null">update_time = #{updateTime},</if>

            <if test="version != null">version = #{version},</if>

        </trim>
        where recource_id = #{recourceId}
    </update>

    <delete id="deleteGoodsCommentResourceByRecourceId"
            parameterType="Long">delete from goods_comment_resource where recource_id = #{recourceId} </delete>


    <delete id="deleteGoodsCommentResourceByRecourceIds" parameterType="String">
        delete from goods_comment_resource where recource_id in
        <foreach close=")" separator="," open="(" collection="array" item="recourceId">#{recourceId}</foreach>

    </delete>

</mapper>
