diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/CategoryBrandController.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/CategoryBrandController.java new file mode 100644 index 0000000..904d508 --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/CategoryBrandController.java @@ -0,0 +1,27 @@ +package com.atguigu.spzx.manger.controller; + +import com.atguigu.spzx.manger.service.CategoryBrandService; +import com.atguigu.spzx.model.dto.product.CategoryBrandDto; +import com.atguigu.spzx.model.entity.product.CategoryBrand; +import com.atguigu.spzx.model.vo.result.Result; +import com.github.pagehelper.PageInfo; +import io.swagger.v3.oas.annotations.Operation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping(value = "/admin/product/categoryBrand") +public class CategoryBrandController { + @Autowired + private CategoryBrandService categoryBrandService; + + @Operation(summary = "分类品牌列表", description = "分类品牌列表接口") + @GetMapping("{page}/{limit}") + public Result> findByPage(@PathVariable Integer page, @PathVariable Integer limit, CategoryBrandDto dto) { + PageInfo pageInfo = categoryBrandService.findByPage(page, limit, dto); + return Result.success(pageInfo); + } +} \ No newline at end of file diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/CategoryController.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/CategoryController.java index e058c60..e15347a 100644 --- a/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/CategoryController.java +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/CategoryController.java @@ -3,7 +3,6 @@ package com.atguigu.spzx.manger.controller; import com.atguigu.spzx.manger.service.CategoryService; import com.atguigu.spzx.model.entity.product.Category; import com.atguigu.spzx.model.vo.result.Result; -import com.atguigu.spzx.model.vo.result.ResultCodeEnum; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; @@ -21,21 +20,21 @@ public class CategoryController { private CategoryService categoryService; @Operation(summary = "根据parentId获取下级节点", description = "根据parentId获取下级节点") - @GetMapping(value = "findByParentId/{parentId}") + @GetMapping(value = "findCategoryList/{parentId}") public Result> findByParentId(@PathVariable Long parentId) { List list = categoryService.findByParentId(parentId); return Result.success(list); } - @Operation(summary = "导出数据",description = "导出数据") + @Operation(summary = "导出数据", description = "导出数据") @GetMapping(value = "/exportData") public void exportData(HttpServletResponse response) { categoryService.exportData(response); } - @Operation(summary = "导入功能",description = "导入功能") + @Operation(summary = "导入功能", description = "导入功能") @PostMapping("importData") - public Result importData(MultipartFile file) { + public Result importData(MultipartFile file) { categoryService.importData(file); return Result.success(); } 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 new file mode 100644 index 0000000..a72adea --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/CategoryBrandMapper.java @@ -0,0 +1,18 @@ +package com.atguigu.spzx.manger.mapper; + +import com.atguigu.spzx.model.dto.product.CategoryBrandDto; +import com.atguigu.spzx.model.entity.product.CategoryBrand; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface CategoryBrandMapper { + /** + * 分类品牌列表 + * + * @param dto 搜索条件实体类 + * @return PageInfo + */ + List findByPage(CategoryBrandDto dto); +} 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 new file mode 100644 index 0000000..2b8231d --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/CategoryBrandService.java @@ -0,0 +1,17 @@ +package com.atguigu.spzx.manger.service; + +import com.atguigu.spzx.model.dto.product.CategoryBrandDto; +import com.atguigu.spzx.model.entity.product.CategoryBrand; +import com.github.pagehelper.PageInfo; + +public interface CategoryBrandService { + /** + * 分类品牌列表 + * + * @param page 当前页 + * @param limit 每页限制 + * @param dto 搜索条件实体类 + * @return PageInfo + */ + PageInfo findByPage(Integer page, Integer limit, CategoryBrandDto dto); +} 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 new file mode 100644 index 0000000..289b213 --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/CategoryBrandServiceImpl.java @@ -0,0 +1,33 @@ +package com.atguigu.spzx.manger.service.impl; + +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.CategoryBrand; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class CategoryBrandServiceImpl implements CategoryBrandService { + @Autowired + private CategoryBrandMapper categoryBrandMapper; + + /** + * 分类品牌列表 + * + * @param page 当前页 + * @param limit 每页限制 + * @param dto 搜索条件实体类 + * @return PageInfo + */ + @Override + public PageInfo findByPage(Integer page, Integer limit, CategoryBrandDto dto) { + PageHelper.startPage(page, limit).close(); + List categoryBrandList = categoryBrandMapper.findByPage(dto); + return new PageInfo<>(categoryBrandList); + } +} diff --git a/spzx-manager/src/main/resources/mapper/CategoryBrandMapper .xml b/spzx-manager/src/main/resources/mapper/CategoryBrandMapper .xml new file mode 100644 index 0000000..7611219 --- /dev/null +++ b/spzx-manager/src/main/resources/mapper/CategoryBrandMapper .xml @@ -0,0 +1,29 @@ + + + + + + id,brand_id,category_id,create_time,update_time,is_deleted + + + + + diff --git a/spzx-model/src/main/java/com/atguigu/spzx/model/entity/product/CategoryBrand.java b/spzx-model/src/main/java/com/atguigu/spzx/model/entity/product/CategoryBrand.java index 2df3d02..63b0ab8 100644 --- a/spzx-model/src/main/java/com/atguigu/spzx/model/entity/product/CategoryBrand.java +++ b/spzx-model/src/main/java/com/atguigu/spzx/model/entity/product/CategoryBrand.java @@ -7,20 +7,18 @@ import lombok.Data; @Data @Schema(description = "分类品牌实体类") public class CategoryBrand extends BaseEntity { + @Schema(description = "品牌id") + private Long brandId; - @Schema(description = "品牌id") - private Long brandId; + @Schema(description = "分类id") + private Long categoryId; - @Schema(description = "分类id") - private Long categoryId; + @Schema(description = "分类名称", required = false) + private String categoryName; - @Schema(description = "分类名称" , required = false) - private String categoryName; - - @Schema(description = "品牌名称" , required = false) - private String brandName; - - @Schema(description = "品牌logo" , required = false) - private String logo; + @Schema(description = "品牌名称", required = false) + private String brandName; + @Schema(description = "品牌logo", required = false) + private String logo; } \ No newline at end of file