Skip to content

Commit

Permalink
🚑 fixed previous page next theme function error
Browse files Browse the repository at this point in the history
  • Loading branch information
hellokaton committed Dec 12, 2017
1 parent d437500 commit 099a7e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/tale/extension/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public static String show_thumb(Contents contents) {
*/
public static Contents article_next() {
Contents cur = current_article();
return null != cur ? siteService.getNhContent(Types.NEXT, cur.getCid()) : null;
return null != cur ? siteService.getNhContent(Types.NEXT, cur.getCreated()) : null;
}

/**
Expand All @@ -354,7 +354,7 @@ public static Contents article_next() {
*/
public static Contents article_prev() {
Contents cur = current_article();
return null != cur ? siteService.getNhContent(Types.PREV, cur.getCid()) : null;
return null != cur ? siteService.getNhContent(Types.PREV, cur.getCreated()) : null;
}

/**
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/tale/service/SiteService.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,17 @@ public List<Metas> getMetas(String searchType, String type, int limit) {
* 获取相邻的文章
*
* @param type 上一篇:prev | 下一篇:next
* @param cid 当前文章id
* @param created 当前文章创建时间
*/
public Contents getNhContent(String type, Integer cid) {
public Contents getNhContent(String type, Integer created) {
Contents contents = null;
if (Types.NEXT.equals(type)) {
return new Contents().where("type", Types.ARTICLE).and("status", Types.PUBLISH).and("cid", ">", cid).find();
contents = new Contents().query("SELECT * FROM t_contents WHERE type = ? AND status = ? AND created > ? ORDER BY created ASC LIMIT 1", Types.ARTICLE, Types.PUBLISH, created);
}
if (Types.PREV.equals(type)) {
return new Contents().where("type", Types.ARTICLE).and("status", Types.PUBLISH).and("cid", "<", cid).find();
contents = new Contents().query("SELECT * FROM t_contents WHERE type = ? AND status = ? AND created < ? ORDER BY created DESC LIMIT 1", Types.ARTICLE, Types.PUBLISH, created);
}
return null;
return contents;
}

/**
Expand Down

0 comments on commit 099a7e8

Please sign in to comment.