SelfSizeMapper.xml 2.82 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.product.dal.SelfSizeMapper" >
  <resultMap id="BaseResultMap" type="com.yoho.product.model.SelfSize" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="product_id" property="productId" jdbcType="INTEGER" />
    <result column="goods_id" property="goodsId" jdbcType="INTEGER" />
    <result column="size_id" property="sizeId" jdbcType="INTEGER" />
    <result column="audit_time" property="auditTime" jdbcType="INTEGER" />
    <result column="audit_uid" property="auditUid" jdbcType="INTEGER" />
    <result column="status" property="status" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, product_id, goods_id, size_id, audit_time, audit_uid, status
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from self_size
    where id = #{id,jdbcType=INTEGER}
  </select>
  
    <sql id="Query_Sql" >
        <if test="selfSizeReq.productName != null and selfSizeReq.productName != '' ">
        <bind name="pattern" value="'%' + selfSizeReq.productName + '%'" />
           and b.product_name like #{pattern}
        </if>
        <if test="selfSizeReq.productCode != null and selfSizeReq.productCode != '' ">
           and b.product_code=#{selfSizeReq.productCode}
        </if>
        <if test="selfSizeReq.status != null">
           and a.status=#{selfSizeReq.status}
        </if>
    </sql>

    <select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.product.model.SelfSizeReq">
        select count(1)   
        from self_size a 
        <if test="selfSizeReq.productName != null or selfSizeReq.productCode != null">
        LEFT JOIN product b
        ON( b.id=a.product_id) 
        </if>
        where 1=1  
        <include refid="Query_Sql"></include>
    </select>
    
    <select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.product.model.SelfSizeReq">
      select a.id, a.product_id, a.goods_id, a.size_id, a.audit_time, a.audit_uid, a.status 
      from self_size a 
      <if test="selfSizeReq.productName != null or selfSizeReq.productCode != null">
        LEFT JOIN product b
        ON( b.id=a.product_id) 
      </if>
      where 1=1 
       <include refid="Query_Sql"></include>
      order by a.id desc 
      <if test="selfSizeReq.start!=null and selfSizeReq.size != null">
        limit #{selfSizeReq.start},#{selfSizeReq.size}
      </if>
    </select>
    
    <update id="upadteAuditResult">
       update self_size set status=#{status}, audit_time=unix_timestamp(), audit_uid=#{auditUid}  
       where id=#{id} and status=0
    </update>
  
</mapper>