Просмотр исходного кода

根据List<id>获取品牌信息

zengchao 8 лет назад
Родитель
Сommit
a8b1935c47

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

@@ -12,10 +12,7 @@ import com.uas.platform.core.model.PageParams;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
@@ -177,4 +174,14 @@ public class BrandController {
     public List<Brand> getHotBrands(@PathVariable("num") Integer num) {
 		return brandService.getHotBrands(num);
     }
+
+	/**
+	 * 根据批次号获取品牌信息
+	 * @param batchIds
+	 * @return 品牌信息
+	 */
+	@RequestMapping(value = "/batchId", method = RequestMethod.POST, produces = "application/json")
+	public List<BrandMostSimpleInfo> getBatchBrands(@RequestBody List<Long> batchIds) {
+		return brandService.getBatchBrandMostSimpleInfs(batchIds);
+	}
 }

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

@@ -24,4 +24,12 @@ 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 batchIds id批次号
+     * @return
+     */
+    @Query(nativeQuery = true, value = "select * from product$brand where br_id in :batchIds")
+    public List<BrandMostSimpleInfo> findBatchBrands(@Param("batchIds") List<Long> batchIds);
 }

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

@@ -141,4 +141,11 @@ public interface BrandService {
 	 * @return 新增品牌数量统计
 	 */
 	List<Map<String, Object>> findCountIncreaseBrandByMonth();
+
+	/**
+	 * 根据批次号获取品牌信息
+	 * @param batchIds
+	 * @return 品牌信息
+	 */
+	public List<BrandMostSimpleInfo> getBatchBrandMostSimpleInfs(List<Long> batchIds);
 }

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

@@ -323,4 +323,12 @@ public class BrandServiceImpl implements BrandService {
 
 		return "success";
 	}
+
+	@Override
+	public List<BrandMostSimpleInfo> getBatchBrandMostSimpleInfs(List<Long> batchIds) {
+		if (batchIds.size() == 0) {
+			return brandMostSimpleInfoDao.findAll();
+		}
+		return brandMostSimpleInfoDao.findBatchBrands(batchIds);
+	}
 }