From a8ba62125f83803ef1d0aa0de2426e2dfff8e153 Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Tue, 26 Mar 2024 14:56:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=96=B0=E5=A2=9E-=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=AE=A1=E7=90=86):=20=E6=B7=BB=E5=8A=A0=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> --- .../java/com/atguigu/constant/MessageConstant.java | 1 + .../spzx/manger/controller/ProductController.java | 14 ++++++++++++++ .../spzx/manger/mapper/CategoryBrandMapper.java | 9 +++++++++ .../spzx/manger/service/CategoryBrandService.java | 11 +++++++++++ .../service/impl/CategoryBrandServiceImpl.java | 13 +++++++++++++ .../main/resources/mapper/CategoryBrandMapper .xml | 10 ++++++++++ 6 files changed, 58 insertions(+) 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 15478d8..647013f 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 @@ -22,4 +22,5 @@ public class MessageConstant { 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 FIND_ID_IS_NOT_EMPTY = "查询ID不能为空"; } diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductController.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductController.java index e9e8965..650e5a2 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductController.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductController.java @@ -1,9 +1,12 @@ package com.atguigu.spzx.manger.controller; +import com.atguigu.spzx.manger.service.CategoryBrandService; import com.atguigu.spzx.manger.service.ProductService; import com.atguigu.spzx.model.dto.product.ProductDto; +import com.atguigu.spzx.model.entity.product.Brand; import com.atguigu.spzx.model.entity.product.Product; import com.atguigu.spzx.model.vo.result.Result; +import com.atguigu.spzx.model.vo.result.ResultCodeEnum; import com.github.pagehelper.PageInfo; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -13,12 +16,16 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + @Tag(name = "商品管理") @RestController @RequestMapping(value = "/admin/product/product") public class ProductController { @Autowired private ProductService productService; + @Autowired + private CategoryBrandService categoryBrandService; @Operation(summary = "列表查询", description = "列表查询") @GetMapping("{page}/{limit}") @@ -26,4 +33,11 @@ public class ProductController { PageInfo pageInfo = productService.findByPage(page, limit, dto); return Result.success(pageInfo); } + + @Operation(summary = "添加功能", description = "添加功能") + @GetMapping("findBrandByCategoryId/{categoryId}") + public Result> findBrandByCategoryId(@PathVariable Long categoryId) { + List brandList = categoryBrandService.findBrandByCategoryId(categoryId); + return Result.build(brandList, ResultCodeEnum.SUCCESS); + } } \ No newline at end of file diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/CategoryBrandMapper.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/CategoryBrandMapper.java index 5bc42b9..20ec330 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/CategoryBrandMapper.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/CategoryBrandMapper.java @@ -1,6 +1,7 @@ package com.atguigu.spzx.manger.mapper; import com.atguigu.spzx.model.dto.product.CategoryBrandDto; +import com.atguigu.spzx.model.entity.product.Brand; import com.atguigu.spzx.model.entity.product.CategoryBrand; import org.apache.ibatis.annotations.Mapper; @@ -31,4 +32,12 @@ public interface CategoryBrandMapper { * @param id 删除的ID */ void deleteById(Long id); + + /** + * 添加功能 + * + * @param categoryId 查询ID + * @return List + */ + List findBrandByCategoryId(Long categoryId); } diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/CategoryBrandService.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/CategoryBrandService.java index 4fe72bc..d697dab 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/CategoryBrandService.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/CategoryBrandService.java @@ -1,9 +1,12 @@ package com.atguigu.spzx.manger.service; import com.atguigu.spzx.model.dto.product.CategoryBrandDto; +import com.atguigu.spzx.model.entity.product.Brand; import com.atguigu.spzx.model.entity.product.CategoryBrand; import com.github.pagehelper.PageInfo; +import java.util.List; + public interface CategoryBrandService { /** * 分类品牌列表 @@ -35,4 +38,12 @@ public interface CategoryBrandService { * @param id 删除的ID */ void deleteById(Long id); + + /** + * 添加功能 + * + * @param categoryId 查询ID + * @return List + */ + List findBrandByCategoryId(Long categoryId); } diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/CategoryBrandServiceImpl.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/CategoryBrandServiceImpl.java index edb408d..00b71d9 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/CategoryBrandServiceImpl.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/CategoryBrandServiceImpl.java @@ -5,6 +5,7 @@ import com.atguigu.exception.BunnyException; import com.atguigu.spzx.manger.mapper.CategoryBrandMapper; import com.atguigu.spzx.manger.service.CategoryBrandService; import com.atguigu.spzx.model.dto.product.CategoryBrandDto; +import com.atguigu.spzx.model.entity.product.Brand; import com.atguigu.spzx.model.entity.product.CategoryBrand; import com.atguigu.utils.StringEmptyUtil; import com.github.pagehelper.Page; @@ -76,4 +77,16 @@ public class CategoryBrandServiceImpl implements CategoryBrandService { emptyUtil.isEmpty(id, MessageConstant.DELETE_ID_IS_NOT_EMPTY); categoryBrandMapper.deleteById(id); } + + /** + * 添加功能 + * + * @param categoryId 查询ID + * @return List + */ + @Override + public List findBrandByCategoryId(Long categoryId) { + emptyUtil.isEmpty(categoryId, MessageConstant.FIND_ID_IS_NOT_EMPTY); + return categoryBrandMapper.findBrandByCategoryId(categoryId); + } } diff --git a/spzx-manager/src/main/resources/mapper/CategoryBrandMapper .xml b/spzx-manager/src/main/resources/mapper/CategoryBrandMapper .xml index b1b7037..cd48f2c 100644 --- a/spzx-manager/src/main/resources/mapper/CategoryBrandMapper .xml +++ b/spzx-manager/src/main/resources/mapper/CategoryBrandMapper .xml @@ -53,4 +53,14 @@ order by cb.id desc + + +