zoukankan      html  css  js  c++  java
  • 批量

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

  • 相关阅读:
    SSM实现mysql数据库账号密码加密连接
    获取系统相关信息 (CPU使用率 内存使用率 系统磁盘大小)
    JavaWeb(一) / /* /**的区别
    IDEA(一) 使用IDEA搭建SSM框架项目
    Mysql连接数据库异常汇总【必收藏】
    Java代理模式及动态代理详解
    SpringBoot集成Thymeleaf
    设计师,程序员,当心字体侵权
    Java开发神器Lombok使用详解
    日期格式化跨年bug,是否与你不期而遇?
  • 原文地址:https://www.cnblogs.com/panxuejun/p/7501101.html
Copyright © 2011-2022 走看看