feat(新增): 分类品牌列表
Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
parent
8dddea3bf5
commit
6de6b4d232
|
@ -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<PageInfo<CategoryBrand>> findByPage(@PathVariable Integer page, @PathVariable Integer limit, CategoryBrandDto dto) {
|
||||
PageInfo<CategoryBrand> pageInfo = categoryBrandService.findByPage(page, limit, dto);
|
||||
return Result.success(pageInfo);
|
||||
}
|
||||
}
|
|
@ -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,7 +20,7 @@ public class CategoryController {
|
|||
private CategoryService categoryService;
|
||||
|
||||
@Operation(summary = "根据parentId获取下级节点", description = "根据parentId获取下级节点")
|
||||
@GetMapping(value = "findByParentId/{parentId}")
|
||||
@GetMapping(value = "findCategoryList/{parentId}")
|
||||
public Result<List<Category>> findByParentId(@PathVariable Long parentId) {
|
||||
List<Category> list = categoryService.findByParentId(parentId);
|
||||
return Result.success(list);
|
||||
|
|
|
@ -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<CategoryBrand>
|
||||
*/
|
||||
List<CategoryBrand> findByPage(CategoryBrandDto dto);
|
||||
}
|
|
@ -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<CategoryBrand>
|
||||
*/
|
||||
PageInfo<CategoryBrand> findByPage(Integer page, Integer limit, CategoryBrandDto dto);
|
||||
}
|
|
@ -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<CategoryBrand>
|
||||
*/
|
||||
@Override
|
||||
public PageInfo<CategoryBrand> findByPage(Integer page, Integer limit, CategoryBrandDto dto) {
|
||||
PageHelper.startPage(page, limit).close();
|
||||
List<CategoryBrand> categoryBrandList = categoryBrandMapper.findByPage(dto);
|
||||
return new PageInfo<>(categoryBrandList);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.atguigu.spzx.manger.mapper.CategoryBrandMapper">
|
||||
<!-- 用于select查询公用抽取的列 -->
|
||||
<sql id="columns">
|
||||
id,brand_id,category_id,create_time,update_time,is_deleted
|
||||
</sql>
|
||||
|
||||
<!-- 分类品牌列表 -->
|
||||
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.CategoryBrand">
|
||||
select
|
||||
cb.id,cb.brand_id,cb.category_id,cb.create_time,cb.update_time,
|
||||
c.name as categoryName,
|
||||
b.name as brandName, b.logo
|
||||
from category_brand cb
|
||||
left join category c on c.id = cb.category_id
|
||||
left join brand b on b.id = cb.brand_id
|
||||
<where>
|
||||
<if test="brandId != null and brandId != ''">
|
||||
and cb.brand_id = #{brandId}
|
||||
</if>
|
||||
<if test="categoryId != null and categoryId != ''">
|
||||
and cb.category_id = #{categoryId}
|
||||
</if>
|
||||
and cb.is_deleted = 0
|
||||
</where>
|
||||
order by cb.id desc
|
||||
</select>
|
||||
</mapper>
|
|
@ -7,7 +7,6 @@ import lombok.Data;
|
|||
@Data
|
||||
@Schema(description = "分类品牌实体类")
|
||||
public class CategoryBrand extends BaseEntity {
|
||||
|
||||
@Schema(description = "品牌id")
|
||||
private Long brandId;
|
||||
|
||||
|
@ -22,5 +21,4 @@ public class CategoryBrand extends BaseEntity {
|
|||
|
||||
@Schema(description = "品牌logo", required = false)
|
||||
private String logo;
|
||||
|
||||
}
|
Loading…
Reference in New Issue