Browse Source

sql条件合并

zou_ht 8 years ago
parent
commit
76bae9cb03

+ 16 - 9
src/main/java/com/goafanti/common/controller/PortalController.java

@@ -251,22 +251,29 @@ public class PortalController extends BaseController {
 		
 		//查询精品成果
 		List<AchievementListBo> boutiqueAchievement = achievementService.getAchievement(1);
-		List<AchievementListBo> ReboutiqueAchievement = null;
-		int index1=(int)(1+Math.random()*(12-1+1));
-		int index2=(int)(1+Math.random()*(12-1+1));
-		int index3=(int)(1+Math.random()*(12-1+1));
+		List<AchievementListBo> reboutiqueAchievement = null;
+		int index=(int)(1+Math.random()*(10-1+1));
 		
 		for (int i = 0; i < boutiqueAchievement.size(); i++) {
-			ReboutiqueAchievement.add(boutiqueAchievement.get(index1));
-			ReboutiqueAchievement.add(boutiqueAchievement.get(index2));
-			ReboutiqueAchievement.add(boutiqueAchievement.get(index3));
+			reboutiqueAchievement.add(boutiqueAchievement.get(index));
+			reboutiqueAchievement.add(boutiqueAchievement.get(index++));
+			reboutiqueAchievement.add(boutiqueAchievement.get(index+2));
 		};
 		
 		//判断登录没登录. 登录了.查找用户喜欢的. 没登录就随机查四个.
 		boolean isLogin = TokenManager.isLogin();
+		List<AchievementListBo> achievementlist = achievementService.getAchievement(0);//查询所有专利
+		List<AchievementListBo> reachievementlist = null;
+		for (int i = 0; i < achievementlist.size(); i++) {
+			reachievementlist.add(boutiqueAchievement.get(index));
+			reachievementlist.add(boutiqueAchievement.get(index+1));
+			reachievementlist.add(boutiqueAchievement.get(index+2));
+			reachievementlist.add(boutiqueAchievement.get(index+3));
+		};
+		List<AchievementListBo> customerLikelist = achievementService.getPerhapLike();//猜你喜欢专利
+		
 		
 		if(isLogin) {
-			List<AchievementListBo> CustomerLike = achievementService.getPerhapLike();
 		}else {
 			
 		}
@@ -274,7 +281,7 @@ public class PortalController extends BaseController {
 		
 		mv.setViewName("/portal/detail/achievementDetail");
 		mv.addObject("achievement", achievementdetail);
-		mv.addObject("ReboutiqueAchievement", ReboutiqueAchievement);
+		mv.addObject("ReboutiqueAchievement", reboutiqueAchievement);
 		return mv;
 	}
 

+ 5 - 21
src/main/java/com/goafanti/common/mapper/AchievementMapper.xml

@@ -1113,35 +1113,19 @@
   	<if test="keyword != null">
   		and a.keyword like "%"#{keyword,jdbcType=VARCHAR}"%"
   	</if>
-  	<if test="bargainingMode != null">
-  		and a.bargaining_mode = #{bargainingMode,jdbcType=INTEGER}
-  	</if>
-  	<if test="category != null">
-  		and a.category = #{category,jdbcType=INTEGER}
-  	</if>
-  	<if test="maturity != null">
-  		and a.maturity = #{maturity,jdbcType=INTEGER}
-  	</if>
-  	<if test="transferPriceLower != null">
-  		and a.transfer_price <![CDATA[ >= ]]> #{transferPriceLower,jdbcType=DECIMAL}
-  	</if>
-  	<if test="transferPriceUpper != null">
-  		and a.transfer_price <![CDATA[ <= ]]> #{transferPriceUpper,jdbcType=DECIMAL}
-  	</if>
   	<if test="transferMode != null">
   		and a.transfer_mode = #{transferMode,jdbcType=INTEGER}
   	</if>
-  	<if test="fieldA != null">
-  		and a.field_a = #{fieldA,jdbcType=INTEGER}
-  	</if>
-  	<if test="fieldB != null">
-  		and a.field_b = #{fieldB,jdbcType=INTEGER}
-  	</if>
   	<if test="dataCategory != null">
   		and a.data_category = #{dataCategory,jdbcType=INTEGER}
   	</if>
+  	<if test="fieldA != null">
+  		and a.field_a = #{fieldA,jdbcType=INTEGER}
+  	</if>
+  	and a.deleted_sign = 0 
   	and a.release_status = 1
   	and a.audit_status = 3
+  	order by a.release_date desc
   </select>
   
   <select id="selectAchievementSearchDetail"  resultType="com.goafanti.portal.bo.AchievementDetailBo">