<?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.WShowsetdtlMapper">
  <resultMap id="BaseResultMap" type="com.fuxi.ws.data.entity.WShowsetdtl">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 04 18:52:39 CST 2017.
    -->
    <id column="ShowSetID" jdbcType="SMALLINT" property="showsetid" />
    <id column="LineID" jdbcType="TINYINT" property="lineid" />
    <id column="ShowSetDtlId" jdbcType="SMALLINT" property="showsetdtlid" />
    <result column="ClumIndex" jdbcType="SMALLINT" property="clumindex" />
    <result column="GoodsTypeID" jdbcType="VARCHAR" property="goodstypeid" />
    <result column="GoodsID" jdbcType="VARCHAR" property="goodsid" />
    <result column="ImgPath" jdbcType="NVARCHAR" property="imgpath" />
    <result column="FocusImg" jdbcType="NVARCHAR" property="focusimg" />
    <result column="ADUrl" jdbcType="NVARCHAR" property="adurl" />
    <result column="TicketID" jdbcType="BIGINT" property="ticketid" />
    <result column="TicketStyle" jdbcType="VARCHAR" property="ticketstyle" />
    <result column="Modified" jdbcType="TIMESTAMP" property="modified" />
  </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 Jan 04 18:52:39 CST 2017.
    -->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <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 close=")" collection="criterion.value" item="listItem" open="(" 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 Jan 04 18:52:39 CST 2017.
    -->
    ShowSetID, LineID, ShowSetDtlId, ClumIndex, GoodsTypeID, GoodsID, ImgPath, FocusImg, 
    ADUrl, TicketID, TicketStyle, Modified
  </sql>
  <select id="selectByExample" parameterType="com.fuxi.ws.data.entity.WShowsetdtlExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 04 18:52:39 CST 2017.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    'false' as QUERYID,
    <include refid="Base_Column_List" />
    from W_ShowSetDtl
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WShowsetdtlKey" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 04 18:52:39 CST 2017.
    -->
    select 
    <include refid="Base_Column_List" />
    from W_ShowSetDtl
    where ShowSetID = #{showsetid,jdbcType=SMALLINT}
      and LineID = #{lineid,jdbcType=TINYINT}
      and ShowSetDtlId = #{showsetdtlid,jdbcType=SMALLINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WShowsetdtlKey">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 04 18:52:39 CST 2017.
    -->
    delete from W_ShowSetDtl
    where ShowSetID = #{showsetid,jdbcType=SMALLINT}
      and LineID = #{lineid,jdbcType=TINYINT}
      and ShowSetDtlId = #{showsetdtlid,jdbcType=SMALLINT}
  </delete>
  <insert id="insert" parameterType="com.fuxi.ws.data.entity.WShowsetdtl">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 04 18:52:39 CST 2017.
    -->
    insert into W_ShowSetDtl (ShowSetID, LineID, ShowSetDtlId, 
      ClumIndex, GoodsTypeID, GoodsID, 
      ImgPath, FocusImg, ADUrl, 
      TicketID, TicketStyle, Modified
      )
    values (#{showsetid,jdbcType=SMALLINT}, #{lineid,jdbcType=TINYINT}, #{showsetdtlid,jdbcType=SMALLINT}, 
      #{clumindex,jdbcType=SMALLINT}, #{goodstypeid,jdbcType=VARCHAR}, #{goodsid,jdbcType=VARCHAR}, 
      #{imgpath,jdbcType=NVARCHAR}, #{focusimg,jdbcType=NVARCHAR}, #{adurl,jdbcType=NVARCHAR}, 
      #{ticketid,jdbcType=BIGINT}, #{ticketstyle,jdbcType=VARCHAR}, #{modified,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.fuxi.ws.data.entity.WShowsetdtl">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 04 18:52:39 CST 2017.
    -->
    insert into W_ShowSetDtl
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="showsetid != null">
        ShowSetID,
      </if>
      <if test="lineid != null">
        LineID,
      </if>
      <if test="showsetdtlid != null">
        ShowSetDtlId,
      </if>
      <if test="clumindex != null">
        ClumIndex,
      </if>
      <if test="goodstypeid != null">
        GoodsTypeID,
      </if>
      <if test="goodsid != null">
        GoodsID,
      </if>
      <if test="imgpath != null">
        ImgPath,
      </if>
      <if test="focusimg != null">
        FocusImg,
      </if>
      <if test="adurl != null">
        ADUrl,
      </if>
      <if test="ticketid != null">
        TicketID,
      </if>
      <if test="ticketstyle != null">
        TicketStyle,
      </if>
      <if test="modified != null">
        Modified,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="showsetid != null">
        #{showsetid,jdbcType=SMALLINT},
      </if>
      <if test="lineid != null">
        #{lineid,jdbcType=TINYINT},
      </if>
      <if test="showsetdtlid != null">
        #{showsetdtlid,jdbcType=SMALLINT},
      </if>
      <if test="clumindex != null">
        #{clumindex,jdbcType=SMALLINT},
      </if>
      <if test="goodstypeid != null">
        #{goodstypeid,jdbcType=VARCHAR},
      </if>
      <if test="goodsid != null">
        #{goodsid,jdbcType=VARCHAR},
      </if>
      <if test="imgpath != null">
        #{imgpath,jdbcType=NVARCHAR},
      </if>
      <if test="focusimg != null">
        #{focusimg,jdbcType=NVARCHAR},
      </if>
      <if test="adurl != null">
        #{adurl,jdbcType=NVARCHAR},
      </if>
      <if test="ticketid != null">
        #{ticketid,jdbcType=BIGINT},
      </if>
      <if test="ticketstyle != null">
        #{ticketstyle,jdbcType=VARCHAR},
      </if>
      <if test="modified != null">
        #{modified,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.fuxi.ws.data.entity.WShowsetdtlExample" resultType="java.lang.Integer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 04 18:52:39 CST 2017.
    -->
    select count(*) from W_ShowSetDtl
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByPrimaryKeySelective" parameterType="com.fuxi.ws.data.entity.WShowsetdtl">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 04 18:52:39 CST 2017.
    -->
    update W_ShowSetDtl
    <set>
      <if test="clumindex != null">
        ClumIndex = #{clumindex,jdbcType=SMALLINT},
      </if>
      <if test="goodstypeid != null">
        GoodsTypeID = #{goodstypeid,jdbcType=VARCHAR},
      </if>
      <if test="goodsid != null">
        GoodsID = #{goodsid,jdbcType=VARCHAR},
      </if>
      <if test="imgpath != null">
        ImgPath = #{imgpath,jdbcType=NVARCHAR},
      </if>
      <if test="focusimg != null">
        FocusImg = #{focusimg,jdbcType=NVARCHAR},
      </if>
      <if test="adurl != null">
        ADUrl = #{adurl,jdbcType=NVARCHAR},
      </if>
      <if test="ticketid != null">
        TicketID = #{ticketid,jdbcType=BIGINT},
      </if>
      <if test="ticketstyle != null">
        TicketStyle = #{ticketstyle,jdbcType=VARCHAR},
      </if>
      <if test="modified != null">
        Modified = #{modified,jdbcType=TIMESTAMP},
      </if>
    </set>
    where ShowSetID = #{showsetid,jdbcType=SMALLINT}
      and LineID = #{lineid,jdbcType=TINYINT}
      and ShowSetDtlId = #{showsetdtlid,jdbcType=SMALLINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WShowsetdtl">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 04 18:52:39 CST 2017.
    -->
    update W_ShowSetDtl
    set ClumIndex = #{clumindex,jdbcType=SMALLINT},
      GoodsTypeID = #{goodstypeid,jdbcType=VARCHAR},
      GoodsID = #{goodsid,jdbcType=VARCHAR},
      ImgPath = #{imgpath,jdbcType=NVARCHAR},
      FocusImg = #{focusimg,jdbcType=NVARCHAR},
      ADUrl = #{adurl,jdbcType=NVARCHAR},
      TicketID = #{ticketid,jdbcType=BIGINT},
      TicketStyle = #{ticketstyle,jdbcType=VARCHAR},
      Modified = #{modified,jdbcType=TIMESTAMP}
    where ShowSetID = #{showsetid,jdbcType=SMALLINT}
      and LineID = #{lineid,jdbcType=TINYINT}
      and ShowSetDtlId = #{showsetdtlid,jdbcType=SMALLINT}
  </update>

	<delete id="delByShowSetID">
		delete from W_ShowSetDtl where ShowSetID=#{ showsetid }
	</delete>

	<select id="existsInShowset" resultType="java.lang.String">
		select top 1 case b.ShowArea when 1 then '商城【首页】的商品不能删除' when 3 then '商城【新品上架】的商品不能删除'
			 when 4 then '商城【热卖专区】的商品不能删除' else '' end as ShowArea
		FROM W_ShowSetDtl AS a INNER JOIN
		W_ShowSet AS b ON a.ShowSetID = b.ShowSetID
		where a.GoodsID = #{goodsid,jdbcType=VARCHAR}
	</select>
</mapper>