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
1bd75841
Commit
1bd75841
authored
Aug 04, 2021
by
吴泽佳
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://47.100.44.39:10001/tp-backend/tanpu-community
into dev
parents
4961ff7c
1bc324ab
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
273 additions
and
198 deletions
+273
-198
CommunityConstant.java
.../main/java/com/tanpu/community/api/CommunityConstant.java
+3
-0
ThemeAnalysDO.java
.../java/com/tanpu/community/api/beans/qo/ThemeAnalysDO.java
+15
-3
QueryFollowReq.java
...anpu/community/api/beans/req/homepage/QueryFollowReq.java
+3
-3
ImagesDTO.java
...main/java/com/tanpu/community/api/beans/vo/ImagesDTO.java
+3
-0
RedisKeyConstant.java
...a/com/tanpu/community/api/constants/RedisKeyConstant.java
+4
-27
HomePageController.java
...va/com/tanpu/community/controller/HomePageController.java
+1
-0
TopicController.java
.../java/com/tanpu/community/controller/TopicController.java
+3
-3
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+3
-0
ConJobManager.java
.../main/java/com/tanpu/community/manager/ConJobManager.java
+13
-1
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+16
-11
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+49
-24
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+8
-11
BatchFeignCallService.java
...va/com/tanpu/community/service/BatchFeignCallService.java
+16
-12
CollectionService.java
...n/java/com/tanpu/community/service/CollectionService.java
+39
-3
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+5
-1
FollowRelService.java
...in/java/com/tanpu/community/service/FollowRelService.java
+54
-15
RecommendService.java
...in/java/com/tanpu/community/service/RecommendService.java
+13
-12
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+10
-68
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+4
-1
PageUtils.java
...ice/src/main/java/com/tanpu/community/util/PageUtils.java
+7
-1
application-test.yml
community-service/src/main/resources/application-test.yml
+4
-2
No files found.
community-api/src/main/java/com/tanpu/community/api/CommunityConstant.java
View file @
1bd75841
...
...
@@ -20,4 +20,7 @@ public final class CommunityConstant {
public
static
final
String
OSS_PREFIX_FOLDER
=
"community/"
;
//图片压缩比例:50%
public
static
final
String
OSS_RESIZE_RATIO
=
"?x-oss-process=image/resize,p_50"
;
}
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeAnalysDO.java
View file @
1bd75841
...
...
@@ -50,11 +50,23 @@ public class ThemeAnalysDO {
private
Double
userWeight
=
0.0
;
public
Double
getRank
()
{
double
viewRatio
=
0.1
;
double
forwardRatio
=
3
;
double
commentRatio
=
2
;
double
likeRation
=
1
;
double
collectRatio
=
3
;
double
userWeightRatio
=
0.8
;
double
initialWeight
=
1.0
;
double
timeRation
=
0.3
;
// 质量=帖子质量+用户质量
double
w
=
(
double
)
(
viewCount
*
0.1
+
forwardCount
*
3
+
commentCount
*
2
+
likeCount
*
1
+
collectCount
*
3
)
+
userWeight
;
double
i
=
1
;
// 初始权重
double
w
=
viewCount
*
viewRatio
+
forwardCount
*
forwardRatio
+
commentCount
*
commentRatio
+
likeCount
*
likeRation
+
collectCount
*
collectRatio
+
Math
.
pow
(
userWeight
,
userWeightRatio
);
double
i
=
initialWeight
;
// 初始权重
double
t
=
Double
.
valueOf
(
minuteTillNow
)
/
60
;
double
g
=
0.1
;
// 时间系数
double
g
=
timeRation
;
// 时间系数
return
(
w
+
i
)
/
Math
.
pow
(
t
+
1
,
g
);
}
...
...
community-api/src/main/java/com/tanpu/community/api/beans/req/homepage/QueryFollowReq.java
View file @
1bd75841
...
...
@@ -10,11 +10,11 @@ import lombok.Data;
public
class
QueryFollowReq
{
@ApiModelProperty
(
value
=
"用户Id"
)
p
rivate
String
userId
;
p
ublic
String
userId
;
@ApiModelProperty
(
value
=
"查询类型,1:粉丝 2:关注"
)
p
rivate
Integer
queryType
;
p
ublic
Integer
queryType
;
@ApiModelProperty
(
value
=
"分页"
)
p
rivate
Pageable
page
;
p
ublic
Pageable
page
;
}
community-api/src/main/java/com/tanpu/community/api/beans/vo/ImagesDTO.java
View file @
1bd75841
...
...
@@ -22,6 +22,9 @@ public class ImagesDTO {
@ApiModelProperty
(
"图片url"
)
private
String
remark
;
@ApiModelProperty
(
"压缩图片url"
)
private
String
resizeUrl
;
@ApiModelProperty
(
"图片宽度"
)
private
Integer
imgHeight
;
...
...
community-api/src/main/java/com/tanpu/community/api/constants/RedisKeyConstant.java
View file @
1bd75841
...
...
@@ -2,32 +2,12 @@ package com.tanpu.community.api.constants;
public
class
RedisKeyConstant
{
//话题页浏览量
public
static
final
String
TOPIC_PAGE_VIEW_COUNT_
=
"TOPIC_PAGE_VIEW_COUNT_"
;
//话题总浏览量=总浏览量+带这个话题的帖子量
public
static
final
String
TOPIC_TOTAL_VIEW_COUNT_
=
"TOPIC_TOTAL_VIEW_COUNT_"
;
//点赞量
public
static
final
String
T
OPIC_LIKE_COUNT_
=
"TOPIC
_LIKE_COUNT_"
;
public
static
final
String
T
HEME_LIKE_COUNT
=
"THEME
_LIKE_COUNT_"
;
//收藏量
public
static
final
String
TOPIC_BOOK_COUNT_
=
"TOPIC_BOOK_COUNT_"
;
//用户数
public
static
final
String
TOPIC_USER_COUNT_
=
"TOPIC_USER_COUNT_"
;
public
static
final
String
THEME_COMMENT_COUNT
=
"THEME_COMMENT_COUNT_"
;
//讨论量=发布主题贴数+回复总数
public
static
final
String
TOPIC_DISCUSS_COUNT_
=
"TOPIC_DISCUSS_COUNT_"
;
//发帖数
public
static
final
String
TOPIC_THEME_COUNT_
=
"TOPIC_THEME_COUNT_"
;
//回帖数
public
static
final
String
TOPIC_COMMENT_COUNT_
=
"TOPIC_COMMENT_COUNT_"
;
//总用户数=访问话题页+发帖+回帖(去重)
public
static
final
String
TOPIC_TOTAL_USER_COUNT_
=
"TOPIC_TOTAL_USER_COUNT_"
;
//访问话题人数
public
static
final
String
TOPIC_USER_VIEW_COUNT_
=
"TOPIC_USER_VIEW_COUNT_"
;
//发帖人数
public
static
final
String
TOPIC_POST_USER_COUNT_
=
"TOPIC_POST_USER_COUNT_"
;
//回帖人数
public
static
final
String
TOPIC_COMMENT_USER_COUNT_
=
"TOPIC_COMMENT_USER_COUNT_"
;
// 出现在用户的搜索列表中的主题id
public
static
final
String
THEME_APPEAR_IN_SEARCH_LIST
=
"THEME_APPEAR_IN_SEARCH_LIST_"
;
public
static
final
String
THEME_FORWARD_COUNT
=
"THEME_FORWARD_COUNT_"
;
// feign 查询用户信息
public
static
final
String
CACHE_FEIGN_USER_INFO
=
"CACHE_FEIGN_USER_INFO_"
;
...
...
@@ -38,12 +18,9 @@ public class RedisKeyConstant {
// 主题本身
public
static
final
String
CACHE_THEME_ID
=
"CACHE_THEME_ID_"
;
// 转发主题本身
public
static
final
String
CACHE_FOR
MER_THEME_ID
=
"CACHE_FORMER
_THEME_ID_"
;
public
static
final
String
CACHE_FOR
WARD_THEME_ID
=
"CACHE_FORWARD
_THEME_ID_"
;
// 关注的人,上次浏览的最新主题last id
public
static
final
String
CACHE_IDOL_THEME_LAST_ID
=
"CACHE_IDOL_THEME_LAST_ID_"
;
public
static
final
String
THEME_VIEW_COUNT_
=
"THEME_VIEW_COUNT_"
;
public
static
final
String
THEME_LIKE_COUNT_
=
"THEME_LIKE_COUNT_"
;
public
static
final
String
THEME_BOOK_COUNT_
=
"THEME_BOOK_COUNT_"
;
}
community-service/src/main/java/com/tanpu/community/controller/HomePageController.java
View file @
1bd75841
...
...
@@ -78,6 +78,7 @@ public class HomePageController {
@PostMapping
(
value
=
"/addIdol"
)
@ApiOperation
(
"关注/取消关注他人"
)
@ResponseBody
@AuthLogin
public
CommonResp
addIdol
(
@RequestBody
FollowRelReq
req
)
{
String
userId
=
userHolder
.
getUserId
();
homePageManager
.
addFollowRel
(
req
,
userId
);
...
...
community-service/src/main/java/com/tanpu/community/controller/TopicController.java
View file @
1bd75841
...
...
@@ -31,7 +31,7 @@ public class TopicController {
@PostMapping
(
value
=
"/list"
)
@ApiOperation
(
"APP全部话题页面,可搜索"
)
@ResponseBody
public
CommonResp
<
Page
<
TopicRankQo
>>
getTopic
BriefInfo
List
(
@RequestBody
TopicSearchReq
req
){
public
CommonResp
<
Page
<
TopicRankQo
>>
getTopicList
(
@RequestBody
TopicSearchReq
req
){
return
CommonResp
.
success
(
topicManager
.
getAllTopicBriefInfo
(
req
));
}
...
...
@@ -39,7 +39,7 @@ public class TopicController {
@GetMapping
(
value
=
"/detailPage"
)
@ApiOperation
(
"话题详情页顶部"
)
@ResponseBody
public
CommonResp
<
TopicRankQo
>
get
hotThemes
(
@RequestParam
String
topicId
){
public
CommonResp
<
TopicRankQo
>
get
Detail
(
@RequestParam
String
topicId
){
return
CommonResp
.
success
(
topicManager
.
getDetail
(
topicId
));
}
...
...
@@ -47,7 +47,7 @@ public class TopicController {
@GetMapping
(
value
=
"/titleList"
)
@ApiOperation
(
"首页顶部话题标题列"
)
@ResponseBody
public
CommonResp
<
List
<
TopicRankQo
>>
getT
itleList
(){
public
CommonResp
<
List
<
TopicRankQo
>>
getT
op4Topic
(){
return
CommonResp
.
success
(
topicManager
.
getTop4TopicTitles
());
}
...
...
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
1bd75841
...
...
@@ -53,6 +53,9 @@ public class CommentManager {
// 发表评论(对主题)
public
void
comment
(
CreateCommentReq
req
,
String
userId
)
{
if
(
StringUtils
.
isEmpty
(
req
.
getComment
()))
{
throw
new
IllegalArgumentException
(
"评论内容不能为空"
);
}
if
(
req
.
getComment
().
length
()>
500
){
throw
new
IllegalArgumentException
(
"评论内容不能超过500字"
);
}
...
...
community-service/src/main/java/com/tanpu/community/manager/ConJobManager.java
View file @
1bd75841
package
com
.
tanpu
.
community
.
manager
;
import
com.tanpu.community.service.RankService
;
import
com.tanpu.community.service.RecommendService
;
import
com.tanpu.community.service.RedisService
;
import
com.tanpu.community.service.VisitLogService
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -23,6 +24,9 @@ public class ConJobManager {
@Autowired
private
RankService
rankService
;
@Autowired
private
RecommendService
recommendService
;
/**
* 定时统计 话题 访问数据,并刷到redis
*/
...
...
@@ -36,9 +40,17 @@ public class ConJobManager {
/**
* 定时统计主题、话题排行
*/
@Scheduled
(
cron
=
"
0 */2
* * * ?"
)
@Scheduled
(
cron
=
"
*/30 *
* * * ?"
)
public
void
themeRank
()
{
rankService
.
rankThemes
();
rankService
.
rankTopics
();
}
/**
* 定时统计主题、话题排行
*/
@Scheduled
(
cron
=
"*/5 * * * * ?"
)
public
void
getThemeNewest
()
{
recommendService
.
refreshNewestThemes
();
}
}
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
1bd75841
...
...
@@ -59,7 +59,8 @@ public class HomePageManager {
//查询 个人中心 相关信息
public
UserInfoResp
queryUsersInfo
(
String
userIdMyself
,
String
userId
)
{
CommonResp
<
UserInfoResp
>
queryUsersListNew
=
feignClientForFatools
.
queryUsersListNew
(
StringUtils
.
isNotBlank
(
userId
)
?
userId
:
userIdMyself
);
if
(
queryUsersListNew
.
isNotSuccess
()
||
!
ObjectUtils
.
anyNotNull
(
queryUsersListNew
.
getData
()))
throw
new
BizException
(
"内部接口调用失败"
);
if
(
queryUsersListNew
.
isNotSuccess
()
||
!
ObjectUtils
.
anyNotNull
(
queryUsersListNew
.
getData
()))
throw
new
BizException
(
"内部接口调用失败"
);
UserInfoResp
userInfoNew
=
queryUsersListNew
.
getData
();
if
(
StringUtils
.
isNotBlank
(
userId
)
&&
!
StringUtils
.
equals
(
userIdMyself
,
userId
))
{
//查询别人的个人主页
...
...
@@ -95,7 +96,7 @@ public class HomePageManager {
}
// 查询首席投顾数量
CommonResp
<
Page
<
UserInfoNewChief
>>
pageCommonResp
=
feignClientForFatools
.
queryChiefFinancialAdviserList
(
1
,
1
);
if
(
pageCommonResp
.
isSuccess
()){
if
(
pageCommonResp
.
isSuccess
())
{
userInfoNew
.
getUserInfoNewChief
().
setChiefCount
(
pageCommonResp
.
getData
().
getTotalSize
());
}
else
{
userInfoNew
.
getUserInfoNewChief
().
setChiefCount
(
0L
);
...
...
@@ -181,28 +182,32 @@ public class HomePageManager {
/**
* 用户关注列表
*
* @param req 目标用户
* @param userId 当前用户
* @return
*/
public
Page
<
FollowQo
>
queryFollow
(
QueryFollowReq
req
,
String
userId
)
{
//TODO 数据库分页
List
<
String
>
userIds
=
QueryFollowTypeEnum
.
QUERY_FANS
.
getCode
().
equals
(
req
.
getQueryType
())
?
followRelService
.
queryFansByIdolId
(
req
.
getUserId
())
:
followRelService
.
queryIdolsByFollowerId
(
req
.
getUserId
());
//数据库分页
Integer
pageSize
=
req
.
page
.
pageSize
;
Integer
pageNumber
=
req
.
page
.
pageNumber
;
Page
<
String
>
userIdsPage
=
QueryFollowTypeEnum
.
QUERY_FANS
.
getCode
().
equals
(
req
.
getQueryType
())
?
followRelService
.
queryFansByIdolId
(
req
.
userId
,
pageNumber
,
pageSize
)
:
followRelService
.
queryIdolsByFansId
(
req
.
userId
,
pageNumber
,
pageSize
);
List
<
FollowQo
>
followQos
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
List
<
UserInfoResp
>
userInfoNews
=
feignClientForFatools
.
queryUserListNew
(
userIds
);
if
(!
CollectionUtils
.
isEmpty
(
userIds
Page
.
getContent
()
))
{
List
<
UserInfoResp
>
userInfoNews
=
feignClientForFatools
.
queryUserListNew
(
userIds
Page
.
getContent
()
);
List
<
FollowQo
>
collect
=
userInfoNews
.
stream
().
map
(
ConvertUtil:
:
userInfoNew2FollowQo
).
collect
(
Collectors
.
toList
());
followQos
=
judgeFollowed
(
collect
,
userId
);
}
//分页
return
PageUtils
.
page
(
req
.
getPage
(),
followQos
);
return
PageUtils
.
page
(
userIdsPage
,
followQos
);
}
//判断返回列表中的用户是否被当前用户关注
public
List
<
FollowQo
>
judgeFollowed
(
List
<
FollowQo
>
followQos
,
String
followerId
)
{
Set
<
String
>
idolSet
=
new
HashSet
<>(
followRelService
.
queryIdolsByF
ollower
Id
(
followerId
));
Set
<
String
>
idolSet
=
new
HashSet
<>(
followRelService
.
queryIdolsByF
ans
Id
(
followerId
));
return
followQos
.
stream
().
map
(
o
->
{
if
(
idolSet
.
contains
(
o
.
getUserId
()))
{
o
.
setFollowed
(
true
);
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
1bd75841
This diff is collapsed.
Click to expand it.
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
1bd75841
package
com
.
tanpu
.
community
.
manager
;
import
com.tanpu.common.auth.UserHolder
;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.community.api.beans.qo.TopicRankQo
;
import
com.tanpu.community.api.beans.req.page.Page
;
import
com.tanpu.community.api.beans.req.topic.TopicSearchReq
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.service.RankService
;
import
com.tanpu.community.service.TopicService
;
import
com.tanpu.community.service.VisitLogService
;
import
com.tanpu.community.util.PageUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
static
com
.
tanpu
.
biz
.
common
.
enums
.
clue
.
PageEnum
.
COMM_VISIT_TOPIC_DETAIL
;
@Service
public
class
TopicManager
{
@Autowired
private
VisitLogService
visitLog
Service
;
private
TopicService
topic
Service
;
@Autowired
private
RankService
rankService
;
@Resource
private
UserHolder
userHolder
;
// 首页-话题标签
...
...
@@ -43,10 +39,11 @@ public class TopicManager {
}
// 话题详情页
public
TopicRankQo
getDetail
(
String
topicId
)
{
//TODO 临时埋点,接入新埋点后删除
visitLogService
.
addPageView
(
userHolder
.
getUserId
(),
topicId
,
COMM_VISIT_TOPIC_DETAIL
);
TopicEntity
topicEntity
=
topicService
.
queryById
(
topicId
);
if
(
topicEntity
==
null
){
throw
new
BizException
(
ErrorCodeConstant
.
TOPIC_NOT_FOUND
);
}
return
rankService
.
getTopicDetail
(
topicId
);
}
...
...
community-service/src/main/java/com/tanpu/community/service/BatchFeignCallService.java
View file @
1bd75841
...
...
@@ -7,6 +7,7 @@ import com.tanpu.biz.common.enums.user.UserLevelEnum;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.enums.fund.ProductTypeEnum
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.community.api.CommunityConstant
;
import
com.tanpu.community.api.beans.qo.AttachmentDetailVo
;
import
com.tanpu.community.api.beans.qo.ThemeContentQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
...
...
@@ -258,10 +259,10 @@ public class BatchFeignCallService {
Set
<
String
>
ifaFundIds
,
Set
<
String
>
notNetFundIds
,
Map
<
String
,
FundInfoBaseResp
>
fundMap
)
{
Map
<
String
,
FundInfoBaseResp
>
tampFundMap
=
null
;
Map
<
String
,
FundInfoBaseResp
>
privateFundMap
=
null
;
Map
<
String
,
FundInfoBaseResp
>
publicFundMap
=
null
;
Map
<
String
,
FundInfoBaseResp
>
ifaFundMap
=
null
;
Map
<
String
,
FundInfoBaseResp
>
tampFundMap
;
Map
<
String
,
FundInfoBaseResp
>
privateFundMap
;
Map
<
String
,
FundInfoBaseResp
>
publicFundMap
;
Map
<
String
,
FundInfoBaseResp
>
ifaFundMap
;
Map
<
String
,
FundInfoBaseResp
>
notNetFundMap
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
tanpuFundIds
))
{
// ProductListReq productListReq = ProductListReq.builder()
...
...
@@ -276,7 +277,7 @@ public class BatchFeignCallService {
}).
collect
(
Collectors
.
toList
());
tampFundMap
=
fundInfoBaseRespList
.
stream
().
collect
(
Collectors
.
toMap
(
FundInfoBaseResp:
:
getFundId
,
item
->
item
));
if
(
tampFundMap
!=
null
&&
tampFundMap
.
size
()
>
0
)
{
if
(
tampFundMap
.
size
()
>
0
)
{
fundMap
.
putAll
(
tampFundMap
);
}
}
...
...
@@ -291,7 +292,7 @@ public class BatchFeignCallService {
}).
collect
(
Collectors
.
toList
());
privateFundMap
=
fundInfoBaseRespList
.
stream
().
collect
(
Collectors
.
toMap
(
FundInfoBaseResp:
:
getFundId
,
item
->
item
));
if
(
privateFundMap
!=
null
&&
privateFundMap
.
size
()
>
0
)
{
if
(
privateFundMap
.
size
()
>
0
)
{
fundMap
.
putAll
(
privateFundMap
);
}
}
...
...
@@ -307,7 +308,7 @@ public class BatchFeignCallService {
ifaFundMap
=
fundInfoBaseRespList
.
stream
().
collect
(
Collectors
.
toMap
(
FundInfoBaseResp:
:
getFundId
,
item
->
item
));
if
(
ifaFundMap
!=
null
&&
ifaFundMap
.
size
()
>
0
)
{
if
(
ifaFundMap
.
size
()
>
0
)
{
fundMap
.
putAll
(
ifaFundMap
);
}
}
...
...
@@ -322,7 +323,7 @@ public class BatchFeignCallService {
}).
collect
(
Collectors
.
toList
());
publicFundMap
=
fundInfoBaseRespList
.
stream
().
collect
(
Collectors
.
toMap
(
FundInfoBaseResp:
:
getFundId
,
item
->
item
));
if
(
publicFundMap
!=
null
&&
publicFundMap
.
size
()
>
0
)
{
if
(
publicFundMap
.
size
()
>
0
)
{
fundMap
.
putAll
(
publicFundMap
);
}
}
...
...
@@ -427,19 +428,20 @@ public class BatchFeignCallService {
//单图封装到imglist列表中
if
(
imgUrlMap
.
containsKey
(
themeContent
.
getValue
()))
{
FileRecordEntity
imgEntity
=
imgUrlMap
.
get
(
themeContent
.
getValue
());
String
extInfo
=
imgEntity
.
getExtInfo
();
if
(!
StringUtils
.
isEmpty
(
extInfo
))
{
Map
<
String
,
Object
>
extMap
=
JsonUtil
.
toMap
(
extInfo
);
if
(
imgEntity
!=
null
&&
!
StringUtils
.
isEmpty
(
imgEntity
.
getExtInfo
()))
{
Map
<
String
,
Object
>
extMap
=
JsonUtil
.
toMap
(
imgEntity
.
getExtInfo
());
ImagesDTO
imagesDTO
=
ImagesDTO
.
builder
().
imgHeight
((
Integer
)
extMap
.
get
(
"height"
))
.
imgWidth
((
Integer
)
extMap
.
get
(
"width"
))
.
remark
(
imgEntity
.
getUrl
())
.
relId
(
imgEntity
.
getFileId
())
//压缩图片
.
resizeUrl
(
imgEntity
.
getUrl
()
+
CommunityConstant
.
OSS_RESIZE_RATIO
)
.
build
();
themeContent
.
setImgList
(
Collections
.
singletonList
(
imagesDTO
));
}
}
}
else
if
(
themeContent
.
getType
().
equals
(
RelTypeEnum
.
MULTIPLE_IMAGE
.
type
))
{
//多图写入图片宽高
//多图写入图片宽高
,压缩图片url
List
<
ImagesDTO
>
imgList
=
themeContent
.
getImgList
();
for
(
ImagesDTO
imagesDTO
:
imgList
)
{
if
(
imgUrlMap
.
containsKey
(
imagesDTO
.
getRelId
()))
{
...
...
@@ -450,6 +452,8 @@ public class BatchFeignCallService {
imagesDTO
.
setImgHeight
((
Integer
)
extMap
.
get
(
"height"
));
imagesDTO
.
setImgWidth
((
Integer
)
extMap
.
get
(
"width"
));
}
//压缩图片地址
imagesDTO
.
setResizeUrl
(
imgEntity
.
getUrl
()
+
CommunityConstant
.
OSS_RESIZE_RATIO
);
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/CollectionService.java
View file @
1bd75841
...
...
@@ -7,12 +7,18 @@ import com.tanpu.community.dao.entity.community.CollectionEntity;
import
com.tanpu.community.dao.entity.community.TimesCountEntity
;
import
com.tanpu.community.dao.mapper.community.CollectionMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -48,7 +54,7 @@ public class CollectionService {
//根据用户、主题、类型查询未删除对象
public
CollectionEntity
getTarget
(
String
targetId
,
String
userId
,
CollectionTypeEnum
type
)
{
public
CollectionEntity
queryCollection
(
String
targetId
,
String
userId
,
CollectionTypeEnum
type
)
{
LambdaQueryWrapper
<
CollectionEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getCollectionType
,
type
.
getCode
())
.
eq
(
CollectionEntity:
:
getUserId
,
userId
)
...
...
@@ -57,6 +63,15 @@ public class CollectionService {
return
collectionMapper
.
selectOne
(
queryWrapper
);
}
//根据用户、主题、类型查询未删除对象
public
CollectionEntity
queryIncludeDelete
(
String
targetId
,
String
userId
,
CollectionTypeEnum
type
)
{
LambdaQueryWrapper
<
CollectionEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getCollectionType
,
type
.
getCode
())
.
eq
(
CollectionEntity:
:
getUserId
,
userId
)
.
eq
(
CollectionEntity:
:
getTargetId
,
targetId
);
return
collectionMapper
.
selectOne
(
queryWrapper
);
}
//根据用户、主题、类型查询未删除对象
public
Set
<
String
>
getTargets
(
List
<
String
>
targetIds
,
String
userId
,
CollectionTypeEnum
type
)
{
if
(
CollectionUtils
.
isEmpty
(
targetIds
)){
...
...
@@ -91,6 +106,27 @@ public class CollectionService {
.
stream
().
map
(
CollectionEntity:
:
getTargetId
).
collect
(
Collectors
.
toList
());
}
// 根据用户id和行为type获取target_id列表
public
List
<
String
>
getListByUser
(
String
userId
,
CollectionTypeEnum
type
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
CollectionEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getUserId
,
userId
)
.
eq
(
CollectionEntity:
:
getCollectionType
,
type
.
getCode
())
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByDesc
(
CollectionEntity:
:
getCollectionTime
);
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
CollectionEntity
target
=
queryIncludeDelete
(
lastId
,
userId
,
type
);
if
(
target
==
null
)
return
Collections
.
emptyList
();
queryWrapper
.
lt
(
CollectionEntity:
:
getCollectionType
,
target
.
getCollectionTime
());
}
if
(
pageSize
!=
null
)
{
queryWrapper
.
last
(
"limit "
+
pageSize
);
}
return
collectionMapper
.
selectList
(
queryWrapper
)
.
stream
().
map
(
CollectionEntity:
:
getTargetId
).
collect
(
Collectors
.
toList
());
}
// 统计单个对象(主题、评论)的数量(点赞、收藏)
public
Integer
getCountByTypeAndId
(
String
targetId
,
CollectionTypeEnum
type
)
{
...
...
@@ -123,7 +159,7 @@ public class CollectionService {
//逻辑删除,修改delete_tag
@Transactional
public
void
delete
(
String
themeId
,
String
userId
,
CollectionTypeEnum
type
)
{
CollectionEntity
queryCollection
=
getTarget
(
themeId
,
userId
,
type
);
CollectionEntity
queryCollection
=
queryCollection
(
themeId
,
userId
,
type
);
if
(
queryCollection
!=
null
)
{
queryCollection
.
setDeleteTag
(
DeleteTagEnum
.
DELETED
.
getCode
());
queryCollection
.
setUncollectionTime
(
LocalDateTime
.
now
());
...
...
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
1bd75841
...
...
@@ -109,7 +109,7 @@ public class CommentService {
CommentEntity
commentEntity
=
commentMapper
.
selectOne
(
new
LambdaQueryWrapper
<
CommentEntity
>()
.
eq
(
CommentEntity:
:
getCommentId
,
lastId
));
if
(
commentEntity
==
null
)
throw
new
BizException
(
"评论未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
CommentEntity:
:
get
Upd
ateTime
,
commentEntity
.
getCreateTime
());
queryWrapper
.
lt
(
CommentEntity:
:
get
Cre
ateTime
,
commentEntity
.
getCreateTime
());
}
if
(
pageSize
!=
null
)
{
queryWrapper
.
last
(
"limit "
+
pageSize
);
...
...
@@ -145,8 +145,12 @@ public class CommentService {
// 失效关联主题缓存
private
void
evictThemeCache
(
String
themeId
){
// 评论内容
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CACHE_COMMENT_THEMEID
,
themeId
));
// 主题内容
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CACHE_THEME_ID
,
themeId
));
// 评论数
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
THEME_LIKE_COUNT
,
themeId
));
}
}
community-service/src/main/java/com/tanpu/community/service/FollowRelService.java
View file @
1bd75841
package
com
.
tanpu
.
community
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.common.constant.BizStatus
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.community.api.beans.req.page.Page
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.dao.entity.community.FollowRelEntity
;
import
com.tanpu.community.dao.mapper.community.FollowRelMapper
;
...
...
@@ -21,7 +23,7 @@ public class FollowRelService {
@Resource
private
FollowRelMapper
followRelMapper
;
public
List
<
String
>
queryIdolsByF
ollower
Id
(
String
followerId
)
{
public
List
<
String
>
queryIdolsByF
ans
Id
(
String
followerId
)
{
return
followRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getFansId
,
followerId
)
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
...
...
@@ -29,19 +31,55 @@ public class FollowRelService {
.
collect
(
Collectors
.
toList
());
}
// @Cacheable(value = "tempCache", keyGenerator = "communityKeyGenerator")
public
List
<
String
>
queryFansByIdolId
(
String
idolId
)
{
public
Page
<
String
>
queryIdolsByFansId
(
String
fansId
,
Integer
pageNum
,
Integer
pageSize
)
{
Integer
pageStart
=
(
pageNum
-
1
)
*
pageSize
;
List
<
FollowRelEntity
>
idols
=
followRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getFansId
,
fansId
)
.
last
(
"limit "
+
pageStart
+
", "
+
pageSize
)
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
List
<
String
>
list
=
idols
.
stream
().
map
(
FollowRelEntity:
:
getIdolId
)
.
collect
(
Collectors
.
toList
());
Integer
totalSize
=
followRelMapper
.
selectCount
(
new
LambdaQueryWrapper
<
FollowRelEntity
>().
eq
(
FollowRelEntity:
:
getFansId
,
fansId
)
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
BizStatus
.
DeleteTag
.
tag_init
));
Page
<
String
>
tPage
=
new
Page
<>(
pageNum
,
pageSize
,
(
long
)
totalSize
,
0
,
list
);
int
totalPage
=
list
.
size
()
/
pageSize
;
if
(
list
.
size
()
%
pageSize
==
0
)
{
tPage
.
setTotalPages
(
totalPage
);
}
else
{
tPage
.
setTotalPages
(
totalPage
+
1
);
}
return
tPage
;
}
public
Page
<
String
>
queryFansByIdolId
(
String
idolId
,
Integer
pageNum
,
Integer
pageSize
)
{
Integer
pageStart
=
(
pageNum
-
1
)
*
pageSize
;
LambdaQueryWrapper
<
FollowRelEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getIdolId
,
idolId
)
.
last
(
"limit "
+
pageStart
+
", "
+
pageSize
)
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
return
followRelMapper
.
selectList
(
queryWrapper
)
List
<
String
>
list
=
followRelMapper
.
selectList
(
queryWrapper
)
.
stream
().
map
(
FollowRelEntity:
:
getFansId
).
collect
(
Collectors
.
toList
());
// 分页
Integer
totalSize
=
followRelMapper
.
selectCount
(
new
LambdaQueryWrapper
<
FollowRelEntity
>().
eq
(
FollowRelEntity:
:
getIdolId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
BizStatus
.
DeleteTag
.
tag_init
));
Page
<
String
>
tPage
=
new
Page
<>(
pageNum
,
pageSize
,
(
long
)
totalSize
,
0
,
list
);
int
totalPage
=
list
.
size
()
/
pageSize
;
if
(
list
.
size
()
%
pageSize
==
0
)
{
tPage
.
setTotalPages
(
totalPage
);
}
else
{
tPage
.
setTotalPages
(
totalPage
+
1
);
}
return
tPage
;
}
@Transactional
public
void
addFollowRel
(
String
idolId
,
String
followerId
)
{
FollowRelEntity
searchResult
=
queryRecord
(
idolId
,
followerId
);
if
(
searchResult
==
null
)
{
if
(
searchResult
==
null
)
{
FollowRelEntity
entity
=
FollowRelEntity
.
builder
()
.
idolId
(
idolId
)
.
fansId
(
followerId
)
...
...
@@ -49,7 +87,7 @@ public class FollowRelService {
.
build
();
followRelMapper
.
insert
(
entity
);
}
else
{
}
else
{
searchResult
.
setFollowTime
(
LocalDateTime
.
now
());
searchResult
.
setDeleteTag
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
followRelMapper
.
updateById
(
searchResult
);
...
...
@@ -59,13 +97,14 @@ public class FollowRelService {
/**
* 逻辑删除关注关系
*
* @param idolId
* @param followerId
*/
@Transactional
public
void
deleteFollowRel
(
String
idolId
,
String
followerId
)
{
FollowRelEntity
searchResult
=
queryRecord
(
idolId
,
followerId
);
if
(
searchResult
==
null
)
{
if
(
searchResult
==
null
)
{
throw
new
BizException
(
"未找到关注关系"
);
}
searchResult
.
setUnfollowTime
(
LocalDateTime
.
now
());
...
...
@@ -73,18 +112,18 @@ public class FollowRelService {
followRelMapper
.
updateById
(
searchResult
);
}
public
FollowRelEntity
queryRecord
(
String
idolId
,
String
followerId
){
public
FollowRelEntity
queryRecord
(
String
idolId
,
String
followerId
)
{
return
followRelMapper
.
selectOne
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getIdolId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getFansId
,
followerId
));
.
eq
(
FollowRelEntity:
:
getIdolId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getFansId
,
followerId
));
}
public
boolean
checkFollow
(
String
idolId
,
String
followerId
)
{
public
boolean
checkFollow
(
String
idolId
,
String
followerId
)
{
return
followRelMapper
.
selectCount
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getIdolId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getFansId
,
followerId
)
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
>
0
;
.
eq
(
FollowRelEntity:
:
getIdolId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getFansId
,
followerId
)
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
>
0
;
}
...
...
community-service/src/main/java/com/tanpu/community/service/RecommendService.java
View file @
1bd75841
...
...
@@ -129,26 +129,28 @@ public class RecommendService {
int
newTimes
=
newRatio
;
int
recTimes
=
pythonRatio
;
String
id
;
while
(
hotTimes
>
0
&&
hotThemeIds
.
size
()
>
hot
Idx
)
{
id
=
hotThemeIds
.
get
(
hot
Idx
);
while
(
newTimes
>
0
&&
newThemeIds
.
size
()
>
new
Idx
)
{
id
=
newThemeIds
.
get
(
new
Idx
);
if
(!
set
.
contains
(
id
))
{
result
.
add
(
id
);
set
.
add
(
id
);
}
hot
Idx
++;
hot
Times
--;
new
Idx
++;
new
Times
--;
}
while
(
newTimes
>
0
&&
newThemeIds
.
size
()
>
newIdx
)
{
id
=
newThemeIds
.
get
(
newIdx
);
while
(
hotTimes
>
0
&&
hotThemeIds
.
size
()
>
hotIdx
)
{
id
=
hotThemeIds
.
get
(
hotIdx
);
if
(!
set
.
contains
(
id
))
{
result
.
add
(
id
);
set
.
add
(
id
);
}
new
Idx
++;
new
Times
--;
hot
Idx
++;
hot
Times
--;
}
while
(
recTimes
>
0
&&
recThemeIds
.
size
()
>
recIdx
)
{
id
=
recThemeIds
.
get
(
recIdx
);
if
(!
set
.
contains
(
id
))
{
...
...
@@ -170,15 +172,14 @@ public class RecommendService {
int
round
=
0
;
while
(
true
)
{
int
hotStart
=
round
*
6
;
int
newestStart
=
round
*
3
;
int
hotStart
=
round
*
3
;
int
newestStart
=
round
*
6
;
int
recmdStart
=
round
;
if
(
hotStart
>=
hotIds
.
size
()
&&
newestStart
>=
newestIds
.
size
()
&&
recmdStart
>=
recmdIds
.
size
())
{
break
;
}
retList
.
addAll
(
BizUtils
.
subList
(
hotIds
,
hotStart
,
hotStart
+
6
));
retList
.
addAll
(
BizUtils
.
subList
(
newestIds
,
newestStart
,
newestStart
+
3
));
retList
.
addAll
(
BizUtils
.
subList
(
hotIds
,
hotStart
,
hotStart
+
6
));
retList
.
addAll
(
BizUtils
.
subList
(
recmdIds
,
recmdStart
,
recmdStart
+
1
));
round
++;
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
1bd75841
...
...
@@ -18,8 +18,12 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -73,15 +77,15 @@ public class ThemeService {
}
//根据用户id查询主题list
public
List
<
ThemeEntity
>
queryThemesByUserId
(
String
userId
,
String
lastId
,
Integer
pageSize
)
{
public
List
<
ThemeEntity
>
queryThemesByUserId
CreateDesc
(
String
userId
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getAuthorId
,
userId
)
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByDesc
(
ThemeEntity:
:
get
Id
);
.
orderByDesc
(
ThemeEntity:
:
get
CreateTime
);
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
get
Upd
ateTime
,
lastEntity
.
getCreateTime
());
queryWrapper
.
lt
(
ThemeEntity:
:
get
Cre
ateTime
,
lastEntity
.
getCreateTime
());
}
if
(
pageSize
!=
null
)
{
queryWrapper
.
last
(
"limit "
+
pageSize
);
...
...
@@ -100,7 +104,7 @@ public class ThemeService {
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
get
Upd
ateTime
,
lastEntity
.
getCreateTime
());
queryWrapper
.
lt
(
ThemeEntity:
:
get
Cre
ateTime
,
lastEntity
.
getCreateTime
());
}
if
(
pageSize
!=
null
)
{
queryWrapper
.
last
(
"limit "
+
pageSize
);
...
...
@@ -126,67 +130,6 @@ public class ThemeService {
}
/**
* 查询非传入作者的主题(可分页)
*
* @param lastId
* @param pageSize
* @param userId
* @return
*/
public
List
<
ThemeEntity
>
selectExcludeUser
(
String
userId
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
if
(!
StringUtils
.
isEmpty
(
userId
))
{
queryWrapper
.
ne
(
ThemeEntity:
:
getAuthorId
,
userId
);
}
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
}
if
(
pageSize
!=
null
)
{
queryWrapper
.
last
(
"limit "
+
pageSize
);
}
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getId
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getCreateTime
);
queryWrapper
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
return
themeMapper
.
selectList
(
queryWrapper
);
}
/**
* 查询非传入作者的主题(可分页)
*
* @param lastId
* @param pageSize
* @param userId
* @return
*/
public
List
<
ThemeEntity
>
queryByThemeIdsExcludeUser
(
List
<
String
>
themeIds
,
String
userId
,
String
lastId
,
Integer
pageSize
)
{
if
(
CollectionUtils
.
isEmpty
(
themeIds
))
{
return
Collections
.
emptyList
();
}
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
in
(
ThemeEntity:
:
getThemeId
,
themeIds
);
if
(!
StringUtils
.
isEmpty
(
userId
))
{
queryWrapper
.
ne
(
ThemeEntity:
:
getAuthorId
,
userId
);
}
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
ThemeEntity
lastEntity
=
queryByThemeId
(
lastId
);
if
(
lastEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
getCreateTime
());
}
if
(
pageSize
!=
null
)
{
queryWrapper
.
last
(
"limit "
+
pageSize
);
}
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getId
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getCreateTime
);
queryWrapper
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
return
themeMapper
.
selectList
(
queryWrapper
);
}
/**
...
...
@@ -230,7 +173,6 @@ public class ThemeService {
if
(
CollectionUtils
.
isEmpty
(
userIds
)){
return
Collections
.
emptyList
();
}
//TODO 索引优化
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
in
(
ThemeEntity:
:
getAuthorId
,
userIds
)
.
last
(
"limit "
+
pageStart
+
", "
+
pageSize
)
...
...
community-service/src/main/java/com/tanpu/community/service/TopicService.java
View file @
1bd75841
...
...
@@ -75,7 +75,10 @@ public class TopicService {
}
public
TopicEntity
queryById
(
String
topicId
)
{
return
topicMapper
.
selectOne
(
new
LambdaQueryWrapper
<
TopicEntity
>().
eq
(
TopicEntity:
:
getTopicId
,
topicId
));
return
topicMapper
.
selectOne
(
new
LambdaQueryWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getTopicId
,
topicId
)
.
eq
(
TopicEntity:
:
getIsConceal
,
StatusEnum
.
FALSE
)
.
eq
(
TopicEntity:
:
getDeleteTag
,
StatusEnum
.
FALSE
));
}
public
List
<
TopicEntity
>
queryByIds
(
List
<
String
>
topicIds
)
{
...
...
community-service/src/main/java/com/tanpu/community/util/PageUtils.java
View file @
1bd75841
...
...
@@ -12,12 +12,14 @@ import java.util.List;
* @email: zhoupeng@wealthgrow.cn
*/
public
class
PageUtils
{
public
static
<
T
>
Page
<
T
>
page
(
Pageable
pageable
,
List
<
T
>
list
)
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
pageable
==
null
){
return
new
Page
<
T
>(
1
,
0
,
(
long
)
list
.
size
(),
1
,
list
);
}
return
new
Page
<>(
pageable
,
0L
,
new
ArrayList
<>());
return
new
Page
<
T
>(
pageable
,
0L
,
new
ArrayList
<>());
}
else
{
if
(
pageable
==
null
){
return
new
Page
<
T
>(
1
,
list
.
size
(),
(
long
)
list
.
size
(),
1
,
list
);
...
...
@@ -64,4 +66,8 @@ public class PageUtils {
}
}
}
public
static
<
T
>
Page
<
T
>
page
(
Page
<
String
>
o
,
List
<
T
>
list
)
{
return
new
Page
<>(
o
.
getPageNum
(),
o
.
getPageSize
(),
o
.
getTotalSize
(),
o
.
getTotalPages
(),
list
);
}
}
community-service/src/main/resources/application-test.yml
View file @
1bd75841
...
...
@@ -15,7 +15,7 @@ server:
spring.datasource
:
community
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
jdbc-url
:
jdbc:mysql://rm-uf6r22t3d798q4kmk.mysql.rds.aliyuncs.com:3306/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
jdbc-url
:
jdbc:mysql://rm-uf6r22t3d798q4kmk
ao
.mysql.rds.aliyuncs.com:3306/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username
:
tamp_admin
password
:
'
@imeng123'
maxActive
:
2
...
...
@@ -23,7 +23,8 @@ spring.datasource:
initialSize
:
2
user
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
jdbc-url
:
jdbc:mysql://rm-uf6r22t3d798q4kmk.mysql.rds.aliyuncs.com:3306/tamp_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
jdbc-url
:
jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username
:
tamp_admin
password
:
'
@imeng123'
maxActive
:
2
minIdle
:
2
...
...
@@ -80,6 +81,7 @@ es:
port
:
9200
userName
:
1
userPasswd
:
2
index
:
test
tencent
:
cloud
:
...
...
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