Commit f0f2842f authored by 张辰's avatar 张辰

Merge branch 'dev' into 'master'

Dev

See merge request !10
parents e4b869fb 3f82e26d
......@@ -59,9 +59,12 @@ public class ThemeQo implements Serializable {
@ApiModelProperty(value = "认证机构")
private String authOrg;
@ApiModelProperty(value = "发表时间")
@ApiModelProperty(value = "发表时间-距今")
public String upToNowTime;
@ApiModelProperty(value = "发表时间-标准格式化")
public String formatTime;
@ApiModelProperty(value = "转发量")
public Integer forwardCount;
......
......@@ -30,7 +30,7 @@ public class CreateThemeReq {
@ApiModelProperty(value = "修改,则传入正在编辑的ThemeId")
private String editThemeId = "";
@ApiModelProperty("是否同步到社区 0为不同步 1为同步 不传也为同步")
@ApiModelProperty("是否同步到社区 0为不同步 1为同步 默认不同步")
private Integer syncToNewComm = 0;
}
......@@ -33,7 +33,7 @@ public class ThemeController {
@ResponseBody
public CommonResp<CreateThemeResp> publishTheme(@Validated @RequestBody CreateThemeReq req) {
String userId = userHolder.getUserId();
return CommonResp.success(themeManager.publishTheme(req, userId));
return themeManager.publishTheme(req, userId);
}
@AuthLogin
......
......@@ -45,7 +45,7 @@ public interface FeignClientForFatools {
// 用户信息查询 (供圈子服务调用)
@ApiOperation(value = "查询用户信息")
@GetMapping(value = "/queryUserInfoNew")
CommonResp<UserInfoResp> queryUsersListNew(@RequestParam("userId") String userId);
CommonResp<UserInfoResp> queryUserInfoNew(@RequestParam("userId") String userId);
@ApiOperation(value = "批量查询查询基本信息")
@GetMapping(value = "/queryUserBaseInfoList")
......
......@@ -2,7 +2,6 @@ package com.tanpu.community.feign.fatools;
import com.tanpu.common.api.CommonResp;
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.fatools.UserInfoNewChief;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoOrg;
......@@ -50,7 +49,7 @@ public class FeignbackForFatools implements FallbackFactory<FeignClientForFatool
}
@Override
public CommonResp<UserInfoResp> queryUsersListNew(String userId) {
public CommonResp<UserInfoResp> queryUserInfoNew(String userId) {
log.info("FeignbackForFatools.queryUsersListNew", throwable);
return CommonResp.error();
}
......
......@@ -108,7 +108,7 @@ public class CommentManager {
}
private UserInfoResp getUserInfo(String authorId){
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(authorId);
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(authorId);
if (userInfoNewCommonResp.isNotSuccess()) {
throw new BizException("内部接口调用失败");
}
......
......@@ -63,7 +63,7 @@ public class HomePageManager {
//查询 个人中心 相关信息
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()))
throw new BizException("内部接口调用失败");
UserInfoResp userInfoNew = queryUsersListNew.getData();
......
......@@ -55,7 +55,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.BeanUtils;
......@@ -197,12 +196,15 @@ public class ThemeManager {
* 发表主题(修改)
*/
@Transactional
public CreateThemeResp publishTheme(CreateThemeReq req, String userId) {
public CommonResp<CreateThemeResp> publishTheme(CreateThemeReq req, String userId) {
// 校验参数
checkAttachment(req.getContent());
// 转播权限校验
liveRelayCheck(userId, req.getContent());
// if (1 == req.getSyncToNewComm()) {
// liveRelayCheck(userId, req.getContent());
// }
// 保存主题表
ThemeEntity themeEntity = new ThemeEntity();
......@@ -216,11 +218,6 @@ public class ThemeManager {
if (StringUtils.isBlank(req.getEditThemeId())) {
// 新建
themeService.insertTheme(themeEntity);
// 同步到专栏
if (1 == req.getSyncToNewComm()) {
synchronizeToNewsFeed(req, themeEntity.getThemeId(), userId);
}
} else {
// 修改
themeService.update(themeEntity, req.getEditThemeId());
......@@ -243,10 +240,30 @@ public class ThemeManager {
redisCache.evict(StringUtils.joinWith("_", CACHE_THEME_ID, themeEntity.getThemeId()));
return CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build();
CreateThemeResp themeResp = CreateThemeResp.builder().themeId(themeEntity.getThemeId()).build();
// 同步到专栏
if (1 == req.getSyncToNewComm()) {
CommonResp response = synchronizeToNewsFeed(req, themeEntity.getThemeId(), userId);
if (response.isNotSuccess()) {
if ("8001".equals(response.getCode())) {
// 内容受限,不会滚发布
return CommonResp.error(ErrorCodeConstant.THEME_SYNCHRONIZE_FAILED.getCode(), "发布成功,同步失败:" + response.getMsg(), themeResp);
} else {
// 其他回滚异常
throw new BizException(ErrorCodeConstant.THEME_PUBLISH_FAILED.getCode()
, "调用专栏同步异常:" + response.getMsg());
}
}
}
return CommonResp.success(themeResp);
}
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())) {
// 只有讨论类型才能同步专栏
throw new BizException("长文类型无法同步专栏");
......@@ -275,15 +292,19 @@ public class ThemeManager {
}
}
newsFeedReq.setNewsFeedResList(feedList);
CommonResp response = feignClientForCommunity.saveNewsFeed4NewComm(newsFeedReq);
if (response.isNotSuccess() || !ObjectUtils.anyNotNull(response.getData())) {
throw new BizException("同步圈子调用失败");
}
return feignClientForCommunity.saveNewsFeed4NewComm(newsFeedReq);
}
/**
* 转存图片到老接口
*
* @param img
* @param userId
* @return
*/
private NewsFeedResReq convertImg(ImagesDTO img, String userId) {
String imgUrl = img.getRemark();
String[] arr = StringUtils.split(imgUrl, ".");
......@@ -349,19 +370,19 @@ public class ThemeManager {
*/
private void checkAttachment(List<ThemeContentReq> themeAttachments) {
if (CollectionUtils.isEmpty(themeAttachments)) {
throw new BizException("正文内容不能为空");
throw new BizException(ErrorCodeConstant.ILLEGAL_ARGEMENT.getCode(), "正文内容不能为空");
}
for (ThemeContentReq content : themeAttachments) {
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());
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.getProductType() == null) {
throw new IllegalArgumentException("附件产品FUND缺少类型");
throw new BizException(ErrorCodeConstant.ILLEGAL_ARGEMENT.getCode(), "附件产品FUND缺少类型");
}
}
}
......@@ -431,7 +452,7 @@ public class ThemeManager {
// 加载第一页时,为防止首页显示空列表,从推荐池中再捞出已看过帖子
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));
}
......@@ -588,7 +609,7 @@ public class ThemeManager {
if (userId.equals(req.getUserId())) {
//如果用户是查询自己的帖子,需要实时查询用户自己的个人信息,防止数据不一致(非收藏类型)
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(userId);
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(userId);
if (userInfoNewCommonResp.isNotSuccess()) {
throw new BizException("内部接口调用失败");
}
......@@ -622,8 +643,6 @@ public class ThemeManager {
//转发、收藏、点赞
buildThemeQoExtraInfo(themeQo);
//时间重制
themeQo.setUpToNowTime(TimeUtils.format(themeEntity.getCreateTime()));
// 添加用户相关信息
buildThemeExtraInfoByUser(userId, themeQo);
return CommonResp.success(themeQo);
......@@ -711,7 +730,7 @@ public class ThemeManager {
// 校验参数
checkAttachment(req.getContent());
// 转播权限校验
liveRelayCheck(userId, req.getContent());
// liveRelayCheck(userId, req.getContent());
// 保存主题表
ThemeEntity themeEntity = new ThemeEntity();
......@@ -856,7 +875,7 @@ public class ThemeManager {
private UserInfoResp getUserInfo(String authorId) {
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(authorId);
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(authorId);
if (userInfoNewCommonResp.isNotSuccess()) {
throw new BizException("内部接口调用失败");
}
......
package com.tanpu.community.service;
import com.alibaba.fastjson.JSON;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
......@@ -16,14 +15,9 @@ import com.tanpu.community.feign.product.FeignForFund;
import com.tanpu.community.feign.product.FeignForPublicFund;
import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom;
import com.tanpu.community.feign.zhibo.FeignClientForZhibo;
import lombok.extern.log4j.Log4j;
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 javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
......@@ -60,7 +54,7 @@ public class FeignService {
public UserInfoResp getUserInfoById(String userId) {
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUsersListNew(userId);
CommonResp<UserInfoResp> userInfoNewCommonResp = feignClientForFatools.queryUserInfoNew(userId);
if (userInfoNewCommonResp.isNotSuccess()) {
throw new BizException("内部接口调用失败");
}
......
......@@ -132,7 +132,7 @@ public class RankService {
}
//排序
Map<ThemeAnalysDO, Double> map = themeAnalysDOS.stream().collect(Collectors.toMap(o -> o, ThemeAnalysDO::getScore));
//排序
hotestThemes = map.entrySet().stream()
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
.map(Map.Entry::getKey).collect(Collectors.toList());
......
......@@ -47,6 +47,7 @@ public class ConvertUtil {
themeQO.setUpdateTime(TimeUtils.getTimestampOfDateTime(themeEntity.getUpdateTime()));
themeQO.setCreateTime(TimeUtils.getTimestampOfDateTime(themeEntity.getCreateTime()));
themeQO.setUpToNowTime(TimeUtils.calUpToNowTime(themeEntity.getCreateTime()));
themeQO.setFormatTime(TimeUtils.format(themeEntity.getCreateTime()));
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() {
});
themeQO.setContent(themeContentQos);
......
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