feat(新增-商品规格管理): 列表查询
Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
parent
608f0defaf
commit
943c945cfb
|
@ -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<PageInfo<ProductSpec>> findByPage(@PathVariable Integer page, @PathVariable Integer limit) {
|
||||
PageInfo<ProductSpec> pageInfo = productSpecService.findByPage(page, limit);
|
||||
return Result.success(pageInfo);
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
/**
|
||||
* 查找分页品牌
|
||||
|
|
|
@ -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<ProductSpec> findByPage();
|
||||
}
|
|
@ -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<ProductSpec> findByPage(Integer page, Integer limit);
|
||||
}
|
|
@ -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<CategoryBrand> findByPage(Integer page, Integer limit, CategoryBrandDto dto) {
|
||||
PageHelper.startPage(page, limit).close();
|
||||
Page<Object> startPage = PageHelper.startPage(page, limit);
|
||||
List<CategoryBrand> categoryBrandList = categoryBrandMapper.findByPage(dto);
|
||||
|
||||
// 关闭资源
|
||||
startPage.close();
|
||||
return new PageInfo<>(categoryBrandList);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ProductSpec> findByPage(Integer page, Integer limit) {
|
||||
Page<Object> startPage = PageHelper.startPage(page, limit);
|
||||
List<ProductSpec> productSpecList = productSpecMapper.findByPage();
|
||||
|
||||
startPage.close();
|
||||
return new PageInfo<>(productSpecList);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?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.ProductSpecMapper">
|
||||
<!-- 用于select查询公用抽取的列 -->
|
||||
<sql id="columns">
|
||||
id,spec_name,spec_value,create_time,update_time,is_deleted
|
||||
</sql>
|
||||
|
||||
<!-- 列表查询 -->
|
||||
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.ProductSpec">
|
||||
select
|
||||
<include refid="columns"/>
|
||||
from product_spec
|
||||
where is_deleted = 0 order by id desc
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue