From cdcbed9af813b2a02cdc01eefa24db8bec6b51a9 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期三, 27 三月 2019 12:17:33 +0800
Subject: [PATCH] 主分类 + 子分类 DAO改造

---
 fanli/src/main/java/com/yeshi/fanli/mapping/GoodsClassMapper.xml |  125 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 102 insertions(+), 23 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/mapping/GoodsClassMapper.xml b/fanli/src/main/java/com/yeshi/fanli/mapping/GoodsClassMapper.xml
index 4b5d74b..3addf0c 100644
--- a/fanli/src/main/java/com/yeshi/fanli/mapping/GoodsClassMapper.xml
+++ b/fanli/src/main/java/com/yeshi/fanli/mapping/GoodsClassMapper.xml
@@ -1,32 +1,72 @@
-<?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" >
+<?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.yeshi.fanli.dao.mybatis.GoodsClassMapper">
-	<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.clazz.GoodsClass">
-	    <id column="id" property="id" jdbcType="BIGINT"/>
-	    <result column="name" property="name" jdbcType="VARCHAR"/>
-	    <result column="picture" property="picture" jdbcType="VARCHAR"/>
-	    <result column="orderby" property="orderby" jdbcType="INTEGER"/>
-	    <result column="createtime" property="createtime" jdbcType="TIMESTAMP"/>
-	    <result column="url" property="url" jdbcType="VARCHAR"/>
-	    <result column="key" property="key" jdbcType="VARCHAR"/>
-	    <result column="ios_click" property="iosClick" jdbcType="BIGINT"/>
-	    <result column="android_click" property="androidClick" jdbcType="BIGINT"/>
-	 </resultMap>
-	  
-  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsClass">
-  	update yeshi_ec_class
+  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.clazz.GoodsClass">
+    <id column="id" property="id" jdbcType="BIGINT"/>
+    <result column="name" property="name" jdbcType="VARCHAR"/>
+    <result column="picture" property="picture" jdbcType="VARCHAR"/>
+    <result column="url" property="url" jdbcType="VARCHAR"/>
+    <result column="key" property="key" jdbcType="VARCHAR"/>
+    <result column="search_param" property="searchParam" jdbcType="VARCHAR"/>
+    <result column="orderby" property="orderby" jdbcType="INTEGER"/>
+    <result column="createtime" property="createtime" jdbcType="BIGINT"/>
+    <result column="ios_click" property="iosClick" jdbcType="BIGINT"/>
+    <result column="android_click" property="androidClick" jdbcType="BIGINT"/>
+  </resultMap>
+  
+   <sql id="Base_Column_List">id,`name`,picture,`key`,search_param,orderby,createtime,ios_click,android_click</sql>
+  
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
+ 		 select * from yeshi_ec_class where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_class where id = #{id,jdbcType=BIGINT}</delete>
+  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_class (id,`name`,picture,url,`key`,search_param,orderby,createtime,ios_click,android_click) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{url,jdbcType=VARCHAR},#{key,jdbcType=VARCHAR},#{searchParam,jdbcType=VARCHAR},#{orderby,jdbcType=INTEGER},#{createtime,jdbcType=BIGINT},#{iosClick,jdbcType=BIGINT},#{androidClick,jdbcType=BIGINT})</insert>
+  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_class
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">id,</if>
+      <if test="name != null">`name`,</if>
+      <if test="picture != null">picture,</if>
+      <if test="url != null">url,</if>
+      <if test="key != null">`key`,</if>
+      <if test="searchParam != null">search_param,</if>
+      <if test="orderby != null">orderby,</if>
+      <if test="createtime != null">createtime,</if>
+      <if test="iosClick != null">ios_click,</if>
+      <if test="androidClick != null">android_click,</if>
+    </trim>values
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">#{id,jdbcType=BIGINT},</if>
+      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
+      <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
+      <if test="url != null">#{url,jdbcType=VARCHAR},</if>
+      <if test="key != null">#{key,jdbcType=VARCHAR},</if>
+      <if test="searchParam != null">#{searchParam,jdbcType=VARCHAR},</if>
+      <if test="orderby != null">#{orderby,jdbcType=INTEGER},</if>
+      <if test="createtime != null">#{createtime,jdbcType=BIGINT},</if>
+      <if test="iosClick != null">#{iosClick,jdbcType=BIGINT},</if>
+      <if test="androidClick != null">#{androidClick,jdbcType=BIGINT},</if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsClass">update yeshi_ec_class set `name` = #{name,jdbcType=VARCHAR},picture = #{picture,jdbcType=VARCHAR},url = #{url,jdbcType=VARCHAR},`key` = #{key,jdbcType=VARCHAR},search_param = #{searchParam,jdbcType=VARCHAR},orderby = #{orderby,jdbcType=INTEGER},createtime = #{createtime,jdbcType=BIGINT},ios_click = #{iosClick,jdbcType=BIGINT},android_click = #{androidClick,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}</update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsClass">update yeshi_ec_class
     <set>
+      <if test="name != null">`name`=#{name,jdbcType=VARCHAR},</if>
+      <if test="picture != null">picture=#{picture,jdbcType=VARCHAR},</if>
+      <if test="url != null">url=#{url,jdbcType=VARCHAR},</if>
+      <if test="key != null">`key`=#{key,jdbcType=VARCHAR},</if>
+      <if test="searchParam != null">search_param=#{searchParam,jdbcType=VARCHAR},</if>
+      <if test="orderby != null">orderby=#{orderby,jdbcType=INTEGER},</if>
+      <if test="createtime != null">createtime=#{createtime,jdbcType=BIGINT},</if>
       <if test="iosClick != null">ios_click=#{iosClick,jdbcType=BIGINT},</if>
       <if test="androidClick != null">android_click=#{androidClick,jdbcType=BIGINT},</if>
     </set> where id = #{id,jdbcType=BIGINT}
   </update>
-	<select id="getKwById" resultType="String">
+  
+  
+    <select id="getKeysById" resultType="java.lang.String">
 		SELECT ec.`key` FROM `yeshi_ec_class` ec WHERE ec.`id` = #{id};
 	</select>
-	
-	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
-		select * from yeshi_ec_class where id = #{id,jdbcType=BIGINT}
- 	</select>
  	
  	<select id="listGoodsClassBySystemId" resultMap="BaseResultMap">
  		SELECT c.id,c.name,c.picture,c.url FROM `yeshi_ec_class` c
@@ -35,5 +75,44 @@
 		ORDER BY c.`orderby`
  	</select>
  	
-	
-</mapper>
\ No newline at end of file
+ 	<select id="getByAdjoinOrder" resultMap="BaseResultMap">
+    	SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_class fd 
+    	WHERE  1=1
+    	<if test="type == -1">
+    		AND fd.`orderby` <![CDATA[<]]> #{order}  
+    		ORDER BY fd.`orderby` desc
+    	</if>
+    	
+    	<if test="type == 1">
+    		AND fd.`orderby` <![CDATA[>]]> #{order}  
+    		ORDER BY fd.`orderby` 
+    	</if>
+    	LIMIT 1
+   </select>
+   
+ 	
+ 	<select id="getGoodsClassAll" resultMap="BaseResultMap">
+ 		SELECT *  FROM yeshi_ec_class rs ORDER BY rs.`orderby`
+ 	</select>
+ 	
+ 	<select id="listByName" resultMap="BaseResultMap">
+ 		SELECT *  from yeshi_ec_class rs 
+ 		WHERE rs.name like '%#{name}%'
+ 		LIMIT ${start},${count}
+ 	</select>
+ 	
+ 	<select id="countByName" resultType="java.lang.Integer">
+ 		SELECT  IFNULL(COUNT(rs.id),0) FROM yeshi_ec_class rs 
+ 		<if test="systemId != null">
+			RIGHT JOIN yeshi_ec_super_goodsclass sp ON sp.`goodsclass_id` = rs.`id` 
+		</if>
+		WHERE rs.name LIKE '%#{name}%' 
+			<if test="systemId != null">
+				AND sp.`system_id` = #{systemId}
+			</if>
+ 	</select>
+ 	
+ 	<select id="getMaxOrder" resultType="java.lang.Integer">
+ 		SELECT IFNULL(MAX(orderby),0) FROM `yeshi_ec_class`
+ 	</select>
+</mapper>

--
Gitblit v1.8.0