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
f0f2842f
Commit
f0f2842f
authored
Aug 10, 2021
by
张辰
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'master'
Dev See merge request
!10
parents
e4b869fb
3f82e26d
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
56 additions
and
40 deletions
+56
-40
ThemeQo.java
...c/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java
+4
-1
CreateThemeReq.java
...m/tanpu/community/api/beans/req/theme/CreateThemeReq.java
+1
-1
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+1
-1
FeignClientForFatools.java
.../tanpu/community/feign/fatools/FeignClientForFatools.java
+1
-1
FeignbackForFatools.java
...om/tanpu/community/feign/fatools/FeignbackForFatools.java
+1
-2
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+1
-1
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+1
-1
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+43
-24
FeignService.java
...c/main/java/com/tanpu/community/service/FeignService.java
+1
-7
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+1
-1
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+1
-0
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java
View file @
f0f2842f
...
...
@@ -59,9 +59,12 @@ public class ThemeQo implements Serializable {
@ApiModelProperty
(
value
=
"认证机构"
)
private
String
authOrg
;
@ApiModelProperty
(
value
=
"发表时间"
)
@ApiModelProperty
(
value
=
"发表时间
-距今
"
)
public
String
upToNowTime
;
@ApiModelProperty
(
value
=
"发表时间-标准格式化"
)
public
String
formatTime
;
@ApiModelProperty
(
value
=
"转发量"
)
public
Integer
forwardCount
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/req/theme/CreateThemeReq.java
View file @
f0f2842f
...
...
@@ -30,7 +30,7 @@ public class CreateThemeReq {
@ApiModelProperty
(
value
=
"修改,则传入正在编辑的ThemeId"
)
private
String
editThemeId
=
""
;
@ApiModelProperty
(
"是否同步到社区 0为不同步 1为同步
不传也为
同步"
)
@ApiModelProperty
(
"是否同步到社区 0为不同步 1为同步
默认不
同步"
)
private
Integer
syncToNewComm
=
0
;
}
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
f0f2842f
...
...
@@ -33,7 +33,7 @@ public class ThemeController {
@ResponseBody
public
CommonResp
<
CreateThemeResp
>
publishTheme
(
@Validated
@RequestBody
CreateThemeReq
req
)
{
String
userId
=
userHolder
.
getUserId
();
return
CommonResp
.
success
(
themeManager
.
publishTheme
(
req
,
userId
)
);
return
themeManager
.
publishTheme
(
req
,
userId
);
}
@AuthLogin
...
...
community-service/src/main/java/com/tanpu/community/feign/fatools/FeignClientForFatools.java
View file @
f0f2842f
...
...
@@ -45,7 +45,7 @@ public interface FeignClientForFatools {
// 用户信息查询 (供圈子服务调用)
@ApiOperation
(
value
=
"查询用户信息"
)
@GetMapping
(
value
=
"/queryUserInfoNew"
)
CommonResp
<
UserInfoResp
>
queryUser
sList
New
(
@RequestParam
(
"userId"
)
String
userId
);
CommonResp
<
UserInfoResp
>
queryUser
Info
New
(
@RequestParam
(
"userId"
)
String
userId
);
@ApiOperation
(
value
=
"批量查询查询基本信息"
)
@GetMapping
(
value
=
"/queryUserBaseInfoList"
)
...
...
community-service/src/main/java/com/tanpu/community/feign/fatools/FeignbackForFatools.java
View file @
f0f2842f
...
...
@@ -2,7 +2,6 @@ package com.tanpu.community.feign.fatools;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.community.api.beans.req.page.Page
;
import
com.tanpu.community.api.beans.req.page.Pageable
;
import
com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNewChief
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoOrg
;
...
...
@@ -50,7 +49,7 @@ public class FeignbackForFatools implements FallbackFactory<FeignClientForFatool
}
@Override
public
CommonResp
<
UserInfoResp
>
queryUser
sList
New
(
String
userId
)
{
public
CommonResp
<
UserInfoResp
>
queryUser
Info
New
(
String
userId
)
{
log
.
info
(
"FeignbackForFatools.queryUsersListNew"
,
throwable
);
return
CommonResp
.
error
();
}
...
...
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
f0f2842f
...
...
@@ -108,7 +108,7 @@ public class CommentManager {
}
private
UserInfoResp
getUserInfo
(
String
authorId
){
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUser
sList
New
(
authorId
);
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUser
Info
New
(
authorId
);
if
(
userInfoNewCommonResp
.
isNotSuccess
())
{
throw
new
BizException
(
"内部接口调用失败"
);
}
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
f0f2842f
...
...
@@ -63,7 +63,7 @@ public class HomePageManager {
//查询 个人中心 相关信息
public
UserInfoResp
queryUsersInfo
(
String
userIdMyself
,
String
userId
)
{
CommonResp
<
UserInfoResp
>
queryUsersListNew
=
feignClientForFatools
.
queryUser
sList
New
(
StringUtils
.
isNotBlank
(
userId
)
?
userId
:
userIdMyself
);
CommonResp
<
UserInfoResp
>
queryUsersListNew
=
feignClientForFatools
.
queryUser
Info
New
(
StringUtils
.
isNotBlank
(
userId
)
?
userId
:
userIdMyself
);
if
(
queryUsersListNew
.
isNotSuccess
()
||
!
ObjectUtils
.
anyNotNull
(
queryUsersListNew
.
getData
()))
throw
new
BizException
(
"内部接口调用失败"
);
UserInfoResp
userInfoNew
=
queryUsersListNew
.
getData
();
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
f0f2842f
...
...
@@ -55,7 +55,6 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.exception.ExceptionUtils
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -197,12 +196,15 @@ public class ThemeManager {
* 发表主题(修改)
*/
@Transactional
public
C
reateThemeResp
publishTheme
(
CreateThemeReq
req
,
String
userId
)
{
public
C
ommonResp
<
CreateThemeResp
>
publishTheme
(
CreateThemeReq
req
,
String
userId
)
{
// 校验参数
checkAttachment
(
req
.
getContent
());
// 转播权限校验
liveRelayCheck
(
userId
,
req
.
getContent
());
// if (1 == req.getSyncToNewComm()) {
// liveRelayCheck(userId, req.getContent());
// }
// 保存主题表
ThemeEntity
themeEntity
=
new
ThemeEntity
();
...
...
@@ -216,11 +218,6 @@ public class ThemeManager {
if
(
StringUtils
.
isBlank
(
req
.
getEditThemeId
()))
{
// 新建
themeService
.
insertTheme
(
themeEntity
);
// 同步到专栏
if
(
1
==
req
.
getSyncToNewComm
())
{
synchronizeToNewsFeed
(
req
,
themeEntity
.
getThemeId
(),
userId
);
}
}
else
{
// 修改
themeService
.
update
(
themeEntity
,
req
.
getEditThemeId
());
...
...
@@ -243,10 +240,30 @@ public class ThemeManager {
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CACHE_THEME_ID
,
themeEntity
.
getThemeId
()));
return
CreateThemeResp
.
builder
().
themeId
(
themeEntity
.
getThemeId
()).
build
();
CreateThemeResp
themeResp
=
CreateThemeResp
.
builder
().
themeId
(
themeEntity
.
getThemeId
()).
build
();
// 同步到专栏
if
(
1
==
req
.
getSyncToNewComm
())
{
CommonResp
response
=
synchronizeToNewsFeed
(
req
,
themeEntity
.
getThemeId
(),
userId
);
if
(
response
.
isNotSuccess
())
{
if
(
"8001"
.
equals
(
response
.
getCode
()))
{
// 内容受限,不会滚发布
return
CommonResp
.
error
(
ErrorCodeConstant
.
THEME_SYNCHRONIZE_FAILED
.
getCode
(),
"发布成功,同步失败:"
+
response
.
getMsg
(),
themeResp
);
}
else
{
// 其他回滚异常
throw
new
BizException
(
ErrorCodeConstant
.
THEME_PUBLISH_FAILED
.
getCode
()
,
"调用专栏同步异常:"
+
response
.
getMsg
());
}
}
}
return
CommonResp
.
success
(
themeResp
);
}
private
void
synchronizeToNewsFeed
(
CreateThemeReq
req
,
String
themeId
,
String
userId
)
{
private
CommonResp
synchronizeToNewsFeed
(
CreateThemeReq
req
,
String
themeId
,
String
userId
)
{
if
(!
ThemeTypeEnum
.
DISCUSSION
.
getCode
().
equals
(
req
.
getThemeType
()))
{
// 只有讨论类型才能同步专栏
throw
new
BizException
(
"长文类型无法同步专栏"
);
...
...
@@ -275,15 +292,19 @@ public class ThemeManager {
}
}
newsFeedReq
.
setNewsFeedResList
(
feedList
);
CommonResp
response
=
feignClientForCommunity
.
saveNewsFeed4NewComm
(
newsFeedReq
);
if
(
response
.
isNotSuccess
()
||
!
ObjectUtils
.
anyNotNull
(
response
.
getData
()))
{
throw
new
BizException
(
"同步圈子调用失败"
);
}
return
feignClientForCommunity
.
saveNewsFeed4NewComm
(
newsFeedReq
);
}
/**
* 转存图片到老接口
*
* @param img
* @param userId
* @return
*/
private
NewsFeedResReq
convertImg
(
ImagesDTO
img
,
String
userId
)
{
String
imgUrl
=
img
.
getRemark
();
String
[]
arr
=
StringUtils
.
split
(
imgUrl
,
"."
);
...
...
@@ -349,19 +370,19 @@ public class ThemeManager {
*/
private
void
checkAttachment
(
List
<
ThemeContentReq
>
themeAttachments
)
{
if
(
CollectionUtils
.
isEmpty
(
themeAttachments
))
{
throw
new
BizException
(
"正文内容不能为空"
);
throw
new
BizException
(
ErrorCodeConstant
.
ILLEGAL_ARGEMENT
.
getCode
(),
"正文内容不能为空"
);
}
for
(
ThemeContentReq
content
:
themeAttachments
)
{
if
(
content
.
getType
()
==
null
)
{
throw
new
IllegalArgumentException
(
"主题内容ThemeContentReq缺少类型"
);
throw
new
BizException
(
ErrorCodeConstant
.
ILLEGAL_ARGEMENT
.
getCode
(),
"主题内容ThemeContentReq缺少类型"
);
}
Set
<
String
>
types
=
Arrays
.
stream
(
RelTypeEnum
.
values
()).
map
(
o
->
o
.
type
).
collect
(
Collectors
.
toSet
());
if
(!
types
.
contains
(
content
.
getType
()))
{
throw
new
IllegalArgumentException
(
"主题内容ThemeContentReq类型错误"
);
throw
new
BizException
(
ErrorCodeConstant
.
ILLEGAL_ARGEMENT
.
getCode
(),
"主题内容ThemeContentReq类型错误"
);
}
if
(
content
.
getType
().
equals
(
RelTypeEnum
.
FUND
.
type
))
{
if
(
content
.
getProductType
()
==
null
)
{
throw
new
IllegalArgumentException
(
"附件产品FUND缺少类型"
);
throw
new
BizException
(
ErrorCodeConstant
.
ILLEGAL_ARGEMENT
.
getCode
(),
"附件产品FUND缺少类型"
);
}
}
}
...
...
@@ -431,7 +452,7 @@ public class ThemeManager {
// 加载第一页时,为防止首页显示空列表,从推荐池中再捞出已看过帖子
if
(
req
.
page
.
pageNumber
<=
3
&&
recmdIds
.
size
()
<
pageSize
)
{
List
<
String
>
reSearchIds
=
ListUtils
.
union
(
excludeIds
,
recmdIds
);
List
<
String
>
reSearchIds
=
ListUtils
.
union
(
excludeIds
,
recmdIds
);
recmdIds
.
addAll
(
recommendService
.
getRecommendThemes
(
pageStart
,
pageSize
,
userId
,
reSearchIds
,
firstThemeTime
));
}
...
...
@@ -588,7 +609,7 @@ public class ThemeManager {
if
(
userId
.
equals
(
req
.
getUserId
()))
{
//如果用户是查询自己的帖子,需要实时查询用户自己的个人信息,防止数据不一致(非收藏类型)
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUser
sList
New
(
userId
);
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUser
Info
New
(
userId
);
if
(
userInfoNewCommonResp
.
isNotSuccess
())
{
throw
new
BizException
(
"内部接口调用失败"
);
}
...
...
@@ -622,8 +643,6 @@ public class ThemeManager {
//转发、收藏、点赞
buildThemeQoExtraInfo
(
themeQo
);
//时间重制
themeQo
.
setUpToNowTime
(
TimeUtils
.
format
(
themeEntity
.
getCreateTime
()));
// 添加用户相关信息
buildThemeExtraInfoByUser
(
userId
,
themeQo
);
return
CommonResp
.
success
(
themeQo
);
...
...
@@ -711,7 +730,7 @@ public class ThemeManager {
// 校验参数
checkAttachment
(
req
.
getContent
());
// 转播权限校验
liveRelayCheck
(
userId
,
req
.
getContent
());
//
liveRelayCheck(userId, req.getContent());
// 保存主题表
ThemeEntity
themeEntity
=
new
ThemeEntity
();
...
...
@@ -856,7 +875,7 @@ public class ThemeManager {
private
UserInfoResp
getUserInfo
(
String
authorId
)
{
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUser
sList
New
(
authorId
);
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUser
Info
New
(
authorId
);
if
(
userInfoNewCommonResp
.
isNotSuccess
())
{
throw
new
BizException
(
"内部接口调用失败"
);
}
...
...
community-service/src/main/java/com/tanpu/community/service/FeignService.java
View file @
f0f2842f
package
com
.
tanpu
.
community
.
service
;
import
com.alibaba.fastjson.JSON
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp
;
...
...
@@ -16,14 +15,9 @@ import com.tanpu.community.feign.product.FeignForFund;
import
com.tanpu.community.feign.product.FeignForPublicFund
;
import
com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom
;
import
com.tanpu.community.feign.zhibo.FeignClientForZhibo
;
import
lombok.extern.log4j.Log4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.Cache
;
import
org.springframework.cache.caffeine.CaffeineCacheManager
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -60,7 +54,7 @@ public class FeignService {
public
UserInfoResp
getUserInfoById
(
String
userId
)
{
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUser
sList
New
(
userId
);
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUser
Info
New
(
userId
);
if
(
userInfoNewCommonResp
.
isNotSuccess
())
{
throw
new
BizException
(
"内部接口调用失败"
);
}
...
...
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
f0f2842f
...
...
@@ -132,7 +132,7 @@ public class RankService {
}
//排序
Map
<
ThemeAnalysDO
,
Double
>
map
=
themeAnalysDOS
.
stream
().
collect
(
Collectors
.
toMap
(
o
->
o
,
ThemeAnalysDO:
:
getScore
));
//排序
hotestThemes
=
map
.
entrySet
().
stream
()
.
sorted
(
Map
.
Entry
.
comparingByValue
(
Comparator
.
reverseOrder
()))
.
map
(
Map
.
Entry
::
getKey
).
collect
(
Collectors
.
toList
());
...
...
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
f0f2842f
...
...
@@ -47,6 +47,7 @@ public class ConvertUtil {
themeQO
.
setUpdateTime
(
TimeUtils
.
getTimestampOfDateTime
(
themeEntity
.
getUpdateTime
()));
themeQO
.
setCreateTime
(
TimeUtils
.
getTimestampOfDateTime
(
themeEntity
.
getCreateTime
()));
themeQO
.
setUpToNowTime
(
TimeUtils
.
calUpToNowTime
(
themeEntity
.
getCreateTime
()));
themeQO
.
setFormatTime
(
TimeUtils
.
format
(
themeEntity
.
getCreateTime
()));
List
<
ThemeContentQo
>
themeContentQos
=
JsonUtil
.
toBean
(
themeEntity
.
getContent
(),
new
TypeReference
<
List
<
ThemeContentQo
>>()
{
});
themeQO
.
setContent
(
themeContentQos
);
...
...
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