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
8c480036
Commit
8c480036
authored
Aug 09, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步专栏
parent
e4a9d965
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
123 additions
and
3 deletions
+123
-3
CommunityConstant.java
.../main/java/com/tanpu/community/api/CommunityConstant.java
+3
-0
CreateThemeReq.java
...m/tanpu/community/api/beans/req/theme/CreateThemeReq.java
+4
-2
NewsFeedResReq.java
...community/api/beans/vo/feign/newsfeed/NewsFeedResReq.java
+38
-0
NewsFeedSave4NewCommReq.java
.../api/beans/vo/feign/newsfeed/NewsFeedSave4NewCommReq.java
+26
-0
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+10
-0
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+42
-1
No files found.
community-api/src/main/java/com/tanpu/community/api/CommunityConstant.java
View file @
8c480036
...
@@ -23,4 +23,7 @@ public final class CommunityConstant {
...
@@ -23,4 +23,7 @@ public final class CommunityConstant {
//图片压缩比例:50%
//图片压缩比例:50%
public
static
final
String
OSS_RESIZE_RATIO
=
"?x-oss-process=image/resize,p_50"
;
public
static
final
String
OSS_RESIZE_RATIO
=
"?x-oss-process=image/resize,p_50"
;
public
static
final
String
THEME_PREFIX
=
"NEW_THEME_"
;
}
}
community-api/src/main/java/com/tanpu/community/api/beans/req/theme/CreateThemeReq.java
View file @
8c480036
...
@@ -24,11 +24,13 @@ public class CreateThemeReq {
...
@@ -24,11 +24,13 @@ public class CreateThemeReq {
private
List
<
ThemeContentReq
>
content
;
private
List
<
ThemeContentReq
>
content
;
@ApiModelProperty
(
value
=
"所属的话题id"
)
@ApiModelProperty
(
value
=
"所属的话题id"
)
private
String
topicId
=
""
;
private
String
topicId
=
""
;
@ApiModelProperty
(
value
=
"修改,则传入正在编辑的ThemeId"
)
@ApiModelProperty
(
value
=
"修改,则传入正在编辑的ThemeId"
)
private
String
editThemeId
=
""
;
private
String
editThemeId
=
""
;
@ApiModelProperty
(
value
=
"同步到专栏"
)
private
Integer
convert
=
0
;
}
}
community-api/src/main/java/com/tanpu/community/api/beans/vo/feign/newsfeed/NewsFeedResReq.java
0 → 100644
View file @
8c480036
package
com
.
tanpu
.
community
.
api
.
beans
.
vo
.
feign
.
newsfeed
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
NewsFeedResReq
{
/**
* 关联类型
*/
@ApiModelProperty
(
"关联类型 产品:88 直播:3 短视频:6 图片:122"
)
private
Integer
relType
;
/**
* 关联id
*/
@ApiModelProperty
(
"关联id"
)
private
String
relId
;
/**
* 产品类型 rel_type等于产品生效
*/
private
Integer
productType
;
/**
* 备注说明
*/
private
String
remark
;
}
community-api/src/main/java/com/tanpu/community/api/beans/vo/feign/newsfeed/NewsFeedSave4NewCommReq.java
0 → 100644
View file @
8c480036
package
com
.
tanpu
.
community
.
api
.
beans
.
vo
.
feign
.
newsfeed
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
/**
* 发布动态
*
* @author hudingguo
*/
@ApiModel
(
"发布动态"
)
@Data
public
class
NewsFeedSave4NewCommReq
{
@ApiModelProperty
(
"专栏id"
)
private
String
newsFeedId
;
@ApiModelProperty
(
"专栏内容内容"
)
private
String
content
;
@ApiModelProperty
(
"关联多个内容"
)
private
List
<
NewsFeedResReq
>
newsFeedResList
;
}
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
8c480036
...
@@ -113,4 +113,14 @@ public class ThemeController {
...
@@ -113,4 +113,14 @@ public class ThemeController {
return
CommonResp
.
success
(
themeManager
.
getFollowUpdateCount
(
userId
));
return
CommonResp
.
success
(
themeManager
.
getFollowUpdateCount
(
userId
));
}
}
@AuthLogin
@ApiOperation
(
"专栏同步主题"
)
@PostMapping
(
value
=
"/convertFromNewsFeed"
)
@ResponseBody
public
CommonResp
<
CreateThemeResp
>
convertFromNewsFeed
(
@Validated
@RequestBody
CreateThemeReq
req
)
{
String
userId
=
userHolder
.
getUserId
();
return
CommonResp
.
success
(
themeManager
.
publishTheme
(
req
,
userId
));
}
}
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
8c480036
...
@@ -9,6 +9,7 @@ import com.tanpu.common.api.CommonResp;
...
@@ -9,6 +9,7 @@ import com.tanpu.common.api.CommonResp;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.community.api.CommunityConstant
;
import
com.tanpu.community.api.beans.qo.ESThemeQo
;
import
com.tanpu.community.api.beans.qo.ESThemeQo
;
import
com.tanpu.community.api.beans.qo.FormerThemeQo
;
import
com.tanpu.community.api.beans.qo.FormerThemeQo
;
import
com.tanpu.community.api.beans.qo.ThemeContentQo
;
import
com.tanpu.community.api.beans.qo.ThemeContentQo
;
...
@@ -24,7 +25,10 @@ import com.tanpu.community.api.beans.req.theme.ThemeListReq;
...
@@ -24,7 +25,10 @@ import com.tanpu.community.api.beans.req.theme.ThemeListReq;
import
com.tanpu.community.api.beans.resp.CreateThemeResp
;
import
com.tanpu.community.api.beans.resp.CreateThemeResp
;
import
com.tanpu.community.api.beans.resp.ThemeFullSearchResp
;
import
com.tanpu.community.api.beans.resp.ThemeFullSearchResp
;
import
com.tanpu.community.api.beans.resp.ThemeListResp
;
import
com.tanpu.community.api.beans.resp.ThemeListResp
;
import
com.tanpu.community.api.beans.vo.ImagesDTO
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedResReq
;
import
com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedSave4NewCommReq
;
import
com.tanpu.community.api.enums.*
;
import
com.tanpu.community.api.enums.*
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.dao.entity.community.BlackListEntity
;
import
com.tanpu.community.dao.entity.community.BlackListEntity
;
...
@@ -161,8 +165,10 @@ public class ThemeManager {
...
@@ -161,8 +165,10 @@ public class ThemeManager {
if
(
CollectionUtils
.
isEmpty
(
req
.
getContent
()))
{
if
(
CollectionUtils
.
isEmpty
(
req
.
getContent
()))
{
throw
new
BizException
(
"正文内容不能为空"
);
throw
new
BizException
(
"正文内容不能为空"
);
}
}
//校验参数
//
校验参数
checkAttachment
(
req
.
getContent
());
checkAttachment
(
req
.
getContent
());
// 转播权限校验
liveRelayCheck
(
userId
,
req
.
getContent
());
// 保存主题表
// 保存主题表
ThemeEntity
themeEntity
=
new
ThemeEntity
();
ThemeEntity
themeEntity
=
new
ThemeEntity
();
...
@@ -176,6 +182,8 @@ public class ThemeManager {
...
@@ -176,6 +182,8 @@ public class ThemeManager {
if
(
StringUtils
.
isBlank
(
req
.
getEditThemeId
()))
{
if
(
StringUtils
.
isBlank
(
req
.
getEditThemeId
()))
{
// 新建
// 新建
themeService
.
insertTheme
(
themeEntity
);
themeService
.
insertTheme
(
themeEntity
);
// 同步到专栏
convertToNewsFeed
(
req
,
themeEntity
.
getThemeId
());
}
else
{
}
else
{
// 修改
// 修改
themeService
.
update
(
themeEntity
,
req
.
getEditThemeId
());
themeService
.
update
(
themeEntity
,
req
.
getEditThemeId
());
...
@@ -201,6 +209,39 @@ public class ThemeManager {
...
@@ -201,6 +209,39 @@ public class ThemeManager {
return
CreateThemeResp
.
builder
().
themeId
(
themeEntity
.
getThemeId
()).
build
();
return
CreateThemeResp
.
builder
().
themeId
(
themeEntity
.
getThemeId
()).
build
();
}
}
private
void
convertToNewsFeed
(
CreateThemeReq
req
,
String
themeId
)
{
if
(!
ThemeTypeEnum
.
DISCUSSION
.
getCode
().
equals
(
req
.
getThemeType
())){
// 只有讨论类型才能同步专栏
throw
new
BizException
(
"长文类型无法同步专栏"
);
}
NewsFeedSave4NewCommReq
convertReq
=
new
NewsFeedSave4NewCommReq
();
convertReq
.
setNewsFeedId
(
CommunityConstant
.
THEME_PREFIX
+
themeId
);
ArrayList
<
NewsFeedResReq
>
feedList
=
new
ArrayList
<>();
for
(
ThemeContentReq
themeContentReq
:
req
.
getContent
())
{
// 文字内容添加到content
if
(
RelTypeEnum
.
TEXT
.
type
.
equals
(
themeContentReq
.
getType
())){
convertReq
.
setContent
(
themeContentReq
.
getValue
());
}
else
if
(
RelTypeEnum
.
MULTIPLE_IMAGE
.
type
.
equals
(
themeContentReq
.
getType
())){
List
<
ImagesDTO
>
imgList
=
themeContentReq
.
getImgList
();
imgList
.
forEach
(
img
->
feedList
.
add
(
NewsFeedResReq
.
builder
()
.
remark
(
img
.
getRemark
())
.
relType
(
Integer
.
parseInt
(
RelTypeEnum
.
IMAGE_FILE
.
type
))
.
relId
(
img
.
getRelId
())
//todo 上传文件并替换id
.
build
()));
}
else
{
//其他类型的附件
feedList
.
add
(
NewsFeedResReq
.
builder
().
relType
(
Integer
.
parseInt
(
themeContentReq
.
getType
()))
.
relId
(
themeContentReq
.
getValue
())
.
productType
(
themeContentReq
.
getProductType
())
.
remark
(
themeContentReq
.
getRemark
())
.
build
());
}
}
convertReq
.
setNewsFeedResList
(
feedList
);
}
/**
/**
* 参数校验
* 参数校验
*
*
...
...
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