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
1871e243
Commit
1871e243
authored
Feb 23, 2022
by
刘基明
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v2.3.1' into 'dev'
V2.3.1 See merge request
!65
parents
b81df074
c15de613
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
96 additions
and
12 deletions
+96
-12
ThemeMapper.java
...com/tanpu/community/dao/mapper/community/ThemeMapper.java
+14
-3
ConJobManager.java
.../main/java/com/tanpu/community/manager/ConJobManager.java
+23
-0
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+9
-0
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+12
-9
TopicReportService.java
...om/tanpu/community/service/quartz/TopicReportService.java
+16
-0
application-test.yml
community-service/src/main/resources/application-test.yml
+5
-0
ThemeEntityMapper.xml
...src/main/resources/mapper/community/ThemeEntityMapper.xml
+17
-0
No files found.
community-service/src/main/java/com/tanpu/community/dao/mapper/community/ThemeMapper.java
View file @
1871e243
package
com
.
tanpu
.
community
.
dao
.
mapper
.
community
;
package
com
.
tanpu
.
community
.
dao
.
mapper
.
community
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.toolkit.Constants
;
import
com.baomidou.mybatisplus.core.toolkit.Constants
;
...
@@ -8,6 +9,7 @@ import org.apache.ibatis.annotations.Param;
...
@@ -8,6 +9,7 @@ import org.apache.ibatis.annotations.Param;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Select
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -24,14 +26,23 @@ public interface ThemeMapper extends BaseMapper<ThemeEntity> {
...
@@ -24,14 +26,23 @@ public interface ThemeMapper extends BaseMapper<ThemeEntity> {
List
<
TimesCountEntity
>
selectCountByThemeIds
(
@Param
(
Constants
.
WRAPPER
)
LambdaQueryWrapper
wrapper
);
List
<
TimesCountEntity
>
selectCountByThemeIds
(
@Param
(
Constants
.
WRAPPER
)
LambdaQueryWrapper
wrapper
);
ThemeEntity
queryOneByTopicIdOrderByUpdateTimeDesc
(
@Param
(
"topicId"
)
String
topicId
);
ThemeEntity
queryOneByTopicIdOrderByUpdateTimeDesc
(
@Param
(
"topicId"
)
String
topicId
);
Integer
countByTopicIdAndCreateTimeAfter
(
@Param
(
"topicId"
)
String
topicId
,
@Param
(
"minCreateTime"
)
LocalDateTime
minCreateTime
);
Integer
countByTopicIdAndCreateTimeAfter
(
@Param
(
"topicId"
)
String
topicId
,
@Param
(
"minCreateTime"
)
LocalDateTime
minCreateTime
);
List
<
ThemeEntity
>
queryRecentdaysOrHasTopic
(
@Param
(
"deleteTag"
)
Integer
deleteTag
,
@Param
(
"minCreateTime"
)
LocalDateTime
minCreateTime
,
@Param
(
"notTopicId"
)
String
notTopicId
);
List
<
ThemeEntity
>
queryRecentdaysOrHasTopic
(
@Param
(
"deleteTag"
)
Integer
deleteTag
,
@Param
(
"minCreateTime"
)
LocalDateTime
minCreateTime
,
@Param
(
"notTopicId"
)
String
notTopicId
);
/**
* 关注人+关注话题下的帖子,带分页
*
* @param followUsers
* @param followTopics
* @return
*/
List
<
ThemeEntity
>
queryFollowList
(
@Param
(
"authorIdCollection"
)
Collection
<
String
>
followUsers
,
@Param
(
"topicIdCollection"
)
Collection
<
String
>
followTopics
,
@Param
(
"pageStart"
)
Integer
pageStart
,
@Param
(
"pageSize"
)
Integer
pageSize
);
}
}
community-service/src/main/java/com/tanpu/community/manager/ConJobManager.java
View file @
1871e243
package
com
.
tanpu
.
community
.
manager
;
package
com
.
tanpu
.
community
.
manager
;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.service.quartz.TopicReportService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -27,6 +28,9 @@ public class ConJobManager {
...
@@ -27,6 +28,9 @@ public class ConJobManager {
@Autowired
@Autowired
private
RecommendService
recommendService
;
private
RecommendService
recommendService
;
@Autowired
private
TopicReportService
topicReportService
;
/**
/**
* 定时统计 话题 访问数据,并刷到redis
* 定时统计 话题 访问数据,并刷到redis
*/
*/
...
@@ -61,4 +65,23 @@ public class ConJobManager {
...
@@ -61,4 +65,23 @@ public class ConJobManager {
public
void
clearRankLog
()
{
public
void
clearRankLog
()
{
rankLogService
.
clearRankLog
();
rankLogService
.
clearRankLog
();
}
}
/**
* 每个工作日早上09:30汇报 topic数据
*/
@Scheduled
(
cron
=
"0 30 9 ? * *"
)
public
void
reportTopicWeekday
()
{
log
.
info
(
"reportTopicWeekday start"
);
topicReportService
.
reportTopicWeekday
();
}
/**
* 每周六早上09:00汇报 topic数据
*/
@Scheduled
(
cron
=
"0 0 9 ? * SAT"
)
public
void
reportTopicSaturday
()
{
log
.
info
(
"reportTopicSaturday start"
);
topicReportService
.
reportTopicSaturday
();
}
}
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
1871e243
...
@@ -532,12 +532,21 @@ public class ThemeManager {
...
@@ -532,12 +532,21 @@ public class ThemeManager {
if
(
StringUtils
.
isEmpty
(
req
.
getTopicId
()))
{
if
(
StringUtils
.
isEmpty
(
req
.
getTopicId
()))
{
throw
new
BizException
(
"TopicId为空"
);
throw
new
BizException
(
"TopicId为空"
);
}
}
// 话题下的置顶
List
<
ThemeEntity
>
topThemes
=
themeService
.
queryTopByTopic
(
req
.
getTopicId
());
excludeIds
.
addAll
(
topThemes
.
stream
().
map
(
ThemeEntity:
:
getThemeId
).
collect
(
Collectors
.
toList
()));
List
<
String
>
rankThemeIds
=
rankService
.
getRankThemeListByTopic
(
req
.
getTopicId
(),
excludeIds
);
List
<
String
>
rankThemeIds
=
rankService
.
getRankThemeListByTopic
(
req
.
getTopicId
(),
excludeIds
);
rankThemeIds
=
BizUtils
.
subList
(
rankThemeIds
,
pageStart
,
pageSize
);
rankThemeIds
=
BizUtils
.
subList
(
rankThemeIds
,
pageStart
,
pageSize
);
themes
=
themeService
.
queryByThemeIds
(
rankThemeIds
);
themes
=
themeService
.
queryByThemeIds
(
rankThemeIds
);
themes
=
RankUtils
.
sortThemeEntityByIds
(
themes
,
rankThemeIds
);
themes
=
RankUtils
.
sortThemeEntityByIds
(
themes
,
rankThemeIds
);
// 置顶
if
(
pageStart
==
0
){
topThemes
.
addAll
(
themes
);
themes
=
topThemes
;
}
}
else
if
(
ThemeListTypeEnum
.
TOPIC_LATEST
.
getCode
().
equals
(
req
.
getType
()))
{
}
else
if
(
ThemeListTypeEnum
.
TOPIC_LATEST
.
getCode
().
equals
(
req
.
getType
()))
{
//根据话题查询最新
//根据话题查询最新
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
1871e243
...
@@ -14,6 +14,7 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
...
@@ -14,6 +14,7 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
import
com.tanpu.community.api.beans.req.theme.ThemeContentReq
;
import
com.tanpu.community.api.beans.req.theme.ThemeContentReq
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.StatusEnum
;
import
com.tanpu.community.api.enums.ThemeTypeEnum
;
import
com.tanpu.community.api.enums.ThemeTypeEnum
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.TimesCountEntity
;
import
com.tanpu.community.dao.entity.community.TimesCountEntity
;
...
@@ -220,15 +221,8 @@ public class ThemeService {
...
@@ -220,15 +221,8 @@ public class ThemeService {
if
(
CollectionUtils
.
isEmpty
(
userIds
))
{
if
(
CollectionUtils
.
isEmpty
(
userIds
))
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
// 权限控制,添加主题为空的情况
userPermitTopics
.
remove
(
""
);
userPermitTopics
.
add
(
""
);
return
themeMapper
.
queryFollowList
(
userIds
,
userPermitTopics
,
pageStart
,
pageSize
);
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
in
(
ThemeEntity:
:
getAuthorId
,
userIds
)
.
in
(
ThemeEntity:
:
getTopicId
,
userPermitTopics
)
.
last
(
"limit "
+
pageStart
+
", "
+
pageSize
)
.
orderByDesc
(
ThemeEntity:
:
getCreateTime
)
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
return
themeMapper
.
selectList
(
queryWrapper
);
}
}
...
@@ -367,4 +361,13 @@ public class ThemeService {
...
@@ -367,4 +361,13 @@ public class ThemeService {
}
}
return
"理财师"
;
return
"理财师"
;
}
}
public
List
<
ThemeEntity
>
queryTopByTopic
(
String
topicId
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getTopicId
,
topicId
)
.
eq
(
ThemeEntity:
:
getDeleteTag
,
StatusEnum
.
FALSE
.
getCode
())
.
eq
(
ThemeEntity:
:
getIsTop
,
StatusEnum
.
TRUE
.
getCode
())
.
orderByDesc
(
ThemeEntity:
:
getSetTopTime
);
return
themeMapper
.
selectList
(
queryWrapper
);
}
}
}
community-service/src/main/java/com/tanpu/community/service/quartz/TopicReportService.java
View file @
1871e243
...
@@ -50,6 +50,13 @@ public class TopicReportService {
...
@@ -50,6 +50,13 @@ public class TopicReportService {
// 每个工作日早上09:30汇报
// 每个工作日早上09:30汇报
public
static
String
content_report_topic_weekday
=
"话题(%s) 当前总成员: %s, 当前总阅读: %s, 当前总讨论: %s, 昨日新增成员: %s, 昨日新增讨论"
;
public
static
String
content_report_topic_weekday
=
"话题(%s) 当前总成员: %s, 当前总阅读: %s, 当前总讨论: %s, 昨日新增成员: %s, 昨日新增讨论"
;
public
void
reportTopicWeekday
()
{
public
void
reportTopicWeekday
()
{
// 跳过双休日
Date
now
=
new
Date
();
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
now
);
int
w
=
cal
.
get
(
Calendar
.
DAY_OF_WEEK
)
-
1
;
if
(
w
==
6
||
w
==
7
)
return
;
List
<
TopicEntity
>
topics
=
topicService
.
queryTopicNeedReport
();
List
<
TopicEntity
>
topics
=
topicService
.
queryTopicNeedReport
();
for
(
TopicEntity
topic
:
topics
)
{
for
(
TopicEntity
topic
:
topics
)
{
// 当前总成员
// 当前总成员
...
@@ -80,6 +87,15 @@ public class TopicReportService {
...
@@ -80,6 +87,15 @@ public class TopicReportService {
}
}
}
}
public
static
void
main
(
String
[]
args
)
{
Date
date
=
new
Date
();
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
date
);
int
w
=
cal
.
get
(
Calendar
.
DAY_OF_WEEK
)
-
1
;
System
.
out
.
println
(
w
);
}
// 每周六早上09:00汇报
// 每周六早上09:00汇报
public
static
String
content_report_topic_saturday
=
"话题(%s) 当前总成员: %s, 当前总阅读: %s, 当前总讨论: %s, 截至本周五新增成员: %s, 昨日新增讨论"
;
public
static
String
content_report_topic_saturday
=
"话题(%s) 当前总成员: %s, 当前总阅读: %s, 当前总讨论: %s, 截至本周五新增成员: %s, 昨日新增讨论"
;
public
void
reportTopicSaturday
()
{
public
void
reportTopicSaturday
()
{
...
...
community-service/src/main/resources/application-test.yml
View file @
1871e243
...
@@ -101,6 +101,11 @@ recommend:
...
@@ -101,6 +101,11 @@ recommend:
tmpfile
:
tmpfile
:
dir
:
/data/tmp
dir
:
/data/tmp
wxcp
:
topicreport
:
agentId
:
1000025
corpId
:
IC6Hpbct4OrYzacDnzXqSRC17vrpNwDZ1HZvFef1QQc
logging.level.com.tanpu
:
debug
logging.level.com.tanpu
:
debug
tanpu
:
tanpu
:
...
...
community-service/src/main/resources/mapper/community/ThemeEntityMapper.xml
View file @
1871e243
...
@@ -64,4 +64,21 @@
...
@@ -64,4 +64,21 @@
and ( create_time
<![CDATA[>]]>
#{minCreateTime}
and ( create_time
<![CDATA[>]]>
#{minCreateTime}
or topic_id
<![CDATA[<>]]>
#{notTopicId})
or topic_id
<![CDATA[<>]]>
#{notTopicId})
</select>
</select>
<!--auto generated by MybatisCodeHelper on 2022-02-23-->
<select
id=
"queryFollowList"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from theme
where delete_tag=0 and ((author_id in
<foreach
item=
"item"
index=
"index"
collection=
"authorIdCollection"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
and topic_id="") or topic_id in
<foreach
item=
"item"
index=
"index"
collection=
"topicIdCollection"
open=
"("
separator=
","
close=
")"
>
#{item}) limit #{pageStart}, #{pageSize}
</foreach>
</select>
</mapper>
</mapper>
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