From 605647283a3cce836b9d320206fb485f6e0855f0 Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Tue, 26 Mar 2024 14:35:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=96=B0=E5=A2=9E-=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E7=AE=A1=E7=90=86):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: bunny <1319900154@qq.com> --- .../manger/controller/ProductSpecController.java | 7 +++++++ .../spzx/manger/mapper/ProductSpecMapper.java | 7 +++++++ .../spzx/manger/service/ProductSpecService.java | 7 +++++++ .../service/impl/ProductSpecServiceImpl.java | 14 ++++++++++++++ .../main/resources/mapper/ProductSpecMapper.xml | 14 ++++++++++++++ 5 files changed, 49 insertions(+) diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductSpecController.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductSpecController.java index 29e9763..688e80c 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductSpecController.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductSpecController.java @@ -28,4 +28,11 @@ public class ProductSpecController { productSpecService.save(productSpec); return Result.success(); } + + @Operation(summary = "修改功能", description = "修改功能") + @PutMapping("updateById") + public Result updateById(@RequestBody ProductSpec productSpec) { + productSpecService.updateById(productSpec); + return Result.success(); + } } \ No newline at end of file diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/ProductSpecMapper.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/ProductSpecMapper.java index 4d94231..2f373d3 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/ProductSpecMapper.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/ProductSpecMapper.java @@ -20,4 +20,11 @@ public interface ProductSpecMapper { * @param productSpec 商品规格实体类 */ void save(ProductSpec productSpec); + + /** + * 修改功能 + * + * @param productSpec 商品规格实体类 + */ + void updateById(ProductSpec productSpec); } diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/ProductSpecService.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/ProductSpecService.java index a68054e..543e33f 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/ProductSpecService.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/ProductSpecService.java @@ -19,4 +19,11 @@ public interface ProductSpecService { * @param productSpec 商品规格实体类 */ void save(ProductSpec productSpec); + + /** + * 修改功能 + * + * @param productSpec 商品规格实体类 + */ + void updateById(ProductSpec productSpec); } diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/ProductSpecServiceImpl.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/ProductSpecServiceImpl.java index 65b1f99..d76a340 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/ProductSpecServiceImpl.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/ProductSpecServiceImpl.java @@ -47,4 +47,18 @@ public class ProductSpecServiceImpl implements ProductSpecService { productSpecMapper.save(productSpec); } + + /** + * 修改功能 + * + * @param productSpec 商品规格实体类 + */ + @Override + public void updateById(ProductSpec productSpec) { + if (productSpec == null) { + throw new BunnyException(MessageConstant.UPDATE_DTO_IS_NULL); + } + + productSpecMapper.updateById(productSpec); + } } diff --git a/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml b/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml index 8f6e097..e012da5 100644 --- a/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml +++ b/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml @@ -12,6 +12,20 @@ values (#{id}, #{specName}, #{specValue}, now(), now(), 0); + + + update product_spec + set + + spec_name = #{specName}, + + + spec_value = #{specValue}, + + update_time = now() + where id = #{id} + +