Authored by Lixiaodi

销售类目查询

  1 +package com.yohoufo.dal.product;
  2 +
  3 +import java.util.List;
  4 +
  5 +import org.apache.ibatis.annotations.Param;
  6 +
  7 +import com.yohoufo.dal.product.model.SaleCategory;
  8 +
  9 +public interface SaleCategoryMapper {
  10 +
  11 + SaleCategory selectByPrimaryKey(Integer id);
  12 +
  13 + List<SaleCategory> selectValid();
  14 +
  15 + List<SaleCategory> selectByPidList(@Param("pidList") List<Integer> pidList);
  16 +}
  1 +package com.yohoufo.dal.product.model;
  2 +
  3 +public class SaleCategory {
  4 + private Integer id;
  5 +
  6 + private String categoryName;
  7 +
  8 + private Short level;
  9 +
  10 + private Integer parentId;
  11 +
  12 + private Byte status;
  13 +
  14 + private Integer createTime;
  15 +
  16 + private Integer updateTime;
  17 +
  18 + private Integer orderBy;
  19 +
  20 + private String linkType;
  21 +
  22 + private String linkDetail;
  23 +
  24 + private String imageUrl;
  25 +
  26 + public Integer getId() {
  27 + return id;
  28 + }
  29 +
  30 + public void setId(Integer id) {
  31 + this.id = id;
  32 + }
  33 +
  34 + public String getCategoryName() {
  35 + return categoryName;
  36 + }
  37 +
  38 + public void setCategoryName(String categoryName) {
  39 + this.categoryName = categoryName == null ? null : categoryName.trim();
  40 + }
  41 +
  42 + public Short getLevel() {
  43 + return level;
  44 + }
  45 +
  46 + public void setLevel(Short level) {
  47 + this.level = level;
  48 + }
  49 +
  50 + public Integer getParentId() {
  51 + return parentId;
  52 + }
  53 +
  54 + public void setParentId(Integer parentId) {
  55 + this.parentId = parentId;
  56 + }
  57 +
  58 + public Byte getStatus() {
  59 + return status;
  60 + }
  61 +
  62 + public void setStatus(Byte status) {
  63 + this.status = status;
  64 + }
  65 +
  66 + public Integer getCreateTime() {
  67 + return createTime;
  68 + }
  69 +
  70 + public void setCreateTime(Integer createTime) {
  71 + this.createTime = createTime;
  72 + }
  73 +
  74 + public Integer getUpdateTime() {
  75 + return updateTime;
  76 + }
  77 +
  78 + public void setUpdateTime(Integer updateTime) {
  79 + this.updateTime = updateTime;
  80 + }
  81 +
  82 + public Integer getOrderBy() {
  83 + return orderBy;
  84 + }
  85 +
  86 + public void setOrderBy(Integer orderBy) {
  87 + this.orderBy = orderBy;
  88 + }
  89 +
  90 + public String getLinkType() {
  91 + return linkType;
  92 + }
  93 +
  94 + public void setLinkType(String linkType) {
  95 + this.linkType = linkType == null ? null : linkType.trim();
  96 + }
  97 +
  98 + public String getLinkDetail() {
  99 + return linkDetail;
  100 + }
  101 +
  102 + public void setLinkDetail(String linkDetail) {
  103 + this.linkDetail = linkDetail == null ? null : linkDetail.trim();
  104 + }
  105 +
  106 + public String getImageUrl() {
  107 + return imageUrl;
  108 + }
  109 +
  110 + public void setImageUrl(String imageUrl) {
  111 + this.imageUrl = imageUrl;
  112 + }
  113 +}
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3 +<mapper namespace="com.yohoufo.dal.product.SaleCategoryMapper" >
  4 + <resultMap id="BaseResultMap" type="com.yohoufo.dal.product.model.SaleCategory" >
  5 + <id column="id" property="id" jdbcType="INTEGER" />
  6 + <result column="category_name" property="categoryName" jdbcType="VARCHAR" />
  7 + <result column="level" property="level" jdbcType="SMALLINT" />
  8 + <result column="parent_id" property="parentId" jdbcType="INTEGER" />
  9 + <result column="status" property="status" jdbcType="TINYINT" />
  10 + <result column="create_time" property="createTime" jdbcType="INTEGER" />
  11 + <result column="update_time" property="updateTime" jdbcType="INTEGER" />
  12 + <result column="order_by" property="orderBy" jdbcType="INTEGER" />
  13 + <result column="link_type" property="linkType" jdbcType="VARCHAR" />
  14 + <result column="link_detail" property="linkDetail" jdbcType="VARCHAR" />
  15 + <result column="image_url" property="imageUrl" jdbcType="VARCHAR" />
  16 + </resultMap>
  17 + <sql id="Base_Column_List" >
  18 + id, category_name, level, parent_id, status, create_time, update_time, order_by,
  19 + link_type, link_detail,image_url
  20 + </sql>
  21 + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  22 + select
  23 + <include refid="Base_Column_List" />
  24 + from sale_category
  25 + where id = #{id,jdbcType=INTEGER}
  26 + </select>
  27 + <select id="selectValid" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  28 + select
  29 + <include refid="Base_Column_List" />
  30 + from sale_category where status=0
  31 + order by order_by
  32 + </select>
  33 +
  34 + <select id="selectByPidList" resultMap="BaseResultMap">
  35 + select <include refid="Base_Column_List" />
  36 + from sale_category where parent_id in
  37 + <foreach item="item" index="index" collection="pidList" open="(" separator="," close=")">
  38 + #{item}
  39 + </foreach>
  40 + and status=0 order by order_by
  41 + </select>
  42 +
  43 +</mapper>
@@ -28,6 +28,7 @@ import com.yohoufo.product.response.ProductDetailResp; @@ -28,6 +28,7 @@ import com.yohoufo.product.response.ProductDetailResp;
28 import com.yohoufo.product.response.ProductSeriesTemplateResp; 28 import com.yohoufo.product.response.ProductSeriesTemplateResp;
29 import com.yohoufo.product.response.ProductSimpleResp; 29 import com.yohoufo.product.response.ProductSimpleResp;
30 import com.yohoufo.product.response.ProductSortTemplateResp; 30 import com.yohoufo.product.response.ProductSortTemplateResp;
  31 +import com.yohoufo.product.response.SaleCategoryBo;
31 import com.yohoufo.product.response.StorageDataResp; 32 import com.yohoufo.product.response.StorageDataResp;
32 import com.yohoufo.product.response.StorageLeastPriceResp; 33 import com.yohoufo.product.response.StorageLeastPriceResp;
33 import com.yohoufo.product.service.ProductService; 34 import com.yohoufo.product.service.ProductService;
@@ -399,4 +400,29 @@ public class ProductController { @@ -399,4 +400,29 @@ public class ProductController {
399 return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("storage data").build(); 400 return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("storage data").build();
400 } 401 }
401 402
  403 +
  404 + @ApiOperation(name = "ufo.product.saleCategory", desc="商品销售类目")
  405 + @IgnoreSignature
  406 + @IgnoreSession
  407 + @RequestMapping(params = "method=ufo.product.saleCategory")
  408 + @Cachable(expire = 180)
  409 + public ApiResponse querySaleCategory() {
  410 +
  411 + LOG.info("in method=ufo.product.querySaleCategory");
  412 + List<SaleCategoryBo> resp = productService.querySaleCategory();
  413 + return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("saleCategory data").build();
  414 + }
  415 +
  416 + @ApiOperation(name = "ufo.product.saleCategoryDetail", desc="商品销售类目二级三级")
  417 + @RequestMapping(params = "method=ufo.product.saleCategoryDetail")
  418 + @Cachable(expire = 180)
  419 + public ApiResponse querySaleCategoryDetail(@RequestParam(value = "id") Integer id) {
  420 + if (id == null || id < 1) {
  421 + LOG.info("in method=ufo.product.saleCategoryDetail id Is Null");
  422 + return null;
  423 + }
  424 + LOG.info("in method=ufo.product.saleCategoryDetail id = {}", id);
  425 + List<SaleCategoryBo> resp = productService.querySaleCategoryDetail(id);
  426 + return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("saleCategoryDetail data").build();
  427 + }
402 } 428 }
@@ -7,6 +7,7 @@ import com.yohoufo.common.caller.UfoServiceCaller; @@ -7,6 +7,7 @@ import com.yohoufo.common.caller.UfoServiceCaller;
7 import com.yohoufo.product.helper.SearchHelpService; 7 import com.yohoufo.product.helper.SearchHelpService;
8 import com.yohoufo.product.request.ProductSearchReq; 8 import com.yohoufo.product.request.ProductSearchReq;
9 import com.yohoufo.product.request.SortIdLevel; 9 import com.yohoufo.product.request.SortIdLevel;
  10 +import com.yohoufo.product.response.ProductBrandSeriesResp;
10 import com.yohoufo.product.response.SearchBrandListResp; 11 import com.yohoufo.product.response.SearchBrandListResp;
11 import com.yohoufo.product.response.SearchProductListFilterResp; 12 import com.yohoufo.product.response.SearchProductListFilterResp;
12 import com.yohoufo.product.response.SearchProductRecommendResp; 13 import com.yohoufo.product.response.SearchProductRecommendResp;
@@ -22,6 +23,7 @@ import com.yohoufo.common.annotation.IgnoreSession; @@ -22,6 +23,7 @@ import com.yohoufo.common.annotation.IgnoreSession;
22 import com.yohoufo.common.cache.Cachable; 23 import com.yohoufo.common.cache.Cachable;
23 import org.springframework.web.bind.annotation.RestController; 24 import org.springframework.web.bind.annotation.RestController;
24 25
  26 +import java.util.List;
25 import java.util.Map; 27 import java.util.Map;
26 28
27 @RestController 29 @RestController
@@ -133,4 +135,16 @@ public class ProductSearchController { @@ -133,4 +135,16 @@ public class ProductSearchController {
133 135
134 return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.brandList").data(resp).build(); 136 return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.brandList").data(resp).build();
135 } 137 }
  138 +
  139 + @IgnoreSignature
  140 + @ApiOperation(name = "ufo.product.search.seriesList", desc="品牌系列列表")
  141 + @RequestMapping(params = "method=ufo.product.search.seriesList")
  142 + @IgnoreSession
  143 + @Cachable(expire = 180)
  144 + public ApiResponse searchSeriesList() {
  145 +
  146 + List<ProductBrandSeriesResp> resp = productSearchService.searchSeriesList();
  147 +
  148 + return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.seriesList").data(resp).build();
  149 + }
136 } 150 }
  1 +package com.yohoufo.product.response;
  2 +
  3 +import com.yohoufo.product.model.ProductSeriesTemplate;
  4 +import com.yohoufo.product.response.SearchBrandListResp.BrandIntro;
  5 +
  6 +import lombok.Data;
  7 +
  8 +import java.util.List;
  9 +
  10 +@Data
  11 +public class ProductBrandSeriesResp {
  12 +
  13 + private BrandIntro brand;
  14 + private List<ProductSeriesTemplate> series;
  15 +
  16 +}
  1 +package com.yohoufo.product.response;
  2 +
  3 +import java.util.List;
  4 +
  5 +import lombok.Data;
  6 +
  7 +@Data
  8 +public class SaleCategoryBo {
  9 +
  10 + private Integer id;
  11 + private String name;
  12 + private String image;
  13 + private String linkType;
  14 + private String link;
  15 + private Integer pid;
  16 +
  17 + private List<SaleCategoryBo> sub;
  18 +}
1 package com.yohoufo.product.service; 1 package com.yohoufo.product.service;
2 2
3 3
  4 +import java.util.List;
  5 +
4 import com.alibaba.fastjson.JSONObject; 6 import com.alibaba.fastjson.JSONObject;
5 import com.yohoufo.product.request.ProductSearchReq; 7 import com.yohoufo.product.request.ProductSearchReq;
6 import com.yohoufo.product.request.SortIdLevel; 8 import com.yohoufo.product.request.SortIdLevel;
  9 +import com.yohoufo.product.response.ProductBrandSeriesResp;
7 import com.yohoufo.product.response.SearchBrandListResp; 10 import com.yohoufo.product.response.SearchBrandListResp;
8 import com.yohoufo.product.response.SearchProductListFilterResp; 11 import com.yohoufo.product.response.SearchProductListFilterResp;
9 import com.yohoufo.product.response.SearchProductRecommendResp; 12 import com.yohoufo.product.response.SearchProductRecommendResp;
@@ -20,4 +23,6 @@ public interface ProductSearchService { @@ -20,4 +23,6 @@ public interface ProductSearchService {
20 23
21 SearchProductRecommendResp searchProductRecommendById(Integer productId); 24 SearchProductRecommendResp searchProductRecommendById(Integer productId);
22 25
  26 + List<ProductBrandSeriesResp> searchSeriesList();
  27 +
23 } 28 }
@@ -8,6 +8,7 @@ import com.yohoufo.product.response.ProductDetailResp; @@ -8,6 +8,7 @@ import com.yohoufo.product.response.ProductDetailResp;
8 import com.yohoufo.product.response.ProductSeriesTemplateResp; 8 import com.yohoufo.product.response.ProductSeriesTemplateResp;
9 import com.yohoufo.product.response.ProductSimpleResp; 9 import com.yohoufo.product.response.ProductSimpleResp;
10 import com.yohoufo.product.response.ProductSortTemplateResp; 10 import com.yohoufo.product.response.ProductSortTemplateResp;
  11 +import com.yohoufo.product.response.SaleCategoryBo;
11 import com.yohoufo.product.response.StorageDataResp; 12 import com.yohoufo.product.response.StorageDataResp;
12 import com.yohoufo.product.response.StorageLeastPriceResp; 13 import com.yohoufo.product.response.StorageLeastPriceResp;
13 14
@@ -65,4 +66,8 @@ public interface ProductService { @@ -65,4 +66,8 @@ public interface ProductService {
65 * @return 66 * @return
66 */ 67 */
67 StorageLeastPriceResp querStorageLeastPriceEx(Integer storageId); 68 StorageLeastPriceResp querStorageLeastPriceEx(Integer storageId);
  69 +
  70 + List<SaleCategoryBo> querySaleCategory();
  71 +
  72 + List<SaleCategoryBo> querySaleCategoryDetail(Integer id);
68 } 73 }
@@ -17,11 +17,15 @@ import com.yohoufo.dal.product.model.Product; @@ -17,11 +17,15 @@ import com.yohoufo.dal.product.model.Product;
17 import com.yohoufo.dal.product.model.ProductSort; 17 import com.yohoufo.dal.product.model.ProductSort;
18 import com.yohoufo.product.helper.SearchParam; 18 import com.yohoufo.product.helper.SearchParam;
19 import com.yohoufo.product.model.FilterItem; 19 import com.yohoufo.product.model.FilterItem;
  20 +import com.yohoufo.product.model.ProductSeriesTemplate;
20 import com.yohoufo.product.request.ProductSearchReq; 21 import com.yohoufo.product.request.ProductSearchReq;
21 import com.yohoufo.product.request.SortIdLevel; 22 import com.yohoufo.product.request.SortIdLevel;
  23 +import com.yohoufo.product.response.ProductBrandSeriesResp;
22 import com.yohoufo.product.response.SearchBrandListResp; 24 import com.yohoufo.product.response.SearchBrandListResp;
23 import com.yohoufo.product.response.SearchProductListFilterResp; 25 import com.yohoufo.product.response.SearchProductListFilterResp;
24 import com.yohoufo.product.response.SearchProductRecommendResp; 26 import com.yohoufo.product.response.SearchProductRecommendResp;
  27 +import com.yohoufo.product.response.SearchBrandListResp.BrandIntro;
  28 +
25 import org.apache.commons.collections.MapUtils; 29 import org.apache.commons.collections.MapUtils;
26 import org.apache.commons.lang3.StringUtils; 30 import org.apache.commons.lang3.StringUtils;
27 import org.slf4j.Logger; 31 import org.slf4j.Logger;
@@ -61,6 +65,8 @@ public class ProductSearchServiceImpl implements ProductSearchService { @@ -61,6 +65,8 @@ public class ProductSearchServiceImpl implements ProductSearchService {
61 65
62 66
63 public static final String BRAND_LIST_URL = "/yohosearch/ufo/brandList.json"; 67 public static final String BRAND_LIST_URL = "/yohosearch/ufo/brandList.json";
  68 +
  69 + public static final String SERIES_LIST_URL = "/yohosearch/ufo/seriesList.json";
64 70
65 71
66 public static final String PRODUCT_RECOMMEND_LIST_URL = "/yohosearch/ufo/recommendList.json"; 72 public static final String PRODUCT_RECOMMEND_LIST_URL = "/yohosearch/ufo/recommendList.json";
@@ -295,4 +301,35 @@ public class ProductSearchServiceImpl implements ProductSearchService { @@ -295,4 +301,35 @@ public class ProductSearchServiceImpl implements ProductSearchService {
295 return sortIdLevel; 301 return sortIdLevel;
296 302
297 } 303 }
  304 +
  305 + @Override
  306 + public List<ProductBrandSeriesResp> searchSeriesList() {
  307 + List<ProductBrandSeriesResp> respList = new ArrayList<>();
  308 + SearchParam searchParam = new SearchParam();
  309 + JSONObject data = search(searchParam.getParam(), SERIES_LIST_URL);
  310 + JSONArray series;
  311 + if (data != null && !CollectionUtils.isEmpty(series = data.getJSONArray("series_list"))) {
  312 + for (int i = 0; i < series.size(); i++) {
  313 + JSONObject jo = series.getJSONObject(i);
  314 + ProductBrandSeriesResp resp = new ProductBrandSeriesResp();
  315 + BrandIntro brand = new BrandIntro();
  316 + brand.setId(jo.getInteger("brand_id"));
  317 + brand.setBrandLogo(jo.getString("brand_logo"));
  318 + resp.setBrand(brand);
  319 + List<ProductSeriesTemplate> seriesList = new ArrayList<>();
  320 + JSONArray brandSeries = jo.getJSONArray("brand_series");
  321 + for (int j = 0; j < brandSeries.size(); j++) {
  322 + JSONObject jo2 = brandSeries.getJSONObject(j);
  323 + ProductSeriesTemplate t = new ProductSeriesTemplate();
  324 + t.setSeriesId(jo2.getString("series_id"));
  325 + t.setSeriesName(jo2.getString("series_name"));
  326 + t.setImageUrl(jo2.getString("series_image"));
  327 + seriesList.add(t);
  328 + }
  329 + resp.setSeries(seriesList);
  330 + respList.add(resp);
  331 + }
  332 + }
  333 + return respList;
  334 + }
298 } 335 }
@@ -2,6 +2,7 @@ package com.yohoufo.product.service.impl; @@ -2,6 +2,7 @@ package com.yohoufo.product.service.impl;
2 2
3 import java.math.BigDecimal; 3 import java.math.BigDecimal;
4 import java.util.ArrayList; 4 import java.util.ArrayList;
  5 +import java.util.Arrays;
5 import java.util.Comparator; 6 import java.util.Comparator;
6 import java.util.HashMap; 7 import java.util.HashMap;
7 import java.util.List; 8 import java.util.List;
@@ -29,6 +30,7 @@ import com.yohoufo.dal.product.BrandSeriesMapper; @@ -29,6 +30,7 @@ import com.yohoufo.dal.product.BrandSeriesMapper;
29 import com.yohoufo.dal.product.GoodsImagesMapper; 30 import com.yohoufo.dal.product.GoodsImagesMapper;
30 import com.yohoufo.dal.product.GoodsMapper; 31 import com.yohoufo.dal.product.GoodsMapper;
31 import com.yohoufo.dal.product.ProductMapper; 32 import com.yohoufo.dal.product.ProductMapper;
  33 +import com.yohoufo.dal.product.SaleCategoryMapper;
32 import com.yohoufo.dal.product.SizeMapper; 34 import com.yohoufo.dal.product.SizeMapper;
33 import com.yohoufo.dal.product.StorageMapper; 35 import com.yohoufo.dal.product.StorageMapper;
34 import com.yohoufo.dal.product.StoragePriceMapper; 36 import com.yohoufo.dal.product.StoragePriceMapper;
@@ -37,6 +39,7 @@ import com.yohoufo.dal.product.model.BrandSeries; @@ -37,6 +39,7 @@ import com.yohoufo.dal.product.model.BrandSeries;
37 import com.yohoufo.dal.product.model.Goods; 39 import com.yohoufo.dal.product.model.Goods;
38 import com.yohoufo.dal.product.model.GoodsImages; 40 import com.yohoufo.dal.product.model.GoodsImages;
39 import com.yohoufo.dal.product.model.Product; 41 import com.yohoufo.dal.product.model.Product;
  42 +import com.yohoufo.dal.product.model.SaleCategory;
40 import com.yohoufo.dal.product.model.Size; 43 import com.yohoufo.dal.product.model.Size;
41 import com.yohoufo.dal.product.model.Storage; 44 import com.yohoufo.dal.product.model.Storage;
42 import com.yohoufo.dal.product.model.StoragePrice; 45 import com.yohoufo.dal.product.model.StoragePrice;
@@ -51,6 +54,7 @@ import com.yohoufo.product.response.ProductDetailResp; @@ -51,6 +54,7 @@ import com.yohoufo.product.response.ProductDetailResp;
51 import com.yohoufo.product.response.ProductSeriesTemplateResp; 54 import com.yohoufo.product.response.ProductSeriesTemplateResp;
52 import com.yohoufo.product.response.ProductSimpleResp; 55 import com.yohoufo.product.response.ProductSimpleResp;
53 import com.yohoufo.product.response.ProductSortTemplateResp; 56 import com.yohoufo.product.response.ProductSortTemplateResp;
  57 +import com.yohoufo.product.response.SaleCategoryBo;
54 import com.yohoufo.product.response.StorageDataResp; 58 import com.yohoufo.product.response.StorageDataResp;
55 import com.yohoufo.product.response.StorageLeastPriceResp; 59 import com.yohoufo.product.response.StorageLeastPriceResp;
56 import com.yohoufo.product.service.ProductService; 60 import com.yohoufo.product.service.ProductService;
@@ -84,7 +88,10 @@ public class ProductServiceImpl implements ProductService{ @@ -84,7 +88,10 @@ public class ProductServiceImpl implements ProductService{
84 88
85 @Autowired 89 @Autowired
86 private SizeMapper sizeMapper; 90 private SizeMapper sizeMapper;
87 - 91 +
  92 + @Autowired
  93 + private SaleCategoryMapper saleCategoryMapper;
  94 +
88 @Override 95 @Override
89 public ProductDetailResp queryProductDetailById(Integer productId) { 96 public ProductDetailResp queryProductDetailById(Integer productId) {
90 ProductDetailResp productDetailResp = new ProductDetailResp(); 97 ProductDetailResp productDetailResp = new ProductDetailResp();
@@ -641,6 +648,14 @@ public class ProductServiceImpl implements ProductService{ @@ -641,6 +648,14 @@ public class ProductServiceImpl implements ProductService{
641 return url; 648 return url;
642 } 649 }
643 } 650 }
  651 +
  652 + private String buildSaleCategoryFullUrl(String url) {
  653 + if (!StringUtils.startsWith(url, "http")){
  654 + return ImagesHelper.template2(url, "salecategoryimg").replaceAll("extent\\/\\{width}x\\{height}\\/","");
  655 + }else{
  656 + return url;
  657 + }
  658 + }
644 659
645 @Override 660 @Override
646 public ProductSimpleResp queryPriceLimit(Integer productId) { 661 public ProductSimpleResp queryPriceLimit(Integer productId) {
@@ -683,4 +698,48 @@ public class ProductServiceImpl implements ProductService{ @@ -683,4 +698,48 @@ public class ProductServiceImpl implements ProductService{
683 public int sellerBatchUpdatePrice(List<Integer> skupList, Double price) { 698 public int sellerBatchUpdatePrice(List<Integer> skupList, Double price) {
684 return storagePriceMapper.updateBatchPrice(skupList, price); 699 return storagePriceMapper.updateBatchPrice(skupList, price);
685 } 700 }
  701 +
  702 + @Override
  703 + public List<SaleCategoryBo> querySaleCategory() {
  704 + // 查数据库List
  705 + List<SaleCategory> dbData = saleCategoryMapper.selectValid();
  706 + List<SaleCategoryBo> result = new ArrayList<>();
  707 + dbData.forEach(data -> {
  708 + result.add(exchange(data));
  709 + });
  710 + return result;
  711 + }
  712 +
  713 + @Override
  714 + public List<SaleCategoryBo> querySaleCategoryDetail(Integer id) {
  715 + List<SaleCategoryBo> result = new ArrayList<>();
  716 + List<SaleCategory> secondCat = saleCategoryMapper.selectByPidList(Arrays.asList(id));
  717 +
  718 + if (!CollectionUtils.isEmpty(secondCat)) {
  719 + secondCat.forEach(data -> {
  720 + result.add(exchange(data));
  721 + });
  722 + Map<Integer, SaleCategoryBo> map = result.stream().collect(Collectors.toMap(SaleCategoryBo::getId, Function.identity()));
  723 + List<Integer> secondCatIds = secondCat.stream().map(SaleCategory::getId).collect(Collectors.toList());
  724 + List<SaleCategory> thirdCat = saleCategoryMapper.selectByPidList(secondCatIds);
  725 + thirdCat.forEach(t -> {
  726 + SaleCategoryBo bo = map.get(t.getParentId());
  727 + if (bo != null) {
  728 + bo.getSub().add(exchange(t));
  729 + }
  730 + });
  731 + }
  732 + return result;
  733 + }
  734 +
  735 + private SaleCategoryBo exchange(SaleCategory data) {
  736 + SaleCategoryBo sc = new SaleCategoryBo();
  737 + sc.setId(data.getId());
  738 + sc.setName(data.getCategoryName());
  739 + sc.setLinkType(data.getLinkType());
  740 + sc.setLink(data.getLinkDetail());
  741 + sc.setImage(buildSaleCategoryFullUrl(data.getImageUrl()));
  742 + sc.setSub(new ArrayList<>());
  743 + return null;
  744 + }
686 } 745 }