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
79e55670
Commit
79e55670
authored
Jul 19, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
关注更新条数
parent
97d39338
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
106 additions
and
70 deletions
+106
-70
VisitTypeEnum.java
...ain/java/com/tanpu/community/api/enums/VisitTypeEnum.java
+2
-1
MetricsController.java
...ava/com/tanpu/community/controller/MetricsController.java
+8
-1
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+9
-0
VisitSummaryEntity.java
...pu/community/dao/entity/community/VisitSummaryEntity.java
+3
-25
VisitSummaryMapper.java
...pu/community/dao/mapper/community/VisitSummaryMapper.java
+1
-1
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+7
-4
VisitSummaryManager.java
...java/com/tanpu/community/manager/VisitSummaryManager.java
+7
-2
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+52
-31
VisitSummaryService.java
...java/com/tanpu/community/service/VisitSummaryService.java
+17
-3
VisitSummaryEntityMapper.xml
...n/resources/mapper/community/VisitSummaryEntityMapper.xml
+0
-2
No files found.
community-api/src/main/java/com/tanpu/community/api/enums/VisitTypeEnum.java
View file @
79e55670
...
@@ -2,7 +2,8 @@ package com.tanpu.community.api.enums;
...
@@ -2,7 +2,8 @@ package com.tanpu.community.api.enums;
public
enum
VisitTypeEnum
{
public
enum
VisitTypeEnum
{
TOPIC_PAGE_VIEW
(
1
,
"进入话题页"
),
TOPIC_PAGE_VIEW
(
1
,
"进入话题页"
),
THEME_PAGE_VIEW
(
2
,
"进入主题正文"
);
THEME_PAGE_VIEW
(
2
,
"进入主题正文"
),
FOLLOW_THEME_VIEW
(
3
,
"查看关注主题"
);
private
Integer
code
;
private
Integer
code
;
private
String
type
;
private
String
type
;
...
...
community-service/src/main/java/com/tanpu/community/controller/MetricsController.java
View file @
79e55670
...
@@ -30,10 +30,17 @@ public class MetricsController {
...
@@ -30,10 +30,17 @@ public class MetricsController {
@ApiOperation
(
"浏览主题"
)
@ApiOperation
(
"浏览主题"
)
@GetMapping
(
"/view/theme"
)
@GetMapping
(
"/view/theme"
)
public
CommonResp
pageViewTheme
(
@RequestParam
String
themeId
){
public
CommonResp
pageViewTheme
(
@RequestParam
String
themeId
){
visitSummaryManager
.
add
ThemePag
eView
(
themeId
);
visitSummaryManager
.
add
FollowThem
eView
(
themeId
);
return
CommonResp
.
success
();
return
CommonResp
.
success
();
}
}
@AuthLogin
@ApiOperation
(
"浏览关注主题"
)
@GetMapping
(
"/view/follow"
)
public
CommonResp
pageViewTheme
(){
visitSummaryManager
.
addFollowThemeView
();
return
CommonResp
.
success
();
}
}
}
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
79e55670
...
@@ -126,4 +126,13 @@ public class ThemeController {
...
@@ -126,4 +126,13 @@ public class ThemeController {
return
CommonResp
.
success
();
return
CommonResp
.
success
();
}
}
@AuthLogin
@ApiOperation
(
"关注主题更新数量"
)
@GetMapping
(
value
=
"/updateCount"
)
@ResponseBody
public
CommonResp
<
Integer
>
updateCount
()
{
String
userId
=
userHolder
.
getUserId
();
return
CommonResp
.
success
(
themeManager
.
getFollowUpdateCount
(
userId
));
}
}
}
community-service/src/main/java/com/tanpu/community/dao/entity/community/VisitSummaryEntity.java
View file @
79e55670
...
@@ -16,12 +16,12 @@ import java.time.LocalDateTime;
...
@@ -16,12 +16,12 @@ import java.time.LocalDateTime;
* </p>
* </p>
*
*
* @author xudong
* @author xudong
* @since 2021-07-
07
* @since 2021-07-
19
*/
*/
@TableName
(
"visit_summary"
)
@TableName
(
"visit_summary"
)
@Builder
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel
(
value
=
"VisitSummaryEntity对象"
,
description
=
"浏览记录"
)
@ApiModel
(
value
=
"VisitSummaryEntity对象"
,
description
=
"浏览记录"
)
public
class
VisitSummaryEntity
implements
Serializable
{
public
class
VisitSummaryEntity
implements
Serializable
{
...
@@ -42,18 +42,14 @@ public class VisitSummaryEntity implements Serializable {
...
@@ -42,18 +42,14 @@ public class VisitSummaryEntity implements Serializable {
@ApiModelProperty
(
value
=
"关联目标ID"
)
@ApiModelProperty
(
value
=
"关联目标ID"
)
private
String
refId
;
private
String
refId
;
@ApiModelProperty
(
value
=
"关联目标类型"
)
@ApiModelProperty
(
value
=
"关联目标类型
1:进入话题页 2:进入主题正文 3、用户查看首页-关注
"
)
private
Integer
refType
;
private
Integer
refType
;
@ApiModelProperty
(
value
=
"浏览时间 单位秒"
)
@ApiModelProperty
(
value
=
"浏览时间 单位秒"
)
private
Integer
duration
;
private
Integer
duration
;
private
String
createBy
;
private
LocalDateTime
createTime
;
private
LocalDateTime
createTime
;
private
String
updateBy
;
private
LocalDateTime
updateTime
;
private
LocalDateTime
updateTime
;
private
Integer
deleteTag
;
private
Integer
deleteTag
;
...
@@ -115,14 +111,6 @@ public class VisitSummaryEntity implements Serializable {
...
@@ -115,14 +111,6 @@ public class VisitSummaryEntity implements Serializable {
this
.
duration
=
duration
;
this
.
duration
=
duration
;
}
}
public
String
getCreateBy
()
{
return
createBy
;
}
public
void
setCreateBy
(
String
createBy
)
{
this
.
createBy
=
createBy
;
}
public
LocalDateTime
getCreateTime
()
{
public
LocalDateTime
getCreateTime
()
{
return
createTime
;
return
createTime
;
}
}
...
@@ -131,14 +119,6 @@ public class VisitSummaryEntity implements Serializable {
...
@@ -131,14 +119,6 @@ public class VisitSummaryEntity implements Serializable {
this
.
createTime
=
createTime
;
this
.
createTime
=
createTime
;
}
}
public
String
getUpdateBy
()
{
return
updateBy
;
}
public
void
setUpdateBy
(
String
updateBy
)
{
this
.
updateBy
=
updateBy
;
}
public
LocalDateTime
getUpdateTime
()
{
public
LocalDateTime
getUpdateTime
()
{
return
updateTime
;
return
updateTime
;
}
}
...
@@ -165,9 +145,7 @@ public class VisitSummaryEntity implements Serializable {
...
@@ -165,9 +145,7 @@ public class VisitSummaryEntity implements Serializable {
", refId="
+
refId
+
", refId="
+
refId
+
", refType="
+
refType
+
", refType="
+
refType
+
", duration="
+
duration
+
", duration="
+
duration
+
", createBy="
+
createBy
+
", createTime="
+
createTime
+
", createTime="
+
createTime
+
", updateBy="
+
updateBy
+
", updateTime="
+
updateTime
+
", updateTime="
+
updateTime
+
", deleteTag="
+
deleteTag
+
", deleteTag="
+
deleteTag
+
"}"
;
"}"
;
...
...
community-service/src/main/java/com/tanpu/community/dao/mapper/community/VisitSummaryMapper.java
View file @
79e55670
...
@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
...
@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p>
* </p>
*
*
* @author xudong
* @author xudong
* @since 2021-07-
07
* @since 2021-07-
19
*/
*/
public
interface
VisitSummaryMapper
extends
BaseMapper
<
VisitSummaryEntity
>
{
public
interface
VisitSummaryMapper
extends
BaseMapper
<
VisitSummaryEntity
>
{
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
79e55670
...
@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
...
@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -53,14 +54,11 @@ public class ThemeManager {
...
@@ -53,14 +54,11 @@ public class ThemeManager {
@Autowired
@Autowired
private
ThemeAttachmentService
themeAttachmentService
;
private
ThemeAttachmentService
themeAttachmentService
;
@Autowired
private
HomePageService
homePageService
;
@Resource
@Resource
private
ProductService
productService
;
private
ProductService
productService
;
@Autowired
@Autowired
private
OSSFileService
ossFile
Service
;
private
VisitSummaryService
visitSummary
Service
;
@Transactional
@Transactional
...
@@ -342,4 +340,9 @@ public class ThemeManager {
...
@@ -342,4 +340,9 @@ public class ThemeManager {
//TODO
//TODO
}
}
public
Integer
getFollowUpdateCount
(
String
userId
)
{
LocalDateTime
lastViewTime
=
visitSummaryService
.
queryLatestViewFollow
(
userId
);
List
<
String
>
fansList
=
followRelService
.
queryFansByFollowerId
(
userId
);
return
themeService
.
queryCountFromLastTime
(
fansList
,
lastViewTime
);
}
}
}
community-service/src/main/java/com/tanpu/community/manager/VisitSummaryManager.java
View file @
79e55670
...
@@ -22,9 +22,14 @@ public class VisitSummaryManager {
...
@@ -22,9 +22,14 @@ public class VisitSummaryManager {
visitSummaryService
.
addPageView
(
userId
,
topicId
,
VisitTypeEnum
.
TOPIC_PAGE_VIEW
);
visitSummaryService
.
addPageView
(
userId
,
topicId
,
VisitTypeEnum
.
TOPIC_PAGE_VIEW
);
}
}
public
void
add
ThemePag
eView
(
String
themeId
)
{
public
void
add
FollowThem
eView
(
String
themeId
)
{
String
userId
=
userHolder
.
getUserId
();
String
userId
=
userHolder
.
getUserId
();
visitSummaryService
.
addPageView
(
userId
,
themeId
,
VisitTypeEnum
.
TOPIC_PAGE_VIEW
);
visitSummaryService
.
addPageView
(
userId
,
themeId
,
VisitTypeEnum
.
THEME_PAGE_VIEW
);
}
public
void
addFollowThemeView
()
{
String
userId
=
userHolder
.
getUserId
();
visitSummaryService
.
addPageView
(
userId
,
userId
,
VisitTypeEnum
.
FOLLOW_THEME_VIEW
);
}
}
}
}
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
79e55670
...
@@ -7,12 +7,14 @@ import com.tanpu.common.uuid.UuidGenHelper;
...
@@ -7,12 +7,14 @@ import com.tanpu.common.uuid.UuidGenHelper;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.mapper.community.ThemeMapper
;
import
com.tanpu.community.dao.mapper.community.ThemeMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -34,20 +36,21 @@ public class ThemeService {
...
@@ -34,20 +36,21 @@ public class ThemeService {
}
}
@Transactional
@Transactional
public
void
update
(
ThemeEntity
themeEntity
,
String
themeId
)
{
public
void
update
(
ThemeEntity
themeEntity
,
String
themeId
)
{
themeMapper
.
update
(
themeEntity
,
new
LambdaUpdateWrapper
<
ThemeEntity
>().
eq
(
ThemeEntity:
:
getThemeId
,
themeId
));
themeMapper
.
update
(
themeEntity
,
new
LambdaUpdateWrapper
<
ThemeEntity
>().
eq
(
ThemeEntity:
:
getThemeId
,
themeId
));
}
}
//根据id返回主题详情
//根据id返回主题详情
(未删)
public
ThemeEntity
queryByThemeId
(
String
themeId
)
{
public
ThemeEntity
queryByThemeId
(
String
themeId
)
{
return
themeMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
return
themeMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getThemeId
,
themeId
));
.
eq
(
ThemeEntity:
:
getThemeId
,
themeId
)
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
}
}
public
List
<
ThemeEntity
>
queryThemesByUserId
(
String
userId
)
{
public
List
<
ThemeEntity
>
queryThemesByUserId
(
String
userId
)
{
return
themeMapper
.
selectList
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
return
themeMapper
.
selectList
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getAuthorId
,
userId
)
.
eq
(
ThemeEntity:
:
getAuthorId
,
userId
)
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByDesc
(
ThemeEntity:
:
getId
));
.
orderByDesc
(
ThemeEntity:
:
getId
));
}
}
...
@@ -58,27 +61,27 @@ public class ThemeService {
...
@@ -58,27 +61,27 @@ public class ThemeService {
.
orderByDesc
(
ThemeEntity:
:
getId
);
.
orderByDesc
(
ThemeEntity:
:
getId
);
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
}
}
if
(
pageSize
!=
null
)
{
if
(
pageSize
!=
null
)
{
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
last
(
"limit "
+
pageSize
);
}
}
return
themeMapper
.
selectList
(
queryWrapper
);
return
themeMapper
.
selectList
(
queryWrapper
);
}
}
//根据ids返回主题详情,带分页
//根据ids返回主题详情,带分页
public
List
<
ThemeEntity
>
queryByThemeIds
(
List
<
String
>
themeIds
,
String
lastId
,
Integer
pageSize
)
{
public
List
<
ThemeEntity
>
queryByThemeIds
(
List
<
String
>
themeIds
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
in
(
ThemeEntity:
:
getThemeId
,
themeIds
)
.
in
(
ThemeEntity:
:
getThemeId
,
themeIds
)
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
}
}
if
(
pageSize
!=
null
)
{
if
(
pageSize
!=
null
)
{
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
last
(
"limit "
+
pageSize
);
}
}
return
themeMapper
.
selectList
(
queryWrapper
);
return
themeMapper
.
selectList
(
queryWrapper
);
}
}
...
@@ -93,26 +96,27 @@ public class ThemeService {
...
@@ -93,26 +96,27 @@ public class ThemeService {
}
}
//分页倒叙lastId之前的主题
//分页倒叙lastId之前的主题
public
List
<
ThemeEntity
>
selectAll
(
String
lastId
,
Integer
pageSize
)
{
public
List
<
ThemeEntity
>
selectAll
(
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>();
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>();
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
}
}
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getId
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getId
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getCreateTime
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getCreateTime
);
queryWrapper
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
queryWrapper
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
return
themeMapper
.
selectList
(
queryWrapper
);
return
themeMapper
.
selectList
(
queryWrapper
);
}
}
/**
/**
* 根据条件查询最新主题
* 根据条件查询最新主题
*
* @param topidId 话题Id
* @param topidId 话题Id
* @param lastId 查询此主题Id之前的主题
* @param lastId 查询此主题Id之前的主题
* @param pageSize 查询数量
* @param pageSize 查询数量
...
@@ -123,20 +127,20 @@ public class ThemeService {
...
@@ -123,20 +127,20 @@ public class ThemeService {
.
eq
(
ThemeEntity:
:
getTopicId
,
topidId
);
.
eq
(
ThemeEntity:
:
getTopicId
,
topidId
);
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
}
}
if
(
pageSize
!=
null
)
{
if
(
pageSize
!=
null
)
{
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
last
(
"limit "
+
pageSize
);
}
}
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getCreateTime
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getCreateTime
);
queryWrapper
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
queryWrapper
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
return
themeMapper
.
selectList
(
queryWrapper
);
return
themeMapper
.
selectList
(
queryWrapper
);
}
}
//根据话题查询所有的主题Id
//根据话题查询所有的主题Id
public
List
<
String
>
queryThemeIdsByTopic
(
String
topidId
)
{
public
List
<
String
>
queryThemeIdsByTopic
(
String
topidId
)
{
if
(
StringUtils
.
isEmpty
(
topidId
))
{
if
(
StringUtils
.
isEmpty
(
topidId
))
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
...
@@ -152,12 +156,12 @@ public class ThemeService {
...
@@ -152,12 +156,12 @@ public class ThemeService {
.
in
(
ThemeEntity:
:
getAuthorId
,
userIds
);
.
in
(
ThemeEntity:
:
getAuthorId
,
userIds
);
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
}
}
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getCreateTime
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getCreateTime
);
queryWrapper
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
queryWrapper
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
return
themeMapper
.
selectList
(
queryWrapper
);
return
themeMapper
.
selectList
(
queryWrapper
);
}
}
...
@@ -176,7 +180,7 @@ public class ThemeService {
...
@@ -176,7 +180,7 @@ public class ThemeService {
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
));
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
));
}
}
public
Integer
getForwardCountByUser
(
String
themeId
,
String
userId
)
{
public
Integer
getForwardCountByUser
(
String
themeId
,
String
userId
)
{
return
themeMapper
.
selectCount
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
return
themeMapper
.
selectCount
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getFormerThemeId
,
themeId
)
.
eq
(
ThemeEntity:
:
getFormerThemeId
,
themeId
)
.
eq
(
ThemeEntity:
:
getAuthorId
,
userId
)
.
eq
(
ThemeEntity:
:
getAuthorId
,
userId
)
...
@@ -187,12 +191,29 @@ public class ThemeService {
...
@@ -187,12 +191,29 @@ public class ThemeService {
public
void
deleteById
(
String
themeId
)
{
public
void
deleteById
(
String
themeId
)
{
ThemeEntity
themeEntity
=
themeMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
ThemeEntity
themeEntity
=
themeMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getThemeId
,
themeId
));
.
eq
(
ThemeEntity:
:
getThemeId
,
themeId
));
if
(
themeEntity
==
null
)
{
if
(
themeEntity
==
null
)
{
throw
new
BizException
(
"主题未找到,id:"
+
themeId
);
throw
new
BizException
(
"主题未找到,id:"
+
themeId
);
}
}
themeEntity
.
setDeleteTag
(
DeleteTagEnum
.
DELETED
.
getCode
());
themeEntity
.
setDeleteTag
(
DeleteTagEnum
.
DELETED
.
getCode
());
themeMapper
.
updateById
(
themeEntity
);
themeMapper
.
updateById
(
themeEntity
);
}
}
/**
* 查询更新节点后的用户新建主题数
* @param userIds 用户ids
* @param lastViewTime 更新时间节点
* @return
*/
public
Integer
queryCountFromLastTime
(
List
<
String
>
userIds
,
LocalDateTime
lastViewTime
)
{
if
(
CollectionUtils
.
isEmpty
(
userIds
))
{
return
0
;
}
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
in
(
ThemeEntity:
:
getAuthorId
,
userIds
)
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
if
(
lastViewTime
!=
null
)
{
queryWrapper
.
gt
(
ThemeEntity:
:
getCreateTime
,
lastViewTime
);
}
return
themeMapper
.
selectCount
(
queryWrapper
);
}
}
}
community-service/src/main/java/com/tanpu/community/service/VisitSummaryService.java
View file @
79e55670
...
@@ -5,10 +5,12 @@ import com.tanpu.community.api.enums.VisitTypeEnum;
...
@@ -5,10 +5,12 @@ import com.tanpu.community.api.enums.VisitTypeEnum;
import
com.tanpu.community.dao.entity.community.VisitSummaryEntity
;
import
com.tanpu.community.dao.entity.community.VisitSummaryEntity
;
import
com.tanpu.community.dao.mapper.community.VisitSummaryMapper
;
import
com.tanpu.community.dao.mapper.community.VisitSummaryMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.List
;
@Slf4j
@Slf4j
...
@@ -31,25 +33,37 @@ public class VisitSummaryService {
...
@@ -31,25 +33,37 @@ public class VisitSummaryService {
public
Integer
queryTopicDetailVisit
(
String
topicId
)
{
public
Integer
queryTopicDetailVisit
(
String
topicId
)
{
return
visitSummaryMapper
.
selectCount
(
new
LambdaQueryWrapper
<
VisitSummaryEntity
>()
return
visitSummaryMapper
.
selectCount
(
new
LambdaQueryWrapper
<
VisitSummaryEntity
>()
.
eq
(
VisitSummaryEntity:
:
getRefId
,
topicId
)
.
eq
(
VisitSummaryEntity:
:
getRefId
,
topicId
)
.
eq
(
VisitSummaryEntity:
:
getRefType
,
VisitTypeEnum
.
TOPIC_PAGE_VIEW
.
getCode
()));
.
eq
(
VisitSummaryEntity:
:
getRefType
,
VisitTypeEnum
.
TOPIC_PAGE_VIEW
.
getCode
()));
}
}
// 查询主题 浏览量
// 查询主题 浏览量
public
Integer
queryThemeVisit
(
String
theme
)
{
public
Integer
queryThemeVisit
(
String
theme
)
{
return
visitSummaryMapper
.
selectCount
(
new
LambdaQueryWrapper
<
VisitSummaryEntity
>()
return
visitSummaryMapper
.
selectCount
(
new
LambdaQueryWrapper
<
VisitSummaryEntity
>()
.
eq
(
VisitSummaryEntity:
:
getRefId
,
theme
)
.
eq
(
VisitSummaryEntity:
:
getRefId
,
theme
)
.
eq
(
VisitSummaryEntity:
:
getRefType
,
VisitTypeEnum
.
TOPIC_PAGE_VIEW
.
getCode
()));
.
eq
(
VisitSummaryEntity:
:
getRefType
,
VisitTypeEnum
.
TOPIC_PAGE_VIEW
.
getCode
()));
}
}
// 查询主题 浏览量
// 查询主题 浏览量
public
Integer
queryThemeVisit
(
List
<
String
>
themes
)
{
public
Integer
queryThemeVisit
(
List
<
String
>
themes
)
{
return
visitSummaryMapper
.
selectCount
(
new
LambdaQueryWrapper
<
VisitSummaryEntity
>()
return
visitSummaryMapper
.
selectCount
(
new
LambdaQueryWrapper
<
VisitSummaryEntity
>()
.
in
(
VisitSummaryEntity:
:
getRefId
,
themes
)
.
in
(
VisitSummaryEntity:
:
getRefId
,
themes
)
.
eq
(
VisitSummaryEntity:
:
getRefType
,
VisitTypeEnum
.
TOPIC_PAGE_VIEW
.
getCode
()));
.
eq
(
VisitSummaryEntity:
:
getRefType
,
VisitTypeEnum
.
TOPIC_PAGE_VIEW
.
getCode
()));
}
}
// 更新访问时长
// 更新访问时长
public
void
updateDurByIdent
(
String
ident
,
Integer
dur
)
{
public
void
updateDurByIdent
(
String
ident
,
Integer
dur
)
{
// visitSummaryMapper.updateDurByIdent(ident, dur);
// visitSummaryMapper.updateDurByIdent(ident, dur);
}
}
public
LocalDateTime
queryLatestViewFollow
(
String
userId
)
{
List
<
VisitSummaryEntity
>
visitSummaryEntities
=
visitSummaryMapper
.
selectList
(
new
LambdaQueryWrapper
<
VisitSummaryEntity
>()
.
eq
(
VisitSummaryEntity:
:
getVisitorId
,
userId
)
.
eq
(
VisitSummaryEntity:
:
getRefType
,
VisitTypeEnum
.
FOLLOW_THEME_VIEW
.
getCode
())
.
orderByDesc
(
VisitSummaryEntity:
:
getCreateTime
));
if
(
CollectionUtils
.
isEmpty
(
visitSummaryEntities
))
{
return
null
;
}
else
{
return
visitSummaryEntities
.
get
(
0
).
getCreateTime
();
}
}
}
}
community-service/src/main/resources/mapper/community/VisitSummaryEntityMapper.xml
View file @
79e55670
...
@@ -11,9 +11,7 @@
...
@@ -11,9 +11,7 @@
<result
column=
"ref_id"
property=
"refId"
/>
<result
column=
"ref_id"
property=
"refId"
/>
<result
column=
"ref_type"
property=
"refType"
/>
<result
column=
"ref_type"
property=
"refType"
/>
<result
column=
"duration"
property=
"duration"
/>
<result
column=
"duration"
property=
"duration"
/>
<result
column=
"create_by"
property=
"createBy"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_by"
property=
"updateBy"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"delete_tag"
property=
"deleteTag"
/>
<result
column=
"delete_tag"
property=
"deleteTag"
/>
</resultMap>
</resultMap>
...
...
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