SizePoolMapper.xml 4.16 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.SizePoolMapper">
    <resultMap id="BaseResultMap" type="com.yoho.ufo.dal.model.SizePool">
      <result column="id" property="id" jdbcType="INTEGER" />
      <result column="status" property="status" jdbcType="INTEGER" />
      <result column="range_type" property="rangeType" jdbcType="INTEGER" />
      <result column="image_url" property="imageUrl" jdbcType="VARCHAR" />
      <result column="update_time" property="updateTime" jdbcType="INTEGER" />
      <result column="update_uid" property="updateUid" jdbcType="INTEGER" />
      <result column="image_width" property="imageWidth" jdbcType="INTEGER" />
      <result column="image_height" property="imageHeight" jdbcType="INTEGER" />
    </resultMap>

    <sql id="Base_Column_List">
        id, status, range_type, image_url, update_time, update_uid, image_width, image_height
    </sql>

    <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.ufo.dal.model.SizePool">
        insert into size_pool(id, status, range_type, image_url, update_time, update_uid, image_width, image_height)
        values (#{id}, #{status}, #{rangeType}, #{imageUrl}, #{updateTime}, #{updateUid}, #{imageWidth}, #{imageHeight})
    </insert>
    
    <update id="updateByPrimaryKeySelective" parameterType="com.yoho.ufo.dal.model.SizePool">
       update size_pool
    <set>
      <if test="status != null" >
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="rangeType != null" >
        range_type = #{rangeType,jdbcType=INTEGER},
      </if>
      <if test="imageUrl != null" >
        image_url = #{imageUrl,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null" >
        update_time = #{updateTime,jdbcType=INTEGER},
      </if>
      <if test="updateUid != null" >
        update_uid = #{updateUid,jdbcType=INTEGER},
      </if>
      <if test="imageWidth != null" >
        image_width = #{imageWidth,jdbcType=INTEGER},
      </if>
      <if test="imageHeight != null" >
        image_height = #{imageHeight,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from size_pool
    where id = #{id,jdbcType=INTEGER}
  </delete>
  
  <select id="querySizePoolById" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from size_pool 
    where id= #{id, jdbcType=INTEGER}
  </select>
  
    <sql id="Query_Sql" >
        <if test="sizePoolReq.brandId != null">
           and b.is_include=1 and b.item_type=1 and b.item_id=#{sizePoolReq.brandId}
        </if>
        <if test="sizePoolReq.productId != null">
           and b.is_include=1 and b.item_type=2 and b.item_id=#{sizePoolReq.productId}
        </if>
        <if test="sizePoolReq.status != null">
           and a.status=#{sizePoolReq.status}
        </if>
    </sql>

    <select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yohobuy.ufo.model.request.size.SizePoolRequest">
        select count(distinct a.id)   
        from size_pool a 
        <if test="sizePoolReq.brandId != null or sizePoolReq.productId">
        LEFT JOIN size_pool_detail b
        ON(b.size_pool_id=a.id)
        </if> 
        where 1=1  
        <include refid="Query_Sql"></include>
    </select>
    
    <select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yohobuy.ufo.model.request.size.SizePoolRequest">
      select a.id, a.status, a.range_type, a.image_url 
      from size_pool a 
      <if test="sizePoolReq.brandId != null or sizePoolReq.productId">
      LEFT JOIN size_pool_detail b
        ON(b.size_pool_id=a.id) 
      </if>
      where 1=1 
       <include refid="Query_Sql"></include>
      order by a.id desc 
      <if test="sizePoolReq.startIndex!=null and sizePoolReq.rows != null">
        limit #{sizePoolReq.startIndex},#{sizePoolReq.rows}
      </if>
    </select>
    
    <update id="updateStatus">
      update size_pool set status=#{status} 
      where id=#{id}
    </update>
</mapper>