<?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.project714.dao.ImageManageDao">
<resultMap id="BaseResultMap" type="com.project714.dto.ProductImageUrlDTO">
<!-- WARNING - @mbg.generated This element is automatically generated by
MyBatis Generator, do not modify. This element was generated on Mon May 22
15:25:15 CST 2017. -->
<result column="product_id" jdbcType="INTEGER" property="productID" />
<result column="product_color" jdbcType="VARCHAR" property="color" />
<result column="product_color_url" jdbcType="VARCHAR" property="imageUrl" />
</resultMap>
<sql id="Base_Column_List">
product_id,product_color,product_color_url
</sql>
<insert id="saveImageUrl" parameterType="com.project714.dto.ProductImageUrlDTO">
insert into `t_product_color_img_mapping`
<trim>
<if test="productID != null">
product_id,
</if>
<if test="color != null">
product_color,
</if>
<if test="imageUrl != null">
product_color_url,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="productID != null">
#{productID,jdbcType=Integer},
</if>
<if test="color != null">
#{color,jdbcType=VERCHAR},
</if>
<if test="imageUrl != null">
#{imageUrl,jdbcType=VERCHAR},
</if>
</trim>
</insert>
<select id="queryImageUrl" resultMap="BaseResultMap"
parameterType="java.lang.String">
select
<include refid="Base_Column_List" />
from t_product_color_img_mapping t
where t.product_id=#{productID}
</select>
<update id="updateImageUrl" parameterType="com.project714.dto.ProductImageUrlDTO">
update t_product_color_img_mapping
<set>
<if test="color != null">
product_color = #{color,jdbcType=VERCHAR},
</if>
<if test="imageUrl != null">
product_color_url = #{imageUrl,jdbcType=VERCHAR},
</if>
</set>
where
product_id=#{productID,jdbcType=INTEGER}
</update>
<update id="updateImageUrlList" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update t_product_color_img_mapping
<set>
<if test="item.color != null">
product_color = #{item.color,jdbcType=VERCHAR},
</if>
<if test="item.imageUrl != null">
product_color_url = #{item.imageUrl,jdbcType=VERCHAR},
</if>
</set>
where
product_id=#{item.productID,jdbcType=INTEGER}
</foreach>
</update>
<delete id="deleteImage" parameterType="java.lang.String">
delete from t_product_color_img_mapping t where
product_id=#{productID,jdbcType=INTEGER}
</delete>
<insert id="saveImageUrlByList" parameterType="java.util.List">
insert into
t_product_color_img_mapping(product_id,product_color,img_url)values
<foreach collection="list" item="item" index="index"
separator=",">
(#{item.productID,jdbcType=VARCHAR},#{item.color,jdbcType=VARCHAR},#{item.imageUrl,jdbcType=VARCHAR})
</foreach>
</insert>
</mapper>