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
49f63e9c
Commit
49f63e9c
authored
Jul 15, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
话题列表fix
parent
102b435b
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
372 additions
and
186 deletions
+372
-186
FollowQo.java
.../main/java/com/tanpu/community/api/beans/qo/FollowQo.java
+6
-4
FormerThemeQo.java
.../java/com/tanpu/community/api/beans/qo/FormerThemeQo.java
+15
-0
ThemeContentQo.java
...java/com/tanpu/community/api/beans/qo/ThemeContentQo.java
+6
-0
ThemeQo.java
...c/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java
+6
-0
FollowRelReq.java
.../tanpu/community/api/beans/req/homepage/FollowRelReq.java
+3
-3
QueryRecordThemeReq.java
...community/api/beans/req/homepage/QueryRecordThemeReq.java
+3
-0
OperationTypeEnum.java
...java/com/tanpu/community/api/enums/OperationTypeEnum.java
+33
-0
HomePageController.java
...va/com/tanpu/community/controller/HomePageController.java
+25
-18
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+8
-8
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+22
-34
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+43
-30
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+19
-0
FollowRelService.java
...in/java/com/tanpu/community/service/FollowRelService.java
+48
-8
ProductService.java
...main/java/com/tanpu/community/service/ProductService.java
+85
-69
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+43
-8
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+7
-4
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/FollowQo.java
View file @
49f63e9c
...
@@ -2,17 +2,19 @@ package com.tanpu.community.api.beans.qo;
...
@@ -2,17 +2,19 @@ package com.tanpu.community.api.beans.qo;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel
(
"关注列表"
)
@ApiModel
(
"关注列表"
)
public
class
FollowQo
{
public
class
FollowQo
{
@ApiModelProperty
(
value
=
"id"
)
private
String
id
;
@ApiModelProperty
(
value
=
"用户id"
)
@ApiModelProperty
(
value
=
"用户id"
)
private
String
userId
;
private
String
userId
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/qo/FormerThemeQo.java
View file @
49f63e9c
...
@@ -25,6 +25,21 @@ public class FormerThemeQo {
...
@@ -25,6 +25,21 @@ public class FormerThemeQo {
@ApiModelProperty
(
value
=
"被转发的主题Id"
)
@ApiModelProperty
(
value
=
"被转发的主题Id"
)
private
String
formerThemeId
;
private
String
formerThemeId
;
@ApiModelProperty
(
value
=
"类型 1:讨论无标题 2:长文有标题 3:转发 "
)
private
Integer
themeType
;
@ApiModelProperty
(
value
=
"被转发的主题标题"
)
private
String
title
;
@ApiModelProperty
(
value
=
"被转发的主题的话题名称"
)
private
String
topicTitle
;
@ApiModelProperty
(
value
=
"被转发的主题所属的话题"
)
private
String
topicId
;
@ApiModelProperty
(
value
=
"被转发的主题的作者id"
)
private
String
authorId
;
@ApiModelProperty
(
value
=
"转发内容"
)
@ApiModelProperty
(
value
=
"转发内容"
)
private
List
<
ThemeContentQo
>
forwardContent
;
private
List
<
ThemeContentQo
>
forwardContent
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeContentQo.java
View file @
49f63e9c
...
@@ -3,12 +3,18 @@ package com.tanpu.community.api.beans.qo;
...
@@ -3,12 +3,18 @@ package com.tanpu.community.api.beans.qo;
import
com.tanpu.community.api.beans.ImagesDTO
;
import
com.tanpu.community.api.beans.ImagesDTO
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
import
java.util.List
;
@Data
@Data
@ApiModel
(
value
=
"主题内容"
)
@ApiModel
(
value
=
"主题内容"
)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
ThemeContentQo
{
public
class
ThemeContentQo
{
@ApiModelProperty
(
value
=
"RelTypeEnum类型,8:文本,88:产品 3:直播 6:短视频 2:课程,9:图片 10:多图(讨论)"
)
@ApiModelProperty
(
value
=
"RelTypeEnum类型,8:文本,88:产品 3:直播 6:短视频 2:课程,9:图片 10:多图(讨论)"
)
...
...
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java
View file @
49f63e9c
...
@@ -3,11 +3,17 @@ package com.tanpu.community.api.beans.qo;
...
@@ -3,11 +3,17 @@ package com.tanpu.community.api.beans.qo;
import
com.tanpu.community.api.beans.ImagesDTO
;
import
com.tanpu.community.api.beans.ImagesDTO
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
import
java.util.List
;
@Data
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel
(
"主题信息流对象"
)
@ApiModel
(
"主题信息流对象"
)
public
class
ThemeQo
{
public
class
ThemeQo
{
...
...
community-api/src/main/java/com/tanpu/community/api/beans/req/homepage/
AddIdo
lReq.java
→
community-api/src/main/java/com/tanpu/community/api/beans/req/homepage/
FollowRe
lReq.java
View file @
49f63e9c
...
@@ -4,11 +4,11 @@ import io.swagger.annotations.ApiModelProperty;
...
@@ -4,11 +4,11 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.Data
;
import
lombok.Data
;
@Data
@Data
public
class
AddIdo
lReq
{
public
class
FollowRe
lReq
{
@ApiModelProperty
(
value
=
"关注对象Id"
)
@ApiModelProperty
(
value
=
"关注对象Id"
)
private
String
followUserId
;
private
String
followUserId
;
@ApiModelProperty
(
value
=
"
粉丝Id
"
)
@ApiModelProperty
(
value
=
"
关注类型,1:关注 2:取消关注
"
)
private
String
followerId
;
private
Integer
type
;
}
}
community-api/src/main/java/com/tanpu/community/api/beans/req/homepage/QueryRecordThemeReq.java
View file @
49f63e9c
...
@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
...
@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
@Data
@Data
...
@@ -11,8 +12,10 @@ import javax.validation.constraints.NotNull;
...
@@ -11,8 +12,10 @@ import javax.validation.constraints.NotNull;
public
class
QueryRecordThemeReq
{
public
class
QueryRecordThemeReq
{
@ApiModelProperty
(
"用户Id"
)
@ApiModelProperty
(
"用户Id"
)
@NotBlank
private
String
userId
;
private
String
userId
;
@NotNull
@ApiModelProperty
(
value
=
"操作类型 1:发布 2:回复 3:点赞 4:收藏"
)
@ApiModelProperty
(
value
=
"操作类型 1:发布 2:回复 3:点赞 4:收藏"
)
private
Integer
recordType
;
private
Integer
recordType
;
...
...
community-api/src/main/java/com/tanpu/community/api/enums/OperationTypeEnum.java
0 → 100644
View file @
49f63e9c
package
com
.
tanpu
.
community
.
api
.
enums
;
/**
* 通用操作类型枚举,包括点赞/取消点赞,收藏/取消收藏,关注/取消关注
*/
public
enum
OperationTypeEnum
{
CONFIRM
(
1
,
"确认操作"
),
CANCEL
(
2
,
"取消操作"
);
private
Integer
code
;
private
String
type
;
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
OperationTypeEnum
(
Integer
code
,
String
type
)
{
this
.
code
=
code
;
this
.
type
=
type
;
}
}
community-service/src/main/java/com/tanpu/community/controller/HomePageController.java
View file @
49f63e9c
package
com
.
tanpu
.
community
.
controller
;
package
com
.
tanpu
.
community
.
controller
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.auth.AuthLogin
;
import
com.tanpu.common.auth.UserHolder
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.req.HomePageReq
;
import
com.tanpu.community.api.beans.req.HomePageReq
;
import
com.tanpu.community.api.beans.req.homepage.
AddIdo
lReq
;
import
com.tanpu.community.api.beans.req.homepage.
FollowRe
lReq
;
import
com.tanpu.community.api.beans.req.homepage.QueryFollowReq
;
import
com.tanpu.community.api.beans.req.homepage.QueryFollowReq
;
import
com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq
;
import
com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq
;
import
com.tanpu.community.api.beans.req.page.Page
;
import
com.tanpu.community.api.beans.req.page.Page
;
...
@@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.List
;
@RestController
@RestController
...
@@ -29,6 +32,9 @@ public class HomePageController {
...
@@ -29,6 +32,9 @@ public class HomePageController {
@Autowired
@Autowired
private
ThemeManager
themeManager
;
private
ThemeManager
themeManager
;
@Resource
private
UserHolder
userHolder
;
@PostMapping
(
value
=
"/editInfo"
)
@PostMapping
(
value
=
"/editInfo"
)
@ApiOperation
(
"编辑圈子个人资料"
)
@ApiOperation
(
"编辑圈子个人资料"
)
@ResponseBody
@ResponseBody
...
@@ -41,36 +47,37 @@ public class HomePageController {
...
@@ -41,36 +47,37 @@ public class HomePageController {
@PostMapping
(
value
=
"/followList"
)
@PostMapping
(
value
=
"/followList"
)
@ApiOperation
(
"查询关注/粉丝列表"
)
@ApiOperation
(
"查询关注/粉丝列表"
)
@ResponseBody
@ResponseBody
@AuthLogin
public
CommonResp
<
Page
<
FollowQo
>>
queryMyFans
(
@RequestBody
QueryFollowReq
req
)
{
public
CommonResp
<
Page
<
FollowQo
>>
queryMyFans
(
@RequestBody
QueryFollowReq
req
)
{
String
userId
=
"123"
;
String
userId
=
userHolder
.
getUserId
()
;
return
CommonResp
.
success
(
homePageManager
.
queryFollow
(
req
));
return
CommonResp
.
success
(
homePageManager
.
queryFollow
(
req
,
userId
));
}
}
@PostMapping
(
value
=
"/addIdol"
)
@PostMapping
(
value
=
"/addIdol"
)
@ApiOperation
(
"关注他人"
)
@ApiOperation
(
"关注
/取消关注
他人"
)
@ResponseBody
@ResponseBody
public
CommonResp
addIdol
(
@RequestBody
AddIdo
lReq
req
)
{
public
CommonResp
addIdol
(
@RequestBody
FollowRe
lReq
req
)
{
String
userId
=
"123"
;
String
userId
=
userHolder
.
getUserId
()
;
homePageManager
.
add
Idol
(
req
.
getFollowUserId
(),
req
.
getFollowUserId
()
);
homePageManager
.
add
FollowRel
(
req
,
userId
);
return
CommonResp
.
success
();
return
CommonResp
.
success
();
}
}
@PostMapping
(
value
=
"/themeList"
)
@PostMapping
(
value
=
"/themeList"
)
@ApiOperation
(
"用户的帖子列表"
)
@ApiOperation
(
"用户的帖子列表"
)
@ResponseBody
@ResponseBody
public
CommonResp
<
List
<
ThemeQo
>>
likeList
(
@RequestBody
QueryRecordThemeReq
req
){
@AuthLogin
String
userId
=
"123"
;
public
CommonResp
<
List
<
ThemeQo
>>
likeList
(
@Validated
@RequestBody
QueryRecordThemeReq
req
){
String
userId
=
userHolder
.
getUserId
();
return
CommonResp
.
success
(
themeManager
.
queryThemesByUser
(
req
,
userId
));
return
CommonResp
.
success
(
themeManager
.
queryThemesByUser
(
req
,
userId
));
}
}
@PostMapping
(
value
=
"/commentThemeList"
)
//
@PostMapping(value = "/commentThemeList")
@ApiOperation
(
"用户评论过的帖子列表"
)
//
@ApiOperation("用户评论过的帖子列表")
@ResponseBody
//
@ResponseBody
public
CommonResp
<
List
<
ThemeQo
>>
commentThemeList
(
@RequestBody
QueryRecordThemeReq
req
){
//
public CommonResp<List<ThemeQo>> commentThemeList(@RequestBody QueryRecordThemeReq req){
String
userId
=
"123"
;
//
String userId="123";
//
return
CommonResp
.
success
(
themeManager
.
queryThemesByUser
(
req
,
userId
));
//
return CommonResp.success(themeManager.queryThemesByUser(req,userId));
}
//
}
}
}
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
49f63e9c
...
@@ -5,6 +5,7 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
...
@@ -5,6 +5,7 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
import
com.tanpu.community.api.beans.req.comment.LikeCommentReq
;
import
com.tanpu.community.api.beans.req.comment.LikeCommentReq
;
import
com.tanpu.community.api.enums.CollectionTypeEnum
;
import
com.tanpu.community.api.enums.CollectionTypeEnum
;
import
com.tanpu.community.api.enums.CommentTypeEnum
;
import
com.tanpu.community.api.enums.CommentTypeEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.user.UserInfoEntity
;
import
com.tanpu.community.dao.entity.user.UserInfoEntity
;
import
com.tanpu.community.service.CollectionService
;
import
com.tanpu.community.service.CollectionService
;
...
@@ -50,7 +51,7 @@ public class CommentManager {
...
@@ -50,7 +51,7 @@ public class CommentManager {
}
}
//查询
//查询
public
List
<
CommentQo
>
queryComments
(
String
themeId
,
String
userId
)
{
public
List
<
CommentQo
>
queryComments
(
String
themeId
,
String
userId
)
{
List
<
CommentEntity
>
commentEntities
=
commentService
.
selectByThemeIdAndParentId
(
themeId
,
null
);
List
<
CommentEntity
>
commentEntities
=
commentService
.
selectByThemeIdAndParentId
(
themeId
,
null
);
List
<
CommentQo
>
commentQos
=
ConvertUtil
.
commentEntity2Qos
(
commentEntities
);
List
<
CommentQo
>
commentQos
=
ConvertUtil
.
commentEntity2Qos
(
commentEntities
);
...
@@ -61,18 +62,18 @@ public class CommentManager {
...
@@ -61,18 +62,18 @@ public class CommentManager {
//用户信息
//用户信息
String
authorId
=
commentQo
.
getAuthorId
();
String
authorId
=
commentQo
.
getAuthorId
();
UserInfoEntity
userInfo
=
userInfoService
.
selectById
(
authorId
);
UserInfoEntity
userInfo
=
userInfoService
.
selectById
(
authorId
);
if
(
userInfo
!=
null
)
{
if
(
userInfo
!=
null
)
{
commentQo
.
setUserImg
(
userInfo
.
getUiHeadimg
());
commentQo
.
setUserImg
(
userInfo
.
getUiHeadimg
());
commentQo
.
setNickName
(
userInfo
.
getUiNickname
());
commentQo
.
setNickName
(
userInfo
.
getUiNickname
());
}
}
//是否点赞及点赞数
//是否点赞及点赞数
String
commentId
=
commentQo
.
getCommentId
();
String
commentId
=
commentQo
.
getCommentId
();
if
(
likeCommentList
.
contains
(
commentId
)){
if
(
likeCommentList
.
contains
(
commentId
))
{
commentQo
.
setHasLiked
(
true
);
commentQo
.
setHasLiked
(
true
);
}
else
{
}
else
{
commentQo
.
setHasLiked
(
false
);
commentQo
.
setHasLiked
(
false
);
}
}
Integer
countByTypeAndId
=
collectionService
.
getCountByTypeAndId
(
commentId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
Integer
countByTypeAndId
=
collectionService
.
getCountByTypeAndId
(
commentId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
commentQo
.
setLikeCount
(
countByTypeAndId
);
commentQo
.
setLikeCount
(
countByTypeAndId
);
//二级评论,本期不上线
//二级评论,本期不上线
...
@@ -86,10 +87,9 @@ public class CommentManager {
...
@@ -86,10 +87,9 @@ public class CommentManager {
//点赞评论/取消点赞
//点赞评论/取消点赞
public
void
likeComment
(
LikeCommentReq
req
,
String
userId
)
{
public
void
likeComment
(
LikeCommentReq
req
,
String
userId
)
{
//todo 枚举值
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
if
(
1
==
req
.
getType
()){
collectionService
.
addIfNotExist
(
req
.
getCommentId
(),
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
collectionService
.
addIfNotExist
(
req
.
getCommentId
(),
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
}
else
if
(
2
==
req
.
getType
(
))
{
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()
))
{
collectionService
.
delete
(
req
.
getCommentId
(),
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
collectionService
.
delete
(
req
.
getCommentId
(),
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
49f63e9c
package
com
.
tanpu
.
community
.
manager
;
package
com
.
tanpu
.
community
.
manager
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.req.
HomePage
Req
;
import
com.tanpu.community.api.beans.req.
homepage.FollowRel
Req
;
import
com.tanpu.community.api.beans.req.homepage.QueryFollowReq
;
import
com.tanpu.community.api.beans.req.homepage.QueryFollowReq
;
import
com.tanpu.community.api.beans.req.page.Page
;
import
com.tanpu.community.api.beans.req.page.Page
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.api.enums.QueryFollowTypeEnum
;
import
com.tanpu.community.api.enums.QueryFollowTypeEnum
;
import
com.tanpu.community.dao.entity.
community.HomePage
Entity
;
import
com.tanpu.community.dao.entity.
user.UserInfo
Entity
;
import
com.tanpu.community.service.FollowRelService
;
import
com.tanpu.community.service.FollowRelService
;
import
com.tanpu.community.service.
HomePage
Service
;
import
com.tanpu.community.service.
UserInfo
Service
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.PageUtils
;
import
com.tanpu.community.util.PageUtils
;
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
javax.annotation.Resource
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -25,42 +25,26 @@ public class HomePageManager {
...
@@ -25,42 +25,26 @@ public class HomePageManager {
@Autowired
@Autowired
private
FollowRelService
followRelService
;
private
FollowRelService
followRelService
;
@Resource
private
HomePageService
homePageService
;
// public void editUserInfo(HomePageReq req,String userId) {
@Autowired
// HomePageEntity entity = HomePageEntity.builder()
private
UserInfoService
userInfoService
;
// .userId(userId)
// .nickName(req.getNickName())
// .headImg(req.getHeadImg())
// .introduction(req.getIntroduction())
// .sex(req.getSex())
// .location(req.getLocation())
// .build();
// if(homePageService.selectByUserId(userId) == null){
// homePageService.insert(entity);
// }else {
// homePageService.update(entity);
// }
// return;
// }
//获取用户关注、粉丝列表
//获取用户关注、粉丝列表
public
Page
<
FollowQo
>
queryFollow
(
QueryFollowReq
req
)
{
public
Page
<
FollowQo
>
queryFollow
(
QueryFollowReq
req
,
String
userId
)
{
List
<
String
>
userIds
=
QueryFollowTypeEnum
.
QUERY_FANS
.
getCode
().
equals
(
req
.
getQueryType
())?
List
<
String
>
userIds
=
QueryFollowTypeEnum
.
QUERY_FANS
.
getCode
().
equals
(
req
.
getQueryType
())
?
followRelService
.
queryFansByIdolId
(
req
.
getUserId
())
:
followRelService
.
queryFansByFollowerId
(
req
.
getUserId
());
followRelService
.
queryFansByIdolId
(
req
.
getUserId
())
:
followRelService
.
queryFansByFollowerId
(
req
.
getUserId
());
List
<
HomePageEntity
>
list
=
homePageService
.
selectListByUser
Ids
(
userIds
);
List
<
UserInfoEntity
>
userInfos
=
userInfoService
.
selectBy
Ids
(
userIds
);
List
<
FollowQo
>
collect
=
list
.
stream
().
map
(
ConvertUtil:
:
homePageEntity2FollowQo
).
collect
(
Collectors
.
toList
());
List
<
FollowQo
>
collect
=
userInfos
.
stream
().
map
(
ConvertUtil:
:
homePageEntity2FollowQo
).
collect
(
Collectors
.
toList
());
List
<
FollowQo
>
followQos
=
judgeFollowed
(
collect
,
req
.
getUserId
()
);
List
<
FollowQo
>
followQos
=
judgeFollowed
(
collect
,
userId
);
return
PageUtils
.
page
(
req
.
getPage
(),
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
.
queryFansByFollowerId
(
followerId
));
Set
<
String
>
idolSet
=
new
HashSet
<>(
followRelService
.
queryFansByFollowerId
(
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
);
}
}
return
o
;
return
o
;
...
@@ -68,7 +52,11 @@ public class HomePageManager {
...
@@ -68,7 +52,11 @@ public class HomePageManager {
}
}
public
void
addIdol
(
String
idolId
,
String
followerId
)
{
public
void
addFollowRel
(
FollowRelReq
req
,
String
followerId
)
{
followRelService
.
addFans
(
idolId
,
followerId
);
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
followRelService
.
addFollowRel
(
req
.
getFollowUserId
(),
followerId
);
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
followRelService
.
deleteFollowRel
(
req
.
getFollowUserId
(),
followerId
);
}
}
}
}
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
49f63e9c
...
@@ -3,17 +3,17 @@ package com.tanpu.community.manager;
...
@@ -3,17 +3,17 @@ package com.tanpu.community.manager;
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.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.ThemeQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq
;
import
com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq
;
import
com.tanpu.community.api.beans.req.theme.*
;
import
com.tanpu.community.api.beans.req.theme.*
;
import
com.tanpu.community.api.enums.BlockTypeEnum
;
import
com.tanpu.community.api.enums.*
;
import
com.tanpu.community.api.enums.CollectionTypeEnum
;
import
com.tanpu.community.api.enums.ThemeListTypeEnum
;
import
com.tanpu.community.api.enums.ThemeTypeEnum
;
import
com.tanpu.community.dao.entity.community.*
;
import
com.tanpu.community.dao.entity.community.*
;
import
com.tanpu.community.dao.entity.user.UserInfoEntity
;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.service.*
;
import
com.tanpu.community.service.other.BlackListService
;
import
com.tanpu.community.service.other.BlackListService
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.ConvertUtil
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -67,12 +67,12 @@ public class ThemeManager {
...
@@ -67,12 +67,12 @@ public class ThemeManager {
BeanUtils
.
copyProperties
(
req
,
themeEntity
);
BeanUtils
.
copyProperties
(
req
,
themeEntity
);
themeEntity
.
setAuthorId
(
userId
);
themeEntity
.
setAuthorId
(
userId
);
themeEntity
.
setContent
(
JsonUtil
.
toJson
(
req
.
getContent
()));
themeEntity
.
setContent
(
JsonUtil
.
toJson
(
req
.
getContent
()));
if
(
StringUtils
.
isEmpty
(
req
.
getEditThemeId
())){
if
(
StringUtils
.
isEmpty
(
req
.
getEditThemeId
()))
{
//新建
//新建
themeService
.
insertTheme
(
themeEntity
);
themeService
.
insertTheme
(
themeEntity
);
}
else
{
}
else
{
//修改
//修改
themeService
.
update
(
themeEntity
,
req
.
getEditThemeId
());
themeService
.
update
(
themeEntity
,
req
.
getEditThemeId
());
}
}
//保存附件表
//保存附件表
...
@@ -111,42 +111,57 @@ public class ThemeManager {
...
@@ -111,42 +111,57 @@ public class ThemeManager {
List
<
ThemeEntity
>
themeEntities
=
Collections
.
emptyList
();
List
<
ThemeEntity
>
themeEntities
=
Collections
.
emptyList
();
switch
(
req
.
getRecordType
())
{
switch
(
req
.
getRecordType
())
{
case
1
:
//发布
case
1
:
//发布
themeEntities
=
themeService
.
queryThemeIdsByUserId
(
req
.
getUserId
());
themeEntities
=
themeService
.
queryThemeIdsByUserId
(
req
.
getUserId
()
,
req
.
getLastId
(),
req
.
getPageSize
()
);
break
;
break
;
case
2
:
//回复
case
2
:
//回复
List
<
CommentEntity
>
commentEntities
=
commentService
.
queryThemesByUserId
(
req
.
getUserId
());
List
<
ThemeQo
>
commentThemeList
=
new
ArrayList
<>();
//评论列表
List
<
CommentEntity
>
commentEntities
=
commentService
.
queryThemesByUserId
(
req
.
getUserId
(),
req
.
getLastId
(),
req
.
getPageSize
());
//当前用户信息
UserInfoEntity
userInfoEntity
=
userInfoService
.
selectById
(
req
.
getUserId
());
Set
<
String
>
replyThemeIds
=
commentEntities
.
stream
().
map
(
CommentEntity:
:
getThemeId
).
collect
(
Collectors
.
toSet
());
Set
<
String
>
replyThemeIds
=
commentEntities
.
stream
().
map
(
CommentEntity:
:
getThemeId
).
collect
(
Collectors
.
toSet
());
if
(
CollectionUtils
.
isEmpty
(
replyThemeIds
)){
return
commentThemeList
;
}
Map
<
String
,
CommentEntity
>
commentMap
=
commentEntities
.
stream
()
.
collect
(
Collectors
.
toMap
(
CommentEntity:
:
getThemeId
,
o
->
o
));
themeEntities
=
themeService
.
queryByThemeIds
(
new
ArrayList
<>(
replyThemeIds
));
themeEntities
=
themeService
.
queryByThemeIds
(
new
ArrayList
<>(
replyThemeIds
));
List
<
ThemeQo
>
themeQos
=
convertEntityToQo
(
themeEntities
,
userId
);
List
<
ThemeQo
>
themeQos
=
convertEntityToQo
(
themeEntities
,
userId
);
for
(
ThemeQo
themeQo
:
themeQos
)
{
for
(
ThemeQo
themeQo
:
themeQos
)
{
FormerThemeQo
f
=
FormerThemeQo
.
builder
().
formerThemeId
(
themeQo
.
getThemeId
())
String
themeId
=
themeQo
.
getThemeId
();
ThemeContentQo
commentContent
=
ThemeContentQo
.
builder
()
.
type
(
RelTypeEnum
.
TEXT
.
type
)
.
value
(
commentMap
.
get
(
themeId
)
.
getContent
())
.
build
();
ThemeQo
commentThemeQo
=
ThemeQo
.
builder
().
userImg
(
themeQo
.
getUserImg
())
.
nickName
(
userInfoEntity
.
getUiNickname
())
.
userImg
(
userInfoEntity
.
getUiHeadimg
())
.
content
(
Arrays
.
asList
(
commentContent
))
.
build
();
FormerThemeQo
f
=
FormerThemeQo
.
builder
().
formerThemeId
(
themeId
)
.
forwardContent
(
themeQo
.
getContent
())
.
forwardContent
(
themeQo
.
getContent
())
.
userImg
(
themeQo
.
getUserImg
())
.
userImg
(
themeQo
.
getUserImg
())
.
nickName
(
themeQo
.
getNickName
())
.
nickName
(
themeQo
.
getNickName
())
.
build
();
.
build
();
t
hemeQo
.
setFormerTheme
(
f
);
commentT
hemeQo
.
setFormerTheme
(
f
);
commentThemeList
.
add
(
commentThemeQo
);
}
}
break
;
return
commentThemeList
;
case
3
:
//点赞
case
3
:
//点赞
Set
<
String
>
likeThemeIds
=
collectionService
.
getListByUser
(
userId
,
CollectionTypeEnum
.
LIKE_THEME
);
Set
<
String
>
likeThemeIds
=
collectionService
.
getListByUser
(
userId
,
CollectionTypeEnum
.
LIKE_THEME
);
themeEntities
=
themeService
.
queryByThemeIds
(
new
ArrayList
<>(
likeThemeIds
));
themeEntities
=
themeService
.
queryByThemeIds
(
new
ArrayList
<>(
likeThemeIds
)
,
req
.
getLastId
(),
req
.
getPageSize
()
);
break
;
break
;
case
4
:
//收藏
case
4
:
//收藏
Set
<
String
>
collectThemeIds
=
collectionService
.
getListByUser
(
userId
,
CollectionTypeEnum
.
COLLECT_THEME
);
Set
<
String
>
collectThemeIds
=
collectionService
.
getListByUser
(
userId
,
CollectionTypeEnum
.
COLLECT_THEME
);
themeEntities
=
themeService
.
queryByThemeIds
(
new
ArrayList
<>(
collectThemeIds
));
themeEntities
=
themeService
.
queryByThemeIds
(
new
ArrayList
<>(
collectThemeIds
)
,
req
.
getLastId
(),
req
.
getPageSize
()
);
break
;
break
;
}
}
List
<
ThemeQo
>
themeQos
=
convertEntityToQo
(
themeEntities
,
userId
);
List
<
ThemeQo
>
themeQos
=
convertEntityToQo
(
themeEntities
,
userId
);
return
themeQos
;
return
themeQos
;
}
}
public
List
<
ThemeQo
>
queryThemesByUserComment
(
QueryRecordThemeReq
req
,
String
userId
)
{
List
<
CommentEntity
>
commentEntities
=
commentService
.
queryThemesByUserId
(
req
.
getUserId
());
Set
<
String
>
replyThemeIds
=
commentEntities
.
stream
().
map
(
CommentEntity:
:
getThemeId
).
collect
(
Collectors
.
toSet
());
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryByThemeIds
(
new
ArrayList
<>(
replyThemeIds
));
return
null
;
}
//查询正文
//查询正文
...
@@ -163,10 +178,9 @@ public class ThemeManager {
...
@@ -163,10 +178,9 @@ public class ThemeManager {
// 点赞/取消点赞
// 点赞/取消点赞
public
void
like
(
LikeThemeReq
req
,
String
userId
)
{
public
void
like
(
LikeThemeReq
req
,
String
userId
)
{
//todo 枚举值
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
if
(
1
==
req
.
getType
())
{
collectionService
.
addIfNotExist
(
req
.
getThemeId
(),
userId
,
CollectionTypeEnum
.
LIKE_THEME
);
collectionService
.
addIfNotExist
(
req
.
getThemeId
(),
userId
,
CollectionTypeEnum
.
LIKE_THEME
);
}
else
if
(
2
==
req
.
getType
(
))
{
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()
))
{
collectionService
.
delete
(
req
.
getThemeId
(),
userId
,
CollectionTypeEnum
.
LIKE_THEME
);
collectionService
.
delete
(
req
.
getThemeId
(),
userId
,
CollectionTypeEnum
.
LIKE_THEME
);
}
}
...
@@ -174,10 +188,9 @@ public class ThemeManager {
...
@@ -174,10 +188,9 @@ public class ThemeManager {
//收藏/取消收藏
//收藏/取消收藏
public
void
collect
(
CollectThemeReq
req
,
String
userId
)
{
public
void
collect
(
CollectThemeReq
req
,
String
userId
)
{
//todo 枚举值
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
if
(
1
==
req
.
getType
())
{
collectionService
.
addIfNotExist
(
req
.
getThemeId
(),
userId
,
CollectionTypeEnum
.
COLLECT_THEME
);
collectionService
.
addIfNotExist
(
req
.
getThemeId
(),
userId
,
CollectionTypeEnum
.
COLLECT_THEME
);
}
else
if
(
2
==
req
.
getType
(
))
{
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()
))
{
collectionService
.
delete
(
req
.
getThemeId
(),
userId
,
CollectionTypeEnum
.
COLLECT_THEME
);
collectionService
.
delete
(
req
.
getThemeId
(),
userId
,
CollectionTypeEnum
.
COLLECT_THEME
);
}
}
}
}
...
@@ -193,12 +206,12 @@ public class ThemeManager {
...
@@ -193,12 +206,12 @@ public class ThemeManager {
.
themeType
(
ThemeTypeEnum
.
FORWARD
.
getCode
())
.
themeType
(
ThemeTypeEnum
.
FORWARD
.
getCode
())
.
build
();
.
build
();
if
(
StringUtils
.
isEmpty
(
req
.
getEditThemeId
())
||
req
.
getEditThemeId
()==
req
.
getFormerThemeId
())
{
if
(
StringUtils
.
isEmpty
(
req
.
getEditThemeId
())
||
req
.
getEditThemeId
()
==
req
.
getFormerThemeId
())
{
//新建
//新建
themeService
.
insertTheme
(
newTheme
);
themeService
.
insertTheme
(
newTheme
);
}
else
{
}
else
{
//修改
//修改
themeService
.
update
(
newTheme
,
req
.
getEditThemeId
());
themeService
.
update
(
newTheme
,
req
.
getEditThemeId
());
}
}
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
49f63e9c
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.exception.BizException
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.community.api.enums.CommentTypeEnum
;
import
com.tanpu.community.api.enums.CommentTypeEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
...
@@ -8,6 +9,7 @@ import com.tanpu.community.api.enums.TopicStatusEnum;
...
@@ -8,6 +9,7 @@ import com.tanpu.community.api.enums.TopicStatusEnum;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.mapper.community.CommentMapper
;
import
com.tanpu.community.dao.mapper.community.CommentMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
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
;
...
@@ -74,4 +76,21 @@ public class CommentService {
...
@@ -74,4 +76,21 @@ public class CommentService {
.
eq
(
CommentEntity:
:
getCommentType
,
CommentTypeEnum
.
THEME
.
getCode
())
.
eq
(
CommentEntity:
:
getCommentType
,
CommentTypeEnum
.
THEME
.
getCode
())
.
eq
(
CommentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
.
eq
(
CommentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
}
}
public
List
<
CommentEntity
>
queryThemesByUserId
(
String
userId
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
CommentEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CommentEntity
>()
.
eq
(
CommentEntity:
:
getAuthorId
,
userId
)
.
eq
(
CommentEntity:
:
getCommentType
,
CommentTypeEnum
.
THEME
.
getCode
())
.
eq
(
CommentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
if
(
StringUtils
.
isNotEmpty
(
lastId
))
{
CommentEntity
commentEntity
=
commentMapper
.
selectById
(
lastId
);
if
(
commentEntity
==
null
)
throw
new
BizException
(
"主题未找到,id:"
+
lastId
);
queryWrapper
.
lt
(
CommentEntity:
:
getUpdateTime
,
commentEntity
.
getCreateTime
());
}
if
(
pageSize
!=
null
){
queryWrapper
.
last
(
"limit "
+
pageSize
);
}
return
commentMapper
.
selectList
(
queryWrapper
);
}
}
}
community-service/src/main/java/com/tanpu/community/service/FollowRelService.java
View file @
49f63e9c
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.exception.BizException
;
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
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.annotation.EnableCaching
;
...
@@ -8,6 +10,7 @@ import org.springframework.stereotype.Service;
...
@@ -8,6 +10,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.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -20,24 +23,61 @@ public class FollowRelService {
...
@@ -20,24 +23,61 @@ public class FollowRelService {
public
List
<
String
>
queryFansByFollowerId
(
String
followerId
)
{
public
List
<
String
>
queryFansByFollowerId
(
String
followerId
)
{
return
followRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
return
followRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getFollowerId
,
followerId
))
.
eq
(
FollowRelEntity:
:
getFollowerId
,
followerId
)
.
stream
().
map
(
FollowRelEntity:
:
getFollowUserId
).
collect
(
Collectors
.
toList
());
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()))
.
stream
().
map
(
FollowRelEntity:
:
getFollowUserId
)
.
collect
(
Collectors
.
toList
());
}
}
// @Cacheable(value = "tempCache", keyGenerator = "communityKeyGenerator")
// @Cacheable(value = "tempCache", keyGenerator = "communityKeyGenerator")
public
List
<
String
>
queryFansByIdolId
(
String
idolId
)
{
public
List
<
String
>
queryFansByIdolId
(
String
idolId
)
{
LambdaQueryWrapper
<
FollowRelEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
FollowRelEntity
>()
LambdaQueryWrapper
<
FollowRelEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getFollowUserId
,
idolId
);
.
eq
(
FollowRelEntity:
:
getFollowUserId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
return
followRelMapper
.
selectList
(
queryWrapper
)
return
followRelMapper
.
selectList
(
queryWrapper
)
.
stream
().
map
(
FollowRelEntity:
:
getFollowerId
).
collect
(
Collectors
.
toList
());
.
stream
().
map
(
FollowRelEntity:
:
getFollowerId
).
collect
(
Collectors
.
toList
());
}
}
@Transactional
@Transactional
public
void
addFans
(
String
idolId
,
String
followerId
)
{
public
void
addFollowRel
(
String
idolId
,
String
followerId
)
{
FollowRelEntity
rel
=
new
FollowRelEntity
();
FollowRelEntity
searchResult
=
queryRecord
(
idolId
,
followerId
);
rel
.
setFollowUserId
(
idolId
);
if
(
searchResult
==
null
){
rel
.
setFollowerId
(
followerId
);
FollowRelEntity
entity
=
FollowRelEntity
.
builder
()
.
followUserId
(
idolId
)
.
followerId
(
followerId
)
.
followTime
(
LocalDateTime
.
now
())
.
build
();
followRelMapper
.
insert
(
rel
);
followRelMapper
.
insert
(
entity
);
}
else
{
searchResult
.
setFollowTime
(
LocalDateTime
.
now
());
searchResult
.
setDeleteTag
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
followRelMapper
.
updateById
(
searchResult
);
}
}
}
/**
* 逻辑删除关注关系
* @param idolId
* @param followerId
*/
@Transactional
public
void
deleteFollowRel
(
String
idolId
,
String
followerId
)
{
FollowRelEntity
searchResult
=
queryRecord
(
idolId
,
followerId
);
if
(
searchResult
==
null
){
throw
new
BizException
(
"未找到关注关系"
);
}
searchResult
.
setUnfollowTime
(
LocalDateTime
.
now
());
searchResult
.
setDeleteTag
(
DeleteTagEnum
.
DELETED
.
getCode
());
followRelMapper
.
updateById
(
searchResult
);
}
public
FollowRelEntity
queryRecord
(
String
idolId
,
String
followerId
){
return
followRelMapper
.
selectOne
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getFollowUserId
,
idolId
)
.
eq
(
FollowRelEntity:
:
getFollowerId
,
followerId
));
}
}
}
community-service/src/main/java/com/tanpu/community/service/ProductService.java
View file @
49f63e9c
package
com
.
tanpu
.
community
.
service
;
package
com
.
tanpu
.
community
.
service
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Sets
;
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
;
...
@@ -31,10 +31,7 @@ import org.springframework.util.CollectionUtils;
...
@@ -31,10 +31,7 @@ import org.springframework.util.CollectionUtils;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Service
@Service
...
@@ -98,9 +95,9 @@ public class ProductService {
...
@@ -98,9 +95,9 @@ public class ProductService {
// 图片信息
// 图片信息
Map
<
String
,
UserInfoEntity
>
userMap
=
Maps
.
newHashMap
();
Map
<
String
,
UserInfoEntity
>
userMap
=
Maps
.
newHashMap
();
// 批量查询资源信息
// 批量查询资源信息
this
.
getResInfo
(
shortVideoMap
,
curriculumMap
,
courseMap
,
zhiboMap
,
fundMap
,
imgMap
,
topicMap
,
userMap
,
themeQos
);
this
.
getResInfo
(
shortVideoMap
,
curriculumMap
,
courseMap
,
zhiboMap
,
fundMap
,
imgMap
,
topicMap
,
userMap
,
themeQos
);
//逐个装入
//逐个装入
setResInfo
(
themeQos
,
shortVideoMap
,
curriculumMap
,
courseMap
,
zhiboMap
,
fundMap
,
imgMap
,
userMap
,
topicMap
);
setResInfo
(
themeQos
,
shortVideoMap
,
curriculumMap
,
courseMap
,
zhiboMap
,
fundMap
,
imgMap
,
userMap
,
topicMap
);
}
}
...
@@ -124,29 +121,29 @@ public class ProductService {
...
@@ -124,29 +121,29 @@ public class ProductService {
List
<
ThemeQo
>
themeQos
List
<
ThemeQo
>
themeQos
)
{
)
{
// 白名单基金id
// 白名单基金id
List
<
String
>
tanpuFundIds
=
Lists
.
newArrayLis
t
();
HashSet
<
String
>
tanpuFundIds
=
Sets
.
newHashSe
t
();
// 私募基金id
// 私募基金id
List
<
String
>
fundIds
=
Lists
.
newArrayLis
t
();
HashSet
<
String
>
fundIds
=
Sets
.
newHashSe
t
();
// 理财师导入
// 理财师导入
List
<
String
>
ifaFundIds
=
Lists
.
newArrayLis
t
();
HashSet
<
String
>
ifaFundIds
=
Sets
.
newHashSe
t
();
// 公募基金id
// 公募基金id
List
<
String
>
publicFundIds
=
Lists
.
newArrayLis
t
();
HashSet
<
String
>
publicFundIds
=
Sets
.
newHashSe
t
();
// 无净值产品id
// 无净值产品id
List
<
String
>
notNetFundIds
=
Lists
.
newArrayLis
t
();
HashSet
<
String
>
notNetFundIds
=
Sets
.
newHashSe
t
();
// 短视频id
// 短视频id
List
<
String
>
shortVideoIds
=
Lists
.
newArrayLis
t
();
HashSet
<
String
>
shortVideoIds
=
Sets
.
newHashSe
t
();
// 直播id
// 直播id
List
<
String
>
zhiboIds
=
Lists
.
newArrayLis
t
();
HashSet
<
String
>
zhiboIds
=
Sets
.
newHashSe
t
();
// 课程id
// 课程id
List
<
String
>
curriculumIds
=
Lists
.
newArrayLis
t
();
HashSet
<
String
>
curriculumIds
=
Sets
.
newHashSe
t
();
// 新课程id
// 新课程id
List
<
String
>
courseIds
=
Lists
.
newArrayLis
t
();
HashSet
<
String
>
courseIds
=
Sets
.
newHashSe
t
();
// 图片id
// 图片id
List
<
String
>
imageIds
=
Lists
.
newArrayLis
t
();
HashSet
<
String
>
imageIds
=
Sets
.
newHashSe
t
();
// 话题id
// 话题id
List
<
String
>
topicIds
=
Lists
.
newArrayLis
t
();
HashSet
<
String
>
topicIds
=
Sets
.
newHashSe
t
();
// 用户id
// 用户id
List
<
String
>
userIds
=
Lists
.
newArrayLis
t
();
HashSet
<
String
>
userIds
=
Sets
.
newHashSe
t
();
// 获取关联资源id
// 获取关联资源id
if
(
themeQos
!=
null
)
{
if
(
themeQos
!=
null
)
{
themeQos
.
forEach
(
o
->
{
themeQos
.
forEach
(
o
->
{
...
@@ -189,43 +186,51 @@ public class ProductService {
...
@@ -189,43 +186,51 @@ public class ProductService {
}
}
if
(!
CollectionUtils
.
isEmpty
(
shortVideoIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
shortVideoIds
))
{
// 短视频列表
// 短视频列表
CommonResp
<
List
<
ShortVideoBaseInfoResp
>>
commonResp
=
feignClientForTanpuroom
.
getShortVideoBaseInfo
(
shortVideoIds
);
CommonResp
<
List
<
ShortVideoBaseInfoResp
>>
commonResp
=
feignClientForTanpuroom
.
getShortVideoBaseInfo
(
setToList
(
shortVideoIds
));
if
(
commonResp
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
commonResp
.
getData
()))
{
if
(
commonResp
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
commonResp
.
getData
()))
{
shortVideoMap
.
putAll
(
commonResp
.
getData
().
stream
().
collect
(
Collectors
.
toMap
(
ShortVideoBaseInfoResp:
:
getSourceId
,
item
->
item
)));
shortVideoMap
.
putAll
(
commonResp
.
getData
().
stream
()
.
collect
(
Collectors
.
toMap
(
ShortVideoBaseInfoResp:
:
getSourceId
,
item
->
item
)));
}
}
}
}
if
(!
CollectionUtils
.
isEmpty
(
curriculumIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
curriculumIds
))
{
// 课程列表
// 课程列表
List
<
ShortVideoBaseInfoResp
>
commonResp
=
feignClientForFatools
.
getCurriculumByColumnRelId
(
curriculumIds
);
List
<
ShortVideoBaseInfoResp
>
commonResp
=
feignClientForFatools
.
getCurriculumByColumnRelId
(
setToList
(
curriculumIds
));
if
(
commonResp
!=
null
&&
!
CollectionUtils
.
isEmpty
(
commonResp
))
{
if
(
commonResp
!=
null
&&
!
CollectionUtils
.
isEmpty
(
commonResp
))
{
curriculumMap
.
putAll
(
commonResp
.
stream
().
collect
(
Collectors
.
toMap
(
ShortVideoBaseInfoResp:
:
getColumnRelId
,
item
->
item
)));
curriculumMap
.
putAll
(
commonResp
.
stream
()
.
collect
(
Collectors
.
toMap
(
ShortVideoBaseInfoResp:
:
getColumnRelId
,
item
->
item
)));
}
}
}
}
if
(!
CollectionUtils
.
isEmpty
(
courseIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
courseIds
))
{
// 新版课程列表
// 新版课程列表
CommonResp
<
List
<
CourseSimpleResp
>>
commonResp
=
feignForCourse
.
getCourseSimpleList
(
courseIds
);
CommonResp
<
List
<
CourseSimpleResp
>>
commonResp
=
feignForCourse
.
getCourseSimpleList
(
setToList
(
courseIds
));
if
(
commonResp
.
isSuccess
()
&
!
CollectionUtils
.
isEmpty
(
commonResp
.
getData
()))
{
if
(
commonResp
.
isSuccess
()
&
!
CollectionUtils
.
isEmpty
(
commonResp
.
getData
()))
{
courseMap
.
putAll
(
commonResp
.
getData
().
stream
().
collect
(
Collectors
.
toMap
(
CourseSimpleResp:
:
getCourseId
,
item
->
item
)));
courseMap
.
putAll
(
commonResp
.
getData
().
stream
().
collect
(
Collectors
.
toMap
(
CourseSimpleResp:
:
getCourseId
,
item
->
item
)));
}
}
}
}
if
(!
CollectionUtils
.
isEmpty
(
zhiboIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
zhiboIds
))
{
// 直播列表
// 直播列表
CommonResp
<
List
<
ZhiboListResp
>>
commonResp
=
feignClientForZhibo
.
simpleList
(
zhiboIds
);
CommonResp
<
List
<
ZhiboListResp
>>
commonResp
=
feignClientForZhibo
.
simpleList
(
setToList
(
zhiboIds
));
if
(
commonResp
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
commonResp
.
getData
()))
{
if
(
commonResp
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
commonResp
.
getData
()))
{
zhiboMap
.
putAll
(
commonResp
.
getData
().
stream
().
collect
(
Collectors
.
toMap
(
ZhiboListResp:
:
getId
,
item
->
item
)));
zhiboMap
.
putAll
(
commonResp
.
getData
().
stream
().
collect
(
Collectors
.
toMap
(
ZhiboListResp:
:
getId
,
item
->
item
)));
}
}
}
}
if
(!
CollectionUtils
.
isEmpty
(
imageIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
imageIds
))
{
// 查询图片
// 查询图片
List
<
FileRecordEntity
>
fileRecordEntities
=
ossFileService
.
queryByIds
(
imageIds
);
List
<
FileRecordEntity
>
fileRecordEntities
=
ossFileService
.
queryByIds
(
setToList
(
imageIds
));
if
(!
CollectionUtils
.
isEmpty
(
fileRecordEntities
))
{
if
(!
CollectionUtils
.
isEmpty
(
fileRecordEntities
))
{
imgMap
.
putAll
(
fileRecordEntities
.
stream
().
collect
(
Collectors
imgMap
.
putAll
(
fileRecordEntities
.
stream
().
collect
(
Collectors
.
toMap
(
FileRecordEntity:
:
getFileId
,
o
->
o
)));
.
toMap
(
FileRecordEntity:
:
getFileId
,
o
->
o
)));
}
}
}
}
if
(!
CollectionUtils
.
isEmpty
(
topicIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
topicIds
))
{
// 查询话题标题
// 查询话题标题
List
<
TopicEntity
>
topicEntities
=
topicService
.
queryByIds
(
topicIds
);
List
<
TopicEntity
>
topicEntities
=
topicService
.
queryByIds
(
setToList
(
topicIds
));
if
(!
CollectionUtils
.
isEmpty
(
topicEntities
))
{
if
(!
CollectionUtils
.
isEmpty
(
topicEntities
))
{
topicMap
.
putAll
(
topicEntities
.
stream
().
collect
(
Collectors
topicMap
.
putAll
(
topicEntities
.
stream
().
collect
(
Collectors
.
toMap
(
TopicEntity:
:
getTopicId
,
TopicEntity:
:
getTopicTitle
)));
.
toMap
(
TopicEntity:
:
getTopicId
,
TopicEntity:
:
getTopicTitle
)));
...
@@ -233,10 +238,11 @@ public class ProductService {
...
@@ -233,10 +238,11 @@ public class ProductService {
}
}
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
// 查询用户信息
// 查询用户信息
List
<
UserInfoEntity
>
userInfos
=
userInfoService
.
selectByIds
(
userIds
);
List
<
UserInfoEntity
>
userInfos
=
userInfoService
.
selectByIds
(
setToList
(
userIds
));
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
userIds
))
{
userMap
.
putAll
(
userInfos
.
stream
().
collect
(
Collectors
userMap
.
putAll
(
userInfos
.
stream
().
collect
(
Collectors
.
toMap
(
UserInfoEntity:
:
getId
,
o
->
o
)));
.
toMap
(
UserInfoEntity:
:
getId
,
o
->
o
)));
}
}
}
}
this
.
getFundInfo
(
tanpuFundIds
,
fundIds
,
publicFundIds
,
ifaFundIds
,
notNetFundIds
,
fundMap
);
this
.
getFundInfo
(
tanpuFundIds
,
fundIds
,
publicFundIds
,
ifaFundIds
,
notNetFundIds
,
fundMap
);
...
@@ -250,11 +256,11 @@ public class ProductService {
...
@@ -250,11 +256,11 @@ public class ProductService {
* @param publicFundIds
* @param publicFundIds
* @param fundMap
* @param fundMap
*/
*/
private
void
getFundInfo
(
Lis
t
<
String
>
tanpuFundIds
,
private
void
getFundInfo
(
Se
t
<
String
>
tanpuFundIds
,
Lis
t
<
String
>
fundIds
,
Se
t
<
String
>
fundIds
,
Lis
t
<
String
>
publicFundIds
,
Se
t
<
String
>
publicFundIds
,
Lis
t
<
String
>
ifaFundIds
,
Se
t
<
String
>
ifaFundIds
,
Lis
t
<
String
>
notNetFundIds
,
Se
t
<
String
>
notNetFundIds
,
Map
<
String
,
FundInfoBaseResp
>
fundMap
)
{
Map
<
String
,
FundInfoBaseResp
>
fundMap
)
{
Map
<
String
,
FundInfoBaseResp
>
tampFundMap
=
null
;
Map
<
String
,
FundInfoBaseResp
>
tampFundMap
=
null
;
Map
<
String
,
FundInfoBaseResp
>
privateFundMap
=
null
;
Map
<
String
,
FundInfoBaseResp
>
privateFundMap
=
null
;
...
@@ -266,7 +272,8 @@ public class ProductService {
...
@@ -266,7 +272,8 @@ public class ProductService {
// .fundIds(Lists.newArrayList(tanpuFundIds))
// .fundIds(Lists.newArrayList(tanpuFundIds))
// .build();
// .build();
// 探普产品
// 探普产品
CommonResp
<
List
<
ProductInfoVO
>>
commonResp
=
feignForProduct
.
getProductInfoByIds
(
tanpuFundIds
);
CommonResp
<
List
<
ProductInfoVO
>>
commonResp
=
feignForProduct
.
getProductInfoByIds
(
setToList
(
tanpuFundIds
));
if
(
commonResp
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
commonResp
.
getData
()))
{
if
(
commonResp
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
commonResp
.
getData
()))
{
List
<
FundInfoBaseResp
>
fundInfoBaseRespList
=
commonResp
.
getData
().
stream
().
map
(
item
->
{
List
<
FundInfoBaseResp
>
fundInfoBaseRespList
=
commonResp
.
getData
().
stream
().
map
(
item
->
{
FundInfoBaseResp
fundInfoBaseResp
=
FundInfoBaseResp
.
builder
().
build
();
FundInfoBaseResp
fundInfoBaseResp
=
FundInfoBaseResp
.
builder
().
build
();
...
@@ -283,7 +290,8 @@ public class ProductService {
...
@@ -283,7 +290,8 @@ public class ProductService {
// 私募产品
// 私募产品
if
(!
CollectionUtils
.
isEmpty
(
fundIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
fundIds
))
{
// 私募产品
// 私募产品
CommonResp
<
List
<
ProductInfoVO
>>
fundResult
=
feignForFund
.
getProductList
(
fundIds
);
CommonResp
<
List
<
ProductInfoVO
>>
fundResult
=
feignForFund
.
getProductList
(
setToList
(
fundIds
));
if
(
fundResult
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
fundResult
.
getData
()))
{
if
(
fundResult
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
fundResult
.
getData
()))
{
List
<
FundInfoBaseResp
>
fundInfoBaseRespList
=
fundResult
.
getData
().
stream
().
map
(
item
->
{
List
<
FundInfoBaseResp
>
fundInfoBaseRespList
=
fundResult
.
getData
().
stream
().
map
(
item
->
{
FundInfoBaseResp
fundInfoBaseResp
=
FundInfoBaseResp
.
builder
().
build
();
FundInfoBaseResp
fundInfoBaseResp
=
FundInfoBaseResp
.
builder
().
build
();
...
@@ -300,7 +308,8 @@ public class ProductService {
...
@@ -300,7 +308,8 @@ public class ProductService {
// 理财师导入产品
// 理财师导入产品
if
(!
CollectionUtils
.
isEmpty
(
ifaFundIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
ifaFundIds
))
{
CommonResp
<
List
<
ProductInfoVO
>>
ifaFundResult
=
feignForFund
.
getPrivateFundList
(
ifaFundIds
);
CommonResp
<
List
<
ProductInfoVO
>>
ifaFundResult
=
feignForFund
.
getPrivateFundList
(
setToList
(
ifaFundIds
));
if
(
ifaFundResult
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
ifaFundResult
.
getData
()))
{
if
(
ifaFundResult
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
ifaFundResult
.
getData
()))
{
List
<
FundInfoBaseResp
>
fundInfoBaseRespList
=
ifaFundResult
.
getData
().
stream
().
map
(
item
->
{
List
<
FundInfoBaseResp
>
fundInfoBaseRespList
=
ifaFundResult
.
getData
().
stream
().
map
(
item
->
{
FundInfoBaseResp
fundInfoBaseResp
=
FundInfoBaseResp
.
builder
().
build
();
FundInfoBaseResp
fundInfoBaseResp
=
FundInfoBaseResp
.
builder
().
build
();
...
@@ -317,7 +326,8 @@ public class ProductService {
...
@@ -317,7 +326,8 @@ public class ProductService {
if
(!
CollectionUtils
.
isEmpty
(
publicFundIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
publicFundIds
))
{
// 公募产品
// 公募产品
CommonResp
<
List
<
ProductInfoVO
>>
publicFundResult
=
feignForPublicFund
.
getProductList
(
publicFundIds
);
CommonResp
<
List
<
ProductInfoVO
>>
publicFundResult
=
feignForPublicFund
.
getProductList
(
setToList
(
publicFundIds
));
if
(
publicFundResult
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
publicFundResult
.
getData
()))
{
if
(
publicFundResult
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
publicFundResult
.
getData
()))
{
List
<
FundInfoBaseResp
>
fundInfoBaseRespList
=
publicFundResult
.
getData
().
stream
().
map
(
item
->
{
List
<
FundInfoBaseResp
>
fundInfoBaseRespList
=
publicFundResult
.
getData
().
stream
().
map
(
item
->
{
FundInfoBaseResp
fundInfoBaseResp
=
FundInfoBaseResp
.
builder
().
build
();
FundInfoBaseResp
fundInfoBaseResp
=
FundInfoBaseResp
.
builder
().
build
();
...
@@ -333,7 +343,8 @@ public class ProductService {
...
@@ -333,7 +343,8 @@ public class ProductService {
if
(!
CollectionUtils
.
isEmpty
(
notNetFundIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
notNetFundIds
))
{
// 无净值产品
// 无净值产品
CommonResp
<
List
<
ProductInfoVO
>>
notNetInfoResult
=
feignForFund
.
getProductListNotNetInfo
(
notNetFundIds
);
CommonResp
<
List
<
ProductInfoVO
>>
notNetInfoResult
=
feignForFund
.
getProductListNotNetInfo
(
setToList
(
notNetFundIds
));
if
(
notNetInfoResult
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
notNetInfoResult
.
getData
()))
{
if
(
notNetInfoResult
.
isSuccess
()
&&
!
CollectionUtils
.
isEmpty
(
notNetInfoResult
.
getData
()))
{
List
<
FundInfoBaseResp
>
fundInfoBaseRespList
=
notNetInfoResult
.
getData
().
stream
().
map
(
item
->
{
List
<
FundInfoBaseResp
>
fundInfoBaseRespList
=
notNetInfoResult
.
getData
().
stream
().
map
(
item
->
{
FundInfoBaseResp
fundInfoBaseResp
=
FundInfoBaseResp
.
builder
().
build
();
FundInfoBaseResp
fundInfoBaseResp
=
FundInfoBaseResp
.
builder
().
build
();
...
@@ -408,7 +419,7 @@ public class ProductService {
...
@@ -408,7 +419,7 @@ public class ProductService {
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
();
String
extInfo
=
imgEntity
.
getExtInfo
();
if
(!
StringUtils
.
isEmpty
(
extInfo
)){
if
(!
StringUtils
.
isEmpty
(
extInfo
))
{
Map
<
String
,
Object
>
extMap
=
JsonUtil
.
toMap
(
extInfo
);
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"
))
...
@@ -419,11 +430,16 @@ public class ProductService {
...
@@ -419,11 +430,16 @@ public class ProductService {
}
}
}
}
}
}
}
}
}
}
}
}
private
List
<
String
>
setToList
(
Set
<
String
>
set
)
{
List
<
String
>
l
=
new
ArrayList
<>();
l
.
addAll
(
set
);
return
l
;
}
}
}
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
49f63e9c
...
@@ -47,14 +47,49 @@ public class ThemeService {
...
@@ -47,14 +47,49 @@ public class ThemeService {
public
List
<
ThemeEntity
>
queryThemeIdsByUserId
(
String
userId
)
{
public
List
<
ThemeEntity
>
queryThemeIdsByUserId
(
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
));
}
public
List
<
ThemeEntity
>
queryThemeIdsByUserId
(
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:
:
getId
);
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
);
}
return
themeMapper
.
selectList
(
queryWrapper
);
}
//根据ids返回主题详情
public
List
<
ThemeEntity
>
queryByThemeIds
(
List
<
String
>
themeIds
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
in
(
ThemeEntity:
:
getThemeId
,
themeIds
)
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
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
);
}
return
themeMapper
.
selectList
(
queryWrapper
);
}
}
//根据ids返回主题详情
//根据ids返回主题详情
public
List
<
ThemeEntity
>
queryByThemeIds
(
List
<
String
>
themeIds
)
{
public
List
<
ThemeEntity
>
queryByThemeIds
(
List
<
String
>
themeIds
)
{
return
themeMapper
.
selectList
(
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
());
return
themeMapper
.
selectList
(
queryWrapper
);
}
}
//分页倒叙lastId之前的主题
//分页倒叙lastId之前的主题
...
@@ -64,7 +99,7 @@ public class ThemeService {
...
@@ -64,7 +99,7 @@ public class ThemeService {
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
.
get
Upd
ateTime
());
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
get
Cre
ateTime
());
}
}
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getId
);
queryWrapper
.
orderByDesc
(
ThemeEntity:
:
getId
);
...
@@ -79,13 +114,13 @@ public class ThemeService {
...
@@ -79,13 +114,13 @@ public class ThemeService {
* @param pageSize 查询数量
* @param pageSize 查询数量
* @return
* @return
*/
*/
public
List
<
ThemeEntity
>
queryByTopic
(
String
topidId
,
String
lastId
,
Integer
pageSize
)
{
public
List
<
ThemeEntity
>
queryByTopic
(
String
topidId
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
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
.
get
Upd
ateTime
());
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
get
Cre
ateTime
());
}
}
if
(
pageSize
!=
null
){
if
(
pageSize
!=
null
){
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
last
(
"limit "
+
pageSize
);
...
@@ -114,7 +149,7 @@ public class ThemeService {
...
@@ -114,7 +149,7 @@ public class ThemeService {
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
.
get
Upd
ateTime
());
queryWrapper
.
lt
(
ThemeEntity:
:
getUpdateTime
,
lastEntity
.
get
Cre
ateTime
());
}
}
queryWrapper
.
last
(
"limit "
+
pageSize
);
queryWrapper
.
last
(
"limit "
+
pageSize
);
...
...
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
49f63e9c
...
@@ -10,6 +10,7 @@ import com.tanpu.community.api.beans.req.theme.ThemeContentReq;
...
@@ -10,6 +10,7 @@ import com.tanpu.community.api.beans.req.theme.ThemeContentReq;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.RelTypeEnum
;
import
com.tanpu.community.api.enums.RelTypeEnum
;
import
com.tanpu.community.dao.entity.community.*
;
import
com.tanpu.community.dao.entity.community.*
;
import
com.tanpu.community.dao.entity.user.UserInfoEntity
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -171,13 +172,15 @@ public class ConvertUtil {
...
@@ -171,13 +172,15 @@ public class ConvertUtil {
return
list
;
return
list
;
}
}
public
static
FollowQo
homePageEntity2FollowQo
(
HomePage
Entity
entity
)
{
public
static
FollowQo
homePageEntity2FollowQo
(
UserInfo
Entity
entity
)
{
if
(
entity
==
null
)
{
if
(
entity
==
null
)
{
return
null
;
return
null
;
}
}
FollowQo
followQo
=
new
FollowQo
();
return
FollowQo
.
builder
().
userId
(
entity
.
getId
())
BeanUtils
.
copyProperties
(
entity
,
followQo
);
.
nickName
(
entity
.
getUiNickname
())
return
followQo
;
.
headImg
(
entity
.
getUiHeadimg
())
.
introduction
(
entity
.
getUiIntroduction
())
.
build
();
}
}
...
...
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