1. Analysis of page
2. Because taotao-common shared independent of other sub-projects, so here the new data show POJO class EasyUIDataGridResult follows:
3.POJO-like sequences of
4. Create an interface ItemService
ItemService.java
com.taotao.service Package; Import com.taotao.common.pojo.EasyUIDataGridResult; / ** * processing related merchandise-Service * @title ItemService.java * <P> Description </ P> * @author * 1.0 @version * / public interface ItemService { / ** * pagination query according to the current page number and the number of lines per page * @param Page * @param rows * @return * / public EasyUIDataGridResult GetItemList (Page Integer, Integer rows); }
The new implementation class ItemServiceImpl
ItemServiceImpl.java
package com.taotao.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.taotao.common.pojo.EasyUIDataGridResult; import com.taotao.mapper.TbItemMapper; import com.taotao.pojo.TbItem; import com.taotao.pojo.TbItemExample; import com.taotao.service.ItemService; @Service public class ItemServiceImpl implements ItemService { @Autowired private TbItemMapper mapper; @Override public EasyUIDataGridResult getItemList(Integer page, Integer rows) { // set page 1. Information used pagehelper if (page == null) Page =. 1; IF (rows == null) rows = 30; PageHelper.startPage (Page, rows); // 2. Mapper injection // example 3. Create objects need not be provided query TbItemExample Example TbItemExample new new = (); // call to query all 4. the data mapper method List <TbItem> List = mapper.selectByExample (Example); // 5. the paging information acquired PageInfo <TbItem> info = new PageInfo <> (List); // 6. the encapsulated EasyUIDataGridResult EasyUIDataGridResult new new EasyUIDataGridResult Result = (); result.setTotal ((int) info.getTotal ()); result.setRows (info.getList ()); //. 7 Returning to return Result; } }
6. Modify applicationContext-service.xml