Commit 64bf0be4 by zhiwei

修复计算热搜时间错误的问题

parent 931e03e7
......@@ -63,7 +63,7 @@ public class HotSearchCacheDAO {
int lastRank = document.getInteger("rank")!=null?document.getInteger("rank"): -1;
int lastCount = document.getInteger("count")!=null?document.getInteger("count"): -1;
Date startTime = document.getDate("time");
Date endTime = new Date(startTime.getTime() + (60 * 1000));
Date endTime = getEndTime(type, startTime);
String topicLead = document.getString("topic_lead")!=null?document.getString("topic_lead"):null;
boolean hot = document.getBoolean("hot")!=null?document.getBoolean("hot"):true;
String url = document.getString("url")!=null?document.getString("url"):null;
......@@ -85,7 +85,7 @@ public class HotSearchCacheDAO {
//计算热搜时长
int duration = nowDoc.getInteger("duration");
int durationNow = getDuration(type, duration);
endTime = new Date(System.currentTimeMillis() + (60 * 1000));
endTime = getEndTime(type, new Date());
//更新相应信息
nowDoc.put("endTime", endTime);
nowDoc.put("lastRank", lastRank);
......@@ -155,6 +155,42 @@ public class HotSearchCacheDAO {
}
/**
* 计算结束时间
* @param type
* @param time
* @return
*/
private Date getEndTime(String type, Date time){
long timeLong = time.getTime();
switch (type){
case "微博热搜" :
timeLong = timeLong + 1*60*1000;
break;
case "百度热搜" :
timeLong = timeLong + 5*60*1000;
break;
case "知乎热搜" :
timeLong = timeLong + 10*60*1000;
break;
case "抖音热搜" :
timeLong = timeLong + 10*60*1000;
break;
case "搜狗微信热搜" :
timeLong = timeLong + 5*60*1000;
break;
case "微博话题" :
timeLong = timeLong + 3*60*1000;
break;
case "今日头条热搜" :
timeLong = timeLong + 1*60*1000;
break;
default :
timeLong = timeLong + 1*60*1000;
}
return new Date(timeLong);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment