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
9ea9f0cf
Commit
9ea9f0cf
authored
Aug 10, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步专栏才做转播校验
parent
9487d269
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
35 deletions
+42
-35
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
+36
-22
FeignService.java
...c/main/java/com/tanpu/community/service/FeignService.java
+1
-7
No files found.
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
9ea9f0cf
...
...
@@ -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 @
9ea9f0cf
...
...
@@ -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 @
9ea9f0cf
...
...
@@ -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 @
9ea9f0cf
...
...
@@ -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 @
9ea9f0cf
...
...
@@ -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 @
9ea9f0cf
...
...
@@ -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,12 @@ public class ThemeManager {
* 发表主题(修改)
*/
@Transactional
public
C
reateThemeResp
publishTheme
(
CreateThemeReq
req
,
String
userId
)
{
public
C
ommonResp
<
CreateThemeResp
>
publishTheme
(
CreateThemeReq
req
,
String
userId
)
{
// 校验参数
checkAttachment
(
req
.
getContent
());
// 转播权限校验
if
(
1
==
req
.
getSyncToNewComm
()){
if
(
1
==
req
.
getSyncToNewComm
())
{
liveRelayCheck
(
userId
,
req
.
getContent
());
}
...
...
@@ -219,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
());
...
...
@@ -246,10 +240,27 @@ public class ThemeManager {
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CACHE_THEME_ID
,
themeEntity
.
getThemeId
()));
return
CreateThemeResp
.
builder
().
themeId
(
themeEntity
.
getThemeId
()).
build
();
// 同步到专栏
if
(
1
==
req
.
getSyncToNewComm
())
{
CommonResp
response
=
synchronizeToNewsFeed
(
req
,
themeEntity
.
getThemeId
(),
userId
);
if
(
response
.
isNotSuccess
())
{
if
(
ErrorCodeConstant
.
LIMIT_CONTENT
.
getCode
().
equals
(
response
.
getCode
()))
{
// 内容受限,不会滚发布
return
CommonResp
.
error
(
ErrorCodeConstant
.
THEME_SYNCHRONIZE_FAILED
.
getCode
(),
response
.
getMsg
());
}
else
{
// 其他回滚异常
throw
new
BizException
(
ErrorCodeConstant
.
THEME_PUBLISH_FAILED
.
getCode
()
,
"调用专栏同步异常:"
+
response
.
getMsg
());
}
}
}
return
CommonResp
.
success
(
CreateThemeResp
.
builder
().
themeId
(
themeEntity
.
getThemeId
()).
build
());
}
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
(
"长文类型无法同步专栏"
);
...
...
@@ -278,15 +289,18 @@ 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
,
"."
);
...
...
@@ -352,19 +366,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缺少类型"
);
}
}
}
...
...
@@ -434,7 +448,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
));
}
...
...
@@ -591,7 +605,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
(
"内部接口调用失败"
);
}
...
...
@@ -714,7 +728,7 @@ public class ThemeManager {
// 校验参数
checkAttachment
(
req
.
getContent
());
// 转播权限校验
// liveRelayCheck(userId, req.getContent());
//
liveRelayCheck(userId, req.getContent());
// 保存主题表
ThemeEntity
themeEntity
=
new
ThemeEntity
();
...
...
@@ -859,7 +873,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 @
9ea9f0cf
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
(
"内部接口调用失败"
);
}
...
...
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