chao 4 سال پیش
والد
کامیت
876fe864b6

+ 15 - 8
src/main/java/com/caimei365/commodity/controller/ProductApi.java → src/main/java/com/caimei365/commodity/controller/ProductPageApi.java

@@ -2,7 +2,8 @@ package com.caimei365.commodity.controller;
 
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.vo.BigTypeVo;
-import com.caimei365.commodity.service.ProductService;
+import com.caimei365.commodity.model.vo.BrandVo;
+import com.caimei365.commodity.service.PageService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -21,13 +22,13 @@ import java.util.Map;
  * @author : Charles
  * @date : 2021/4/12
  */
-@Api(tags="商品API")
+@Api(tags="商品页面数据API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/commodity")
-public class ProductApi {
+public class ProductPageApi {
 
-    private final ProductService productService;
+    private final PageService pageService;
     /**
      * 获取分类列表
      *
@@ -41,7 +42,7 @@ public class ProductApi {
     })
     @GetMapping("/classify")
     public ResponseJson<List<BigTypeVo>> getClassify(String typeSort, String source) {
-        return productService.getClassify(typeSort, source);
+        return pageService.getClassify(typeSort, source);
     }
 
     /**
@@ -62,7 +63,7 @@ public class ProductApi {
         if (pageId == null) {
             return ResponseJson.error("参数异常", null);
         }
-        return productService.getClassifyData(pageId, userId, source);
+        return pageService.getClassifyData(pageId, userId, source);
     }
 
     /**
@@ -78,8 +79,14 @@ public class ProductApi {
     })
     @GetMapping("/home/floor")
     public ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source) {
-        return productService.getHomeData(userId, source);
+        return pageService.getHomeData(userId, source);
     }
 
-
+    /**
+     * 商品品牌列表
+     */
+    @GetMapping("brandList")
+    public ResponseJson<List<BrandVo>> getBrandList() {
+        return pageService.getBrandList();
+    }
 }

+ 1 - 1
src/main/java/com/caimei365/commodity/controller/PriceApi.java → src/main/java/com/caimei365/commodity/controller/ProductPriceApi.java

@@ -26,7 +26,7 @@ import java.util.List;
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/commodity/price")
-public class PriceApi {
+public class ProductPriceApi {
 
     private final PriceService priceService;
     /**

+ 0 - 1
src/main/java/com/caimei365/commodity/controller/SecondHandApi.java

@@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.List;
 
 /**
  * Description

+ 5 - 1
src/main/java/com/caimei365/commodity/mapper/ProductMapper.java → src/main/java/com/caimei365/commodity/mapper/PageMapper.java

@@ -12,7 +12,7 @@ import java.util.List;
  * @date : 2021/4/12
  */
 @Mapper
-public interface ProductMapper {
+public interface PageMapper {
     /**
      * 获取大分类
      * @param typeSort 分类类型:1产品,2仪器
@@ -76,4 +76,8 @@ public interface ProductMapper {
      * @param source
      */
     List<ShopImageVo> getSupplierImage(Integer source);
+    /**
+     * 商品品牌列表
+     */
+    List<BrandVo> getBrandList();
 }

+ 66 - 0
src/main/java/com/caimei365/commodity/model/vo/BrandVo.java

@@ -0,0 +1,66 @@
+package com.caimei365.commodity.model.vo;
+
+
+import lombok.Data;
+import java.io.Serializable;
+
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/4/16
+ */
+@Data
+public class BrandVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Integer id;
+    /**
+     * 品牌名字
+     */
+    private String name;
+//    /**
+//     * 添加来源 0:后台添加 ,1:供应商添加
+//     */
+//    private String source;
+//    /**
+//     * 添加用户ID,后台则为后台用户ID,供应商则为供应商用户ID
+//     */
+//    private Integer userId;
+//    /**
+//     * 品牌状态 0:待审核,1:审核通过,2:审核失败
+//     */
+//    private String status;
+//    /**
+//     * 审核备注
+//     */
+//    private String auditNote;
+//    /**
+//     * 排序
+//     */
+//    private Integer sort;
+//    /**
+//     * 删除标记 0 否,其余是
+//     */
+//    private String delFlag;
+//    /**
+//     * 创建时间
+//     */
+//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+//    private Date createDate;
+//    /**
+//     * 最后更新时间
+//     */
+//    private Date updateDate;
+//    /**
+//     * 品牌logo
+//     */
+//    private String logo;
+//    /**
+//     * 品牌描述
+//     */
+//    private String description;
+
+}
+

+ 7 - 1
src/main/java/com/caimei365/commodity/service/ProductService.java → src/main/java/com/caimei365/commodity/service/PageService.java

@@ -2,6 +2,7 @@ package com.caimei365.commodity.service;
 
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.vo.BigTypeVo;
+import com.caimei365.commodity.model.vo.BrandVo;
 
 import java.util.List;
 import java.util.Map;
@@ -12,7 +13,7 @@ import java.util.Map;
  * @author : Charles
  * @date : 2021/4/12
  */
-public interface ProductService {
+public interface PageService {
     /**
      * 获取分类列表
      *
@@ -37,4 +38,9 @@ public interface ProductService {
      * @param source 来源:1网站,2小程序
      */
     ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source);
+
+    /**
+     * 商品品牌列表
+     */
+    ResponseJson<List<BrandVo>> getBrandList();
 }

+ 31 - 18
src/main/java/com/caimei365/commodity/service/impl/ProductServiceImpl.java → src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -1,9 +1,9 @@
 package com.caimei365.commodity.service.impl;
 
-import com.caimei365.commodity.mapper.ProductMapper;
+import com.caimei365.commodity.mapper.PageMapper;
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.vo.*;
-import com.caimei365.commodity.service.ProductService;
+import com.caimei365.commodity.service.PageService;
 import com.caimei365.commodity.utils.AppletsLinkUtil;
 import com.caimei365.commodity.utils.ImageUtils;
 import com.caimei365.commodity.components.PriceUtilService;
@@ -28,11 +28,11 @@ import java.util.Map;
  */
 @Slf4j
 @Service
-public class ProductServiceImpl implements ProductService {
+public class PageServiceImpl implements PageService {
     @Value("${caimei.wwwDomain}")
     private String domain;
     @Resource
-    private ProductMapper productMapper;
+    private PageMapper pageMapper;
     @Resource
     private PriceUtilService priceUtilService;
 
@@ -45,17 +45,17 @@ public class ProductServiceImpl implements ProductService {
     @Override
     @Cacheable(value = "getClassify", key = "#typeSort +'-'+ #source", unless = "#result == null")
     public ResponseJson<List<BigTypeVo>> getClassify(String typeSort, String source) {
-        List<BigTypeVo> bigTypeList = productMapper.getBigTypeList(typeSort,source);
+        List<BigTypeVo> bigTypeList = pageMapper.getBigTypeList(typeSort,source);
         bigTypeList.forEach(bigType -> {
             String caiMeiImage = ImageUtils.getImageURL("caiMeiImage", null, 0, domain);
             bigType.setWwwIcon(StringUtils.isEmpty(bigType.getWwwIcon())?caiMeiImage:bigType.getWwwIcon());
             bigType.setCrmIcon(StringUtils.isEmpty(bigType.getCrmIcon())?caiMeiImage:bigType.getCrmIcon());
-            List<SmallTypeVo> smallTypeList = productMapper.getSmallTypeList(bigType.getBigTypeId(), source);
+            List<SmallTypeVo> smallTypeList = pageMapper.getSmallTypeList(bigType.getBigTypeId(), source);
             if (!CollectionUtils.isEmpty(smallTypeList)) {
                 smallTypeList.forEach(smallType -> {
                     smallType.setWwwIcon(StringUtils.isEmpty(smallType.getWwwIcon())?caiMeiImage:smallType.getWwwIcon());
                     smallType.setCrmIcon(StringUtils.isEmpty(smallType.getCrmIcon())?caiMeiImage:smallType.getCrmIcon());
-                    List<TinyTypeVo> tinyTypeList = productMapper.getTinyTypeList(smallType.getSmallTypeId(), source);
+                    List<TinyTypeVo> tinyTypeList = pageMapper.getTinyTypeList(smallType.getSmallTypeId(), source);
                     if (!CollectionUtils.isEmpty(tinyTypeList)) {
                         tinyTypeList.forEach(tinyType -> {
                             tinyType.setWwwIcon(StringUtils.isEmpty(tinyType.getWwwIcon())?caiMeiImage:tinyType.getWwwIcon());
@@ -82,14 +82,14 @@ public class ProductServiceImpl implements ProductService {
     public ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source) {
         source = source == null ? 1 : source;
         Map<String, Object> map = new HashMap<>(3);
-        Integer typeSort = productMapper.getPageTypeSort(pageId);
-        List<HotSearchVo> hotSearchList = productMapper.getHotSearchByPageId(pageId, source);
-        List<PageFloorVo> floorList = productMapper.getFloorByPageId(pageId, source);
+        Integer typeSort = pageMapper.getPageTypeSort(pageId);
+        List<HotSearchVo> hotSearchList = pageMapper.getHotSearchByPageId(pageId, source);
+        List<PageFloorVo> floorList = pageMapper.getFloorByPageId(pageId, source);
         for (PageFloorVo floor : floorList) {
-            FloorContentVo floorContent = productMapper.getFloorContentById(floor.getId());
+            FloorContentVo floorContent = pageMapper.getFloorContentById(floor.getId());
             setFloorLinkType(floorContent);
             floor.setFloorContent(floorContent);
-            List<FloorImageVo> floorImageList = productMapper.getFloorImageById(floor.getId(), source);
+            List<FloorImageVo> floorImageList = pageMapper.getFloorImageById(floor.getId(), source);
             setFloorImageProduct(userId, floorImageList);
             floor.setFloorImageList(floorImageList);
         }
@@ -110,14 +110,14 @@ public class ProductServiceImpl implements ProductService {
         Map<String, Object> map = new HashMap<>(2);
         //楼层管理
         source = source == null ? 1 : source;
-        List<PageFloorVo> homePageFloor = productMapper.getHomePageFloor(source);
+        List<PageFloorVo> homePageFloor = pageMapper.getHomePageFloor(source);
         Iterator<PageFloorVo> floorIterator = homePageFloor.iterator();
         while (floorIterator.hasNext()) {
             PageFloorVo floor = floorIterator.next();
-            FloorContentVo floorContent = productMapper.getFloorContentById(floor.getId());
+            FloorContentVo floorContent = pageMapper.getFloorContentById(floor.getId());
             setFloorLinkType(floorContent);
             floor.setFloorContent(floorContent);
-            List<FloorImageVo> floorImageList = productMapper.getFloorImageById(floor.getId(), source);
+            List<FloorImageVo> floorImageList = pageMapper.getFloorImageById(floor.getId(), source);
             if (floorImageList == null || floorImageList.size() == 0) {
                 floorIterator.remove();
                 continue;
@@ -127,8 +127,8 @@ public class ProductServiceImpl implements ProductService {
         }
         map.put("homePageFloor", homePageFloor);
         // 优质供应商
-        ShopFloorVo supplierImage = productMapper.getSupplierFloorImage();
-        List<ShopImageVo> supplierList = productMapper.getSupplierImage(source);
+        ShopFloorVo supplierImage = pageMapper.getSupplierFloorImage();
+        List<ShopImageVo> supplierList = pageMapper.getSupplierImage(source);
         supplierList.forEach(supplier -> {
             Integer linkType = AppletsLinkUtil.getLinkType(supplier.getLink());
             supplier.setLinkType(linkType);
@@ -146,6 +146,19 @@ public class ProductServiceImpl implements ProductService {
         return ResponseJson.success(map);
     }
 
+    /**
+     * 商品品牌列表
+     */
+    @Override
+    public ResponseJson<List<BrandVo>> getBrandList() {
+        List<BrandVo> brandList = pageMapper.getBrandList();
+        BrandVo other = new BrandVo();
+        other.setId(161);
+        other.setName("其他");
+        brandList.add(other);
+        return ResponseJson.success(brandList);
+    }
+
     /**
      * 设置跳转参数
      * @param floorContent FloorContentVo
@@ -183,7 +196,7 @@ public class ProductServiceImpl implements ProductService {
             image.setLinkParam(linkParam);
             if (image.getProductId() != null) {
                 // 获取商品及价格
-                ProductItemVo product = productMapper.getProductItemById(image.getProductId());
+                ProductItemVo product = pageMapper.getProductItemById(image.getProductId());
                 if (product != null) {
                     image.setListType(1);
                     image.setName(product.getName());

+ 7 - 1
src/main/resources/mapper/ProductMapper.xml → src/main/resources/mapper/PageMapper.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.caimei365.commodity.mapper.ProductMapper">
+<mapper namespace="com.caimei365.commodity.mapper.PageMapper">
     <select id="getBigTypeList" resultType="com.caimei365.commodity.model.vo.BigTypeVo">
         select
             bigTypeID as bigTypeId, typeSort, `name`, bigTypeCode, wwwValidFlag, crmValidFlag, wwwIcon, crmIcon, addTime, sortIndex
@@ -149,6 +149,12 @@
         </if>
         order by - sort desc,createDate desc
     </select>
+    <select id="getBrandList" resultType="com.caimei365.commodity.model.vo.BrandVo">
+        select id, name
+        from cm_brand
+		where status = '1' and delFlag = '0' and description is not null and description != '' and id not in (161)
+		order by sort
+    </select>
 
 
 </mapper>