Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
searchhotcrawler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhiwei
searchhotcrawler
Commits
f3df8331
Commit
f3df8331
authored
Jul 21, 2021
by
chenweitao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'working' into 'master'
修改热搜多条储存方式 See merge request
!121
parents
dedaa7f5
a252c834
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchListDAO.java
+7
-5
No files found.
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchListDAO.java
View file @
f3df8331
...
@@ -32,7 +32,7 @@ public class HotSearchListDAO{
...
@@ -32,7 +32,7 @@ public class HotSearchListDAO{
public
HotSearchListDAO
()
{
public
HotSearchListDAO
()
{
String
time
=
TimeParse
.
dateFormartString
(
new
Date
(),
"yyyy-MM-dd"
);
String
time
=
TimeParse
.
dateFormartString
(
new
Date
(),
"yyyy-MM-dd"
);
String
year
=
time
.
substring
(
0
,
4
);
String
year
=
time
.
substring
(
0
,
4
);
String
month
=
time
.
substring
(
5
,
7
);
String
month
=
time
.
substring
(
5
,
7
);
String
collName
=
DBConfig
.
searchCollName
+
year
+
"_"
+
month
;
String
collName
=
DBConfig
.
searchCollName
+
year
+
"_"
+
month
;
mongoCollection
=
mongoDatabase
.
getCollection
(
collName
);
mongoCollection
=
mongoDatabase
.
getCollection
(
collName
);
...
@@ -43,19 +43,21 @@ public class HotSearchListDAO{
...
@@ -43,19 +43,21 @@ public class HotSearchListDAO{
/**
/**
* 添加数据入库
* 添加数据入库
* @param list
* @param list
*/
*/
public
void
addHotSearchList
(
List
<
Document
>
list
){
public
void
addHotSearchList
(
List
<
Document
>
list
){
try
{
try
{
mongoCollection
.
insertMany
(
list
);
for
(
Document
document
:
list
)
{
addHotSearch
(
document
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"存储数据时出错,错误为:{}"
,
e
);
log
.
error
(
"存储数据时出错,错误为:{}"
,
e
);
}
}
}
}
public
void
addHotSearch
(
Document
doc
){
public
void
addHotSearch
(
Document
doc
){
try
{
try
{
mongoCollection
.
insertOne
(
doc
);
mongoCollection
.
insertOne
(
doc
);
...
@@ -92,5 +94,5 @@ public class HotSearchListDAO{
...
@@ -92,5 +94,5 @@ public class HotSearchListDAO{
mongoCollection
.
replaceOne
(
basicDBObject
,
document
);
mongoCollection
.
replaceOne
(
basicDBObject
,
document
);
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment