GoodsImagesMapper.xml 2.56 KB
<?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.yoho.ufo.dal.GoodsImagesMapper">
  <resultMap id="BaseResultMap" type="com.yoho.ufo.dal.model.GoodsImages">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="goods_id" jdbcType="INTEGER" property="goodsId" />
    <result column="product_id" jdbcType="INTEGER" property="productId" />
    <result column="is_default" jdbcType="CHAR" property="isDefault" />
    <result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
    <result column="order_by" jdbcType="INTEGER" property="orderBy" />
  </resultMap>

  <insert id="insert" parameterType="com.yoho.ufo.dal.model.GoodsImages">
    insert into goods_images (id, goods_id, product_id, 
      is_default, image_url, order_by
      )
    values (#{id,jdbcType=INTEGER}, #{goodsId,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, 
      #{isDefault,jdbcType=CHAR}, #{imageUrl,jdbcType=VARCHAR}, #{orderBy,jdbcType=INTEGER}
      )
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yoho.ufo.dal.model.GoodsImages">
    update goods_images
    set goods_id = #{goodsId,jdbcType=INTEGER},
      product_id = #{productId,jdbcType=INTEGER},
      is_default = #{isDefault,jdbcType=CHAR},
      image_url = #{imageUrl,jdbcType=VARCHAR},
      order_by = #{orderBy,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select id, goods_id, product_id, is_default, image_url, order_by
    from goods_images
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectAll" resultMap="BaseResultMap">
    select id, goods_id, product_id, is_default, image_url, order_by
    from goods_images
  </select>
  <delete id="deleteByGoodsId" parameterType="java.lang.Integer">
    delete from goods_images
    where goods_id = #{goodsId,jdbcType=INTEGER}
  </delete>
  <select id="selectByGoodsId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select id, goods_id, product_id, is_default, image_url, order_by
    from goods_images
    where goods_id = #{goodsId,jdbcType=INTEGER}
  </select>
    <select id="selectDefaultByGoodsIdList" resultMap="BaseResultMap">
    select id, goods_id, product_id, is_default, image_url, order_by
    from goods_images
    where is_default='Y' and goods_id in 
    <foreach collection="list" item="goodsId" open="(" close=")" separator=",">
     #{goodsId}
    </foreach>
  </select>
  
</mapper>