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
c15de613
Commit
c15de613
authored
Feb 23, 2022
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
讨论区置顶
parent
0a2f0251
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
12 deletions
+52
-12
ThemeMapper.java
...com/tanpu/community/dao/mapper/community/ThemeMapper.java
+14
-3
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
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 @
c15de613
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/ThemeManager.java
View file @
c15de613
...
@@ -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 @
c15de613
...
@@ -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/resources/mapper/community/ThemeEntityMapper.xml
View file @
c15de613
...
@@ -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