From db13ce6630768fb9054f20f1e29b17077d462f4a Mon Sep 17 00:00:00 2001 From: wayn <1669738430@qq.com> Date: Sat, 11 Jul 2020 00:27:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/shop/GoodsController.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/waynboot-admin-api/src/main/java/com/wayn/admin/api/controller/shop/GoodsController.java b/waynboot-admin-api/src/main/java/com/wayn/admin/api/controller/shop/GoodsController.java index c8dd3ef..8f0041e 100644 --- a/waynboot-admin-api/src/main/java/com/wayn/admin/api/controller/shop/GoodsController.java +++ b/waynboot-admin-api/src/main/java/com/wayn/admin/api/controller/shop/GoodsController.java @@ -7,10 +7,10 @@ import com.wayn.admin.api.service.shop.IGoodsService; import com.wayn.common.base.BaseController; import com.wayn.common.util.R; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; /** *

@@ -33,6 +33,18 @@ public class GoodsController extends BaseController { return R.success().add("page", iGoodsService.listPage(page, goods)); } + @PostMapping + public R addGoods(@Validated @RequestBody Goods goods) { + goods.setCreateTime(new Date()); + return R.result(iGoodsService.save(goods)); + } + + @PutMapping + public R updateGoods(@Validated @RequestBody Goods goods) { + goods.setUpdateTime(new Date()); + return R.result(iGoodsService.updateById(goods)); + } + @GetMapping("{goodsId}") public R getGoods(@PathVariable Long goodsId) { return R.success().add("data", iGoodsService.getById(goodsId));