yansen преди 5 години
родител
ревизия
6fd20910a9
променени са 1 файла, в които са добавени 13 реда и са изтрити 13 реда
  1. 13
    13
      src/main/resources/mapper/TaBuildingMapper.xml

+ 13
- 13
src/main/resources/mapper/TaBuildingMapper.xml Целия файл

89
                 <if test="cityId != null">
89
                 <if test="cityId != null">
90
                     AND city_id = #{cityId}
90
                     AND city_id = #{cityId}
91
                 </if>
91
                 </if>
92
-                <if test="targets != null">
92
+                <if test="targets != null and targets.size > 0">
93
                     AND building_id IN
93
                     AND building_id IN
94
                     <foreach collection="targets" item="buildingId" open="(" close=")" separator=",">
94
                     <foreach collection="targets" item="buildingId" open="(" close=")" separator=",">
95
                         #{buildingId}
95
                         #{buildingId}
101
                 </if>
101
                 </if>
102
             ) as tb
102
             ) as tb
103
 
103
 
104
-            <if test="priceList != null or buildingTypeList != null">
105
-                LEFT JOIN
104
+            <if test="(priceList != null and priceList.size > 0) or (buildingTypeList != null and buildingTypeList.length > 0)">
105
+                INNER JOIN
106
                 (
106
                 (
107
                 SELECT * FROM ta_building_project_type
107
                 SELECT * FROM ta_building_project_type
108
                 <trim prefix="where" prefixOverrides="and | or">
108
                 <trim prefix="where" prefixOverrides="and | or">
110
                     <if test="priceList != null">
110
                     <if test="priceList != null">
111
                         <foreach collection="priceList" item="priceArr" open="(" close=")" separator=" OR ">
111
                         <foreach collection="priceList" item="priceArr" open="(" close=")" separator=" OR ">
112
                             (
112
                             (
113
-                                <if test="priceArr[0] != null and priceArr[0] > 0">
113
+                                <if test='priceArr[0] != null and priceArr[0] != ""'>
114
                                     <![CDATA[ price >= ${priceArr[0]}  ]]>
114
                                     <![CDATA[ price >= ${priceArr[0]}  ]]>
115
                                 </if>
115
                                 </if>
116
-                                <if test="priceArr.length > 1 and priceArr[0] != null">
116
+                                <if test='priceArr.length > 1 and priceArr[0] != null and priceArr[0] != ""'>
117
                                     AND
117
                                     AND
118
                                 </if>
118
                                 </if>
119
-                                <if test="priceArr[1] != null and priceArr[1] > 0">
119
+                                <if test='priceArr.length > 1 and priceArr[1] != null and priceArr[1] != ""'>
120
                                     <![CDATA[ price <= ${priceArr[1]}  ]]>
120
                                     <![CDATA[ price <= ${priceArr[1]}  ]]>
121
                                 </if>
121
                                 </if>
122
                             )
122
                             )
123
                         </foreach>
123
                         </foreach>
124
                     </if>
124
                     </if>
125
 
125
 
126
-                    <if test="buildingTypeList != null">
126
+                    <if test="buildingTypeList != null and buildingTypeList.length > 0">
127
                         AND building_type_id in
127
                         AND building_type_id in
128
                         <foreach collection="buildingTypeList" item="buildingType" open="(" close=")" separator=",">
128
                         <foreach collection="buildingTypeList" item="buildingType" open="(" close=")" separator=",">
129
                             #{buildingType}
129
                             #{buildingType}
135
                 AS tbpt ON tb.building_id = tbpt.building_id
135
                 AS tbpt ON tb.building_id = tbpt.building_id
136
             </if>
136
             </if>
137
 
137
 
138
-            <if test="areaList != null or houseTypeList != null">
139
-                LEFT JOIN
138
+            <if test="(areaList != null and areaList.size > 0) or (houseTypeList != null and houseTypeList.length > 0)">
139
+                INNER JOIN
140
                 (
140
                 (
141
                 SELECT * FROM ta_building_apartment
141
                 SELECT * FROM ta_building_apartment
142
                 <trim prefix="where" prefixOverrides="and | or">
142
                 <trim prefix="where" prefixOverrides="and | or">
143
                     <if test="areaList != null">
143
                     <if test="areaList != null">
144
                         <foreach collection="areaList" item="areaArr" open="(" close=")" separator=" OR ">
144
                         <foreach collection="areaList" item="areaArr" open="(" close=")" separator=" OR ">
145
                             (
145
                             (
146
-                                <if test="areaArr[0] != null and areaArr[0] > 0">
146
+                                <if test='areaArr[0] != null and areaArr[0] != ""'>
147
                                     <![CDATA[ building_area >= ${areaArr[0]}  ]]>
147
                                     <![CDATA[ building_area >= ${areaArr[0]}  ]]>
148
                                 </if>
148
                                 </if>
149
-                                <if test="areaArr.length > 1 and areaArr[0] != null">
149
+                                <if test='areaArr.length > 1 and areaArr[0] != null and areaArr[0] != ""'>
150
                                     AND
150
                                     AND
151
                                 </if>
151
                                 </if>
152
-                                <if test="areaArr[1] != null and areaArr[1] > 0">
152
+                                <if test='areaArr.length > 1 and areaArr[1] != null and areaArr[1] != ""'>
153
                                     <![CDATA[ building_area <= ${areaArr[1]}  ]]>
153
                                     <![CDATA[ building_area <= ${areaArr[1]}  ]]>
154
                                 </if>
154
                                 </if>
155
                             )
155
                             )
156
                         </foreach>
156
                         </foreach>
157
                     </if>
157
                     </if>
158
 
158
 
159
-                    <if test="houseTypeList != null">
159
+                    <if test="houseTypeList != null and houseTypeList.length > 0">
160
                         AND house_type in
160
                         AND house_type in
161
                         <foreach collection="houseTypeList" item="houseType" open="(" close=")" separator=",">
161
                         <foreach collection="houseTypeList" item="houseType" open="(" close=")" separator=",">
162
                             #{houseType}
162
                             #{houseType}