public Pagination getPageByRight(String title, Integer typeId,
Integer inputUserId, boolean topLevel, boolean recommend,
ContentStatus status, Byte checkStep, Integer siteId,
Integer channelId, Integer userId, boolean selfData, int orderBy,
int pageNo, int pageSize) {
Finder f = Finder.create("select bean from Content bean");
if (prepared == status || passed == status || rejected == status) {
f.append(" join bean.contentCheckSet check");
}
f.append(" join bean.channel channel join channel.users user");
if (channelId != null) {
f.append(",Channel parent");
f.append(" where channel.lft between parent.lft and parent.rgt");
f.append(" and channel.site.id=parent.site.id");
f.append(" and parent.id=:parentId");
f.setParam("parentId", channelId);
f.append(" and user.id=:userId");
f.setParam("userId", userId);
} else if (siteId != null) {
f.append(" where user.id=:userId");
f.setParam("userId", userId);
f.append(" and bean.site.id=:siteId");
f.setParam("siteId", siteId);
} else {
f.append(" where user.id=:userId");
f.setParam("userId", userId);
}
if (selfData) {
// userId前面已赋值
f.append(" and bean.user.id=:userId");
}
if (prepared == status) {
f.append(" and check.checkStep<:checkStep");
f.append(" and check.rejected=false");
f.setParam("checkStep", checkStep);
} else if (passed == status) {
f.append(" and check.checkStep=:checkStep");
f.append(" and check.rejected=false");
f.setParam("checkStep", checkStep);
} else if (rejected == status) {
f.append(" and check.checkStep=:checkStep");
f.append(" and check.rejected=true");
f.setParam("checkStep", checkStep);
}
appendQuery(f, title, typeId, inputUserId, status, topLevel, recommend);
if (prepared == status) {
f.append(" order by check.checkStep desc,bean.id desc");
} else {
appendOrder(f, orderBy);
}
return find(f, pageNo, pageSize);
}