From 3d69821e67ccaa56b7b2a06ba9cad7a0fd0acad7 Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Tue, 26 Mar 2024 14:50:41 +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=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: bunny <1319900154@qq.com> --- .../manger/controller/ProductController.java | 29 ++++++++++++++ .../spzx/manger/mapper/ProductMapper.java | 18 +++++++++ .../spzx/manger/service/ProductService.java | 17 +++++++++ .../service/impl/ProductServiceImpl.java | 36 ++++++++++++++++++ .../main/resources/mapper/ProductMapper.xml | 38 +++++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductController.java create mode 100644 spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/ProductMapper.java create mode 100644 spzx-manager/src/main/java/com/atguigu/spzx/manger/service/ProductService.java create mode 100644 spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/ProductServiceImpl.java create mode 100644 spzx-manager/src/main/resources/mapper/ProductMapper.xml 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 new file mode 100644 index 0000000..e9e8965 --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductController.java @@ -0,0 +1,29 @@ +package com.atguigu.spzx.manger.controller; + +import com.atguigu.spzx.manger.service.ProductService; +import com.atguigu.spzx.model.dto.product.ProductDto; +import com.atguigu.spzx.model.entity.product.Product; +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/product") +public class ProductController { + @Autowired + private ProductService productService; + + @Operation(summary = "列表查询", description = "列表查询") + @GetMapping("{page}/{limit}") + public Result> findByPage(@PathVariable Integer page, @PathVariable Integer limit, ProductDto dto) { + PageInfo pageInfo = productService.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/mapper/ProductMapper.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/ProductMapper.java new file mode 100644 index 0000000..a4ecbbd --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/ProductMapper.java @@ -0,0 +1,18 @@ +package com.atguigu.spzx.manger.mapper; + +import com.atguigu.spzx.model.dto.product.ProductDto; +import com.atguigu.spzx.model.entity.product.Product; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface ProductMapper { + + /** + * 列表查询 + * + * @return 查询结果 + */ + List findByPage(ProductDto dto); +} diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/ProductService.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/ProductService.java new file mode 100644 index 0000000..464c5d2 --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/ProductService.java @@ -0,0 +1,17 @@ +package com.atguigu.spzx.manger.service; + + +import com.atguigu.spzx.model.dto.product.ProductDto; +import com.atguigu.spzx.model.entity.product.Product; +import com.github.pagehelper.PageInfo; + +public interface ProductService { + /** + * 列表查询 + * + * @param page 当前也 + * @param limit 每页限制 + * @return 分页结果 + */ + PageInfo findByPage(Integer page, Integer limit, ProductDto dto); +} diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/ProductServiceImpl.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/ProductServiceImpl.java new file mode 100644 index 0000000..71aefb2 --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/ProductServiceImpl.java @@ -0,0 +1,36 @@ +package com.atguigu.spzx.manger.service.impl; + +import com.atguigu.spzx.manger.mapper.ProductMapper; +import com.atguigu.spzx.manger.service.ProductService; +import com.atguigu.spzx.model.dto.product.ProductDto; +import com.atguigu.spzx.model.entity.product.Product; +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 ProductServiceImpl implements ProductService { + @Autowired + private ProductMapper productMapper; + + /** + * 列表查询 + * + * @param page 当前也 + * @param limit 每页限制 + * @param dto + * @return 分页结果 + */ + @Override + public PageInfo findByPage(Integer page, Integer limit, ProductDto dto) { + Page startPage = PageHelper.startPage(page, limit); + + List productList = productMapper.findByPage(dto); + startPage.close(); + return new PageInfo<>(productList); + } +} diff --git a/spzx-manager/src/main/resources/mapper/ProductMapper.xml b/spzx-manager/src/main/resources/mapper/ProductMapper.xml new file mode 100644 index 0000000..970f4e7 --- /dev/null +++ b/spzx-manager/src/main/resources/mapper/ProductMapper.xml @@ -0,0 +1,38 @@ + + + + + + id,name,brand_id,category1_id,category2_id,category3_id,unit_name,slider_urls,spec_value,status,audit_status,audit_message,create_time,update_time,is_deleted + + + + +