Commit f79ce678 authored by 刘基明's avatar 刘基明

同步专栏userId

parent 68be1bfc
package com.tanpu.community.api.beans.req.theme;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 专栏同步到圈子
*/
@Data
public class SynchroThemeReq {
@NotNull(message = "类型不能为空")
@ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题")
private Integer themeType;
@ApiModelProperty(value = "专栏id")
private String themeId = "";
@NotEmpty(message = "内容不能为空")
@ApiModelProperty(value = "文本内容")
private List<ThemeContentReq> content;
public String userId = "";
}
...@@ -23,4 +23,7 @@ public class NewsFeedSave4NewCommReq { ...@@ -23,4 +23,7 @@ public class NewsFeedSave4NewCommReq {
@ApiModelProperty("关联多个内容") @ApiModelProperty("关联多个内容")
private List<NewsFeedResReq> newsFeedResList; private List<NewsFeedResReq> newsFeedResList;
@ApiModelProperty("用户id")
public String userId = "";
} }
...@@ -113,13 +113,11 @@ public class ThemeController { ...@@ -113,13 +113,11 @@ public class ThemeController {
return CommonResp.success(themeManager.getFollowUpdateCount(userId)); return CommonResp.success(themeManager.getFollowUpdateCount(userId));
} }
@AuthLogin
@ApiOperation("专栏同步主题") @ApiOperation("专栏同步主题")
@PostMapping(value = "/convertFromNewsFeed") @PostMapping(value = "/convertFromNewsFeed")
@ResponseBody @ResponseBody
public CommonResp<Void> convertFromNewsFeed(@Validated @RequestBody CreateThemeReq req) { public CommonResp<Void> convertFromNewsFeed(@Validated @RequestBody SynchroThemeReq req) {
String userId = userHolder.getUserId(); themeManager.convertFromNewsFeed(req);
themeManager.convertFromNewsFeed(req, userId);
return CommonResp.success(); return CommonResp.success();
} }
......
...@@ -21,6 +21,7 @@ import com.tanpu.community.api.beans.req.theme.CreateThemeReq; ...@@ -21,6 +21,7 @@ import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.ForwardThemeReq; import com.tanpu.community.api.beans.req.theme.ForwardThemeReq;
import com.tanpu.community.api.beans.req.theme.LikeThemeReq; import com.tanpu.community.api.beans.req.theme.LikeThemeReq;
import com.tanpu.community.api.beans.req.theme.ReportThemeReq; import com.tanpu.community.api.beans.req.theme.ReportThemeReq;
import com.tanpu.community.api.beans.req.theme.SynchroThemeReq;
import com.tanpu.community.api.beans.req.theme.ThemeContentReq; import com.tanpu.community.api.beans.req.theme.ThemeContentReq;
import com.tanpu.community.api.beans.req.theme.ThemeListReq; 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;
...@@ -238,13 +239,14 @@ public class ThemeManager { ...@@ -238,13 +239,14 @@ public class ThemeManager {
// 只有讨论类型才能同步专栏 // 只有讨论类型才能同步专栏
throw new BizException("长文类型无法同步专栏"); throw new BizException("长文类型无法同步专栏");
} }
NewsFeedSave4NewCommReq convertReq = new NewsFeedSave4NewCommReq(); NewsFeedSave4NewCommReq newsFeedReq = new NewsFeedSave4NewCommReq();
convertReq.setNewsFeedId(themeId); newsFeedReq.setNewsFeedId(themeId);
newsFeedReq.setUserId(userId);
ArrayList<NewsFeedResReq> feedList = new ArrayList<>(); ArrayList<NewsFeedResReq> feedList = new ArrayList<>();
for (ThemeContentReq themeContentReq : req.getContent()) { for (ThemeContentReq themeContentReq : req.getContent()) {
// 文字内容添加到content // 文字内容添加到content
if (RelTypeEnum.TEXT.type.equals(themeContentReq.getType())) { if (RelTypeEnum.TEXT.type.equals(themeContentReq.getType())) {
convertReq.setContent(themeContentReq.getValue()); newsFeedReq.setContent(themeContentReq.getValue());
} else if (RelTypeEnum.MULTIPLE_IMAGE.type.equals(themeContentReq.getType())) { } else if (RelTypeEnum.MULTIPLE_IMAGE.type.equals(themeContentReq.getType())) {
List<ImagesDTO> imgList = themeContentReq.getImgList(); List<ImagesDTO> imgList = themeContentReq.getImgList();
...@@ -260,8 +262,8 @@ public class ThemeManager { ...@@ -260,8 +262,8 @@ public class ThemeManager {
.build()); .build());
} }
} }
convertReq.setNewsFeedResList(feedList); newsFeedReq.setNewsFeedResList(feedList);
CommonResp restResponse = feignClientForCommunity.saveNewsFeed4NewComm(convertReq); CommonResp restResponse = feignClientForCommunity.saveNewsFeed4NewComm(newsFeedReq);
if (restResponse.isNotSuccess() || !ObjectUtils.anyNotNull(restResponse.getData())) { if (restResponse.isNotSuccess() || !ObjectUtils.anyNotNull(restResponse.getData())) {
throw new BizException("同步圈子调用失败"); throw new BizException("同步圈子调用失败");
...@@ -679,7 +681,13 @@ public class ThemeManager { ...@@ -679,7 +681,13 @@ public class ThemeManager {
} }
// 从专栏同步 // 从专栏同步
public void convertFromNewsFeed(CreateThemeReq req, String userId) { public void convertFromNewsFeed(SynchroThemeReq req2) {
String userId = req2.getUserId();
CreateThemeReq req = new CreateThemeReq();
BeanUtils.copyProperties(req2,req);
req.setTopicId("");
req.setTitle("");
// 校验参数 // 校验参数
checkAttachment(req.getContent()); checkAttachment(req.getContent());
// 转播权限校验 // 转播权限校验
...@@ -690,7 +698,7 @@ public class ThemeManager { ...@@ -690,7 +698,7 @@ 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()));
themeEntity.setThemeId(CommunityConstant.THEME_PREFIX + req.getEditThemeId()); themeEntity.setThemeId(CommunityConstant.THEME_PREFIX + req2.getThemeId());
themeService.insertTheme(themeEntity); themeService.insertTheme(themeEntity);
// 保存附件表 // 保存附件表
......
...@@ -4,7 +4,14 @@ import com.fasterxml.jackson.core.type.TypeReference; ...@@ -4,7 +4,14 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.tanpu.biz.common.enums.RelTypeEnum; import com.tanpu.biz.common.enums.RelTypeEnum;
import com.tanpu.biz.common.enums.community.TopicStatusEnum; import com.tanpu.biz.common.enums.community.TopicStatusEnum;
import com.tanpu.common.util.JsonUtil; import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.beans.qo.*; import com.tanpu.community.api.beans.qo.CommentQo;
import com.tanpu.community.api.beans.qo.ESThemeQo;
import com.tanpu.community.api.beans.qo.FollowQo;
import com.tanpu.community.api.beans.qo.FormerThemeQo;
import com.tanpu.community.api.beans.qo.ThemeAnalysDO;
import com.tanpu.community.api.beans.qo.ThemeContentQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.qo.TopicRankQo;
import com.tanpu.community.api.beans.req.theme.CreateThemeReq; import com.tanpu.community.api.beans.req.theme.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.ThemeContentReq; import com.tanpu.community.api.beans.req.theme.ThemeContentReq;
import com.tanpu.community.api.beans.resp.FileUploadResp; import com.tanpu.community.api.beans.resp.FileUploadResp;
...@@ -12,7 +19,12 @@ import com.tanpu.community.api.beans.vo.ImagesDTO; ...@@ -12,7 +19,12 @@ import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg; import com.tanpu.community.api.beans.vo.KafkaDurationUptMsg;
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.enums.DeleteTagEnum; import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.dao.entity.community.*; import com.tanpu.community.dao.entity.community.CommentEntity;
import com.tanpu.community.dao.entity.community.FileRecordEntity;
import com.tanpu.community.dao.entity.community.ThemeAttachmentEntity;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.entity.community.VisitLogEntity;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment