Commit f3df8331 by chenweitao

Merge branch 'working' into 'master'

修改热搜多条储存方式

See merge request !121
parents dedaa7f5 a252c834
......@@ -32,7 +32,7 @@ public class HotSearchListDAO{
public HotSearchListDAO() {
String time = TimeParse.dateFormartString(new Date(), "yyyy-MM-dd");
String year = time.substring(0,4);
String month = time.substring(5,7);
String month = time.substring(5,7);
String collName = DBConfig.searchCollName + year + "_" + month;
mongoCollection = mongoDatabase.getCollection(collName);
......@@ -43,19 +43,21 @@ public class HotSearchListDAO{
/**
* 添加数据入库
* @param list
*/
public void addHotSearchList(List<Document> list){
try {
mongoCollection.insertMany(list);
for (Document document : list) {
addHotSearch(document);
}
} catch (Exception e) {
log.error("存储数据时出错,错误为:{}", e);
}
}
public void addHotSearch(Document doc){
try {
mongoCollection.insertOne(doc);
......@@ -92,5 +94,5 @@ public class HotSearchListDAO{
mongoCollection.replaceOne(basicDBObject,document);
}
}
}
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