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));