public List<ThanksgivingVideoDataVO> listWithPagerQuery(Query query) {
if (!query.containsKey("sidx")) {
List<ThanksgivingVideoDataVO> listThanksgivingVideo = thanksgivingVideoDataDao.listWithPagerQuery(query);
Comparator<ThanksgivingVideoDataVO> comparator = new Comparator<ThanksgivingVideoDataVO>() {
@Override
public int compare(ThanksgivingVideoDataVO o1, ThanksgivingVideoDataVO o2) {
if (o1.getCollectionNum() < o2.getCollectionNum()) {
return 1;
} else if (o1.getCollectionNum() == o2.getCollectionNum()) {
return 0;
} else {
return -1;
}
}
};
listThanksgivingVideo.sort(comparator);
for (int i = 0, s = listThanksgivingVideo.size(); i < s; i++) {
if (i > 0 && listThanksgivingVideo.get(i).getCollectionNum() == listThanksgivingVideo.get(i - 1).getCollectionNum()) {
listThanksgivingVideo.get(i).setRanking(listThanksgivingVideo.get(i - 1).getRanking());
} else {
listThanksgivingVideo.get(i).setRanking(i + 1);
}
}
return listThanksgivingVideo;
} else {
return thanksgivingVideoDataDao.listWithPagerQuery(query);
}
}
网友评论