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
40d76196
Commit
40d76196
authored
Aug 03, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
粉丝列表分页查询
parent
44b86aed
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
100 additions
and
56 deletions
+100
-56
QueryFollowReq.java
...anpu/community/api/beans/req/homepage/QueryFollowReq.java
+3
-3
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+16
-11
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+4
-14
BatchFeignCallService.java
...va/com/tanpu/community/service/BatchFeignCallService.java
+16
-12
FollowRelService.java
...in/java/com/tanpu/community/service/FollowRelService.java
+54
-15
PageUtils.java
...ice/src/main/java/com/tanpu/community/util/PageUtils.java
+7
-1
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/req/homepage/QueryFollowReq.java
View file @
40d76196
...
@@ -10,11 +10,11 @@ import lombok.Data;
...
@@ -10,11 +10,11 @@ import lombok.Data;
public
class
QueryFollowReq
{
public
class
QueryFollowReq
{
@ApiModelProperty
(
value
=
"用户Id"
)
@ApiModelProperty
(
value
=
"用户Id"
)
p
rivate
String
userId
;
p
ublic
String
userId
;
@ApiModelProperty
(
value
=
"查询类型,1:粉丝 2:关注"
)
@ApiModelProperty
(
value
=
"查询类型,1:粉丝 2:关注"
)
p
rivate
Integer
queryType
;
p
ublic
Integer
queryType
;
@ApiModelProperty
(
value
=
"分页"
)
@ApiModelProperty
(
value
=
"分页"
)
p
rivate
Pageable
page
;
p
ublic
Pageable
page
;
}
}
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
40d76196
...
@@ -58,7 +58,8 @@ public class HomePageManager {
...
@@ -58,7 +58,8 @@ public class HomePageManager {
//查询 个人中心 相关信息
//查询 个人中心 相关信息
public
UserInfoResp
queryUsersInfo
(
String
userIdMyself
,
String
userId
)
{
public
UserInfoResp
queryUsersInfo
(
String
userIdMyself
,
String
userId
)
{
CommonResp
<
UserInfoResp
>
queryUsersListNew
=
feignClientForFatools
.
queryUsersListNew
(
StringUtils
.
isNotBlank
(
userId
)
?
userId
:
userIdMyself
);
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
();
UserInfoResp
userInfoNew
=
queryUsersListNew
.
getData
();
if
(
StringUtils
.
isNotBlank
(
userId
)
&&
!
StringUtils
.
equals
(
userIdMyself
,
userId
))
{
//查询别人的个人主页
if
(
StringUtils
.
isNotBlank
(
userId
)
&&
!
StringUtils
.
equals
(
userIdMyself
,
userId
))
{
//查询别人的个人主页
...
@@ -94,7 +95,7 @@ public class HomePageManager {
...
@@ -94,7 +95,7 @@ public class HomePageManager {
}
}
// 查询首席投顾数量
// 查询首席投顾数量
CommonResp
<
Page
<
UserInfoNewChief
>>
pageCommonResp
=
feignClientForFatools
.
queryChiefFinancialAdviserList
(
1
,
1
);
CommonResp
<
Page
<
UserInfoNewChief
>>
pageCommonResp
=
feignClientForFatools
.
queryChiefFinancialAdviserList
(
1
,
1
);
if
(
pageCommonResp
.
isSuccess
()){
if
(
pageCommonResp
.
isSuccess
())
{
userInfoNew
.
getUserInfoNewChief
().
setChiefCount
(
pageCommonResp
.
getData
().
getTotalSize
());
userInfoNew
.
getUserInfoNewChief
().
setChiefCount
(
pageCommonResp
.
getData
().
getTotalSize
());
}
else
{
}
else
{
userInfoNew
.
getUserInfoNewChief
().
setChiefCount
(
0L
);
userInfoNew
.
getUserInfoNewChief
().
setChiefCount
(
0L
);
...
@@ -180,28 +181,32 @@ public class HomePageManager {
...
@@ -180,28 +181,32 @@ public class HomePageManager {
/**
/**
* 用户关注列表
* 用户关注列表
*
* @param req 目标用户
* @param req 目标用户
* @param userId 当前用户
* @param userId 当前用户
* @return
* @return
*/
*/
public
Page
<
FollowQo
>
queryFollow
(
QueryFollowReq
req
,
String
userId
)
{
public
Page
<
FollowQo
>
queryFollow
(
QueryFollowReq
req
,
String
userId
)
{
//TODO 数据库分页
//数据库分页
List
<
String
>
userIds
=
QueryFollowTypeEnum
.
QUERY_FANS
.
getCode
().
equals
(
req
.
getQueryType
())
?
Integer
pageSize
=
req
.
page
.
pageSize
;
followRelService
.
queryFansByIdolId
(
req
.
getUserId
())
:
followRelService
.
queryIdolsByFollowerId
(
req
.
getUserId
());
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
<>();
List
<
FollowQo
>
followQos
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
userIds
Page
.
getContent
()
))
{
List
<
UserInfoResp
>
userInfoNews
=
feignClientForFatools
.
queryUserListNew
(
userIds
);
List
<
UserInfoResp
>
userInfoNews
=
feignClientForFatools
.
queryUserListNew
(
userIds
Page
.
getContent
()
);
List
<
FollowQo
>
collect
=
userInfoNews
.
stream
().
map
(
ConvertUtil:
:
userInfoNew2FollowQo
).
collect
(
Collectors
.
toList
());
List
<
FollowQo
>
collect
=
userInfoNews
.
stream
().
map
(
ConvertUtil:
:
userInfoNew2FollowQo
).
collect
(
Collectors
.
toList
());
followQos
=
judgeFollowed
(
collect
,
userId
);
followQos
=
judgeFollowed
(
collect
,
userId
);
}
}
//分页
return
PageUtils
.
page
(
userIdsPage
,
followQos
);
return
PageUtils
.
page
(
req
.
getPage
(),
followQos
);
}
}
//判断返回列表中的用户是否被当前用户关注
//判断返回列表中的用户是否被当前用户关注
public
List
<
FollowQo
>
judgeFollowed
(
List
<
FollowQo
>
followQos
,
String
followerId
)
{
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
->
{
return
followQos
.
stream
().
map
(
o
->
{
if
(
idolSet
.
contains
(
o
.
getUserId
()))
{
if
(
idolSet
.
contains
(
o
.
getUserId
()))
{
o
.
setFollowed
(
true
);
o
.
setFollowed
(
true
);
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
40d76196
...
@@ -9,7 +9,6 @@ import com.tanpu.common.api.CommonResp;
...
@@ -9,7 +9,6 @@ import com.tanpu.common.api.CommonResp;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.community.api.CommunityConstant
;
import
com.tanpu.community.api.beans.qo.ESThemeQo
;
import
com.tanpu.community.api.beans.qo.ESThemeQo
;
import
com.tanpu.community.api.beans.qo.FormerThemeQo
;
import
com.tanpu.community.api.beans.qo.FormerThemeQo
;
import
com.tanpu.community.api.beans.qo.ThemeContentQo
;
import
com.tanpu.community.api.beans.qo.ThemeContentQo
;
...
@@ -25,7 +24,6 @@ import com.tanpu.community.api.beans.req.theme.ThemeListReq;
...
@@ -25,7 +24,6 @@ import com.tanpu.community.api.beans.req.theme.ThemeListReq;
import
com.tanpu.community.api.beans.resp.CreateThemeResp
;
import
com.tanpu.community.api.beans.resp.CreateThemeResp
;
import
com.tanpu.community.api.beans.resp.ThemeFullSearchResp
;
import
com.tanpu.community.api.beans.resp.ThemeFullSearchResp
;
import
com.tanpu.community.api.beans.resp.ThemeListResp
;
import
com.tanpu.community.api.beans.resp.ThemeListResp
;
import
com.tanpu.community.api.beans.vo.ImagesDTO
;
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.BlockTypeEnum
;
import
com.tanpu.community.api.enums.BlockTypeEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
...
@@ -281,7 +279,7 @@ public class ThemeManager {
...
@@ -281,7 +279,7 @@ public class ThemeManager {
}
else
if
(
ThemeListTypeEnum
.
FOLLOW
.
getCode
().
equals
(
req
.
getType
()))
{
}
else
if
(
ThemeListTypeEnum
.
FOLLOW
.
getCode
().
equals
(
req
.
getType
()))
{
// 根据关注列表查询,按时间倒序
// 根据关注列表查询,按时间倒序
List
<
String
>
fansList
=
followRelService
.
queryIdolsByF
ollower
Id
(
userId
);
List
<
String
>
fansList
=
followRelService
.
queryIdolsByF
ans
Id
(
userId
);
themes
=
themeService
.
queryByUserIdsCreateDesc
(
fansList
,
pageStart
,
pageSize
);
themes
=
themeService
.
queryByUserIdsCreateDesc
(
fansList
,
pageStart
,
pageSize
);
if
(
CollectionUtils
.
isEmpty
(
excludeIds
)
&&
!
themes
.
isEmpty
())
{
if
(
CollectionUtils
.
isEmpty
(
excludeIds
)
&&
!
themes
.
isEmpty
())
{
...
@@ -346,15 +344,7 @@ public class ThemeManager {
...
@@ -346,15 +344,7 @@ public class ThemeManager {
FormerThemeQo
former
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
CACHE_FORMER_THEME_ID
,
themeId
),
60
,
FormerThemeQo
former
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
CACHE_FORMER_THEME_ID
,
themeId
),
60
,
()
->
this
.
getFormerTheme
(
themeQo
.
getFormerThemeId
()),
FormerThemeQo
.
class
);
()
->
this
.
getFormerTheme
(
themeQo
.
getFormerThemeId
()),
FormerThemeQo
.
class
);
themeQo
.
setFormerTheme
(
former
);
themeQo
.
setFormerTheme
(
former
);
//压缩图片
themeQo
.
getContent
().
stream
().
forEach
(
o
->
{
if
(
o
.
getImgList
()
!=
null
)
{
for
(
ImagesDTO
imagesDTO
:
o
.
getImgList
())
{
if
(
StringUtils
.
isNotBlank
(
imagesDTO
.
getRemark
()))
imagesDTO
.
setResizeUrl
(
imagesDTO
.
getRemark
()
+
CommunityConstant
.
OSS_RESIZE_RATIO
);
}
}
});
// 点赞,收藏,转发
// 点赞,收藏,转发
...
@@ -390,7 +380,7 @@ public class ThemeManager {
...
@@ -390,7 +380,7 @@ public class ThemeManager {
private
void
buildThemeExtraInfoByUser
(
String
userId
,
List
<
ThemeQo
>
themeQos
)
{
private
void
buildThemeExtraInfoByUser
(
String
userId
,
List
<
ThemeQo
>
themeQos
)
{
// 批量查询
// 批量查询
List
<
String
>
themeIds
=
themeQos
.
stream
().
map
(
ThemeQo:
:
getThemeId
).
collect
(
Collectors
.
toList
());
List
<
String
>
themeIds
=
themeQos
.
stream
().
map
(
ThemeQo:
:
getThemeId
).
collect
(
Collectors
.
toList
());
Set
<
String
>
idolSet
=
new
HashSet
<>(
followRelService
.
queryIdolsByF
ollower
Id
(
userId
));
Set
<
String
>
idolSet
=
new
HashSet
<>(
followRelService
.
queryIdolsByF
ans
Id
(
userId
));
Set
<
String
>
likeSet
=
collectionService
.
getTargets
(
themeIds
,
userId
,
CollectionTypeEnum
.
LIKE_THEME
);
Set
<
String
>
likeSet
=
collectionService
.
getTargets
(
themeIds
,
userId
,
CollectionTypeEnum
.
LIKE_THEME
);
Set
<
String
>
bookSet
=
collectionService
.
getTargets
(
themeIds
,
userId
,
CollectionTypeEnum
.
COLLECT_THEME
);
Set
<
String
>
bookSet
=
collectionService
.
getTargets
(
themeIds
,
userId
,
CollectionTypeEnum
.
COLLECT_THEME
);
Set
<
String
>
forwardUsers
=
themeService
.
getForwardUsers
(
themeIds
);
Set
<
String
>
forwardUsers
=
themeService
.
getForwardUsers
(
themeIds
);
...
@@ -512,7 +502,7 @@ public class ThemeManager {
...
@@ -512,7 +502,7 @@ public class ThemeManager {
public
Integer
getFollowUpdateCount
(
String
userId
)
{
public
Integer
getFollowUpdateCount
(
String
userId
)
{
String
lastIdStr
=
redisCache
.
get
(
CACHE_IDOL_THEME_LAST_ID
+
userId
);
String
lastIdStr
=
redisCache
.
get
(
CACHE_IDOL_THEME_LAST_ID
+
userId
);
Long
lastId
=
StringUtils
.
isBlank
(
lastIdStr
)
?
0L
:
Long
.
parseLong
(
lastIdStr
);
Long
lastId
=
StringUtils
.
isBlank
(
lastIdStr
)
?
0L
:
Long
.
parseLong
(
lastIdStr
);
List
<
String
>
fansList
=
followRelService
.
queryIdolsByF
ollower
Id
(
userId
);
List
<
String
>
fansList
=
followRelService
.
queryIdolsByF
ans
Id
(
userId
);
return
themeService
.
queryCountFromLastId
(
fansList
,
lastId
);
return
themeService
.
queryCountFromLastId
(
fansList
,
lastId
);
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/BatchFeignCallService.java
View file @
40d76196
...
@@ -7,6 +7,7 @@ import com.tanpu.biz.common.enums.user.UserLevelEnum;
...
@@ -7,6 +7,7 @@ import com.tanpu.biz.common.enums.user.UserLevelEnum;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.enums.fund.ProductTypeEnum
;
import
com.tanpu.common.enums.fund.ProductTypeEnum
;
import
com.tanpu.common.util.JsonUtil
;
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.AttachmentDetailVo
;
import
com.tanpu.community.api.beans.qo.ThemeContentQo
;
import
com.tanpu.community.api.beans.qo.ThemeContentQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
...
@@ -258,10 +259,10 @@ public class BatchFeignCallService {
...
@@ -258,10 +259,10 @@ public class BatchFeignCallService {
Set
<
String
>
ifaFundIds
,
Set
<
String
>
ifaFundIds
,
Set
<
String
>
notNetFundIds
,
Set
<
String
>
notNetFundIds
,
Map
<
String
,
FundInfoBaseResp
>
fundMap
)
{
Map
<
String
,
FundInfoBaseResp
>
fundMap
)
{
Map
<
String
,
FundInfoBaseResp
>
tampFundMap
=
null
;
Map
<
String
,
FundInfoBaseResp
>
tampFundMap
;
Map
<
String
,
FundInfoBaseResp
>
privateFundMap
=
null
;
Map
<
String
,
FundInfoBaseResp
>
privateFundMap
;
Map
<
String
,
FundInfoBaseResp
>
publicFundMap
=
null
;
Map
<
String
,
FundInfoBaseResp
>
publicFundMap
;
Map
<
String
,
FundInfoBaseResp
>
ifaFundMap
=
null
;
Map
<
String
,
FundInfoBaseResp
>
ifaFundMap
;
Map
<
String
,
FundInfoBaseResp
>
notNetFundMap
=
null
;
Map
<
String
,
FundInfoBaseResp
>
notNetFundMap
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
tanpuFundIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
tanpuFundIds
))
{
// ProductListReq productListReq = ProductListReq.builder()
// ProductListReq productListReq = ProductListReq.builder()
...
@@ -276,7 +277,7 @@ public class BatchFeignCallService {
...
@@ -276,7 +277,7 @@ public class BatchFeignCallService {
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
tampFundMap
=
fundInfoBaseRespList
.
stream
().
collect
(
Collectors
.
toMap
(
FundInfoBaseResp:
:
getFundId
,
item
->
item
));
tampFundMap
=
fundInfoBaseRespList
.
stream
().
collect
(
Collectors
.
toMap
(
FundInfoBaseResp:
:
getFundId
,
item
->
item
));
if
(
tampFundMap
!=
null
&&
tampFundMap
.
size
()
>
0
)
{
if
(
tampFundMap
.
size
()
>
0
)
{
fundMap
.
putAll
(
tampFundMap
);
fundMap
.
putAll
(
tampFundMap
);
}
}
}
}
...
@@ -291,7 +292,7 @@ public class BatchFeignCallService {
...
@@ -291,7 +292,7 @@ public class BatchFeignCallService {
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
privateFundMap
=
fundInfoBaseRespList
.
stream
().
collect
(
Collectors
.
toMap
(
FundInfoBaseResp:
:
getFundId
,
item
->
item
));
privateFundMap
=
fundInfoBaseRespList
.
stream
().
collect
(
Collectors
.
toMap
(
FundInfoBaseResp:
:
getFundId
,
item
->
item
));
if
(
privateFundMap
!=
null
&&
privateFundMap
.
size
()
>
0
)
{
if
(
privateFundMap
.
size
()
>
0
)
{
fundMap
.
putAll
(
privateFundMap
);
fundMap
.
putAll
(
privateFundMap
);
}
}
}
}
...
@@ -307,7 +308,7 @@ public class BatchFeignCallService {
...
@@ -307,7 +308,7 @@ public class BatchFeignCallService {
ifaFundMap
=
fundInfoBaseRespList
.
stream
().
collect
(
Collectors
.
toMap
(
FundInfoBaseResp:
:
getFundId
,
item
->
item
));
ifaFundMap
=
fundInfoBaseRespList
.
stream
().
collect
(
Collectors
.
toMap
(
FundInfoBaseResp:
:
getFundId
,
item
->
item
));
if
(
ifaFundMap
!=
null
&&
ifaFundMap
.
size
()
>
0
)
{
if
(
ifaFundMap
.
size
()
>
0
)
{
fundMap
.
putAll
(
ifaFundMap
);
fundMap
.
putAll
(
ifaFundMap
);
}
}
}
}
...
@@ -322,7 +323,7 @@ public class BatchFeignCallService {
...
@@ -322,7 +323,7 @@ public class BatchFeignCallService {
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
publicFundMap
=
fundInfoBaseRespList
.
stream
().
collect
(
Collectors
.
toMap
(
FundInfoBaseResp:
:
getFundId
,
item
->
item
));
publicFundMap
=
fundInfoBaseRespList
.
stream
().
collect
(
Collectors
.
toMap
(
FundInfoBaseResp:
:
getFundId
,
item
->
item
));
if
(
publicFundMap
!=
null
&&
publicFundMap
.
size
()
>
0
)
{
if
(
publicFundMap
.
size
()
>
0
)
{
fundMap
.
putAll
(
publicFundMap
);
fundMap
.
putAll
(
publicFundMap
);
}
}
}
}
...
@@ -427,19 +428,20 @@ public class BatchFeignCallService {
...
@@ -427,19 +428,20 @@ public class BatchFeignCallService {
//单图封装到imglist列表中
//单图封装到imglist列表中
if
(
imgUrlMap
.
containsKey
(
themeContent
.
getValue
()))
{
if
(
imgUrlMap
.
containsKey
(
themeContent
.
getValue
()))
{
FileRecordEntity
imgEntity
=
imgUrlMap
.
get
(
themeContent
.
getValue
());
FileRecordEntity
imgEntity
=
imgUrlMap
.
get
(
themeContent
.
getValue
());
String
extInfo
=
imgEntity
.
getExtInfo
();
if
(
imgEntity
!=
null
&&
!
StringUtils
.
isEmpty
(
imgEntity
.
getExtInfo
()))
{
if
(!
StringUtils
.
isEmpty
(
extInfo
))
{
Map
<
String
,
Object
>
extMap
=
JsonUtil
.
toMap
(
imgEntity
.
getExtInfo
());
Map
<
String
,
Object
>
extMap
=
JsonUtil
.
toMap
(
extInfo
);
ImagesDTO
imagesDTO
=
ImagesDTO
.
builder
().
imgHeight
((
Integer
)
extMap
.
get
(
"height"
))
ImagesDTO
imagesDTO
=
ImagesDTO
.
builder
().
imgHeight
((
Integer
)
extMap
.
get
(
"height"
))
.
imgWidth
((
Integer
)
extMap
.
get
(
"width"
))
.
imgWidth
((
Integer
)
extMap
.
get
(
"width"
))
.
remark
(
imgEntity
.
getUrl
())
.
remark
(
imgEntity
.
getUrl
())
.
relId
(
imgEntity
.
getFileId
())
.
relId
(
imgEntity
.
getFileId
())
//压缩图片
.
resizeUrl
(
imgEntity
.
getUrl
()
+
CommunityConstant
.
OSS_RESIZE_RATIO
)
.
build
();
.
build
();
themeContent
.
setImgList
(
Collections
.
singletonList
(
imagesDTO
));
themeContent
.
setImgList
(
Collections
.
singletonList
(
imagesDTO
));
}
}
}
}
}
else
if
(
themeContent
.
getType
().
equals
(
RelTypeEnum
.
MULTIPLE_IMAGE
.
type
))
{
}
else
if
(
themeContent
.
getType
().
equals
(
RelTypeEnum
.
MULTIPLE_IMAGE
.
type
))
{
//多图写入图片宽高
//多图写入图片宽高
,压缩图片url
List
<
ImagesDTO
>
imgList
=
themeContent
.
getImgList
();
List
<
ImagesDTO
>
imgList
=
themeContent
.
getImgList
();
for
(
ImagesDTO
imagesDTO
:
imgList
)
{
for
(
ImagesDTO
imagesDTO
:
imgList
)
{
if
(
imgUrlMap
.
containsKey
(
imagesDTO
.
getRelId
()))
{
if
(
imgUrlMap
.
containsKey
(
imagesDTO
.
getRelId
()))
{
...
@@ -450,6 +452,8 @@ public class BatchFeignCallService {
...
@@ -450,6 +452,8 @@ public class BatchFeignCallService {
imagesDTO
.
setImgHeight
((
Integer
)
extMap
.
get
(
"height"
));
imagesDTO
.
setImgHeight
((
Integer
)
extMap
.
get
(
"height"
));
imagesDTO
.
setImgWidth
((
Integer
)
extMap
.
get
(
"width"
));
imagesDTO
.
setImgWidth
((
Integer
)
extMap
.
get
(
"width"
));
}
}
//压缩图片地址
imagesDTO
.
setResizeUrl
(
imgEntity
.
getUrl
()
+
CommunityConstant
.
OSS_RESIZE_RATIO
);
}
}
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/FollowRelService.java
View file @
40d76196
package
com
.
tanpu
.
community
.
service
;
package
com
.
tanpu
.
community
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.common.constant.BizStatus
;
import
com.tanpu.common.exception.BizException
;
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.api.enums.DeleteTagEnum
;
import
com.tanpu.community.dao.entity.community.FollowRelEntity
;
import
com.tanpu.community.dao.entity.community.FollowRelEntity
;
import
com.tanpu.community.dao.mapper.community.FollowRelMapper
;
import
com.tanpu.community.dao.mapper.community.FollowRelMapper
;
...
@@ -21,7 +23,7 @@ public class FollowRelService {
...
@@ -21,7 +23,7 @@ public class FollowRelService {
@Resource
@Resource
private
FollowRelMapper
followRelMapper
;
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
>()
return
followRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getFansId
,
followerId
)
.
eq
(
FollowRelEntity:
:
getFansId
,
followerId
)
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
...
@@ -29,19 +31,55 @@ public class FollowRelService {
...
@@ -29,19 +31,55 @@ public class FollowRelService {
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
}
}
// @Cacheable(value = "tempCache", keyGenerator = "communityKeyGenerator")
public
Page
<
String
>
queryIdolsByFansId
(
String
fansId
,
Integer
pageNum
,
Integer
pageSize
)
{
public
List
<
String
>
queryFansByIdolId
(
String
idolId
)
{
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
>()
LambdaQueryWrapper
<
FollowRelEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getIdolId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getIdolId
,
idolId
)
.
last
(
"limit "
+
pageStart
+
", "
+
pageSize
)
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
return
followRelMapper
.
selectList
(
queryWrapper
)
List
<
String
>
list
=
followRelMapper
.
selectList
(
queryWrapper
)
.
stream
().
map
(
FollowRelEntity:
:
getFansId
).
collect
(
Collectors
.
toList
());
.
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
@Transactional
public
void
addFollowRel
(
String
idolId
,
String
followerId
)
{
public
void
addFollowRel
(
String
idolId
,
String
followerId
)
{
FollowRelEntity
searchResult
=
queryRecord
(
idolId
,
followerId
);
FollowRelEntity
searchResult
=
queryRecord
(
idolId
,
followerId
);
if
(
searchResult
==
null
)
{
if
(
searchResult
==
null
)
{
FollowRelEntity
entity
=
FollowRelEntity
.
builder
()
FollowRelEntity
entity
=
FollowRelEntity
.
builder
()
.
idolId
(
idolId
)
.
idolId
(
idolId
)
.
fansId
(
followerId
)
.
fansId
(
followerId
)
...
@@ -49,7 +87,7 @@ public class FollowRelService {
...
@@ -49,7 +87,7 @@ public class FollowRelService {
.
build
();
.
build
();
followRelMapper
.
insert
(
entity
);
followRelMapper
.
insert
(
entity
);
}
else
{
}
else
{
searchResult
.
setFollowTime
(
LocalDateTime
.
now
());
searchResult
.
setFollowTime
(
LocalDateTime
.
now
());
searchResult
.
setDeleteTag
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
searchResult
.
setDeleteTag
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
followRelMapper
.
updateById
(
searchResult
);
followRelMapper
.
updateById
(
searchResult
);
...
@@ -59,13 +97,14 @@ public class FollowRelService {
...
@@ -59,13 +97,14 @@ public class FollowRelService {
/**
/**
* 逻辑删除关注关系
* 逻辑删除关注关系
*
* @param idolId
* @param idolId
* @param followerId
* @param followerId
*/
*/
@Transactional
@Transactional
public
void
deleteFollowRel
(
String
idolId
,
String
followerId
)
{
public
void
deleteFollowRel
(
String
idolId
,
String
followerId
)
{
FollowRelEntity
searchResult
=
queryRecord
(
idolId
,
followerId
);
FollowRelEntity
searchResult
=
queryRecord
(
idolId
,
followerId
);
if
(
searchResult
==
null
)
{
if
(
searchResult
==
null
)
{
throw
new
BizException
(
"未找到关注关系"
);
throw
new
BizException
(
"未找到关注关系"
);
}
}
searchResult
.
setUnfollowTime
(
LocalDateTime
.
now
());
searchResult
.
setUnfollowTime
(
LocalDateTime
.
now
());
...
@@ -73,18 +112,18 @@ public class FollowRelService {
...
@@ -73,18 +112,18 @@ public class FollowRelService {
followRelMapper
.
updateById
(
searchResult
);
followRelMapper
.
updateById
(
searchResult
);
}
}
public
FollowRelEntity
queryRecord
(
String
idolId
,
String
followerId
){
public
FollowRelEntity
queryRecord
(
String
idolId
,
String
followerId
)
{
return
followRelMapper
.
selectOne
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
return
followRelMapper
.
selectOne
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getIdolId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getIdolId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getFansId
,
followerId
));
.
eq
(
FollowRelEntity:
:
getFansId
,
followerId
));
}
}
public
boolean
checkFollow
(
String
idolId
,
String
followerId
)
{
public
boolean
checkFollow
(
String
idolId
,
String
followerId
)
{
return
followRelMapper
.
selectCount
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
return
followRelMapper
.
selectCount
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getIdolId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getIdolId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getFansId
,
followerId
)
.
eq
(
FollowRelEntity:
:
getFansId
,
followerId
)
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
>
0
;
>
0
;
}
}
...
...
community-service/src/main/java/com/tanpu/community/util/PageUtils.java
View file @
40d76196
...
@@ -12,12 +12,14 @@ import java.util.List;
...
@@ -12,12 +12,14 @@ import java.util.List;
* @email: zhoupeng@wealthgrow.cn
* @email: zhoupeng@wealthgrow.cn
*/
*/
public
class
PageUtils
{
public
class
PageUtils
{
public
static
<
T
>
Page
<
T
>
page
(
Pageable
pageable
,
List
<
T
>
list
)
{
public
static
<
T
>
Page
<
T
>
page
(
Pageable
pageable
,
List
<
T
>
list
)
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
pageable
==
null
){
if
(
pageable
==
null
){
return
new
Page
<
T
>(
1
,
0
,
(
long
)
list
.
size
(),
1
,
list
);
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
{
}
else
{
if
(
pageable
==
null
){
if
(
pageable
==
null
){
return
new
Page
<
T
>(
1
,
list
.
size
(),
(
long
)
list
.
size
(),
1
,
list
);
return
new
Page
<
T
>(
1
,
list
.
size
(),
(
long
)
list
.
size
(),
1
,
list
);
...
@@ -64,4 +66,8 @@ public class PageUtils {
...
@@ -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
);
}
}
}
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