feat(新增-商品规格管理): 添加功能
Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
parent
943c945cfb
commit
b70fc9ed4e
|
@ -21,5 +21,5 @@ public class MessageConstant {
|
||||||
public static final String DELETE_ID_IS_NOT_EMPTY = "修改id不能为空";
|
public static final String DELETE_ID_IS_NOT_EMPTY = "修改id不能为空";
|
||||||
public static final String MENU_IS_NOT_EXIST = "菜单不存在";
|
public static final String MENU_IS_NOT_EXIST = "菜单不存在";
|
||||||
public static final String SAVE_DTO_IS_NULL = "添加参数不能为空";
|
public static final String SAVE_DTO_IS_NULL = "添加参数不能为空";
|
||||||
public static final String UPDATE_DTO_IS_NULL = "修改功能";
|
public static final String UPDATE_DTO_IS_NULL = "修改参数不能为空";
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,7 @@ import com.github.pagehelper.PageInfo;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@Tag(name = "商品规格管理")
|
@Tag(name = "商品规格管理")
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -25,4 +22,10 @@ public class ProductSpecController {
|
||||||
PageInfo<ProductSpec> pageInfo = productSpecService.findByPage(page, limit);
|
PageInfo<ProductSpec> pageInfo = productSpecService.findByPage(page, limit);
|
||||||
return Result.success(pageInfo);
|
return Result.success(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "添加功能", description = "添加功能")
|
||||||
|
public Result<ProductSpec> save(@RequestBody ProductSpec productSpec) {
|
||||||
|
productSpecService.save(productSpec);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -13,4 +13,11 @@ public interface ProductSpecMapper {
|
||||||
* @return 分页结果
|
* @return 分页结果
|
||||||
*/
|
*/
|
||||||
List<ProductSpec> findByPage();
|
List<ProductSpec> findByPage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加功能
|
||||||
|
*
|
||||||
|
* @param productSpec 商品规格实体类
|
||||||
|
*/
|
||||||
|
void save(ProductSpec productSpec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,4 +12,11 @@ public interface ProductSpecService {
|
||||||
* @return 分页结果
|
* @return 分页结果
|
||||||
*/
|
*/
|
||||||
PageInfo<ProductSpec> findByPage(Integer page, Integer limit);
|
PageInfo<ProductSpec> findByPage(Integer page, Integer limit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加功能
|
||||||
|
*
|
||||||
|
* @param productSpec 商品规格实体类
|
||||||
|
*/
|
||||||
|
void save(ProductSpec productSpec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.atguigu.spzx.manger.service.impl;
|
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.mapper.ProductSpecMapper;
|
||||||
import com.atguigu.spzx.manger.service.ProductSpecService;
|
import com.atguigu.spzx.manger.service.ProductSpecService;
|
||||||
import com.atguigu.spzx.model.entity.product.ProductSpec;
|
import com.atguigu.spzx.model.entity.product.ProductSpec;
|
||||||
|
@ -31,4 +33,18 @@ public class ProductSpecServiceImpl implements ProductSpecService {
|
||||||
startPage.close();
|
startPage.close();
|
||||||
return new PageInfo<>(productSpecList);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,12 @@
|
||||||
id,spec_name,spec_value,create_time,update_time,is_deleted
|
id,spec_name,spec_value,create_time,update_time,is_deleted
|
||||||
</sql>
|
</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 id="findByPage" resultType="com.atguigu.spzx.model.entity.product.ProductSpec">
|
||||||
select
|
select
|
||||||
|
|
Loading…
Reference in New Issue