Commit 8c480036 authored by 刘基明's avatar 刘基明

同步专栏

parent e4a9d965
...@@ -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_";
} }
...@@ -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;
} }
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;
}
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;
}
...@@ -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));
}
} }
...@@ -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);
}
/** /**
* 参数校验 * 参数校验
* *
......
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