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} + +