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
01503896
Commit
01503896
authored
Aug 09, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步专栏
parent
26264f8b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
6 deletions
+45
-6
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+3
-2
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+38
-3
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+4
-1
No files found.
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
01503896
...
@@ -117,9 +117,10 @@ public class ThemeController {
...
@@ -117,9 +117,10 @@ public class ThemeController {
@ApiOperation
(
"专栏同步主题"
)
@ApiOperation
(
"专栏同步主题"
)
@PostMapping
(
value
=
"/convertFromNewsFeed"
)
@PostMapping
(
value
=
"/convertFromNewsFeed"
)
@ResponseBody
@ResponseBody
public
CommonResp
<
CreateThemeResp
>
convertFromNewsFeed
(
@Validated
@RequestBody
CreateThemeReq
req
)
{
public
CommonResp
<
Void
>
convertFromNewsFeed
(
@Validated
@RequestBody
CreateThemeReq
req
)
{
String
userId
=
userHolder
.
getUserId
();
String
userId
=
userHolder
.
getUserId
();
return
CommonResp
.
success
(
themeManager
.
publishTheme
(
req
,
userId
));
themeManager
.
convertFromNewsFeed
(
req
,
userId
);
return
CommonResp
.
success
();
}
}
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
01503896
...
@@ -150,14 +150,13 @@ public class ThemeManager {
...
@@ -150,14 +150,13 @@ public class ThemeManager {
}
}
/**
/**
* 发表主题(修改)
* 发表主题(修改)
*/
*/
@Transactional
@Transactional
public
CreateThemeResp
publishTheme
(
CreateThemeReq
req
,
String
userId
)
{
public
CreateThemeResp
publishTheme
(
CreateThemeReq
req
,
String
userId
)
{
if
(
CollectionUtils
.
isEmpty
(
req
.
getContent
()))
{
throw
new
BizException
(
"正文内容不能为空"
);
}
// 校验参数
// 校验参数
checkAttachment
(
req
.
getContent
());
checkAttachment
(
req
.
getContent
());
// 转播权限校验
// 转播权限校验
...
@@ -236,6 +235,8 @@ public class ThemeManager {
...
@@ -236,6 +235,8 @@ public class ThemeManager {
}
}
private
void
convertImg
(
ImagesDTO
img
,
String
userId
){
private
void
convertImg
(
ImagesDTO
img
,
String
userId
){
HashMap
map
=
new
HashMap
<>();
HashMap
map
=
new
HashMap
<>();
// todo 图片类型
// todo 图片类型
...
@@ -246,12 +247,18 @@ public class ThemeManager {
...
@@ -246,12 +247,18 @@ public class ThemeManager {
}
}
/**
/**
* 参数校验
* 参数校验
*
*
* @param themeAttachments
* @param themeAttachments
*/
*/
private
void
checkAttachment
(
List
<
ThemeContentReq
>
themeAttachments
)
{
private
void
checkAttachment
(
List
<
ThemeContentReq
>
themeAttachments
)
{
if
(
CollectionUtils
.
isEmpty
(
themeAttachments
))
{
throw
new
BizException
(
"正文内容不能为空"
);
}
for
(
ThemeContentReq
content
:
themeAttachments
)
{
for
(
ThemeContentReq
content
:
themeAttachments
)
{
if
(
content
.
getType
()
==
null
)
{
if
(
content
.
getType
()
==
null
)
{
throw
new
IllegalArgumentException
(
"主题内容ThemeContentReq缺少类型"
);
throw
new
IllegalArgumentException
(
"主题内容ThemeContentReq缺少类型"
);
...
@@ -592,6 +599,33 @@ public class ThemeManager {
...
@@ -592,6 +599,33 @@ public class ThemeManager {
this
.
evictThemeCache
(
themeId
);
this
.
evictThemeCache
(
themeId
);
}
}
// 从专栏同步
public
void
convertFromNewsFeed
(
CreateThemeReq
req
,
String
userId
)
{
// 校验参数
checkAttachment
(
req
.
getContent
());
// 转播权限校验
liveRelayCheck
(
userId
,
req
.
getContent
());
// 保存主题表
ThemeEntity
themeEntity
=
new
ThemeEntity
();
BeanUtils
.
copyProperties
(
req
,
themeEntity
);
themeEntity
.
setAuthorId
(
userId
);
themeEntity
.
setContent
(
JsonUtil
.
toJson
(
req
.
getContent
()));
themeEntity
.
setThemeId
(
CommunityConstant
.
THEME_PREFIX
+
req
.
getEditThemeId
());
themeService
.
insertTheme
(
themeEntity
);
// 保存附件表
List
<
ThemeAttachmentEntity
>
themeAttachments
=
ConvertUtil
.
themeReqToAttachmentList
(
req
,
themeEntity
.
getThemeId
());
themeAttachmentService
.
insertList
(
themeAttachments
);
try
{
esService
.
insertOrUpdateTheme
(
ConvertUtil
.
convert
(
themeEntity
));
}
catch
(
Exception
e
)
{
log
.
error
(
"error in save theme to ES. themeId:{}, error:{}"
,
themeEntity
.
getThemeId
(),
ExceptionUtils
.
getStackTrace
(
e
));
}
}
/**
/**
* 腾讯云-内容检测
* 腾讯云-内容检测
...
@@ -743,4 +777,5 @@ public class ThemeManager {
...
@@ -743,4 +777,5 @@ public class ThemeManager {
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CACHE_THEME_ID
,
themeId
));
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CACHE_THEME_ID
,
themeId
));
}
}
}
}
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
01503896
...
@@ -40,7 +40,10 @@ public class ThemeService {
...
@@ -40,7 +40,10 @@ public class ThemeService {
@Transactional
@Transactional
public
void
insertTheme
(
ThemeEntity
themeEntity
)
{
public
void
insertTheme
(
ThemeEntity
themeEntity
)
{
themeEntity
.
setThemeId
(
uuidGenHelper
.
getUuidStr
());
if
(
StringUtils
.
isBlank
(
themeEntity
.
getThemeId
())){
themeEntity
.
setThemeId
(
uuidGenHelper
.
getUuidStr
());
}
themeMapper
.
insert
(
themeEntity
);
themeMapper
.
insert
(
themeEntity
);
}
}
...
...
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