diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductSpecController.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductSpecController.java new file mode 100644 index 0000000..bd14695 --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/controller/ProductSpecController.java @@ -0,0 +1,28 @@ +package com.atguigu.spzx.manger.controller; + +import com.atguigu.spzx.manger.service.ProductSpecService; +import com.atguigu.spzx.model.entity.product.ProductSpec; +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.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "商品规格管理") +@RestController +@RequestMapping(value = "/admin/product/productSpec") +public class ProductSpecController { + @Autowired + private ProductSpecService productSpecService; + + @Operation(summary = "列表查询", description = "列表查询") + @PutMapping("{page}/{limit}") + public Result> findByPage(@PathVariable Integer page, @PathVariable Integer limit) { + PageInfo pageInfo = productSpecService.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 index 53c93eb..7163aa9 100644 --- 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 @@ -1,9 +1,11 @@ package com.atguigu.spzx.manger.mapper; import com.atguigu.spzx.model.entity.product.Brand; +import org.apache.ibatis.annotations.Mapper; import java.util.List; +@Mapper public interface BrandMapper { /** * 查找分页品牌 diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/ProductSpecMapper.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/ProductSpecMapper.java new file mode 100644 index 0000000..35ae23d --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/mapper/ProductSpecMapper.java @@ -0,0 +1,16 @@ +package com.atguigu.spzx.manger.mapper; + +import com.atguigu.spzx.model.entity.product.ProductSpec; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface ProductSpecMapper { + /** + * 列表查询 + * + * @return 分页结果 + */ + List findByPage(); +} diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/ProductSpecService.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/ProductSpecService.java new file mode 100644 index 0000000..622a6e8 --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/ProductSpecService.java @@ -0,0 +1,15 @@ +package com.atguigu.spzx.manger.service; + +import com.atguigu.spzx.model.entity.product.ProductSpec; +import com.github.pagehelper.PageInfo; + +public interface ProductSpecService { + /** + * 列表查询 + * + * @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/CategoryBrandServiceImpl.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/CategoryBrandServiceImpl.java index 45663b9..edb408d 100644 --- 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 @@ -7,6 +7,7 @@ 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.utils.StringEmptyUtil; +import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; @@ -31,8 +32,11 @@ public class CategoryBrandServiceImpl implements CategoryBrandService { */ @Override public PageInfo findByPage(Integer page, Integer limit, CategoryBrandDto dto) { - PageHelper.startPage(page, limit).close(); + Page startPage = PageHelper.startPage(page, limit); List categoryBrandList = categoryBrandMapper.findByPage(dto); + + // 关闭资源 + startPage.close(); return new PageInfo<>(categoryBrandList); } diff --git a/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/ProductSpecServiceImpl.java b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/ProductSpecServiceImpl.java new file mode 100644 index 0000000..7f9cea0 --- /dev/null +++ b/spzx-manager/src/main/java/com/atguigu/spzx/manger/service/impl/ProductSpecServiceImpl.java @@ -0,0 +1,34 @@ +package com.atguigu.spzx.manger.service.impl; + +import com.atguigu.spzx.manger.mapper.ProductSpecMapper; +import com.atguigu.spzx.manger.service.ProductSpecService; +import com.atguigu.spzx.model.entity.product.ProductSpec; +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 ProductSpecServiceImpl implements ProductSpecService { + @Autowired + private ProductSpecMapper productSpecMapper; + + /** + * 列表查询 + * + * @param page 当前页 + * @param limit 每页限制 + * @return 分页结果 + */ + @Override + public PageInfo findByPage(Integer page, Integer limit) { + Page startPage = PageHelper.startPage(page, limit); + List productSpecList = productSpecMapper.findByPage(); + + startPage.close(); + return new PageInfo<>(productSpecList); + } +} diff --git a/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml b/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml new file mode 100644 index 0000000..4ffc847 --- /dev/null +++ b/spzx-manager/src/main/resources/mapper/ProductSpecMapper.xml @@ -0,0 +1,16 @@ + + + + + + id,spec_name,spec_value,create_time,update_time,is_deleted + + + + +