feat(新增): 品牌列表查询
Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
parent
a7b8646010
commit
bc7bc4afd2
|
@ -0,0 +1,28 @@
|
||||||
|
package com.atguigu.spzx.manger.controller;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.manger.service.BrandService;
|
||||||
|
import com.atguigu.spzx.model.entity.product.Brand;
|
||||||
|
import com.atguigu.spzx.model.vo.result.Result;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Tag(name = "品牌管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/admin/product/brand")
|
||||||
|
public class BrandController {
|
||||||
|
@Autowired
|
||||||
|
private BrandService brandService;
|
||||||
|
|
||||||
|
@Operation(summary = "品牌列表查询", description = "品牌列表查询")
|
||||||
|
@GetMapping("{page}/{limit}")
|
||||||
|
public Result<PageInfo<Brand>> findByPage(@PathVariable Integer page, @PathVariable Integer limit) {
|
||||||
|
PageInfo<Brand> pageInfo = brandService.findByPage(page, limit);
|
||||||
|
return Result.success(pageInfo);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.atguigu.spzx.manger.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.entity.product.Brand;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface BrandMapper {
|
||||||
|
/**
|
||||||
|
* 查找分页品牌
|
||||||
|
*
|
||||||
|
* @return 品牌列表
|
||||||
|
*/
|
||||||
|
List<Brand> findByPage();
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.atguigu.spzx.manger.service;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.entity.product.Brand;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
public interface BrandService {
|
||||||
|
/**
|
||||||
|
* 品牌列表查询
|
||||||
|
*
|
||||||
|
* @param page 当前页
|
||||||
|
* @param limit 每页大小
|
||||||
|
* @return 品牌分页结果
|
||||||
|
*/
|
||||||
|
PageInfo<Brand> findByPage(Integer page, Integer limit);
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.atguigu.spzx.manger.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.manger.mapper.BrandMapper;
|
||||||
|
import com.atguigu.spzx.manger.service.BrandService;
|
||||||
|
import com.atguigu.spzx.model.entity.product.Brand;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
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 BrandServiceImpl implements BrandService {
|
||||||
|
@Autowired
|
||||||
|
private BrandMapper brandMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品牌列表查询
|
||||||
|
*
|
||||||
|
* @param page 当前页
|
||||||
|
* @param limit 每页大小
|
||||||
|
* @return 品牌分页结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageInfo<Brand> findByPage(Integer page, Integer limit) {
|
||||||
|
Page<Brand> startPage = PageHelper.startPage(page, limit);
|
||||||
|
// 查找分页品牌
|
||||||
|
List<Brand> brandList = brandMapper.findByPage();
|
||||||
|
startPage.close();
|
||||||
|
return new PageInfo<>(brandList);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?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.BrandMapper">
|
||||||
|
<!-- 用于select查询公用抽取的列 -->
|
||||||
|
<sql id="columns">
|
||||||
|
id,name,logo,create_time,update_time,is_deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 查找分页品牌 -->
|
||||||
|
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.Brand">
|
||||||
|
select
|
||||||
|
<include refid="columns"/>
|
||||||
|
from brand
|
||||||
|
where is_deleted = 0
|
||||||
|
order by id desc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue