Przeglądaj źródła

Merge branch 'master' of http://47.108.128.78:3080/wuyongqiang/maintain

woody 6 miesięcy temu
rodzic
commit
65c466d62a

+ 25 - 0
src/main/java/com/chelvc/cloud/maintain/controller/GoodsController.java

@@ -10,6 +10,7 @@ import com.chelvc.cloud.vehicle.client.FavoriteClient;
 import com.chelvc.cloud.vehicle.client.GoodsClient;
 import com.chelvc.cloud.vehicle.client.dto.GoodsDTO;
 import com.chelvc.cloud.vehicle.client.dto.GoodsDetailDTO;
+import com.chelvc.cloud.vehicle.client.param.GoodsModifyParam;
 import com.chelvc.cloud.vehicle.client.param.GoodsQueryParam;
 import com.chelvc.framework.base.annotation.ResponseWrapping;
 import lombok.RequiredArgsConstructor;
@@ -18,6 +19,7 @@ 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.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -83,5 +85,28 @@ public class GoodsController {
         return this.goodsClient.getMerchantGoodsList(param);
     }
 
+    /**
+     * 新增商品
+     *
+     * @param param 新增参数
+     * @return 商品主键
+     */
+    @PostMapping("/goods")
+    public Long addGoods(@RequestBody @Valid GoodsModifyParam param) {
+        return this.goodsClient.addGoods(param);
+    }
+
+    /**
+     * 修改商品
+     *
+     * @param id    商品主键
+     * @param param 修改参数
+     */
+    @PutMapping("/goods/{id}")
+    public void updateGoods(@PathVariable("id") @Min(value = 1, message = "商品主键不能小于1") Long id,
+                            @RequestBody @Valid GoodsModifyParam param) {
+        this.goodsClient.updateGoods(id, param);
+    }
+
 
 }