<?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.WGoodsimgMapper" >
  <resultMap id="BaseResultMap" type="com.fuxi.ws.data.entity.WGoodsimg" >
    <!--
      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="GoodsImgID" property="goodsimgid" jdbcType="INTEGER" />
    <result column="ImgIndex" property="imgindex" jdbcType="TINYINT" />
    <result column="GoodsImgPath" property="goodsimgpath" jdbcType="NVARCHAR" />
    <result column="MainImg" property="mainimg" jdbcType="TINYINT" />
  </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, GoodsImgID, ImgIndex, GoodsImgPath, MainImg
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.fuxi.ws.data.entity.WGoodsimgExample" >
    <!--
      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_GoodsImg
    <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.WGoodsimgKey" >
    <!--
      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_GoodsImg
    where GoodsID = #{goodsid,jdbcType=VARCHAR}
      and GoodsImgID = #{goodsimgid,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WGoodsimgKey" >
    <!--
      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_GoodsImg
    where GoodsID = #{goodsid,jdbcType=VARCHAR}
      and GoodsImgID = #{goodsimgid,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.fuxi.ws.data.entity.WGoodsimg" >
    <!--
      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_GoodsImg (GoodsID, GoodsImgID, ImgIndex, 
      GoodsImgPath, MainImg)
    values (#{goodsid,jdbcType=VARCHAR}, #{goodsimgid,jdbcType=INTEGER}, #{imgindex,jdbcType=TINYINT}, 
      #{goodsimgpath,jdbcType=NVARCHAR}, #{mainimg,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" parameterType="com.fuxi.ws.data.entity.WGoodsimg" >
    <!--
      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_GoodsImg
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="goodsid != null" >
        GoodsID,
      </if>
      <if test="goodsimgid != null" >
        GoodsImgID,
      </if>
      <if test="imgindex != null" >
        ImgIndex,
      </if>
      <if test="goodsimgpath != null" >
        GoodsImgPath,
      </if>
      <if test="mainimg != null" >
        MainImg,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="goodsid != null" >
        #{goodsid,jdbcType=VARCHAR},
      </if>
      <if test="goodsimgid != null" >
        #{goodsimgid,jdbcType=INTEGER},
      </if>
      <if test="imgindex != null" >
        #{imgindex,jdbcType=TINYINT},
      </if>
      <if test="goodsimgpath != null" >
        #{goodsimgpath,jdbcType=NVARCHAR},
      </if>
      <if test="mainimg != null" >
        #{mainimg,jdbcType=TINYINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.fuxi.ws.data.entity.WGoodsimgExample" 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_GoodsImg
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByPrimaryKeySelective" parameterType="com.fuxi.ws.data.entity.WGoodsimg" >
    <!--
      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_GoodsImg
    <set >
      <if test="imgindex != null" >
        ImgIndex = #{imgindex,jdbcType=TINYINT},
      </if>
      <if test="goodsimgpath != null" >
        GoodsImgPath = #{goodsimgpath,jdbcType=NVARCHAR},
      </if>
      <if test="mainimg != null" >
        MainImg = #{mainimg,jdbcType=TINYINT},
      </if>
    </set>
    where GoodsID = #{goodsid,jdbcType=VARCHAR}
      and GoodsImgID = #{goodsimgid,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WGoodsimg" >
    <!--
      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_GoodsImg
    set ImgIndex = #{imgindex,jdbcType=TINYINT},
      GoodsImgPath = #{goodsimgpath,jdbcType=NVARCHAR},
      MainImg = #{mainimg,jdbcType=TINYINT}
    where GoodsID = #{goodsid,jdbcType=VARCHAR}
      and GoodsImgID = #{goodsimgid,jdbcType=INTEGER}
  </update>
  
  <!-- 获取商品图像ID -->
  <select id="selectimgid" parameterType="java.lang.String" resultType="java.lang.Integer" >    
    select isnull(max(GoodsImgID),0) + 1 as GoodsImgID from W_GoodsImg
    where GoodsID = #{goodsid,jdbcType=VARCHAR}
  </select>
  
  <delete id="deleteByGoodsId" parameterType="java.lang.String" >   
    delete from W_GoodsImg
    where GoodsID = #{goodsid,jdbcType=VARCHAR}
  </delete>
</mapper>