From 3f1dc57d57ef0ceafcc59cd5ce34ff90cfe6d146 Mon Sep 17 00:00:00 2001
From: 1098226878 <1098226878@qq.com>
Date: 星期一, 13 九月 2021 17:06:16 +0800
Subject: [PATCH] 优化代码
---
java110-db/src/main/resources/mapper/goods/ProductLabelServiceDaoImplMapper.xml | 154 ++++++++++++++++++++++++++++----------------------
1 files changed, 86 insertions(+), 68 deletions(-)
diff --git a/java110-db/src/main/resources/mapper/goods/ProductLabelServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/goods/ProductLabelServiceDaoImplMapper.xml
old mode 100644
new mode 100755
index c3f26c6..0a03593
--- a/java110-db/src/main/resources/mapper/goods/ProductLabelServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/goods/ProductLabelServiceDaoImplMapper.xml
@@ -5,93 +5,111 @@
<mapper namespace="productLabelServiceDaoImpl">
-
-
-
<!-- 淇濆瓨浜у搧鏍囩淇℃伅 add by wuxw 2018-07-03 -->
<insert id="saveProductLabelInfo" parameterType="Map">
insert into product_label(
-label_id,product_id,store_id,label_cd
-) values (
-#{labelId},#{productId},#{storeId},#{labelCd}
-)
+ label_id,product_id,store_id,label_cd
+ ) values (
+ #{labelId},#{productId},#{storeId},#{labelCd}
+ )
</insert>
-
<!-- 鏌ヨ浜у搧鏍囩淇℃伅 add by wuxw 2018-07-03 -->
<select id="getProductLabelInfo" parameterType="Map" resultType="Map">
- select t.label_id,t.label_id labelId,t.product_id,t.product_id productId,t.status_cd,t.status_cd statusCd,t.store_id,t.store_id storeId,t.label_cd,t.label_cd labelCd
-from product_label t
-where 1 =1
-<if test="labelId !=null and labelId != ''">
- and t.label_id= #{labelId}
-</if>
-<if test="productId !=null and productId != ''">
- and t.product_id= #{productId}
-</if>
-<if test="statusCd !=null and statusCd != ''">
- and t.status_cd= #{statusCd}
-</if>
-<if test="storeId !=null and storeId != ''">
- and t.store_id= #{storeId}
-</if>
-<if test="labelCd !=null and labelCd != ''">
- and t.label_cd= #{labelCd}
-</if>
-order by t.create_time desc
-<if test="page != -1 and page != null ">
- limit #{page}, #{row}
-</if>
+ select t.label_id,t.label_id labelId,p.product_id productId,p.store_id storeId,t.label_cd,t.label_cd labelCd,
+ p.unit_name unitName,p.is_postage isPostage,p.sort,p.bar_code barCode,p.postage,p.prod_name prodName,
+ p.state,p.keyword,p.prod_desc prodDesc,p.category_id categoryId,pc.category_name categoryName,td.name stateName,
+ t.create_time createTime,
+ psv.cost_price costPrice,psv.ot_price otPrice,psv.price,psv.sales,psv.stock,psv.vip_price vipPrice
+ from product p
+ left join product_category pc on pc.category_id = p.category_id and pc.store_id = p.store_id and pc.status_cd = '0'
+ left join t_dict td on p.state = td.status_cd and td.table_name= 'product' and td.table_columns = 'state'
+ left join product_label t on t.product_id = p.product_id and t.store_id = p.store_id and t.status_cd = '0'
+ left join product_spec_value psv on psv.product_id = t.product_id and psv.store_id = t.store_id and psv.is_default = 'T'
+ <if test="labelCd !=null and labelCd != ''">
+ and t.label_cd= #{labelCd}
+ </if>
+ where 1 =1
+ <if test="labelId !=null and labelId != ''">
+ and t.label_id= #{labelId}
+ </if>
+ <if test="productId !=null and productId != ''">
+ and t.product_id= #{productId}
+ </if>
+ <if test="statusCd !=null and statusCd != ''">
+ and p.status_cd= #{statusCd}
+ </if>
+ <if test="storeId !=null and storeId != ''">
+ and p.store_id= #{storeId}
+ </if>
+ <if test='hasProduct !=null and hasProduct == "N"'>
+ and t.product_id is null
+ </if>
+ <if test='hasProduct !=null and hasProduct == "Y"'>
+ and t.product_id is not null
+ </if>
+ order by t.create_time desc
+ <if test="page != -1 and page != null ">
+ limit #{page}, #{row}
+ </if>
</select>
-
-
<!-- 淇敼浜у搧鏍囩淇℃伅 add by wuxw 2018-07-03 -->
<update id="updateProductLabelInfo" parameterType="Map">
- update product_label t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if>
-<if test="productId !=null and productId != ''">
-, t.product_id= #{productId}
-</if>
-<if test="storeId !=null and storeId != ''">
-, t.store_id= #{storeId}
-</if>
-<if test="labelCd !=null and labelCd != ''">
-, t.label_cd= #{labelCd}
-</if>
- where 1=1 <if test="labelId !=null and labelId != ''">
-and t.label_id= #{labelId}
-</if>
+ update product_label t set t.status_cd = #{statusCd}
+ <if test="newBId != null and newBId != ''">
+ ,t.b_id = #{newBId}
+ </if>
+ <if test="productId !=null and productId != ''">
+ , t.product_id= #{productId}
+ </if>
+ <if test="storeId !=null and storeId != ''">
+ , t.store_id= #{storeId}
+ </if>
+ <if test="labelCd !=null and labelCd != ''">
+ , t.label_cd= #{labelCd}
+ </if>
+ where 1=1
+ <if test="labelId !=null and labelId != ''">
+ and t.label_id= #{labelId}
+ </if>
</update>
<!-- 鏌ヨ浜у搧鏍囩鏁伴噺 add by wuxw 2018-07-03 -->
- <select id="queryProductLabelsCount" parameterType="Map" resultType="Map">
- select count(1) count
-from product_label t
-where 1 =1
-<if test="labelId !=null and labelId != ''">
- and t.label_id= #{labelId}
-</if>
-<if test="productId !=null and productId != ''">
- and t.product_id= #{productId}
-</if>
-<if test="statusCd !=null and statusCd != ''">
- and t.status_cd= #{statusCd}
-</if>
-<if test="storeId !=null and storeId != ''">
- and t.store_id= #{storeId}
-</if>
-<if test="labelCd !=null and labelCd != ''">
- and t.label_cd= #{labelCd}
-</if>
+ <select id="queryProductLabelsCount" parameterType="Map" resultType="Map">
+ select count(1) count
+ from product p
+ left join product_category pc on pc.category_id = p.category_id and pc.store_id = p.store_id and pc.status_cd = '0'
+ left join t_dict td on p.state = td.status_cd and td.table_name= 'product' and td.table_columns = 'state'
+ left join product_label t on t.product_id = p.product_id and t.store_id = p.store_id and t.status_cd = '0'
+ <if test="labelCd !=null and labelCd != ''">
+ and t.label_cd= #{labelCd}
+ </if>
+ where 1 =1
+ <if test="labelId !=null and labelId != ''">
+ and t.label_id= #{labelId}
+ </if>
+ <if test="productId !=null and productId != ''">
+ and t.product_id= #{productId}
+ </if>
+ <if test="statusCd !=null and statusCd != ''">
+ and p.status_cd= #{statusCd}
+ </if>
+ <if test="storeId !=null and storeId != ''">
+ and p.store_id= #{storeId}
+ </if>
+ <if test='hasProduct !=null and hasProduct == "N"'>
+ and t.product_id is null
+ </if>
+ <if test='hasProduct !=null and hasProduct == "Y"'>
+ and t.product_id is not null
+ </if>
- </select>
+ </select>
</mapper>
--
Gitblit v1.8.0