Commit 9ea9f0cf authored by 刘基明's avatar 刘基明

同步专栏才做转播校验

parent 9487d269
...@@ -33,7 +33,7 @@ public class ThemeController { ...@@ -33,7 +33,7 @@ public class ThemeController {
@ResponseBody @ResponseBody
public CommonResp<CreateThemeResp> publishTheme(@Validated @RequestBody CreateThemeReq req) { public CommonResp<CreateThemeResp> publishTheme(@Validated @RequestBody CreateThemeReq req) {
String userId = userHolder.getUserId(); String userId = userHolder.getUserId();
return CommonResp.success(themeManager.publishTheme(req, userId)); return themeManager.publishTheme(req, userId);
} }
@AuthLogin @AuthLogin
......
...@@ -45,7 +45,7 @@ public interface FeignClientForFatools { ...@@ -45,7 +45,7 @@ public interface FeignClientForFatools {
// 用户信息查询 (供圈子服务调用) // 用户信息查询 (供圈子服务调用)
@ApiOperation(value = "查询用户信息") @ApiOperation(value = "查询用户信息")
@GetMapping(value = "/queryUserInfoNew") @GetMapping(value = "/queryUserInfoNew")
CommonResp<UserInfoResp> queryUsersListNew(@RequestParam("userId") String userId); CommonResp<UserInfoResp> queryUserInfoNew(@RequestParam("userId") String userId);
@ApiOperation(value = "批量查询查询基本信息") @ApiOperation(value = "批量查询查询基本信息")
@GetMapping(value = "/queryUserBaseInfoList") @GetMapping(value = "/queryUserBaseInfoList")
......
...@@ -2,7 +2,6 @@ package com.tanpu.community.feign.fatools; ...@@ -2,7 +2,6 @@ package com.tanpu.community.feign.fatools;
import com.tanpu.common.api.CommonResp; import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.req.page.Page; 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.course.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNewChief; import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNewChief;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoOrg; import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoOrg;
...@@ -50,7 +49,7 @@ public class FeignbackForFatools implements FallbackFactory<FeignClientForFatool ...@@ -50,7 +49,7 @@ public class FeignbackForFatools implements FallbackFactory<FeignClientForFatool
} }
@Override @Override
public CommonResp<UserInfoResp> queryUsersListNew(String userId) { public CommonResp<UserInfoResp> queryUserInfoNew(String userId) {
log.info("FeignbackForFatools.queryUsersListNew", throwable); log.info("FeignbackForFatools.queryUsersListNew", throwable);
return CommonResp.error(); return CommonResp.error();
} }
......
...@@ -108,7 +108,7 @@ public class CommentManager { ...@@ -108,7 +108,7 @@ public class CommentManager {
} }
private UserInfoResp getUserInfo(String authorId){ private UserInfoResp getUserInfo(String authorId){
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(authorId); CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(authorId);
if (userInfoNewCommonResp.isNotSuccess()) { if (userInfoNewCommonResp.isNotSuccess()) {
throw new BizException("内部接口调用失败"); throw new BizException("内部接口调用失败");
} }
......
...@@ -63,7 +63,7 @@ public class HomePageManager { ...@@ -63,7 +63,7 @@ public class HomePageManager {
//查询 个人中心 相关信息 //查询 个人中心 相关信息
public UserInfoResp queryUsersInfo(String userIdMyself, String userId) { public UserInfoResp queryUsersInfo(String userIdMyself, String userId) {
CommonResp<UserInfoResp> queryUsersListNew = feignClientForFatools.queryUsersListNew(StringUtils.isNotBlank(userId) ? userId : userIdMyself); CommonResp<UserInfoResp> queryUsersListNew = feignClientForFatools.queryUserInfoNew(StringUtils.isNotBlank(userId) ? userId : userIdMyself);
if (queryUsersListNew.isNotSuccess() || !ObjectUtils.anyNotNull(queryUsersListNew.getData())) if (queryUsersListNew.isNotSuccess() || !ObjectUtils.anyNotNull(queryUsersListNew.getData()))
throw new BizException("内部接口调用失败"); throw new BizException("内部接口调用失败");
UserInfoResp userInfoNew = queryUsersListNew.getData(); UserInfoResp userInfoNew = queryUsersListNew.getData();
......
...@@ -55,7 +55,6 @@ import lombok.extern.slf4j.Slf4j; ...@@ -55,7 +55,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -197,12 +196,12 @@ public class ThemeManager { ...@@ -197,12 +196,12 @@ public class ThemeManager {
* 发表主题(修改) * 发表主题(修改)
*/ */
@Transactional @Transactional
public CreateThemeResp publishTheme(CreateThemeReq req, String userId) { public CommonResp<CreateThemeResp> publishTheme(CreateThemeReq req, String userId) {
// 校验参数 // 校验参数
checkAttachment(req.getContent()); checkAttachment(req.getContent());
// 转播权限校验 // 转播权限校验
if (1 == req.getSyncToNewComm()){ if (1 == req.getSyncToNewComm()) {
liveRelayCheck(userId, req.getContent()); liveRelayCheck(userId, req.getContent());
} }
...@@ -219,11 +218,6 @@ public class ThemeManager { ...@@ -219,11 +218,6 @@ public class ThemeManager {
if (StringUtils.isBlank(req.getEditThemeId())) { if (StringUtils.isBlank(req.getEditThemeId())) {
// 新建 // 新建
themeService.insertTheme(themeEntity); themeService.insertTheme(themeEntity);
// 同步到专栏
if (1 == req.getSyncToNewComm()) {
synchronizeToNewsFeed(req, themeEntity.getThemeId(), userId);
}
} else { } else {
// 修改 // 修改
themeService.update(themeEntity, req.getEditThemeId()); themeService.update(themeEntity, req.getEditThemeId());
...@@ -246,10 +240,27 @@ public class ThemeManager { ...@@ -246,10 +240,27 @@ public class ThemeManager {
redisCache.evict(StringUtils.joinWith("_", CACHE_THEME_ID, themeEntity.getThemeId())); 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())) { if (!ThemeTypeEnum.DISCUSSION.getCode().equals(req.getThemeType())) {
// 只有讨论类型才能同步专栏 // 只有讨论类型才能同步专栏
throw new BizException("长文类型无法同步专栏"); throw new BizException("长文类型无法同步专栏");
...@@ -278,15 +289,18 @@ public class ThemeManager { ...@@ -278,15 +289,18 @@ public class ThemeManager {
} }
} }
newsFeedReq.setNewsFeedResList(feedList); newsFeedReq.setNewsFeedResList(feedList);
CommonResp response = feignClientForCommunity.saveNewsFeed4NewComm(newsFeedReq); return feignClientForCommunity.saveNewsFeed4NewComm(newsFeedReq);
if (response.isNotSuccess() || !ObjectUtils.anyNotNull(response.getData())) {
throw new BizException("同步圈子调用失败");
}
} }
/**
* 转存图片到老接口
* @param img
* @param userId
* @return
*/
private NewsFeedResReq convertImg(ImagesDTO img, String userId) { private NewsFeedResReq convertImg(ImagesDTO img, String userId) {
String imgUrl = img.getRemark(); String imgUrl = img.getRemark();
String[] arr = StringUtils.split(imgUrl, "."); String[] arr = StringUtils.split(imgUrl, ".");
...@@ -352,19 +366,19 @@ public class ThemeManager { ...@@ -352,19 +366,19 @@ public class ThemeManager {
*/ */
private void checkAttachment(List<ThemeContentReq> themeAttachments) { private void checkAttachment(List<ThemeContentReq> themeAttachments) {
if (CollectionUtils.isEmpty(themeAttachments)) { if (CollectionUtils.isEmpty(themeAttachments)) {
throw new BizException("正文内容不能为空"); throw new BizException(ErrorCodeConstant.ILLEGAL_ARGEMENT.getCode(), "正文内容不能为空");
} }
for (ThemeContentReq content : themeAttachments) { for (ThemeContentReq content : themeAttachments) {
if (content.getType() == null) { 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()); Set<String> types = Arrays.stream(RelTypeEnum.values()).map(o -> o.type).collect(Collectors.toSet());
if (!types.contains(content.getType())) { 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.getType().equals(RelTypeEnum.FUND.type)) {
if (content.getProductType() == null) { if (content.getProductType() == null) {
throw new IllegalArgumentException("附件产品FUND缺少类型"); throw new BizException(ErrorCodeConstant.ILLEGAL_ARGEMENT.getCode(), "附件产品FUND缺少类型");
} }
} }
} }
...@@ -434,7 +448,7 @@ public class ThemeManager { ...@@ -434,7 +448,7 @@ public class ThemeManager {
// 加载第一页时,为防止首页显示空列表,从推荐池中再捞出已看过帖子 // 加载第一页时,为防止首页显示空列表,从推荐池中再捞出已看过帖子
if (req.page.pageNumber <= 3 && recmdIds.size() < pageSize) { 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)); recmdIds.addAll(recommendService.getRecommendThemes(pageStart, pageSize, userId, reSearchIds, firstThemeTime));
} }
...@@ -591,7 +605,7 @@ public class ThemeManager { ...@@ -591,7 +605,7 @@ public class ThemeManager {
if (userId.equals(req.getUserId())) { if (userId.equals(req.getUserId())) {
//如果用户是查询自己的帖子,需要实时查询用户自己的个人信息,防止数据不一致(非收藏类型) //如果用户是查询自己的帖子,需要实时查询用户自己的个人信息,防止数据不一致(非收藏类型)
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(userId); CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(userId);
if (userInfoNewCommonResp.isNotSuccess()) { if (userInfoNewCommonResp.isNotSuccess()) {
throw new BizException("内部接口调用失败"); throw new BizException("内部接口调用失败");
} }
...@@ -714,7 +728,7 @@ public class ThemeManager { ...@@ -714,7 +728,7 @@ public class ThemeManager {
// 校验参数 // 校验参数
checkAttachment(req.getContent()); checkAttachment(req.getContent());
// 转播权限校验 // 转播权限校验
// liveRelayCheck(userId, req.getContent()); // liveRelayCheck(userId, req.getContent());
// 保存主题表 // 保存主题表
ThemeEntity themeEntity = new ThemeEntity(); ThemeEntity themeEntity = new ThemeEntity();
...@@ -859,7 +873,7 @@ public class ThemeManager { ...@@ -859,7 +873,7 @@ public class ThemeManager {
private UserInfoResp getUserInfo(String authorId) { private UserInfoResp getUserInfo(String authorId) {
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(authorId); CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(authorId);
if (userInfoNewCommonResp.isNotSuccess()) { if (userInfoNewCommonResp.isNotSuccess()) {
throw new BizException("内部接口调用失败"); throw new BizException("内部接口调用失败");
} }
......
package com.tanpu.community.service; package com.tanpu.community.service;
import com.alibaba.fastjson.JSON;
import com.tanpu.common.api.CommonResp; import com.tanpu.common.api.CommonResp;
import com.tanpu.common.exception.BizException; import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp; import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
...@@ -16,14 +15,9 @@ import com.tanpu.community.feign.product.FeignForFund; ...@@ -16,14 +15,9 @@ import com.tanpu.community.feign.product.FeignForFund;
import com.tanpu.community.feign.product.FeignForPublicFund; import com.tanpu.community.feign.product.FeignForPublicFund;
import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom; import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom;
import com.tanpu.community.feign.zhibo.FeignClientForZhibo; import com.tanpu.community.feign.zhibo.FeignClientForZhibo;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j; 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 org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -60,7 +54,7 @@ public class FeignService { ...@@ -60,7 +54,7 @@ public class FeignService {
public UserInfoResp getUserInfoById(String userId) { public UserInfoResp getUserInfoById(String userId) {
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(userId); CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(userId);
if (userInfoNewCommonResp.isNotSuccess()) { if (userInfoNewCommonResp.isNotSuccess()) {
throw new BizException("内部接口调用失败"); throw new BizException("内部接口调用失败");
} }
......
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