<?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.fuxi.ws.data.dao.WGoodsdtlimgMapper" >
  <resultMap id="BaseResultMap" type="com.fuxi.ws.data.entity.WGoodsdtlimg" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Dec 10 11:22:02 CST 2014.
    -->
    <id column="GoodsID" property="goodsid" jdbcType="VARCHAR" />
    <id column="GoodsDtlImgID" property="goodsdtlimgid" jdbcType="INTEGER" />
    <result column="ImgIndex" property="imgindex" jdbcType="TINYINT" />
    <result column="GoodsDtlImgPath" property="goodsdtlimgpath" jdbcType="NVARCHAR" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Dec 10 11:22:02 CST 2014.
    -->
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Dec 10 11:22:02 CST 2014.
    -->
    GoodsID, GoodsDtlImgID, ImgIndex, GoodsDtlImgPath
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.fuxi.ws.data.entity.WGoodsdtlimgExample" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Dec 10 11:22:02 CST 2014.
    -->
    select
    <if test="distinct" >
      distinct
    </if>
    'false' as QUERYID,
    <include refid="Base_Column_List" />
    from W_GoodsDtlImg
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="com.fuxi.ws.data.entity.WGoodsdtlimgKey" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Dec 10 11:22:02 CST 2014.
    -->
    select 
    <include refid="Base_Column_List" />
    from W_GoodsDtlImg
    where GoodsID = #{goodsid,jdbcType=VARCHAR}
      and GoodsDtlImgID = #{goodsdtlimgid,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WGoodsdtlimgKey" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Dec 10 11:22:02 CST 2014.
    -->
    delete from W_GoodsDtlImg
    where GoodsID = #{goodsid,jdbcType=VARCHAR}
      and GoodsDtlImgID = #{goodsdtlimgid,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.fuxi.ws.data.entity.WGoodsdtlimg" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Dec 10 11:22:02 CST 2014.
    -->
    insert into W_GoodsDtlImg (GoodsID, GoodsDtlImgID, ImgIndex, 
      GoodsDtlImgPath)
    values (#{goodsid,jdbcType=VARCHAR}, #{goodsdtlimgid,jdbcType=INTEGER}, #{imgindex,jdbcType=TINYINT}, 
      #{goodsdtlimgpath,jdbcType=NVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.fuxi.ws.data.entity.WGoodsdtlimg" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Dec 10 11:22:02 CST 2014.
    -->
    insert into W_GoodsDtlImg
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="goodsid != null" >
        GoodsID,
      </if>
      <if test="goodsdtlimgid != null" >
        GoodsDtlImgID,
      </if>
      <if test="imgindex != null" >
        ImgIndex,
      </if>
      <if test="goodsdtlimgpath != null" >
        GoodsDtlImgPath,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="goodsid != null" >
        #{goodsid,jdbcType=VARCHAR},
      </if>
      <if test="goodsdtlimgid != null" >
        #{goodsdtlimgid,jdbcType=INTEGER},
      </if>
      <if test="imgindex != null" >
        #{imgindex,jdbcType=TINYINT},
      </if>
      <if test="goodsdtlimgpath != null" >
        #{goodsdtlimgpath,jdbcType=NVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.fuxi.ws.data.entity.WGoodsdtlimgExample" resultType="java.lang.Integer" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Dec 10 11:22:02 CST 2014.
    -->
    select count(*) from W_GoodsDtlImg
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByPrimaryKeySelective" parameterType="com.fuxi.ws.data.entity.WGoodsdtlimg" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Dec 10 11:22:02 CST 2014.
    -->
    update W_GoodsDtlImg
    <set >
      <if test="imgindex != null" >
        ImgIndex = #{imgindex,jdbcType=TINYINT},
      </if>
      <if test="goodsdtlimgpath != null" >
        GoodsDtlImgPath = #{goodsdtlimgpath,jdbcType=NVARCHAR},
      </if>
    </set>
    where GoodsID = #{goodsid,jdbcType=VARCHAR}
      and GoodsDtlImgID = #{goodsdtlimgid,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WGoodsdtlimg" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Dec 10 11:22:02 CST 2014.
    -->
    update W_GoodsDtlImg
    set ImgIndex = #{imgindex,jdbcType=TINYINT},
      GoodsDtlImgPath = #{goodsdtlimgpath,jdbcType=NVARCHAR}
    where GoodsID = #{goodsid,jdbcType=VARCHAR}
      and GoodsDtlImgID = #{goodsdtlimgid,jdbcType=INTEGER}
  </update>
  
   <!-- 获取商品明细图像ID -->
  <select id="selectimgid" parameterType="java.lang.String" resultType="java.lang.Integer" >    
    select isnull(max(GoodsDtlImgID),0) + 1 as GoodsDtlImgID from W_GoodsDtlImg
    where GoodsID = #{goodsid,jdbcType=VARCHAR}
  </select>
  
  <delete id="deleteByGoodsId" parameterType="java.lang.String" >   
    delete from W_GoodsDtlImg
    where GoodsID = #{goodsid,jdbcType=VARCHAR}
  </delete>
  
</mapper>