分类分页查询
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.sky.service;
|
||||
|
||||
import com.sky.dto.CategoryPageQueryDTO;
|
||||
import com.sky.result.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface CategoryService {
|
||||
/**
|
||||
* 分类分页查询
|
||||
* @param categoryPageQueryDTO
|
||||
* @return
|
||||
*/
|
||||
PageResult pageQuery(CategoryPageQueryDTO categoryPageQueryDTO);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.sky.service.impl;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.sky.dto.CategoryPageQueryDTO;
|
||||
import com.sky.entity.Category;
|
||||
import com.sky.mapper.CategoryMapper;
|
||||
import com.sky.result.PageResult;
|
||||
import com.sky.service.CategoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CategoryServiceImpl implements CategoryService {
|
||||
|
||||
@Autowired
|
||||
private CategoryMapper categoryMapper;
|
||||
|
||||
/**
|
||||
* 分类分页查询
|
||||
* @param categoryPageQueryDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageResult pageQuery(CategoryPageQueryDTO categoryPageQueryDTO) {
|
||||
//设置分页
|
||||
PageHelper.startPage(categoryPageQueryDTO.getPage(), categoryPageQueryDTO.getPageSize());
|
||||
|
||||
Page<Category> page = categoryMapper.pageQuery(categoryPageQueryDTO);
|
||||
|
||||
long total = page.getTotal();
|
||||
List<Category> result = page.getResult();
|
||||
|
||||
return new PageResult(total,result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user