}
private Finder byChannelIds(Integer[] channelIds, Integer[] typeIds,
Boolean titleImg, Boolean recommend, String title, int orderBy,
int option) {
Finder f = Finder.create();
int len = channelIds.length;
// 如果多个栏目
if (option == 0 || len > 1) {
f.append("select bean from Content bean");
f.append(" join bean.contentExt as ext");
if (len == 1) {
f.append(" where bean.channel.id=:channelId");
f.setParam("channelId", channelIds[0]);
} else {
f.append(" where bean.channel.id in (:channelIds)");
f.setParamList("channelIds", channelIds);
}
} else if (option == 1) {
// 包含子栏目
f.append("select bean from Content bean");
f.append(" join bean.contentExt as ext");
f.append(" join bean.channel node,Channel parent");
f.append(" where node.lft between parent.lft and parent.rgt");
f.append(" and bean.site.id=parent.site.id");
f.append(" and parent.id=:channelId");
f.setParam("channelId", channelIds[0]);
} else if (option == 2) {
// 包含副栏目
f.append("select bean from Content bean");
f.append(" join bean.contentExt as ext");
f.append(" join bean.channels as channel");
f.append(" where channel.id=:channelId");
f.setParam("channelId", channelIds[0]);
} else {
throw new RuntimeException("option value must be 0 or 1 or 2.");
}
if (titleImg != null) {
f.append(" and bean.hasTitleImg=:titleImg");
f.setParam("titleImg", titleImg);
}
if (recommend != null) {
f.append(" and bean.recommend=:recommend");
f.setParam("recommend", recommend);
}
appendReleaseDate(f);
appendTypeIds(f, typeIds);
f.append(" and bean.status=" + ContentCheck.CHECKED);
if (!StringUtils.isBlank(title)) {
f.append(" and bean.contentExt.title like :title");
f.setParam("title", "%" + title + "%");
}
appendOrder(f, orderBy);
return f;
}