diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/BrandController.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/BrandController.java new file mode 100644 index 0000000..4ebeb2a --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/BrandController.java @@ -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> findByPage(@PathVariable Integer page, @PathVariable Integer limit) { + PageInfo pageInfo = brandService.findByPage(page, limit); + return Result.success(pageInfo); + } +} \ No newline at end of file diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/BrandMapper.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/BrandMapper.java new file mode 100644 index 0000000..97bcf72 --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/BrandMapper.java @@ -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 findByPage(); +} diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/BrandService.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/BrandService.java new file mode 100644 index 0000000..c217042 --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/BrandService.java @@ -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 findByPage(Integer page, Integer limit); +} diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/BrandServiceImpl.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/BrandServiceImpl.java new file mode 100644 index 0000000..6f83ebd --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/BrandServiceImpl.java @@ -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 findByPage(Integer page, Integer limit) { + Page startPage = PageHelper.startPage(page, limit); + // 查找分页品牌 + List brandList = brandMapper.findByPage(); + startPage.close(); + return new PageInfo<>(brandList); + } +} diff --git a/spzx-manager/src/main/resources/mapper/BrandMapper.xml b/spzx-manager/src/main/resources/mapper/BrandMapper.xml new file mode 100644 index 0000000..6e502f0 --- /dev/null +++ b/spzx-manager/src/main/resources/mapper/BrandMapper.xml @@ -0,0 +1,17 @@ + + + + + + id,name,logo,create_time,update_time,is_deleted + + + + +