• 批量


    <?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>

  • 相关阅读:
    细思极恐-你真的会写java吗?
    java定时器无法自动注入的问题解析(原来Spring定时器可以这样注入service)
    java并发编程之volatile
    细思极恐-你真的会写java吗?
    细思极恐-你真的会写java吗?
    细思极恐-你真的会写java吗
    1月中旬值得一读的10本技术新书(机器学习、Java、大数据等)!
    0基础小白怎么学好Java?
    java日常知识点积累
    (解决)ECSHOP info: Can't Connect MySQL Server(localhost:3306)!转删
  • 原文地址:https://www.cnblogs.com/panxuejun/p/7501101.html
Copyright © 2020-2023  润新知