Explorar el Código

新增 品牌中心分页展示接口

wangdy hace 8 años
padre
commit
9ec81b54f1

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

@@ -65,6 +65,17 @@ public class BrandController {
 		return brandService.getInitialSimpleInfo(keyword);
 	}
 
+	/**
+	 * 分页获取按字符串获取以此字符为首字母的品牌信息
+	 * @return map(首字母,超简易品牌信息)
+	 */
+	@RequestMapping(value = "/initial/first/{keyword}", method = RequestMethod.GET)
+	public Page<BrandMostSimpleInfo> getInitialSimpleInfoByFirst(@PathVariable String keyword ,PageParams page) {
+		if (StringUtils.isEmpty(keyword))
+			keyword = "A";
+		return brandService.getInitialSimpleInfoByFirst(keyword,page);
+	}
+
 	/**
 	 * 查找所有简单有效品牌信息
 	 * @param keyword 关键词

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

@@ -1,6 +1,8 @@
 package com.uas.platform.b2c.prod.product.brand.dao;
 
 import com.uas.platform.b2c.prod.product.brand.modal.BrandMostSimpleInfo;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Query;
@@ -25,6 +27,14 @@ public interface BrandMostSimpleInfoDao extends JpaSpecificationExecutor<BrandMo
     @Query(nativeQuery = true, value = "select * from product$brand where br_inital in :initals")
     public List<BrandMostSimpleInfo> findInInitals(@Param("initals") String[] initals);
 
+    /**
+     * 分页根据首字母获取品牌信息
+     * @param initals
+     * @return
+     */
+    @Query(value = "select b from BrandMostSimpleInfo b  where b.inital in :initals")
+    public Page<BrandMostSimpleInfo> findInInitalsPage(@Param("initals") String[] initals , Pageable pageable);
+
     /**
      * 根据批次号获取品牌信息
      * @param batchIds id批次号

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

@@ -5,6 +5,7 @@ import com.uas.platform.b2c.prod.product.brand.modal.BrandInfo;
 import com.uas.platform.b2c.prod.product.brand.modal.BrandMostSimpleInfo;
 import com.uas.platform.b2c.prod.product.brand.modal.BrandVersion;
 import com.uas.platform.core.model.PageInfo;
+import com.uas.platform.core.model.PageParams;
 import org.springframework.data.domain.Page;
 
 import java.util.List;
@@ -54,6 +55,13 @@ public interface BrandService {
 	 */
 	public Map<String, List<BrandMostSimpleInfo>> getInitialSimpleInfo(String keyword);
 
+	/**
+	 * 获取按字符串获取以此字符串为首字母的品牌信息
+	 * @param keyword 关键词
+	 * @return 品牌简易信息
+	 */
+	public Page<BrandMostSimpleInfo> getInitialSimpleInfoByFirst(String keyword , PageParams params);
+
 	/**
 	 * 获取BrandInfo分页数据
 	 * @param keyword 关键词

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

@@ -12,6 +12,7 @@ import com.uas.platform.b2c.prod.product.brand.service.BrandService;
 import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
 import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.PageInfo;
+import com.uas.platform.core.model.PageParams;
 import com.uas.platform.core.persistence.criteria.CriterionExpression;
 import com.uas.platform.core.persistence.criteria.CriterionExpression.Operator;
 import com.uas.platform.core.persistence.criteria.LogicalExpression;
@@ -20,6 +21,7 @@ import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
@@ -117,6 +119,12 @@ public class BrandServiceImpl implements BrandService {
 		return map;
 	}
 
+	@Override
+	public Page<BrandMostSimpleInfo> getInitialSimpleInfoByFirst(String keyword , PageParams params) {
+		Pageable pageable = new PageInfo(params);
+		return brandMostSimpleInfoDao.findInInitalsPage(new String[]{keyword},pageable);
+	}
+
 	// 判断一个字符串是否含有中文
 	public static boolean isChinese(String str) {
 		if (str == null) return false;