feat(修改): 添加功能

Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
bunny 2024-03-26 13:43:43 +08:00
parent b950c186fa
commit 6f9a28d25e
6 changed files with 44 additions and 4 deletions

View File

@ -20,4 +20,5 @@ public class MessageConstant {
public static final String UPDATE_ID_IS_NOT_EMPTY = "删除id不能为空"; public static final String UPDATE_ID_IS_NOT_EMPTY = "删除id不能为空";
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 = "添加参数不能为空";
} }

View File

@ -8,10 +8,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.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "分类品牌") @Tag(name = "分类品牌")
@RestController @RestController
@ -26,4 +23,11 @@ public class CategoryBrandController {
PageInfo<CategoryBrand> pageInfo = categoryBrandService.findByPage(page, limit, dto); PageInfo<CategoryBrand> pageInfo = categoryBrandService.findByPage(page, limit, dto);
return Result.success(pageInfo); return Result.success(pageInfo);
} }
@Operation(summary = "添加功能", description = "添加功能")
@PostMapping("save")
public Result<CategoryBrand> save(@RequestBody CategoryBrand categoryBrand) {
categoryBrandService.save(categoryBrand);
return Result.success();
}
} }

View File

@ -15,4 +15,11 @@ public interface CategoryBrandMapper {
* @return PageInfo<CategoryBrand> * @return PageInfo<CategoryBrand>
*/ */
List<CategoryBrand> findByPage(CategoryBrandDto dto); List<CategoryBrand> findByPage(CategoryBrandDto dto);
/**
* 添加功能
*
* @param categoryBrand 分类品牌实体类
*/
void save(CategoryBrand categoryBrand);
} }

View File

@ -14,4 +14,11 @@ public interface CategoryBrandService {
* @return PageInfo<CategoryBrand> * @return PageInfo<CategoryBrand>
*/ */
PageInfo<CategoryBrand> findByPage(Integer page, Integer limit, CategoryBrandDto dto); PageInfo<CategoryBrand> findByPage(Integer page, Integer limit, CategoryBrandDto dto);
/**
* 添加功能
*
* @param categoryBrand 分类品牌实体类
*/
void save(CategoryBrand categoryBrand);
} }

View File

@ -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.CategoryBrandMapper; import com.atguigu.spzx.manger.mapper.CategoryBrandMapper;
import com.atguigu.spzx.manger.service.CategoryBrandService; import com.atguigu.spzx.manger.service.CategoryBrandService;
import com.atguigu.spzx.model.dto.product.CategoryBrandDto; import com.atguigu.spzx.model.dto.product.CategoryBrandDto;
@ -30,4 +32,17 @@ public class CategoryBrandServiceImpl implements CategoryBrandService {
List<CategoryBrand> categoryBrandList = categoryBrandMapper.findByPage(dto); List<CategoryBrand> categoryBrandList = categoryBrandMapper.findByPage(dto);
return new PageInfo<>(categoryBrandList); return new PageInfo<>(categoryBrandList);
} }
/**
* 添加功能
*
* @param categoryBrand 分类品牌实体类
*/
@Override
public void save(CategoryBrand categoryBrand) {
if (categoryBrand == null) {
throw new BunnyException(MessageConstant.SAVE_DTO_IS_NULL);
}
categoryBrandMapper.save(categoryBrand);
}
} }

View File

@ -6,6 +6,12 @@
id,brand_id,category_id,create_time,update_time,is_deleted id,brand_id,category_id,create_time,update_time,is_deleted
</sql> </sql>
<!-- 添加功能 -->
<insert id="save">
insert into category_brand (id, brand_id, category_id, create_time, update_time, is_deleted)
values (#{id}, #{brandId}, #{categoryId}, now(), now(), 0);
</insert>
<!-- 分类品牌列表 --> <!-- 分类品牌列表 -->
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.CategoryBrand"> <select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.CategoryBrand">
select select