Переглянути джерело

分类增加商家ID与类型

liude 1 рік тому
батько
коміт
c7efc75cb1

+ 8 - 3
src/main/java/com/chelvc/cloud/maintain/controller/CategoryController.java

@@ -4,13 +4,18 @@ import java.util.List;
 
 import com.chelvc.cloud.maintain.copier.CategoryCopier;
 import com.chelvc.cloud.maintain.vo.CategoryVO;
+import com.chelvc.cloud.vehicle.api.param.CategoryListParam;
 import com.chelvc.cloud.vehicle.api.service.CategoryService;
 import com.chelvc.framework.base.annotation.ResponseWrapping;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.validation.Valid;
+
 /**
  * 分类接口
  *
@@ -29,8 +34,8 @@ public class CategoryController {
      *
      * @return 分类信息列表
      */
-    @GetMapping("/categories")
-    public List<CategoryVO> listCategories() {
-        return CategoryCopier.INSTANCE.copying(this.categoryService.listActiveCategories());
+    @PostMapping("/categories")
+    public List<CategoryVO> listCategories(@RequestBody @Valid CategoryListParam param) {
+        return CategoryCopier.INSTANCE.copying(this.categoryService.listActiveCategories(param));
     }
 }

+ 40 - 0
src/main/java/com/chelvc/cloud/maintain/controller/MerchantController.java

@@ -2,6 +2,7 @@ package com.chelvc.cloud.maintain.controller;
 
 import com.chelvc.cloud.maintain.copier.MerchantCopier;
 import com.chelvc.cloud.maintain.vo.SimpleMerchantVO;
+import com.chelvc.cloud.vehicle.api.constant.GoodsStatus;
 import com.chelvc.cloud.vehicle.api.dto.BalanceDetailDTO;
 import com.chelvc.cloud.vehicle.api.dto.MerchantDTO;
 import com.chelvc.cloud.vehicle.api.dto.MerchantDetailDTO;
@@ -9,6 +10,7 @@ import com.chelvc.cloud.vehicle.api.dto.MerchantRankDTO;
 import com.chelvc.cloud.vehicle.api.param.*;
 import com.chelvc.cloud.vehicle.api.service.BalanceDetailService;
 import com.chelvc.cloud.vehicle.api.service.FavoriteService;
+import com.chelvc.cloud.vehicle.api.service.GoodsService;
 import com.chelvc.cloud.vehicle.api.service.MerchantService;
 import com.chelvc.framework.base.annotation.ResponseWrapping;
 import com.chelvc.framework.base.context.SessionContextHolder;
@@ -18,10 +20,12 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
 import javax.validation.constraints.Min;
+import javax.validation.constraints.NotEmpty;
 import java.util.List;
 
 /**
@@ -42,6 +46,8 @@ public class MerchantController {
 
     @DubboReference
     private BalanceDetailService balanceDetailService;
+    @DubboReference
+    private GoodsService goodsService;
 
     /**
      * 获取商家列表
@@ -118,4 +124,38 @@ public class MerchantController {
         return this.merchantService.getUserMineCartPaging(param);
     }
 
+
+    /**
+     * 上架商品
+     *
+     * @param goodsIds    商品ID集合
+     */
+    @PutMapping("/merchant/list-goods/{goodsIds}")
+    public void listGoods(@PathVariable("goodsIds") @NotEmpty(message = "商品ID不能为空") List<Long> goodsIds) {
+        this.goodsService.updateGoodsStatus(goodsIds, GoodsStatus.ONLINE);
+    }
+
+    /**
+     * 下架商品
+     *
+     * @param goodsIds    商品ID集合
+     */
+    @PutMapping("/merchant/delist-goods/{goodsIds}")
+    public void delistGoods(@PathVariable("goodsIds") @NotEmpty(message = "商品ID不能为空") List<Long> goodsIds) {
+        this.goodsService.updateGoodsStatus(goodsIds, GoodsStatus.OFFLINE);
+    }
+
+
+    /**
+     * 修改商家营业状态
+     *
+     * @param id    商家主键
+     * @param businessStatus 修改参数  营业状态 0-营业中,1-休息中
+     */
+    @PutMapping("/merchant/updateBusinessStatus/{id}")
+    public void updateMerchant(@PathVariable("id") @Min(value = 1, message = "商家主键不能小于1") Long id,
+                               String businessStatus) {
+        this.merchantService.updateMerchantBusinessStatus(id,businessStatus);
+    }
+
 }

+ 9 - 6
src/main/java/com/chelvc/cloud/maintain/vo/CategoryVO.java

@@ -28,12 +28,6 @@ public class CategoryVO implements Serializable {
      */
     private Long id;
 
-    /**
-     * 分类类型
-     */
-    @JsonSerialize(using = EnumerationFormatSerializer.class)
-    private CategoryType type;
-
     /**
      * 分类图标
      */
@@ -47,4 +41,13 @@ public class CategoryVO implements Serializable {
      * 子集分类
      */
     private List<CategoryDTO> children;
+
+    /**
+     * 分类类型 分类类型 0-平台的分类 1-商家的分类
+     */
+    private String  type;
+    /**
+     * 商家ID
+     */
+    private Long merchantId;
 }