diff --git a/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java b/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java index 2af2b3f..3ff9e10 100644 --- a/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java +++ b/src/main/java/net/lamgc/cgj/bot/BotCommandProcess.java @@ -9,6 +9,7 @@ import net.lamgc.cgj.bot.cache.CacheStore; import net.lamgc.cgj.bot.cache.CacheStoreCentral; import net.lamgc.cgj.bot.cache.JsonRedisCacheStore; import net.lamgc.cgj.bot.event.BufferMessageEvent; +import net.lamgc.cgj.bot.sort.PreLoadDataAttribute; import net.lamgc.cgj.bot.sort.PreLoadDataComparator; import net.lamgc.cgj.pixiv.PixivDownload; import net.lamgc.cgj.pixiv.PixivDownload.PageQuality; @@ -109,11 +110,11 @@ public class BotCommandProcess { "\n作品标题:" + illustPreLoadData.get("illustTitle").getAsString() + "\n作者(作者Id):" + illustPreLoadData.get("userName").getAsString() + "(" + illustPreLoadData.get("userId").getAsInt() + ")" + - "\n点赞数:" + illustPreLoadData.get(PreLoadDataComparator.Attribute.LIKE.attrName).getAsInt() + - "\n收藏数:" + illustPreLoadData.get(PreLoadDataComparator.Attribute.BOOKMARK.attrName).getAsInt() + - "\n围观数:" + illustPreLoadData.get(PreLoadDataComparator.Attribute.VIEW.attrName).getAsInt() + - "\n评论数:" + illustPreLoadData.get(PreLoadDataComparator.Attribute.COMMENT.attrName).getAsInt() + - "\n页数:" + illustPreLoadData.get(PreLoadDataComparator.Attribute.PAGE.attrName).getAsInt() + "页" + + "\n点赞数:" + illustPreLoadData.get(PreLoadDataAttribute.LIKE.attrName).getAsInt() + + "\n收藏数:" + illustPreLoadData.get(PreLoadDataAttribute.BOOKMARK.attrName).getAsInt() + + "\n围观数:" + illustPreLoadData.get(PreLoadDataAttribute.VIEW.attrName).getAsInt() + + "\n评论数:" + illustPreLoadData.get(PreLoadDataAttribute.COMMENT.attrName).getAsInt() + + "\n页数:" + illustPreLoadData.get(PreLoadDataAttribute.PAGE.attrName).getAsInt() + "页" + "\n作品链接:" + artworksLink(fromGroup, illustId) + "\n" + "---------------- 作品图片 ----------------\n" + CacheStoreCentral.getCentral().getImageById(fromGroup, illustId, PageQuality.REGULAR, 1) + "\n" + @@ -337,7 +338,7 @@ public class BotCommandProcess { .getAsJsonObject(searchArea.jsonKey).getAsJsonArray("data"); ArrayList illustsList = new ArrayList<>(); illustsArray.forEach(illustsList::add); - illustsList.sort(new PreLoadDataComparator(PreLoadDataComparator.Attribute.LIKE)); + illustsList.sort(new PreLoadDataComparator(PreLoadDataAttribute.LIKE)); log.debug("已找到与 {} 相关插图信息({}):", content, searchArea.name().toLowerCase()); int count = 1; @@ -394,13 +395,13 @@ public class BotCommandProcess { .append("\n\t作品标题: ").append(illustObj.get("illustTitle").getAsString()) .append("\n\t作品页数: ").append(illustObj.get("pageCount").getAsInt()).append("页") .append("\n\t点赞数:") - .append(illustPreLoadData.get(PreLoadDataComparator.Attribute.LIKE.attrName).getAsInt()) + .append(illustPreLoadData.get(PreLoadDataAttribute.LIKE.attrName).getAsInt()) .append("\n\t收藏数:") - .append(illustPreLoadData.get(PreLoadDataComparator.Attribute.BOOKMARK.attrName).getAsInt()) + .append(illustPreLoadData.get(PreLoadDataAttribute.BOOKMARK.attrName).getAsInt()) .append("\n\t围观数:") - .append(illustPreLoadData.get(PreLoadDataComparator.Attribute.VIEW.attrName).getAsInt()) + .append(illustPreLoadData.get(PreLoadDataAttribute.VIEW.attrName).getAsInt()) .append("\n\t评论数:") - .append(illustPreLoadData.get(PreLoadDataComparator.Attribute.COMMENT.attrName).getAsInt()) + .append(illustPreLoadData.get(PreLoadDataAttribute.COMMENT.attrName).getAsInt()) .append("\n").append(imageMsg).append("\n"); count++; totalCount++; diff --git a/src/main/java/net/lamgc/cgj/bot/sort/PreLoadDataAttribute.java b/src/main/java/net/lamgc/cgj/bot/sort/PreLoadDataAttribute.java new file mode 100644 index 0000000..095aa9a --- /dev/null +++ b/src/main/java/net/lamgc/cgj/bot/sort/PreLoadDataAttribute.java @@ -0,0 +1,41 @@ +package net.lamgc.cgj.bot.sort; + +@SuppressWarnings("unused") +public enum PreLoadDataAttribute { + /** + * 按点赞数排序 + */ + LIKE("likeCount"), + + /** + * 按页面数排序 + */ + PAGE("pageCount"), + + /** + * 按收藏数排序 + */ + BOOKMARK("bookmarkCount"), + + /** + * 按评论数排序 + */ + COMMENT("commentCount"), + + /** + * 不明 + */ + RESPONSE("responseCount"), + + /** + * 按查看次数排序 + */ + VIEW("viewCount"), + ; + + public final String attrName; + + PreLoadDataAttribute(String attrName) { + this.attrName = attrName; + } +} \ No newline at end of file diff --git a/src/main/java/net/lamgc/cgj/bot/sort/PreLoadDataComparator.java b/src/main/java/net/lamgc/cgj/bot/sort/PreLoadDataComparator.java index 5b9aaa9..369a2c5 100644 --- a/src/main/java/net/lamgc/cgj/bot/sort/PreLoadDataComparator.java +++ b/src/main/java/net/lamgc/cgj/bot/sort/PreLoadDataComparator.java @@ -12,9 +12,9 @@ import java.util.Comparator; */ public class PreLoadDataComparator implements Comparator { - private final Attribute attribute; + private final PreLoadDataAttribute attribute; - public PreLoadDataComparator(Attribute attribute) { + public PreLoadDataComparator(PreLoadDataAttribute attribute) { this.attribute = attribute; } @@ -52,44 +52,4 @@ public class PreLoadDataComparator implements Comparator { } } - public enum Attribute { - /** - * 按点赞数排序 - */ - LIKE("likeCount"), - - /** - * 按页面数排序 - */ - PAGE("pageCount"), - - /** - * 按收藏数排序 - */ - BOOKMARK("bookmarkCount"), - - /** - * 按评论数排序 - */ - COMMENT("commentCount"), - - /** - * 不明 - */ - RESPONSE("responseCount"), - - /** - * 按查看次数排序 - */ - VIEW("viewCount"), - ; - - public final String attrName; - - Attribute(String attrName) { - this.attrName = attrName; - } - } - - }