public Pagination getPage(Integer siteId, Integer sendUserId,
Integer receiverUserId, String title, Date sendBeginTime,
Date sendEndTime, Boolean status, Integer box, Boolean cacheable,
int pageNo, int pageSize) {
String hql = " select msg from CmsReceiverMessage msg where 1=1 ";
Finder finder = Finder.create(hql);
if (siteId != null) {
finder.append(" and msg.site.id=:siteId")
.setParam("siteId", siteId);
}
// 垃圾箱
if (sendUserId != null && receiverUserId != null) {
finder
.append(
" and ((msg.msgReceiverUser.id=:receiverUserId and msg.msgBox =:box) or (msg.msgSendUser.id=:sendUserId and msg.msgBox =:box) )")
.setParam("sendUserId", sendUserId).setParam(
"receiverUserId", receiverUserId).setParam("box",
box);
} else {
if (sendUserId != null) {
finder.append(" and msg.msgSendUser.id=:sendUserId").setParam(
"sendUserId", sendUserId);
}
if (receiverUserId != null) {
finder.append(" and msg.msgReceiverUser.id=:receiverUserId")
.setParam("receiverUserId", receiverUserId);
}
if (box != null) {
finder.append(" and msg.msgBox =:box").setParam("box", box);
}
}
if (StringUtils.isNotBlank(title)) {
finder.append(" and msg.msgTitle like:title").setParam("title",
"%" + title + "%");
}
if (sendBeginTime != null) {
finder.append(" and msg.sendTime >=:sendBeginTime").setParam(
"sendBeginTime", sendBeginTime);
}
if (sendEndTime != null) {
finder.append(" and msg.sendTime <=:sendEndTime").setParam(
"sendEndTime", sendEndTime);
}
if (status != null) {
if (status) {
finder.append(" and msg.msgStatus =true");
} else {
finder.append(" and msg.msgStatus =false");
}
}
finder.append(" order by msg.id desc");
return find(finder, pageNo, pageSize);
}