Commit 0c44b7f3 authored by shiyu's avatar shiyu

分页查询

parent bc789b62
package com.wwdz.ch.db.dao;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.db.dto.request.CoinRequestDto;
......@@ -12,6 +13,8 @@ public interface ItemManager {
List<Item> findList(CoinRequestDto coinRequestDto);
PageInfo<Item> findByPage(CoinRequestDto coinRequestDto);
Item findDetails(Long id);
boolean setCoin(Item item);
......
package com.wwdz.ch.db.dao.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.db.mapper.ItemMapper;
import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.db.domain.ItemExample;
......@@ -45,6 +47,18 @@ public class ItemManagerImpl implements ItemManager {
return itemMapper.selectByExample(example);
}
@Override
public PageInfo<Item> findByPage(CoinRequestDto coinRequestDto) {
ItemExample example = new ItemExample();
ItemExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(coinRequestDto.getId(), criteria :: andIdEqualTo);
JdbcHelper.ifPresent(coinRequestDto.getName(), criteria :: andNameLike);
JdbcHelper.ifPresent(coinRequestDto.getCid(), criteria :: andCidEqualTo);
PageHelper.startPage(coinRequestDto.getPage(), coinRequestDto.getLimit());
List<Item> list = itemMapper.selectByExample(example);
return new PageInfo<>(list);
}
@Override
public Item findDetails(Long id) {
ItemExample example = new ItemExample();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment