From 27105b32207f75ff31444ca4986a3ac8f1962e38 Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Tue, 26 Mar 2024 14:38:47 +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=E5=88=A0=E9=99=A4?= =?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 | 8 ++++++++ 5 files changed, 43 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 688e80c..0831f92 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 @@ -35,4 +35,11 @@ public class ProductSpecController { productSpecService.updateById(productSpec); return Result.success(); } + + @Operation(summary = "删除功能", description = "删除功能") + @DeleteMapping("deleteById/{id}") + public Result removeById(@PathVariable Long id) { + productSpecService.deleteById(id); + 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 2f373d3..8264b95 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 @@ -27,4 +27,11 @@ public interface ProductSpecMapper { * @param productSpec 商品规格实体类 */ void updateById(ProductSpec productSpec); + + /** + * 删除功能 + * + * @param id 要删除的ID + */ + void deleteById(Long id); } 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 543e33f..fd87850 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 @@ -26,4 +26,11 @@ public interface ProductSpecService { * @param productSpec 商品规格实体类 */ void updateById(ProductSpec productSpec); + + /** + * 删除功能 + * + * @param id 要删除的ID + */ + void deleteById(Long id); } 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 d76a340..ffcf39e 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 @@ -5,6 +5,7 @@ import com.atguigu.exception.BunnyException; import com.atguigu.spzx.manger.mapper.ProductSpecMapper; import com.atguigu.spzx.manger.service.ProductSpecService; import com.atguigu.spzx.model.entity.product.ProductSpec; +import com.atguigu.utils.StringEmptyUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -17,6 +18,8 @@ import java.util.List; public class ProductSpecServiceImpl implements ProductSpecService { @Autowired private ProductSpecMapper productSpecMapper; + @Autowired + private StringEmptyUtil emptyUtil; /** * 列表查询 @@ -61,4 +64,15 @@ public class ProductSpecServiceImpl implements ProductSpecService { productSpecMapper.updateById(productSpec); } + + /** + * 删除功能 + * + * @param id 要删除的ID + */ + @Override + public void deleteById(Long id) { + emptyUtil.isEmpty(id, MessageConstant.UPDATE_ID_IS_NOT_EMPTY); + productSpecMapper.deleteById(id); + } } diff --git a/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml b/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml index e012da5..32fde16 100644 --- a/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml +++ b/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml @@ -26,6 +26,14 @@ where id = #{id} + + + update product_spec + set is_deleted = 1, + update_time = now() + where id = #{id} + +