Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
06fb196e
Commit
06fb196e
authored
Aug 02, 2021
by
张辰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加圈子支持
parent
41c4373d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
3 deletions
+12
-3
VisitLogMapper.java
.../tanpu/community/dao/mapper/community/VisitLogMapper.java
+2
-2
VisitSummaryManager.java
...java/com/tanpu/community/manager/VisitSummaryManager.java
+9
-0
VisitLogService.java
...ain/java/com/tanpu/community/service/VisitLogService.java
+1
-1
No files found.
community-service/src/main/java/com/tanpu/community/dao/mapper/community/VisitLogMapper.java
View file @
06fb196e
...
@@ -21,8 +21,8 @@ import java.util.List;
...
@@ -21,8 +21,8 @@ import java.util.List;
* @since 2021-07-28
* @since 2021-07-28
*/
*/
public
interface
VisitLogMapper
extends
BaseMapper
<
VisitLogEntity
>
{
public
interface
VisitLogMapper
extends
BaseMapper
<
VisitLogEntity
>
{
@Select
(
"select * from visit_log where ident=#{ident}"
)
@Select
(
"select * from visit_log where ident=#{ident}
and ref_id=#{refId}
"
)
VisitLogEntity
selectByIdent
(
@Param
(
"ident"
)
String
ident
);
VisitLogEntity
selectByIdent
AndRefId
(
@Param
(
"ident"
)
String
ident
,
@Param
(
"refId"
)
String
refId
);
@Update
(
"update visit_log set duration=duration+#{duration} where ident=#{ident}"
)
@Update
(
"update visit_log set duration=duration+#{duration} where ident=#{ident}"
)
void
updateDurByIdent
(
@Param
(
"duration"
)
Integer
dur
,
@Param
(
"ident"
)
String
ident
);
void
updateDurByIdent
(
@Param
(
"duration"
)
Integer
dur
,
@Param
(
"ident"
)
String
ident
);
...
...
community-service/src/main/java/com/tanpu/community/manager/VisitSummaryManager.java
View file @
06fb196e
package
com
.
tanpu
.
community
.
manager
;
package
com
.
tanpu
.
community
.
manager
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.tanpu.biz.common.enums.clue.PageEnum
;
import
com.tanpu.community.api.beans.vo.KafkaDurationUptMsg
;
import
com.tanpu.community.api.beans.vo.KafkaDurationUptMsg
;
import
com.tanpu.community.dao.entity.community.VisitLogEntity
;
import
com.tanpu.community.dao.entity.community.VisitLogEntity
;
import
com.tanpu.community.service.VisitLogService
;
import
com.tanpu.community.service.VisitLogService
;
...
@@ -11,6 +12,9 @@ import org.springframework.kafka.annotation.KafkaListener;
...
@@ -11,6 +12,9 @@ import org.springframework.kafka.annotation.KafkaListener;
import
org.springframework.kafka.core.KafkaTemplate
;
import
org.springframework.kafka.core.KafkaTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Arrays
;
import
java.util.List
;
@Slf4j
@Slf4j
@Service
@Service
public
class
VisitSummaryManager
{
public
class
VisitSummaryManager
{
...
@@ -24,11 +28,16 @@ public class VisitSummaryManager {
...
@@ -24,11 +28,16 @@ public class VisitSummaryManager {
private
VisitLogService
visitLogService
;
private
VisitLogService
visitLogService
;
List
<
String
>
PAGEID_NEED_SAVE
=
Arrays
.
asList
(
PageEnum
.
COMM_VISIT_HOME_PAGE
.
getId
(),
PageEnum
.
COMM_VISIT_THEME
.
getId
());
@KafkaListener
(
topics
=
kafakTopic
)
@KafkaListener
(
topics
=
kafakTopic
)
public
void
updateVisitSummary
(
String
message
)
{
public
void
updateVisitSummary
(
String
message
)
{
// {"durMillsInc":10000,"ident":"AD7B8CE8-2DA4-4FB4-907F-C551B926BA5C","localDate":"2021-08-02","pageId":"p13503","refId":"88737580570230824","visitorId":"275321532031467520"}
// {"durMillsInc":10000,"ident":"AD7B8CE8-2DA4-4FB4-907F-C551B926BA5C","localDate":"2021-08-02","pageId":"p13503","refId":"88737580570230824","visitorId":"275321532031467520"}
log
.
info
(
"receive kafka msg: {}"
,
message
);
log
.
info
(
"receive kafka msg: {}"
,
message
);
KafkaDurationUptMsg
msg
=
JSON
.
parseObject
(
message
,
KafkaDurationUptMsg
.
class
);
KafkaDurationUptMsg
msg
=
JSON
.
parseObject
(
message
,
KafkaDurationUptMsg
.
class
);
// 做一个筛选
if
(!
PAGEID_NEED_SAVE
.
contains
(
msg
.
pageId
))
{
return
;
}
// ident在每次进入新页面 & 回退 的时候都会随机生成一个,所以用ident做唯一key即可。
// ident在每次进入新页面 & 回退 的时候都会随机生成一个,所以用ident做唯一key即可。
VisitLogEntity
vs
=
ConvertUtil
.
convertFromKafka
(
msg
);
VisitLogEntity
vs
=
ConvertUtil
.
convertFromKafka
(
msg
);
visitLogService
.
insertOrUpdateDur
(
vs
);
visitLogService
.
insertOrUpdateDur
(
vs
);
...
...
community-service/src/main/java/com/tanpu/community/service/VisitLogService.java
View file @
06fb196e
...
@@ -58,7 +58,7 @@ public class VisitLogService {
...
@@ -58,7 +58,7 @@ public class VisitLogService {
@Transactional
@Transactional
public
void
insertOrUpdateDur
(
VisitLogEntity
vs
)
{
public
void
insertOrUpdateDur
(
VisitLogEntity
vs
)
{
if
(
visitLogMapper
.
selectByIdent
(
vs
.
getIdent
())
==
null
)
{
if
(
visitLogMapper
.
selectByIdent
AndRefId
(
vs
.
getIdent
(),
vs
.
getRefId
())
==
null
)
{
visitLogMapper
.
insert
(
vs
);
visitLogMapper
.
insert
(
vs
);
}
else
{
}
else
{
visitLogMapper
.
updateDurByIdent
(
vs
.
getDuration
(),
vs
.
getIdent
());
visitLogMapper
.
updateDurByIdent
(
vs
.
getDuration
(),
vs
.
getIdent
());
...
...
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