Browse Source

搜索关键词获取逻辑 更新

wangdy 8 years ago
parent
commit
1903afff6d

+ 11 - 0
src/main/java/com/uas/platform/b2c/prod/product/brand/api/BrandController.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2c.prod.product.brand.api;
 
+import com.uas.platform.b2c.core.support.log.ControllerUsageLog;
 import com.uas.platform.b2c.prod.product.brand.modal.Brand;
 import com.uas.platform.b2c.prod.product.brand.modal.BrandInfo;
 import com.uas.platform.b2c.prod.product.brand.modal.BrandMostSimpleInfo;
@@ -230,4 +231,14 @@ public class BrandController {
 	public List<BrandMostSimpleInfo> getBatchBrands(@RequestBody List<Long> batchIds) {
 		return brandService.getBatchBrandMostSimpleInfs(batchIds);
 	}
+
+	/**
+	 * 获取搜索量最高的2个品牌
+	 * @return 品牌信息
+	 */
+	@RequestMapping(value = "/mostSearchBrands", method = RequestMethod.GET)
+	@ControllerUsageLog(module = "品牌查询接口", detail = "获取搜索量最高的2个品牌")
+	public List<Brand> getMostSearchBrands() {
+		return brandService.getMostSearchBrands();
+	}
 }

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

@@ -81,6 +81,13 @@ public interface BrandDao extends JpaSpecificationExecutor<Brand>, JpaRepository
 	@Query(value = "select b from Brand b  where b.inital in :initals and (b.nameEn like %:keyword% or b.nameCn like %:keyword%)")
 	public Page<Brand> findInInitalsPage(@Param("initals") String[] initals ,@Param("keyword") String keyword, Pageable pageable);
 
+	/**
+	 * 获取搜索量最高的2个品牌
+	 * @return
+	 */
+	@Query(nativeQuery = true , value = "select b from product$brand b order by br_search_count desc LIMIT 2)")
+	public List<Brand> findMostSearchBrands();
+
 	/**
 	 * 器件点击次数加一
 	 * @param uuid

+ 6 - 0
src/main/java/com/uas/platform/b2c/prod/product/brand/service/BrandService.java

@@ -179,6 +179,12 @@ public interface BrandService {
 	 */
 	public List<BrandMostSimpleInfo> getBatchBrandMostSimpleInfs(List<Long> batchIds);
 
+	/**
+	 * 获取搜索量最高的2个品牌
+	 * @return 品牌信息
+	 */
+	public List<Brand> getMostSearchBrands();
+
 	/**
 	 * 器件点击次数加一
 	 * @param uuid

+ 5 - 0
src/main/java/com/uas/platform/b2c/prod/product/brand/service/impl/BrandServiceImpl.java

@@ -385,6 +385,11 @@ public class BrandServiceImpl implements BrandService {
 		return brandMostSimpleInfoDao.findBatchBrands(batchIds);
 	}
 
+	@Override
+	public List<Brand> getMostSearchBrands() {
+		return brandDao.findMostSearchBrands();
+	}
+
 	@Override
 	public void addVisitCount(String uuid) {
 		brandDao.addVisitCount(uuid);

+ 12 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/api/ComponentController.java

@@ -1,6 +1,7 @@
 package com.uas.platform.b2c.prod.product.component.api;
 
 import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.core.support.log.ControllerUsageLog;
 import com.uas.platform.b2c.prod.commodity.model.Goods;
 import com.uas.platform.b2c.prod.commodity.service.GoodsService;
 import com.uas.platform.b2c.prod.product.component.modal.Component;
@@ -277,4 +278,15 @@ public class ComponentController {
 	public List<ComponentInfo> getBatchBrands(@RequestBody List<Long> batchIds) {
 		return componentService.getBatchComponents(batchIds);
 	}
+
+
+	/**
+	 * 获取搜索量最高的2个器件
+	 * @return 品牌信息
+	 */
+	@RequestMapping(value = "/mostSearchComponent", method = RequestMethod.GET)
+	@ControllerUsageLog(module = "品牌查询接口", detail = "获取搜索量最高的2个器件")
+	public List<Component> getMostSearchBrands() {
+		return componentService.getMostSearchComponent();
+	}
 }

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

@@ -121,6 +121,14 @@ public interface ComponentDao extends JpaSpecificationExecutor<Component>, JpaRe
 	@Query("select count(1) from Component")
 	public Integer findAllCount();
 
+	/**
+	 * 获取搜索量最高的2个器件
+	 * @return
+	 */
+	@Query(nativeQuery = true , value = "select c from product$component c order by cmp_search_count desc LIMIT 2)")
+	public List<Component> findMostSearchComponent();
+
+
 	/**
 	 * 器件点击次数加一
 	 * @param uuid

+ 7 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/service/ComponentService.java

@@ -217,4 +217,11 @@ public interface ComponentService {
 	 * @return
 	 */
 	public void addVisitCount(String uuid);
+
+	/**
+	 * 获取搜索量最高的2个器件
+	 * @return 品牌信息
+	 */
+	public List<Component> getMostSearchComponent();
+
 }

+ 5 - 0
src/main/java/com/uas/platform/b2c/prod/product/component/service/impl/ComponentServiceImpl.java

@@ -548,4 +548,9 @@ public class ComponentServiceImpl implements ComponentService {
 	public void addVisitCount(String uuid) {
 		componentDao.addVisitCount(uuid);
 	}
+
+	@Override
+	public List<Component> getMostSearchComponent() {
+		return componentDao.findMostSearchComponent();
+	}
 }