|
|
@@ -19,6 +19,7 @@ import com.jfinal.plugin.activerecord.Page;
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
import com.jfinal.plugin.ehcache.IDataLoader;
|
|
|
import io.jpress.model.Content;
|
|
|
+import io.jpress.model.Taxonomy;
|
|
|
import io.jpress.model.core.Jdb;
|
|
|
import io.jpress.model.vo.Archive;
|
|
|
import io.jpress.template.TemplateManager;
|
|
|
@@ -130,7 +131,7 @@ public class ContentQuery extends JBaseQuery {
|
|
|
|
|
|
}
|
|
|
|
|
|
- sql.append(" WHERE c.status = 'normal' ");
|
|
|
+ sql.append(" WHERE c.status != 'normal' ");
|
|
|
|
|
|
appendIfNotEmpty(sql, "c.module", module, params, false);
|
|
|
|
|
|
@@ -557,7 +558,33 @@ public class ContentQuery extends JBaseQuery {
|
|
|
}
|
|
|
if(index==list.size()-1){return null;}
|
|
|
content = list.get(index+1);
|
|
|
- }else{
|
|
|
+ } else if ("news".equals(currentContent.getModule())) {
|
|
|
+ List<Content> list = DAO.getFromListCache(buildKey(currentContent.getModule(), "next:" + currentContent.getId()),
|
|
|
+ new IDataLoader() {
|
|
|
+ @Override
|
|
|
+ public Object load() {
|
|
|
+ StringBuilder sqlBuilder = new StringBuilder(" select c.* from content c ,mapping m, taxonomy t where c.module='news' and c.status!='normal' and m.content_id=c.id and m.taxonomy_id=t.id and t.type = 'category' ");
|
|
|
+ List<Taxonomy> taxonomys = currentContent.getTaxonomys();
|
|
|
+ for (int i = 0; i < taxonomys.size(); i++) {
|
|
|
+ String slug = taxonomys.get(i).getSlug();
|
|
|
+ if ("tradeNews".equals(slug) || "companyDynamic".equals(slug)) {
|
|
|
+ sqlBuilder.append(" and t.slug = '" + slug +"'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sqlBuilder.append(" order by c.created asc");
|
|
|
+
|
|
|
+ return DAO.find(sqlBuilder.toString());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ int index = 0;
|
|
|
+ for(int i=0;i<list.size();i++){
|
|
|
+ if (list.get(i).getId().toString().equals(currentContent.getId().toString())){
|
|
|
+ index = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(index==list.size()-1){return null;}
|
|
|
+ content = list.get(index+1);
|
|
|
+ } else{
|
|
|
content = DAO.getFromListCache(buildKey(currentContent.getModule(), "next:" + currentContent.getId()),
|
|
|
new IDataLoader() {
|
|
|
@Override
|
|
|
@@ -620,7 +647,35 @@ public class ContentQuery extends JBaseQuery {
|
|
|
return null;
|
|
|
}
|
|
|
content = list.get(index - 1);
|
|
|
- }else{
|
|
|
+ } else if ("news".equals(currentContent.getModule())) {
|
|
|
+ List<Content> list = DAO.getFromListCache(buildKey(currentContent.getModule(), "previous:" + currentContent.getId()),
|
|
|
+ new IDataLoader() {
|
|
|
+ @Override
|
|
|
+ public Object load() {
|
|
|
+ StringBuilder sqlBuilder = new StringBuilder(" select c.* from content c ,mapping m, taxonomy t where c.module='news' and c.status!='normal' and m.content_id=c.id and m.taxonomy_id=t.id and t.type = 'category' ");
|
|
|
+ List<Taxonomy> taxonomys = currentContent.getTaxonomys();
|
|
|
+ for (int i = 0; i < taxonomys.size(); i++) {
|
|
|
+ String slug = taxonomys.get(i).getSlug();
|
|
|
+ if ("tradeNews".equals(slug) || "companyDynamic".equals(slug)) {
|
|
|
+ sqlBuilder.append(" and t.slug = '" + slug +"'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sqlBuilder.append(" order by c.created asc");
|
|
|
+
|
|
|
+ return DAO.find(sqlBuilder.toString());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ int index = 0;
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ if (list.get(i).getId().toString().equals(currentContent.getId().toString())) {
|
|
|
+ index = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (index == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ content = list.get(index - 1);
|
|
|
+ } else{
|
|
|
content = DAO.getFromListCache(buildKey(currentContent.getModule(), "previous:" + currentContent.getId()),
|
|
|
new IDataLoader() {
|
|
|
@Override
|