- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
int limit = 10;
int countNews = daoService.getCountNews();
int currentPage = 1;
if (linkOffset != 0) {
currentPage += linkOffset / limit;
}
int offset = countNews - (linkOffset + limit);
if (offset < 0) {
offset = 0;
limit = (countNews - (linkOffset + limit)) + limit;
}
List newsList = daoService.getLimitNews(limit, offset);
List news = new ArrayList();
int index = 0;
for (int i = newsList.size() - 1; i >= 0; i--) {
news.add(index, newsList.get(i));
index++;
}
//DaoService.getLimitNews:
public List getLimitNews(String owner, int limit, int offset) {
return super.getSimpleJdbcTemplate().query(
"SELECT * FROM news WHERE owner=? AND apply=? AND local=? "
+ "ORDER BY created limit ? offset ?",
new NewsMapper(),
owner, true, true, limit, offset);
}
Получение списка новостей в ленте в обратном хронологическом порядке.
Lure Of Chaos 25.01.2012 23:53 # 0
bugmenot 26.01.2012 11:40 # +2
0rt 26.01.2012 13:17 # 0