feat(新增-商品规格管理): 添加功能

Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
bunny 2024-03-26 14:32:42 +08:00
parent 943c945cfb
commit b70fc9ed4e
6 changed files with 44 additions and 5 deletions

View File

@ -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 = "修改参数不能为空";
}

View File

@ -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<ProductSpec> pageInfo = productSpecService.findByPage(page, limit);
return Result.success(pageInfo);
}
@Operation(summary = "添加功能", description = "添加功能")
public Result<ProductSpec> save(@RequestBody ProductSpec productSpec) {
productSpecService.save(productSpec);
return Result.success();
}
}

View File

@ -13,4 +13,11 @@ public interface ProductSpecMapper {
* @return 分页结果
*/
List<ProductSpec> findByPage();
/**
* 添加功能
*
* @param productSpec 商品规格实体类
*/
void save(ProductSpec productSpec);
}

View File

@ -12,4 +12,11 @@ public interface ProductSpecService {
* @return 分页结果
*/
PageInfo<ProductSpec> findByPage(Integer page, Integer limit);
/**
* 添加功能
*
* @param productSpec 商品规格实体类
*/
void save(ProductSpec productSpec);
}

View File

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

View File

@ -6,6 +6,12 @@
id,spec_name,spec_value,create_time,update_time,is_deleted
</sql>
<!-- 添加功能 -->
<insert id="save">
insert into product_spec (id, spec_name, spec_value, create_time, update_time, is_deleted)
values (#{id}, #{specName}, #{specValue}, now(), now(), 0);
</insert>
<!-- 列表查询 -->
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.ProductSpec">
select