yujian
2019-06-25 b7b8f2a4fe9059ef7b5470a68bb1b34787bc92b2
fanli/src/main/java/com/yeshi/fanli/mapping/homemodule/HomeNavbarMapper.xml
@@ -33,41 +33,116 @@
    <include refid="Base_Column_List"/>from yeshi_ec_home_navbar where br_id = #{id,jdbcType=BIGINT}
  </select>
  
  <select id="getMaxOrder" resultType="java.lang.Integer">
       SELECT IFNULL(MAX(br_orderby),0) FROM yeshi_ec_home_navbar
  <select id="getDefaultMaxOrder" resultType="java.lang.Integer">
      SELECT IFNULL(MAX(br_orderby),0) FROM yeshi_ec_home_navbar
      order by br_orderby desc
  </select>
  
  <select id="getChangeOrder" resultMap="BaseResultMap">
       SELECT  <include refid="Base_Column_List" /> FROM yeshi_ec_home_navbar
       WHERE 1=1
       <if test="type == -1">
          <![CDATA[and br_orderby < #{order}]]>
          order by br_orderby desc
  <select id="getManMaxOrder" resultType="java.lang.Integer">
      SELECT IFNULL(MAX(br_order_man),0) FROM yeshi_ec_home_navbar
      order by br_order_man desc
  </select>
  <select id="getWomanMaxOrder" resultType="java.lang.Integer">
      SELECT IFNULL(MAX(br_order_woman),0) FROM yeshi_ec_home_navbar
      order by br_order_woman desc
  </select>
   <select id="getDefaultChangeOrder" resultType="java.lang.Integer">
      SELECT h.* FROM yeshi_ec_home_navbar h
      LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
    WHERE 1=1 and h.br_orderby is not null
      <if test="type == -1">
            <![CDATA[and h.br_orderby < #{order}]]>
            order by h.br_orderby  desc
       </if>
       <if test="type == 1">
          <![CDATA[and br_orderby > #{order} ]]>
          order by br_orderby
          <![CDATA[and h.br_orderby > #{order}]]>
          order by h.br_orderby
       </if>
        LIMIT 1
   </select>
     LIMIT 1
  </select>
  <select id="getManChangeOrder" resultType="java.lang.Integer">
      SELECT h.* FROM yeshi_ec_home_navbar h
      LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
    WHERE 1=1 and h.br_order_man is  not null
      <if test="type == -1">
            <![CDATA[and h.br_order_man < #{order}]]>
            order by h.br_order_man  desc
       </if>
       <if test="type == 1">
          <![CDATA[and h.br_order_man > #{order}]]>
          order by h.br_order_man
       </if>
     LIMIT 1
  </select>
  <select id="getWomanChangeOrder" resultType="java.lang.Integer">
      SELECT h.* FROM yeshi_ec_home_navbar h
      LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
    WHERE 1=1 and h.br_order_woman is not null
      <if test="type == -1">
            <![CDATA[and h.br_order_woman < #{order}]]>
            order by h.br_order_woman  desc
       </if>
       <if test="type == 1">
          <![CDATA[and h.br_order_woman > #{order}]]>
          order by h.br_order_woman
       </if>
     LIMIT 1
  </select>
   
   <select id="listQuery" resultMap="BaseResultMap">
       SELECT <include refid="Base_Column_List" />  FROM yeshi_ec_home_navbar
       SELECT h.*,c.sex AS sex  FROM yeshi_ec_home_navbar h
       LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
       WHERE 1=1
         <if test='key != null and key != ""'>
               AND (br_name like '%${key}%')
               AND (h.br_name like '%${key}%')
         </if>
         ORDER BY br_orderby
         <!-- 通用版 -->
         <if test="sex == 0">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 0 OR c.`sex` = 10 OR c.`sex` = 20))
            ORDER BY h.br_orderby
         </if>
         <!-- 女版 -->
         <if test="sex == 1">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 1 OR c.`sex` = 10 OR c.`sex` = 12))
            ORDER BY h.br_order_woman
         </if>
         <!-- 男版 -->
         <if test="sex == 2">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 2 OR c.`sex` = 20 OR c.`sex` = 12))
            ORDER BY h.br_order_man
         </if>
       LIMIT ${start},${count}
   </select>
   
   <select id="countListQuery" resultType="java.lang.Long">
       SELECT IFNULL(count(br_id),0)  FROM yeshi_ec_home_navbar
       SELECT IFNULL(count(br_id),0)  FROM yeshi_ec_home_navbar h
       LEFT JOIN `yeshi_ec_class` c ON c.`id` = h.`br_class_id`
       WHERE 1=1
         <if test='key != null and key != ""'>
               AND (br_name like '%${key}%')
               AND (h.br_name like '%${key}%')
         </if>
         <!-- 通用版 -->
         <if test="sex == 0">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 0 OR c.`sex` = 10 OR c.`sex` = 20))
            ORDER BY h.br_orderby
         </if>
         <!-- 女版 -->
         <if test="sex == 1">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 1 OR c.`sex` = 10 OR c.`sex` = 12))
            ORDER BY h.br_order_woman
         </if>
         <!-- 男版 -->
         <if test="sex == 2">
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 2 OR c.`sex` = 20 OR c.`sex` = 12))
            ORDER BY h.br_order_man
         </if>
   </select>
     
   <select id="listQueryEffective" resultMap="BaseResultMap">
@@ -86,24 +161,19 @@
     WHERE h.br_state = 1 AND br_is_default = 1
           AND IF(h.br_start_time IS NULL,TRUE, h.br_start_time<![CDATA[<=]]> NOW()) 
           AND IF(h.br_end_time IS NULL,TRUE, h.br_end_time <![CDATA[>=]]> NOW())
           <!-- 全部使用 -->
         <if test="sex == null">
            AND c.`sex`= 120
            ORDER BY h.br_orderby
         </if>
         <!-- 通用版 -->
            <!-- 通用版 -->
         <if test="sex == 0">
            AND (c.`sex`= 120 OR c.`sex` = 0 OR c.`sex` = 10 OR c.`sex` = 20)
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 0 OR c.`sex` = 10 OR c.`sex` = 20))
            ORDER BY h.br_orderby 
         </if>
         <!-- 女版 -->
         <if test="sex == 1">
            AND (c.`sex`= 120 OR c.`sex` = 1 OR c.`sex` = 10 OR c.`sex` = 12)
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 1 OR c.`sex` = 10 OR c.`sex` = 12))
            ORDER BY h.br_order_woman
         </if>
         <!-- 男版 -->
         <if test="sex == 2">
            AND (c.`sex`= 120 OR c.`sex` = 2 OR c.`sex` = 20 OR c.`sex` = 12)
            AND (c.`id` is null OR (c.`sex`= 120 OR c.`sex` = 2 OR c.`sex` = 20 OR c.`sex` = 12))
            ORDER BY h.br_order_man  
         </if>
   </select>