<?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.GoodsImageMapper">

    <resultMap type="com.younike.system.domain.GoodsImage" id="GoodsImageResult">
        <result property="imageId"    column="image_id"    />
        <result property="goodsId"    column="goods_id"    />
        <result property="url"    column="url"    />
        <result property="faceImg"    column="face_img"    />
        <result property="type"    column="type"    />
        <result property="sorting"    column="sorting"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="loginIp"    column="login_ip"    />
        <result property="loginDate"    column="login_date"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="column1"    column="column1"    />
        <result property="column2"    column="column2"    />
        <result property="column3"    column="column3"    />
    </resultMap>

    <sql id="selectGoodsImageVo">
        select image_id, goods_id, url, face_img, type, sorting, del_flag, login_ip, login_date, create_by, create_time, update_by, update_time, column1, column2, column3 from goods_image
    </sql>

    <select id="selectGoodsImageList" parameterType="com.younike.system.domain.GoodsImage" resultMap="GoodsImageResult">
        <include refid="selectGoodsImageVo"/>
        <where>
            <if test="goodsId != null  and goodsId != ''"> and goods_id = #{goodsId}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="faceImg != null  and faceImg != ''"> and face_img = #{faceImg}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="sorting != null "> and sorting = #{sorting}</if>
            <if test="loginIp != null  and loginIp != ''"> and login_ip = #{loginIp}</if>
            <if test="loginDate != null "> and login_date = #{loginDate}</if>
            <if test="column1 != null  and column1 != ''"> and column1 = #{column1}</if>
            <if test="column2 != null  and column2 != ''"> and column2 = #{column2}</if>
            <if test="column3 != null  and column3 != ''"> and column3 = #{column3}</if>
        </where>
    </select>

    <select id="selectGoodsImageByImageId" parameterType="String" resultMap="GoodsImageResult">
        <include refid="selectGoodsImageVo"/>
        where image_id = #{imageId}
    </select>

    <insert id="insertGoodsImage" parameterType="com.younike.system.domain.GoodsImage">
        insert into goods_image
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="imageId != null">image_id,</if>
            <if test="goodsId != null and goodsId != ''">goods_id,</if>
            <if test="url != null and url != ''">url,</if>
            <if test="faceImg != null">face_img,</if>
            <if test="type != null and type != ''">type,</if>
            <if test="sorting != null">sorting,</if>
            <if test="delFlag != null and delFlag != ''">del_flag,</if>
            <if test="loginIp != null">login_ip,</if>
            <if test="loginDate != null">login_date,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="column1 != null">column1,</if>
            <if test="column2 != null">column2,</if>
            <if test="column3 != null">column3,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="imageId != null">#{imageId},</if>
            <if test="goodsId != null and goodsId != ''">#{goodsId},</if>
            <if test="url != null and url != ''">#{url},</if>
            <if test="faceImg != null">#{faceImg},</if>
            <if test="type != null and type != ''">#{type},</if>
            <if test="sorting != null">#{sorting},</if>
            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
            <if test="loginIp != null">#{loginIp},</if>
            <if test="loginDate != null">#{loginDate},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="column1 != null">#{column1},</if>
            <if test="column2 != null">#{column2},</if>
            <if test="column3 != null">#{column3},</if>
         </trim>
    </insert>

    <update id="updateGoodsImage" parameterType="com.younike.system.domain.GoodsImage">
        update goods_image
        <trim prefix="SET" suffixOverrides=",">
            <if test="goodsId != null and goodsId != ''">goods_id = #{goodsId},</if>
            <if test="url != null and url != ''">url = #{url},</if>
            <if test="faceImg != null">face_img = #{faceImg},</if>
            <if test="type != null and type != ''">type = #{type},</if>
            <if test="sorting != null">sorting = #{sorting},</if>
            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
            <if test="loginIp != null">login_ip = #{loginIp},</if>
            <if test="loginDate != null">login_date = #{loginDate},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="column1 != null">column1 = #{column1},</if>
            <if test="column2 != null">column2 = #{column2},</if>
            <if test="column3 != null">column3 = #{column3},</if>
        </trim>
        where image_id = #{imageId}
    </update>

    <delete id="deleteGoodsImageByImageId" parameterType="String">
        delete from goods_image where image_id = #{imageId}
    </delete>

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