From b70fc9ed4e2c01384350a76acd5c3547a11891a9 Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Tue, 26 Mar 2024 14:32:42 +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=E6=B7=BB=E5=8A=A0?= =?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> --- .../com/atguigu/constant/MessageConstant.java | 2 +- .../manger/controller/ProductSpecController.java | 11 +++++++---- .../spzx/manger/mapper/ProductSpecMapper.java | 7 +++++++ .../spzx/manger/service/ProductSpecService.java | 7 +++++++ .../service/impl/ProductSpecServiceImpl.java | 16 ++++++++++++++++ .../main/resources/mapper/ProductSpecMapper.xml | 6 ++++++ 6 files changed, 44 insertions(+), 5 deletions(-) diff --git a/spzx-common/common-util/src/main/java/com/atguigu/constant/MessageConstant.java b/spzx-common/common-util/src/main/java/com/atguigu/constant/MessageConstant.java index cd37193..15478d8 100644 --- a/spzx-common/common-util/src/main/java/com/atguigu/constant/MessageConstant.java +++ b/spzx-common/common-util/src/main/java/com/atguigu/constant/MessageConstant.java @@ -21,5 +21,5 @@ public class MessageConstant { public static final String DELETE_ID_IS_NOT_EMPTY = "修改id不能为空"; public static final String MENU_IS_NOT_EXIST = "菜单不存在"; public static final String SAVE_DTO_IS_NULL = "添加参数不能为空"; - public static final String UPDATE_DTO_IS_NULL = "修改功能"; + public static final String UPDATE_DTO_IS_NULL = "修改参数不能为空"; } 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 bd14695..29e9763 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 @@ -7,10 +7,7 @@ import com.github.pagehelper.PageInfo; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @Tag(name = "商品规格管理") @RestController @@ -25,4 +22,10 @@ public class ProductSpecController { PageInfo pageInfo = productSpecService.findByPage(page, limit); return Result.success(pageInfo); } + + @Operation(summary = "添加功能", description = "添加功能") + public Result save(@RequestBody ProductSpec productSpec) { + productSpecService.save(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 35ae23d..4d94231 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 @@ -13,4 +13,11 @@ public interface ProductSpecMapper { * @return 分页结果 */ List findByPage(); + + /** + * 添加功能 + * + * @param productSpec 商品规格实体类 + */ + void save(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 622a6e8..a68054e 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 @@ -12,4 +12,11 @@ public interface ProductSpecService { * @return 分页结果 */ PageInfo findByPage(Integer page, Integer limit); + + /** + * 添加功能 + * + * @param productSpec 商品规格实体类 + */ + void save(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 7f9cea0..65b1f99 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 @@ -1,5 +1,7 @@ package com.atguigu.spzx.manger.service.impl; +import com.atguigu.constant.MessageConstant; +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; @@ -31,4 +33,18 @@ public class ProductSpecServiceImpl implements ProductSpecService { startPage.close(); return new PageInfo<>(productSpecList); } + + /** + * 添加功能 + * + * @param productSpec 商品规格实体类 + */ + @Override + public void save(ProductSpec productSpec) { + if (productSpec == null) { + throw new BunnyException(MessageConstant.SAVE_DTO_IS_NULL); + } + + productSpecMapper.save(productSpec); + } } diff --git a/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml b/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml index 4ffc847..8f6e097 100644 --- a/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml +++ b/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml @@ -6,6 +6,12 @@ id,spec_name,spec_value,create_time,update_time,is_deleted + + + insert into product_spec (id, spec_name, spec_value, create_time, update_time, is_deleted) + values (#{id}, #{specName}, #{specValue}, now(), now(), 0); + +