Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
brandkbs2
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
shenjunjie
brandkbs2
Commits
696ab642
Commit
696ab642
authored
Jun 28, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'dev'
Feature See merge request
!349
parents
ae7cf13b
910d03b4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
25 deletions
+43
-25
src/main/java/com/zhiwei/brandkbs2/controller/app/AppHotController.java
+34
-20
src/main/java/com/zhiwei/brandkbs2/service/impl/CommonServiceImpl.java
+4
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/UserServiceImpl.java
+3
-3
src/main/resources/application-local.properties
+2
-2
No files found.
src/main/java/com/zhiwei/brandkbs2/controller/app/AppHotController.java
View file @
696ab642
...
@@ -100,20 +100,24 @@ public class AppHotController extends BaseController {
...
@@ -100,20 +100,24 @@ public class AppHotController extends BaseController {
@RequestParam
(
value
=
"type"
,
defaultValue
=
"weibo"
)
String
type
,
@RequestParam
(
value
=
"type"
,
defaultValue
=
"weibo"
)
String
type
,
@RequestParam
(
value
=
"sort"
,
defaultValue
=
"endTime"
)
String
sort
,
@RequestParam
(
value
=
"sort"
,
defaultValue
=
"endTime"
)
String
sort
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
Long
startTime
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
Long
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
)
{
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
Long
endTime
,
JSONObject
result
=
searchHotHandler
(
pageSize
,
page
,
type
,
sort
,
startTime
,
endTime
);
@RequestParam
(
value
=
"contendId"
,
required
=
false
)
String
contendId
)
{
JSONObject
result
=
searchHotHandler
(
pageSize
,
page
,
type
,
sort
,
startTime
,
endTime
,
contendId
);
if
(
Objects
.
isNull
(
result
))
{
if
(
Objects
.
isNull
(
result
))
{
return
ResponseResult
.
success
();
return
ResponseResult
.
success
();
}
}
// 查询在榜数据
// 查询在榜数据
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
getForEntity
(
trendsListUrl
,
JSONObject
.
class
,
null
,
type
,
null
);
List
<
String
>
rankingIds
=
new
ArrayList
<>();
List
<
String
>
rankingIds
=
new
ArrayList
<>();
if
(
Objects
.
nonNull
(
responseEntity
.
getBody
()))
{
if
(!
allPlatform
.
equals
(
type
))
{
rankingIds
=
responseEntity
.
getBody
().
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
((
JSONObject
)
obj
).
getString
(
"_id"
)).
collect
(
Collectors
.
toList
());
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
getForEntity
(
trendsListUrl
,
JSONObject
.
class
,
null
,
type
,
null
);
if
(
Objects
.
nonNull
(
responseEntity
.
getBody
()))
{
rankingIds
=
responseEntity
.
getBody
().
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
((
JSONObject
)
obj
).
getString
(
"_id"
)).
collect
(
Collectors
.
toList
());
}
}
}
List
<
String
>
finalRankingIds
=
rankingIds
;
List
<
String
>
finalRankingIds
=
rankingIds
;
// 对比补录词
// 对比补录词
List
<
Object
>
valueList
=
redisUtil
.
getMapValueAll
(
RedisKeyPrefix
.
supplementWordKey
(
UserThreadLocal
.
getProjectId
()));
String
keyId
=
null
==
contendId
?
UserThreadLocal
.
getProjectId
()
:
contendId
;
List
<
Object
>
valueList
=
redisUtil
.
getMapValueAll
(
RedisKeyPrefix
.
supplementWordKey
(
keyId
));
List
<
String
>
supplementList
=
valueList
.
stream
().
map
(
word
->
JSON
.
parseObject
((
String
)
word
,
SupplementWord
.
class
).
getTitle
()).
collect
(
Collectors
.
toList
());
List
<
String
>
supplementList
=
valueList
.
stream
().
map
(
word
->
JSON
.
parseObject
((
String
)
word
,
SupplementWord
.
class
).
getTitle
()).
collect
(
Collectors
.
toList
());
List
<
JSONObject
>
list
=
result
.
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
{
List
<
JSONObject
>
list
=
result
.
getJSONArray
(
"data"
).
stream
().
map
(
obj
->
{
JSONObject
json
=
(
JSONObject
)
obj
;
JSONObject
json
=
(
JSONObject
)
obj
;
...
@@ -131,24 +135,28 @@ public class AppHotController extends BaseController {
...
@@ -131,24 +135,28 @@ public class AppHotController extends BaseController {
@ApiOperation
(
"热点库-品牌热点-关键词获取"
)
@ApiOperation
(
"热点库-品牌热点-关键词获取"
)
@GetMapping
(
"/keyword"
)
@GetMapping
(
"/keyword"
)
public
ResponseResult
getKeyword
()
{
public
ResponseResult
getKeyword
(
@ApiParam
(
name
=
"竞品id"
)
@RequestParam
(
required
=
false
)
String
contendId
)
{
String
projectId
=
UserThreadLocal
.
getProjectId
()
;
String
keyId
=
null
==
contendId
?
UserThreadLocal
.
getProjectId
()
:
contendId
;
String
key
=
RedisKeyPrefix
.
hotKeywordKey
(
project
Id
);
String
key
=
RedisKeyPrefix
.
hotKeywordKey
(
key
Id
);
String
keywordStr
=
redisUtil
.
get
(
key
);
String
keywordStr
=
redisUtil
.
get
(
key
);
if
(
null
==
keywordStr
)
{
if
(
null
!=
keywordStr
)
{
// 默认返回并设置品牌名
return
ResponseResult
.
success
(
JSONArray
.
parseArray
(
keywordStr
));
List
<
String
>
defaultKeyword
=
Collections
.
singletonList
(
projectService
.
getProjectById
(
projectId
).
getBrandName
());
}
// 主品牌则默认返回并设置品牌名
if
(
null
==
contendId
)
{
List
<
String
>
defaultKeyword
=
Collections
.
singletonList
(
projectService
.
getProjectById
(
keyId
).
getBrandName
());
redisUtil
.
set
(
key
,
JSON
.
toJSONString
(
defaultKeyword
));
redisUtil
.
set
(
key
,
JSON
.
toJSONString
(
defaultKeyword
));
return
ResponseResult
.
success
(
defaultKeyword
);
return
ResponseResult
.
success
(
defaultKeyword
);
}
}
return
ResponseResult
.
success
(
JSONArray
.
parseArray
(
keywordStr
)
);
return
ResponseResult
.
success
();
}
}
@ApiOperation
(
"热点库-品牌热点-关键词调整"
)
@ApiOperation
(
"热点库-品牌热点-关键词调整"
)
@PutMapping
(
"/keyword/update"
)
@PutMapping
(
"/keyword/update"
)
public
ResponseResult
updateKeyword
(
@RequestBody
JSONObject
json
)
{
public
ResponseResult
updateKeyword
(
@
ApiParam
(
name
=
"json:{list:关键词数组,contendId:竞品id}"
)
@
RequestBody
JSONObject
json
)
{
JSONArray
list
=
json
.
getJSONArray
(
"list"
);
JSONArray
list
=
json
.
getJSONArray
(
"list"
);
redisUtil
.
set
(
RedisKeyPrefix
.
hotKeywordKey
(
UserThreadLocal
.
getProjectId
()),
list
.
toJSONString
());
String
contendId
=
json
.
getString
(
"contendId"
);
redisUtil
.
set
(
RedisKeyPrefix
.
hotKeywordKey
(
null
==
contendId
?
UserThreadLocal
.
getProjectId
()
:
contendId
),
list
.
toJSONString
());
return
ResponseResult
.
success
();
return
ResponseResult
.
success
();
}
}
...
@@ -200,9 +208,10 @@ public class AppHotController extends BaseController {
...
@@ -200,9 +208,10 @@ public class AppHotController extends BaseController {
@ApiOperation
(
"热点库-根据热搜平台和标题匹配查询条件"
)
@ApiOperation
(
"热点库-根据热搜平台和标题匹配查询条件"
)
@GetMapping
(
"/match-criteria"
)
@GetMapping
(
"/match-criteria"
)
public
ResponseResult
matchSearchCriteria
(
@RequestParam
String
name
,
@RequestParam
String
type
)
{
public
ResponseResult
matchSearchCriteria
(
@RequestParam
String
name
,
@RequestParam
String
type
)
{
Long
[]
timeRangeMonth
=
commonService
.
getTimeRangeMonth
();
long
endTime
=
System
.
currentTimeMillis
();
long
startTime
=
endTime
-
Constant
.
ONE_MONTH
;
int
defaultPageSize
=
5
;
int
defaultPageSize
=
5
;
JSONObject
result
=
searchHotHandler
(
10000
,
1
,
HotPlatformEnum
.
convertFromName2Eng
(
type
),
"endTime"
,
timeRangeMonth
[
0
],
timeRangeMonth
[
1
]
);
JSONObject
result
=
searchHotHandler
(
10000
,
1
,
HotPlatformEnum
.
convertFromName2Eng
(
type
),
"endTime"
,
startTime
,
endTime
);
int
index
=
0
;
int
index
=
0
;
boolean
matched
=
false
;
boolean
matched
=
false
;
List
<
JSONObject
>
data
=
result
.
getJSONArray
(
"data"
).
toJavaList
(
JSONObject
.
class
);
List
<
JSONObject
>
data
=
result
.
getJSONArray
(
"data"
).
toJavaList
(
JSONObject
.
class
);
...
@@ -369,13 +378,14 @@ public class AppHotController extends BaseController {
...
@@ -369,13 +378,14 @@ public class AppHotController extends BaseController {
* @param endTime
* @param endTime
* @return
* @return
*/
*/
private
JSONObject
searchHotHandler
(
int
pageSize
,
int
page
,
String
type
,
String
sort
,
Long
startTime
,
Long
endTime
)
{
private
JSONObject
searchHotHandler
(
int
pageSize
,
int
page
,
String
type
,
String
sort
,
Long
startTime
,
Long
endTime
,
String
contendId
)
{
String
keywordStr
=
redisUtil
.
get
(
RedisKeyPrefix
.
hotKeywordKey
(
UserThreadLocal
.
getProjectId
()));
String
keyId
=
null
==
contendId
?
UserThreadLocal
.
getProjectId
()
:
contendId
;
String
keywordStr
=
redisUtil
.
get
(
RedisKeyPrefix
.
hotKeywordKey
(
keyId
));
if
(
null
==
keywordStr
)
{
if
(
null
==
keywordStr
)
{
return
null
;
return
null
;
}
}
String
accurateWord
=
null
;
String
accurateWord
=
null
;
List
<
Object
>
valueList
=
redisUtil
.
getMapValueAll
(
RedisKeyPrefix
.
supplementWordKey
(
UserThreadLocal
.
getProjectId
()
));
List
<
Object
>
valueList
=
redisUtil
.
getMapValueAll
(
RedisKeyPrefix
.
supplementWordKey
(
keyId
));
if
(
CollectionUtils
.
isNotEmpty
(
valueList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
valueList
))
{
List
<
String
>
collect
=
valueList
.
stream
().
map
(
word
->
JSON
.
parseObject
((
String
)
word
,
SupplementWord
.
class
).
getTitle
()).
collect
(
Collectors
.
toList
());
List
<
String
>
collect
=
valueList
.
stream
().
map
(
word
->
JSON
.
parseObject
((
String
)
word
,
SupplementWord
.
class
).
getTitle
()).
collect
(
Collectors
.
toList
());
accurateWord
=
StringUtils
.
join
(
collect
,
"|"
);
accurateWord
=
StringUtils
.
join
(
collect
,
"|"
);
...
@@ -390,6 +400,10 @@ public class AppHotController extends BaseController {
...
@@ -390,6 +400,10 @@ public class AppHotController extends BaseController {
return
jsonObjectResponseEntity
.
getBody
();
return
jsonObjectResponseEntity
.
getBody
();
}
}
private
JSONObject
searchHotHandler
(
int
pageSize
,
int
page
,
String
type
,
String
sort
,
Long
startTime
,
Long
endTime
)
{
return
searchHotHandler
(
pageSize
,
page
,
type
,
sort
,
startTime
,
endTime
,
null
);
}
private
JSONObject
contrastReport
(
List
<
JSONObject
>
source
,
Long
[]
timeRange
,
Long
space
)
{
private
JSONObject
contrastReport
(
List
<
JSONObject
>
source
,
Long
[]
timeRange
,
Long
space
)
{
JSONObject
result
=
new
JSONObject
();
JSONObject
result
=
new
JSONObject
();
List
<
JSONObject
>
list
=
source
.
stream
().
filter
(
json
->
json
.
getLong
(
"startTime"
)
>=
timeRange
[
0
]).
collect
(
Collectors
.
toList
());
List
<
JSONObject
>
list
=
source
.
stream
().
filter
(
json
->
json
.
getLong
(
"startTime"
)
>=
timeRange
[
0
]).
collect
(
Collectors
.
toList
());
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/CommonServiceImpl.java
View file @
696ab642
...
@@ -166,6 +166,10 @@ public class CommonServiceImpl implements CommonService {
...
@@ -166,6 +166,10 @@ public class CommonServiceImpl implements CommonService {
Date
date
=
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
);
Date
date
=
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
);
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
setTime
(
date
);
// 如果是周日
if
(
calendar
.
get
(
Calendar
.
DAY_OF_WEEK
)
==
Calendar
.
SUNDAY
)
{
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
-
1
);
}
calendar
.
set
(
Calendar
.
DAY_OF_WEEK
,
1
);
calendar
.
set
(
Calendar
.
DAY_OF_WEEK
,
1
);
startTime
=
calendar
.
getTime
().
getTime
();
startTime
=
calendar
.
getTime
().
getTime
();
calendar
.
set
(
Calendar
.
DAY_OF_WEEK
,
7
);
calendar
.
set
(
Calendar
.
DAY_OF_WEEK
,
7
);
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/UserServiceImpl.java
View file @
696ab642
...
@@ -171,12 +171,12 @@ public class UserServiceImpl implements UserService {
...
@@ -171,12 +171,12 @@ public class UserServiceImpl implements UserService {
newUser
.
setNickname
(
userDTO
.
getNickname
());
newUser
.
setNickname
(
userDTO
.
getNickname
());
newUser
.
setRoles
(
Collections
.
singletonList
(
UserRole
.
createFromUserDto
(
userDTO
)));
newUser
.
setRoles
(
Collections
.
singletonList
(
UserRole
.
createFromUserDto
(
userDTO
)));
newUser
.
setSuperAdmin
(
false
);
newUser
.
setSuperAdmin
(
false
);
userDao
.
insertOne
(
newUser
);
userCenterService
.
addProduct
(
newUser
.
getId
());
}
else
{
}
else
{
newUser
=
User
.
createFromUserDTO
(
userDTO
,
nickname
);
newUser
=
User
.
createFromUserDTO
(
userDTO
,
nickname
);
userDao
.
insertOne
(
newUser
);
}
}
userDao
.
insertOne
(
newUser
);
// 通知用户中心开通权限
userCenterService
.
addProduct
(
newUser
.
getId
());
return
ResponseResult
.
success
();
return
ResponseResult
.
success
();
}
}
List
<
UserRole
>
roles
=
user
.
getRoles
();
List
<
UserRole
>
roles
=
user
.
getRoles
();
...
...
src/main/resources/application-local.properties
View file @
696ab642
...
@@ -87,8 +87,8 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
...
@@ -87,8 +87,8 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.longTimeInListSearchByInner.url
=
https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.findHotSearchESDataInTimeByInner.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.longTimeInListSearch.url
=
https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.getHotSearchFromEsInTimeAndTypeOrWord.url
=
http
://192.168.0.192:9091/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5
}&accurateWord={6}
trends.getHotSearchFromEsInTimeAndTypeOrWord.url
=
http
s://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5
\
}
&accurateWord={6}
trends.queryHotSearchTrendInner.url
=
http
://192.168.27.203:9094
/hotSearchTrend/inner/queryHotSearchTrendInner?name={1}&startTime={2}&type={3}
trends.queryHotSearchTrendInner.url
=
http
s://trends.zhiweidata.com
/hotSearchTrend/inner/queryHotSearchTrendInner?name={1}&startTime={2}&type={3}
trends.getHotSearchSnapshot.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchSnapshot?type={1}&time={2}&rank={3}
trends.getHotSearchSnapshot.url
=
https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchSnapshot?type={1}&time={2}&rank={3}
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
...
...
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