Browse Source

增加搜索量 新增

wangdy 8 years ago
parent
commit
bab6f379df

+ 10 - 0
src/main/java/com/uas/platform/b2c/common/search/service/impl/SearcherServiceImpl.java

@@ -13,8 +13,10 @@ import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
 import com.uas.platform.b2c.prod.commodity.model.Goods;
 import com.uas.platform.b2c.prod.product.brand.dao.BrandDao;
+import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentGoodsDao;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentInfoDao;
+import com.uas.platform.b2c.prod.product.component.modal.Component;
 import com.uas.platform.b2c.prod.product.component.modal.ComponentGoods;
 import com.uas.platform.b2c.prod.product.component.modal.ComponentInfo;
 import com.uas.platform.core.exception.SystemException;
@@ -66,6 +68,9 @@ public class SearcherServiceImpl implements SearcherService {
 	@Autowired
 	private GoodsDao goodsDao;
 
+    @Autowired
+    private ComponentDao componentDao;
+
 	@Autowired
 	private SearchHistoryDao searchHistoryDao;
 
@@ -215,6 +220,7 @@ public class SearcherServiceImpl implements SearcherService {
 			for (Map<String, Object> brand : brands){
 				if (keyword.equalsIgnoreCase(brand.get("nameCn").toString()) || keyword.equalsIgnoreCase(brand.get("nameEn").toString())){
 					map.put("brands",brand);
+					brandDao.addSearchCount(brand.get("uuid").toString());
 				}
 			}
 		}
@@ -249,6 +255,10 @@ public class SearcherServiceImpl implements SearcherService {
 				}
 			}
 			map.put("components", components);// 当前页器件内容
+            // 假如第一个结果与器件型号一致,则该型号增加一次 搜索量
+            if (components.get(0).getCode().equals(keyword)) {
+                componentDao.addSearchCount(components.get(0).getUuid());
+            }
 		}
 
         map.put("total", results.get("total"));// 搜索结果总数

+ 11 - 1
src/main/java/com/uas/platform/b2c/prod/product/brand/dao/BrandDao.java

@@ -89,7 +89,7 @@ public interface BrandDao extends JpaSpecificationExecutor<Brand>, JpaRepository
 	public List<Brand> findMostSearchBrands();
 
 	/**
-	 * 器件点击次数加一
+	 * 品牌点击次数加一
 	 * @param uuid
 	 * @return
 	 */
@@ -97,4 +97,14 @@ public interface BrandDao extends JpaSpecificationExecutor<Brand>, JpaRepository
 	@Transactional
 	@Query( nativeQuery = true, value = "update product$brand b set b.br_visit_count = ifnull(b.br_visit_count, 0) + 1 where b.br_uuid = :uuid")
 	public void addVisitCount(@Param("uuid") String uuid);
+
+	/**
+	 * 品牌搜索次数加一
+	 * @param uuid
+	 * @return
+	 */
+	@Modifying
+	@Transactional
+	@Query( nativeQuery = true, value = "update product$brand b set b.br_search_count = ifnull(b.br_search_count, 0) + 1 where b.br_uuid = :uuid")
+	public void addSearchCount(@Param("uuid") String uuid);
 }

+ 10 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/dao/ComponentDao.java

@@ -138,4 +138,14 @@ public interface ComponentDao extends JpaSpecificationExecutor<Component>, JpaRe
 	@Transactional
 	@Query( nativeQuery = true, value = "update product$component set cmp_visit_count = ifnull(cmp_visit_count, 0) + 1 where cmp_uuid = :uuid")
 	public void addVisitCount(@Param("uuid") String uuid);
+
+	/**
+	 * 器件搜索次数加一
+	 * @param uuid
+	 * @return
+	 */
+	@Modifying
+	@Transactional
+	@Query( nativeQuery = true, value = "update product$component set cmp_search_count = ifnull(cmp_search_count, 0) + 1 where cmp_uuid = :uuid")
+	public void addSearchCount(@Param("uuid") String uuid);
 }