Commit 0413dd68 authored by 刘基明's avatar 刘基明

产品接口修改

parent 0bdbd00c
......@@ -18,10 +18,10 @@ public class AttachmentDetailVo {
@ApiModelProperty("直播信息")
private ZhiboListResp zhibo;
@ApiModelProperty("产品信息")
private ProductInfoVO product;
private FundInfoBaseResp product;
@ApiModelProperty("短视频")
private ShortVideoBaseInfoResp shortVideo;
@ApiModelProperty("新版课程")
private CoursePackageDetail course;
@ApiModelProperty("课程")
private ShortVideoBaseInfoResp curriculum;
}
......@@ -7,6 +7,10 @@ import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* @author: zhoupeng
* @email: zhoupeng_08@163.com
*/
@ApiModel("产品信息")
@Data
public class ProductInfoVO {
......@@ -154,7 +158,7 @@ public class ProductInfoVO {
private Integer fundNum;
@ApiModelProperty("公司资产规模")
private Integer companyAssetSize;
private String companyAssetSize;
@ApiModelProperty("点评")
private List<Type> commentContent;
......
package com.tanpu.community.api.beans.vo.feign;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@ApiModel(description = "用户信息")
@Data
public class UserInfoVo {
@ApiModelProperty("用户ID")
private String id;
@ApiModelProperty("用户姓名")
private String uiUsername;
@ApiModelProperty("用户昵称")
private String uiNickname;
@ApiModelProperty("用户头像")
private String uiHeadimg;
@ApiModelProperty("用户头像")
private String uiHeadimgMp;
@ApiModelProperty("二维码名片图片")
private String uiWechatQrcode;
@ApiModelProperty("微店小程序图片")
private String uiWechatXcxQrcode;
@ApiModelProperty("用户权限")
private String uiAuth;
@ApiModelProperty("用户手机号")
private String uiMobilephoneMp;
@ApiModelProperty("名片电话")
private String uiTelphoneMp;
@ApiModelProperty("注册手机号")
private String uiTelphone;
@ApiModelProperty("微信id'")
private String uiOpenId;
@ApiModelProperty("realname")
private String realname;
@ApiModelProperty("level")
private Integer level;
@ApiModelProperty("0游客,1注册用户,20探普理顾 30:探普专家理顾 40:交易理财师")
private Integer levelGrade;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("注册时间")
private Date uiRegisterTime;
}
......@@ -17,14 +17,14 @@ public class FeignBackClientForCourse implements FallbackFactory<FeignClientForC
public CommonResp<CourseDetailExt> getCourseIdDetailInfo(String id, String packageId) {
log.error("请求信息", throwable);
log.error("FeignClientForCourse.getCourseIdDetailInfo-查询课程id:{},package:{}", id,packageId);
return null;
return CommonResp.failed("调用getCourseIdDetailInfo失败");
}
@Override
public CommonResp<CoursePackageDetail> getCoursePackageDetailInfo(String id) {
log.error("请求信息", throwable);
log.error("FeignClientForCourse.getCoursePackageDetailInfo-查询课程包id:{}", id);
return null;
return CommonResp.failed("调用getCoursePackageDetailInfo失败");
}
};
}
......
package com.tanpu.community.feign.fatools;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.UserInfoVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Set;
//@FeignClient(value = "fatools", fallbackFactory = FeignbackForFatools.class, url = "http://127.0.0.1:8189/fatools")
@FeignClient(value = "fatools", contextId = "fatoolsUser", fallbackFactory = FeignbackForFatools.class, path = "/fatools")
public interface FeignClientForFatools {
@ApiOperation(value = "查询用户详情")
@GetMapping("/user/getUserInfoById")
UserInfoVo getUserInfoById(@RequestParam("userId") String userId);
@GetMapping("/column/getCurriculumByColumnRelId")
List<ShortVideoBaseInfoResp> getCurriculumByColumnRelId(@RequestParam("ids") List<String> ids);
@ApiOperation(value = "获取不能转播直播")
@GetMapping(value = "/app/getNotRelaySet")
CommonResp<Set<String>> getNotRelaySet(@ApiParam("用户id") @RequestParam("userId") String userId,
@ApiParam("直播列表id") @RequestParam("roomIds") Set<String> roomIds);
}
package com.tanpu.community.feign.fatools;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.UserInfoVo;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Set;
@Slf4j
@Component
public class FeignbackForFatools implements FallbackFactory<FeignClientForFatools> {
@Override
public FeignClientForFatools create(Throwable throwable) {
return new FeignClientForFatools() {
@Override
public UserInfoVo getUserInfoById(String userId) {
log.info("FeignbackForFatools.getUserInfoById调用失败", throwable);
return null;
}
@Override
public List<ShortVideoBaseInfoResp> getCurriculumByColumnRelId(List<String> ids) {
log.info("FeignbackForFatools.getCurriculumByColumnRelId调用失败", throwable);
return null;
}
@Override
public CommonResp<Set<String>> getNotRelaySet(String userId, Set roomIds) {
log.info("FeignbackForFatools.getNotRelaySet", throwable);
return CommonResp.error();
}
};
}
}
package com.tanpu.community.feign.product;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.ProductInfoVO;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
//@FeignClient(value = "service-fund", url = "http://127.0.0.1:8194/fund")
@FeignClient(value = "service-fund", path = "/fund")
public interface FeignForFund {
@ApiOperation("获取产品详情")
@GetMapping("/product/list")
CommonResp<List<ProductInfoVO>> getProductList(@ApiParam("产品id") @RequestParam("ids") List<String> ids);
@ApiOperation("获取ifa导入产品")
@GetMapping("/privatefund/list")
CommonResp<List<ProductInfoVO>> getPrivateFundList(@ApiParam("产品id") @RequestParam("ids") List<String> ids);
@ApiOperation("获取非净值产品")
@GetMapping("/product/not/net")
CommonResp<List<ProductInfoVO>> getProductListNotNetInfo(@ApiParam("产品id") @RequestParam("ids") List<String> ids);
}
package com.tanpu.community.feign.product;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.ProductInfoVO;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
//@FeignClient(value = "service-fundpublic", url = "http://127.0.0.1:8194/fundpublic")
@FeignClient(value = "service-fundpublic",path = "/fundpublic")
public interface FeignForPublicFund {
@ApiOperation("获取产品详情")
@GetMapping("/product/list")
CommonResp<List<ProductInfoVO>> getProductList(@ApiParam("产品id") @RequestParam("ids") List<String> ids);
}
package com.tanpu.community.feign.product;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.ProductInfoVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
public class FeignbackForFund implements FallbackFactory<FeignForFund> {
@Override
public FeignForFund create(Throwable throwable) {
return new FeignForFund() {
@Override
public CommonResp<List<ProductInfoVO>> getProductList(List<String> ids) {
log.error("FeignbackForFund.getProductList");
return CommonResp.failed("调用私募详情失败");
}
@Override
public CommonResp<List<ProductInfoVO>> getPrivateFundList(List<String> ids) {
log.error("FeignbackForFund.getPrivateFundList");
return CommonResp.failed("调用ifa导入基金失败");
}
@Override
public CommonResp<List<ProductInfoVO>> getProductListNotNetInfo(List<String> ids) {
log.error("FeignbackForFund.getProductListNotNetInfo", throwable);
return CommonResp.failed("查询无净值产品");
}
};
}
}
package com.tanpu.community.feign.product;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.ProductInfoVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
public class FeignbackForPublicFund implements FallbackFactory<FeignForPublicFund> {
@Override
public FeignForPublicFund create(Throwable throwable) {
return new FeignForPublicFund() {
@Override
public CommonResp<List<ProductInfoVO>> getProductList(List<String> ids) {
log.error("getProductList.getProductList");
return CommonResp.failed("调用公募详情失败");
}
};
}
}
package com.tanpu.community.manager;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.exception.BizException;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.CommunityConstant;
import com.tanpu.community.api.beans.qo.AttachmentDetailVo;
import com.tanpu.community.api.beans.qo.FormerThemeQo;
import com.tanpu.community.api.beans.qo.ThemeContentQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.homepage.QueryRecordThemeReq;
import com.tanpu.community.api.beans.req.theme.*;
import com.tanpu.community.api.beans.vo.feign.*;
import com.tanpu.community.api.enums.*;
import com.tanpu.community.api.enums.BlockTypeEnum;
import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.api.enums.ThemeListTypeEnum;
import com.tanpu.community.api.enums.ThemeTypeEnum;
import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.feign.course.FeignClientForCourse;
import com.tanpu.community.feign.product.FeignClientForProducts;
import com.tanpu.community.feign.tanpuroom.FeignClientForTanpuroom;
import com.tanpu.community.feign.zhibo.FeignClientForZhibo;
import com.tanpu.community.service.*;
import com.tanpu.community.service.other.*;
import com.tanpu.community.util.ConvertUtil;
......@@ -29,7 +23,10 @@ import javax.annotation.Resource;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Service
public class ThemeManager {
......@@ -70,16 +67,7 @@ public class ThemeManager {
private HomePageService homePageService;
@Resource
private FeignClientForTanpuroom feignClientForTanpuroom;
@Resource
private FeignClientForZhibo feignClientForZhibo;
@Resource
private FeignClientForProducts feignClientForProducts;
@Autowired
private FeignClientForCourse feignClientForCourse;
private ProductService productService;
@Autowired
private OSSFileService ossFileService;
......@@ -140,7 +128,7 @@ public class ThemeManager {
if (themeEntity == null) {
throw new BizException("找不到帖子id:" + themeId);
}
ThemeQo themeQo = ConvertUtil.themeEntityToQo(themeEntity);
ThemeQo themeQo = ConvertUtil.themeEntityToQo2(themeEntity);
buildMainTestExtraInfo(themeQo, userId);
return themeQo;
}
......@@ -220,6 +208,7 @@ public class ThemeManager {
//主题Entity转QO
private List<ThemeQo> convertEntityToQo(List<ThemeEntity> themeEntities, String userId) {
List<ThemeQo> themeQos = ConvertUtil.themeEntitiesToDTOs(themeEntities);
productService.transferAttachment(themeQos,userId);
for (ThemeQo themeQO : themeQos) {
buildThemeQoExtraInfo(userId, themeQO);
}
......@@ -231,15 +220,7 @@ public class ThemeManager {
private void buildThemeQoExtraInfo(String userId, ThemeQo themeQo) {
//附件列表
String themeId = themeQo.getThemeId();
List<ThemeContentQo> content = themeQo.getContent();
if (content != null && content.size() > 2) {
themeQo.setContent(content.subList(0, 2));
}
content = themeQo.getContent();
for (ThemeContentQo themeContentQo : content) {
transferAttachment(themeContentQo, userId);
}
//迄今时间
themeQo.setUpToNowTime(calUpToNowTime(themeQo.getCreateTime()));
......@@ -256,7 +237,7 @@ public class ThemeManager {
//转发原文
String formerThemeId = themeQo.getFormerThemeId();
if (formerThemeId!=null){
ThemeQo formerTheme = ConvertUtil.themeEntityToQo(themeService.queryByThemeId(formerThemeId));
ThemeQo formerTheme = ConvertUtil.themeEntityToQo2(themeService.queryByThemeId(formerThemeId));
if (formerTheme==null){
throw new BizException("转发主题Id错误,id:"+formerThemeId);
}
......@@ -285,10 +266,6 @@ public class ThemeManager {
private void buildMainTestExtraInfo(ThemeQo themeQo, String userId) {
//附件列表
String themeId = themeQo.getThemeId();
List<ThemeContentQo> content = themeQo.getContent();
for (ThemeContentQo themeContentQo : content) {
transferAttachment(themeContentQo, userId);
}
//迄今时间
themeQo.setUpToNowTime(calUpToNowTime(themeQo.getCreateTime()));
//用户信息:头像、昵称
......@@ -298,7 +275,7 @@ public class ThemeManager {
//转发原文
String formerThemeId = themeQo.getFormerThemeId();
if (formerThemeId!=null){
ThemeQo formerTheme = ConvertUtil.themeEntityToQo(themeService.queryByThemeId(formerThemeId));
ThemeQo formerTheme = ConvertUtil.themeEntityToQo2(themeService.queryByThemeId(formerThemeId));
if (formerTheme==null){
throw new BizException("转发主题Id错误,id:"+formerThemeId);
}
......@@ -315,47 +292,6 @@ public class ThemeManager {
}
public void transferAttachment(ThemeContentQo themeContentQo, String userId) {
String type = themeContentQo.getType();
if (RelTypeEnum.FUND.type.equals(type)) {
//产品
String productId = themeContentQo.getValue();
CommonResp<ProductInfoVO> productDetailInfo = feignClientForProducts.getProductDetailInfo(productId);
themeContentQo.setDetail(AttachmentDetailVo.builder().product(productDetailInfo.getData()).build());
} else if (RelTypeEnum.LIVE.type.equals(type)) {
//直播
String zhiboId = themeContentQo.getValue();
String[] roomIds = new String[]{zhiboId};
CommonResp<List<ZhiboListResp>> zhiboDetailVOCommonResp = feignClientForZhibo.simpleList(Arrays.asList(roomIds));
themeContentQo.setDetail(AttachmentDetailVo.builder().zhibo(zhiboDetailVOCommonResp.getData().get(0)).build());
} else if (RelTypeEnum.SHORT_VIDEO.type.equals(type)) {
//短视频
String videoId = themeContentQo.getValue();
String[] attachmentIds = new String[]{videoId};
CommonResp<List<ShortVideoBaseInfoResp>> shortVideoBaseInfo =
feignClientForTanpuroom.getShortVideoBaseInfo(Arrays.asList(attachmentIds));
themeContentQo.setDetail(AttachmentDetailVo.builder().shortVideo(shortVideoBaseInfo.getData().get(0)).build());
} else if (RelTypeEnum.NEW_COURSE_WARE.type.equals(type)) {
//课程
String packageId = themeContentQo.getValue();
CommonResp<CoursePackageDetail> courseIdDetailInfo = feignClientForCourse.getCoursePackageDetailInfo(packageId);
themeContentQo.setDetail(AttachmentDetailVo.builder().course(courseIdDetailInfo.getData()).build());
} else if (RelTypeEnum.SINGLE_IMG.type.equals(type)) {
//单图,根据id传入url
String imgId = themeContentQo.getValue();
FileRecordEntity fileEntity = ossFileService.queryById(imgId);
if (fileEntity == null) {
throw new BizException("图片未找到,id:" + imgId);
}
themeContentQo.setValue(CommunityConstant.OSS_PREFIX_URL + fileEntity.getFileOssKey());
}
}
//计算迄今时间
private String calUpToNowTime(LocalDateTime start) {
......
//package com.tanpu.community.service;
//
//import com.google.common.collect.Lists;
//import org.springframework.beans.BeanUtils;
//import org.springframework.util.CollectionUtils;
//
//import java.util.List;
//import java.util.Map;
//import java.util.stream.Collectors;
//
//public class ProductService {
//
// /**
// * 获取资源信息
// *
// * @param shortVideoMap
// * @param curriculumMap
// * @param zhiboMap
// * @param fundMap
// */
// private void getResInfo(Map<String, ShortVideoBaseInfoResp> shortVideoMap,
// Map<String, ShortVideoBaseInfoResp> curriculumMap,
// Map<String, ZhiboListResp> zhiboMap,
// Map<String, FundInfoBaseResp> fundMap,
// List<NewsFeedRes> newsFeedRes,
// Map<String, NewsFeedRes> newFeedMap
// ) {
// // 白名单基金id
// List<String> tanpuFundIds = Lists.newArrayList();
// // 私募基金id
// List<String> fundIds = Lists.newArrayList();
// // 理财师导入
// List<String> ifaFundIds = Lists.newArrayList();
// // 公募基金id
// List<String> publicFundIds = Lists.newArrayList();
// // 无净值产品id
// List<String> notNetFundIds = Lists.newArrayList();
// // 短视频id
// List<String> shortVideoIds = Lists.newArrayList();
// // 直播id
// List<String> zhiboIds = Lists.newArrayList();
// // 课程id
// List<String> curriculumIds = Lists.newArrayList();
// // 获取关联资源id
// if (newsFeedRes != null) {
//
// }
// if (!CollectionUtils.isEmpty(shortVideoIds)) {
// // 短视频列表
// }
// if (!CollectionUtils.isEmpty(curriculumIds)) {
// // 课程列表
// }
// if (!CollectionUtils.isEmpty(zhiboIds)) {
// // 直播列表
// }
// this.getFundInfo(tanpuFundIds, fundIds, publicFundIds, ifaFundIds, notNetFundIds, fundMap);
// }
//
// /**
// * 设置产品信息
// *
// * @param tanpuFundIds
// * @param fundIds
// * @param publicFundIds
// * @param fundMap
// */
// private void getFundInfo(List<String> tanpuFundIds,
// List<String> fundIds,
// List<String> publicFundIds,
// List<String> ifaFundIds,
// List<String> notNetFundIds,
// Map<String, FundInfoBaseResp> fundMap) {
// Map<String, FundInfoBaseResp> tampFundMap = null;
// Map<String, FundInfoBaseResp> privateFundMap = null;
// Map<String, FundInfoBaseResp> publicFundMap = null;
// Map<String, FundInfoBaseResp> ifaFundMap = null;
// Map<String, FundInfoBaseResp> notNetFundMap = null;
// if (!CollectionUtils.isEmpty(tanpuFundIds)) {
//// ProductListReq productListReq = ProductListReq.builder()
//// .fundIds(Lists.newArrayList(tanpuFundIds))
//// .build();
// // 探普产品
// CommonResp<List<ProductInfoVO>> commonResp = feignForProduct.getProductInfoByIds(tanpuFundIds);
// if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getAttributes())) {
// List<FundInfoBaseResp> fundInfoBaseRespList = commonResp.attributes.stream().map(item -> {
// FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
// BeanUtils.copyProperties(item, fundInfoBaseResp);
// return fundInfoBaseResp;
// }).collect(Collectors.toList());
// tampFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
// }
//
// if (tampFundMap != null && tampFundMap.size() > 0) {
// fundMap.putAll(tampFundMap);
// }
// }
// // 私募产品
// if (!CollectionUtils.isEmpty(fundIds)) {
// // 私募产品
// CommonResp<List<ProductInfoVO>> fundResult = feignForFund.getProductList(fundIds);
// if (fundResult.isSuccess() && !CollectionUtils.isEmpty(fundResult.getAttributes())) {
// List<FundInfoBaseResp> fundInfoBaseRespList = fundResult.attributes.stream().map(item -> {
// FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
// BeanUtils.copyProperties(item, fundInfoBaseResp);
// return fundInfoBaseResp;
// }).collect(Collectors.toList());
// privateFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
// }
//
// if (privateFundMap != null && privateFundMap.size() > 0) {
// fundMap.putAll(privateFundMap);
// }
// }
//
// // 理财师导入产品
// if (!CollectionUtils.isEmpty(ifaFundIds)) {
// CommonResp<List<ProductInfoVO>> ifaFundResult = feignForFund.getPrivateFundList(ifaFundIds);
// if (ifaFundResult.isSuccess() && !CollectionUtils.isEmpty(ifaFundResult.getAttributes())) {
// List<FundInfoBaseResp> fundInfoBaseRespList = ifaFundResult.attributes.stream().map(item -> {
// FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
// BeanUtils.copyProperties(item, fundInfoBaseResp);
// return fundInfoBaseResp;
// }).collect(Collectors.toList());
// ifaFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
// }
//
// if (ifaFundMap != null && ifaFundMap.size() > 0) {
// fundMap.putAll(ifaFundMap);
// }
// }
//
// if (!CollectionUtils.isEmpty(publicFundIds)) {
// // 公募产品
// CommonResp<List<ProductInfoVO>> publicFundResult = feignForPublicFund.getProductList(publicFundIds);
// if (publicFundResult.isSuccess() && !CollectionUtils.isEmpty(publicFundResult.getAttributes())) {
// List<FundInfoBaseResp> fundInfoBaseRespList = publicFundResult.attributes.stream().map(item -> {
// FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
// BeanUtils.copyProperties(item, fundInfoBaseResp);
// return fundInfoBaseResp;
// }).collect(Collectors.toList());
// publicFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
// }
// if (publicFundMap != null && publicFundMap.size() > 0) {
// fundMap.putAll(publicFundMap);
// }
// }
//
// if (!CollectionUtils.isEmpty(notNetFundIds)) {
// // 无净值产品
// CommonResp<List<ProductInfoVO>> notNetInfoResult = feignForFund.getProductListNotNetInfo(notNetFundIds);
// if (notNetInfoResult.isSuccess() && !CollectionUtils.isEmpty(notNetInfoResult.getAttributes())) {
// List<FundInfoBaseResp> fundInfoBaseRespList = notNetInfoResult.attributes.stream().map(item -> {
// FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
// BeanUtils.copyProperties(item, fundInfoBaseResp);
// return fundInfoBaseResp;
// }).collect(Collectors.toList());
// notNetFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
// }
// if (notNetFundMap != null && notNetFundMap.size() > 0) {
// fundMap.putAll(notNetFundMap);
// }
// }
// }
//
// /**
// * 设置资源信息
// *
// * @param item
// * @param resp
// * @param newFeedMap
// * @param shortVideoMap
// * @param curriculumMap
// * @param zhiboMap
// * @param fundMap
// */
// private void setResInfo(NewsFeed item,
// NewsFeedResp resp,
// Map<String, NewsFeedRes> newFeedMap,
// Map<String, ShortVideoBaseInfoResp> shortVideoMap,
// Map<String, ShortVideoBaseInfoResp> curriculumMap,
// Map<String, ZhiboListResp> zhiboMap,
// Map<String, FundInfoBaseResp> fundMap) {
// if (newFeedMap.containsKey(item.getId())) {
// NewsFeedRes nf = newFeedMap.get(item.getId());
// if (nf.getRelType().equals(RelTypeEnum.LIVE.type)) {
// if (zhiboMap.containsKey(nf.getRemark())) {
// ZhiboListResp zhibo = zhiboMap.get(nf.getRemark());
// zhibo.setParentId(zhibo.getParentId());
// zhibo.setId(zhibo.getId());
// resp.setResList(RelContentResp.builder()
// .relType(RelTypeEnum.LIVE.type)
// .zhibo(zhibo).build());
// }
// } else if (nf.getRelType().equals(RelTypeEnum.SHORT_VIDEO.type)) {
// if (shortVideoMap.containsKey(nf.getRelId())) {
// resp.setResList(RelContentResp.builder()
// .relType(RelTypeEnum.SHORT_VIDEO.type)
// .shortVideo(shortVideoMap.get(nf.getRelId())).build());
// }
// } else if (nf.getRelType().equals(RelTypeEnum.VIDEO.type) || nf.getRelType().equals(RelTypeEnum.AUDIO.type)) {
// if (curriculumMap.containsKey(nf.getRelId())) {
// resp.setResList(RelContentResp.builder()
// .relType(curriculumMap.get(nf.getRelId()).getRelType())
// .curriculum(curriculumMap.get(nf.getRelId())).build());
// }
// } else if (nf.getRelType().equals(RelTypeEnum.FUND.type)) {
// if (fundMap.containsKey(nf.getRelId())) {
// FundInfoBaseResp product = fundMap.get(nf.getRelId());
// // 推荐语
// product.setRemark(nf.getRemark());
// // 产品类型
// product.setProductType(nf.getProductType());
// resp.setResList(RelContentResp.builder()
// .relType(RelTypeEnum.FUND.type)
// .product(product).build());
// }
// }
// }
// }
//}
package com.tanpu.community.service;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.enums.fund.ProductTypeEnum;
import com.tanpu.community.api.beans.qo.AttachmentDetailVo;
import com.tanpu.community.api.beans.qo.ThemeContentQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.vo.feign.FundInfoBaseResp;
import com.tanpu.community.api.beans.vo.feign.ProductInfoVO;
import com.tanpu.community.api.beans.vo.feign.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.ZhiboListResp;
import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.dao.entity.community.FileRecordEntity;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.feign.product.FeignClientForProducts;
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 org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class ProductService {
@Resource
private FeignClientForTanpuroom feignClientForTanpuroom;
@Resource
private FeignClientForZhibo feignClientForZhibo;
@Resource
private FeignClientForProducts feignForProduct;
@Resource
private FeignForFund feignForFund;
@Resource
private FeignForPublicFund feignForPublicFund;
@Resource
private FeignClientForFatools feignClientForFatools;
@Autowired
private OSSFileService ossFileService;
public void transferAttachment(List<ThemeQo> themeQos, String userId) {
// 短视频信息
Map<String, ShortVideoBaseInfoResp> shortVideoMap = Maps.newHashMap();
// 课程信息
Map<String, ShortVideoBaseInfoResp> curriculumMap = Maps.newHashMap();
// 直播信息
Map<String, ZhiboListResp> zhiboMap = Maps.newHashMap();
// 设置产品信息
Map<String, FundInfoBaseResp> fundMap = Maps.newHashMap();
// 图片信息
Map<String, String> imgMap = Maps.newHashMap();
// 批量查询资源信息
this.getResInfo(shortVideoMap, curriculumMap, zhiboMap, fundMap, imgMap, themeQos);
//逐个装入
setResInfo(themeQos,shortVideoMap,curriculumMap,zhiboMap,fundMap,imgMap);
}
/**
* 获取资源信息
*
* @param shortVideoMap
* @param curriculumMap
* @param zhiboMap
* @param fundMap
*/
private void getResInfo(Map<String, ShortVideoBaseInfoResp> shortVideoMap,
Map<String, ShortVideoBaseInfoResp> curriculumMap,
Map<String, ZhiboListResp> zhiboMap,
Map<String, FundInfoBaseResp> fundMap,
Map<String, String> imgMap,
List<ThemeQo> themeQos
) {
// 白名单基金id
List<String> tanpuFundIds = Lists.newArrayList();
// 私募基金id
List<String> fundIds = Lists.newArrayList();
// 理财师导入
List<String> ifaFundIds = Lists.newArrayList();
// 公募基金id
List<String> publicFundIds = Lists.newArrayList();
// 无净值产品id
List<String> notNetFundIds = Lists.newArrayList();
// 短视频id
List<String> shortVideoIds = Lists.newArrayList();
// 直播id
List<String> zhiboIds = Lists.newArrayList();
// 课程id
List<String> curriculumIds = Lists.newArrayList();
// 图片id
List<String> imageIds = Lists.newArrayList();
// 获取关联资源id
if (themeQos != null) {
themeQos.stream().forEach(o -> o.getContent().stream().forEach(c -> {
if (c.getType().equals(RelTypeEnum.LIVE.type)) {
zhiboIds.add(c.getRemark());
} else if (c.getType().equals(RelTypeEnum.SHORT_VIDEO.type)) {
shortVideoIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.FUND.type)) {
if (c.getProductType() == ProductTypeEnum.PUBLIC.type) {
publicFundIds.add(c.getValue());
} else if (c.getProductType() == ProductTypeEnum.PRIVATE.type) {
fundIds.add(c.getValue());
} else if (c.getProductType() == ProductTypeEnum.TAMP.type) {
tanpuFundIds.add(c.getValue());
} else if (c.getProductType() == ProductTypeEnum.CUSTOMER_IMPORT.type) {
ifaFundIds.add(c.getValue());
} else if (c.getProductType() == ProductTypeEnum.NOT_NET_PRODUCT.type) {
notNetFundIds.add(c.getValue());
}
} else if (c.getType().equals(RelTypeEnum.VIDEO.type) || c.getType().equals(RelTypeEnum.AUDIO.type)) {
curriculumIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
imageIds.add(c.getValue());
}
}));
}
if (!CollectionUtils.isEmpty(shortVideoIds)) {
// 短视频列表
CommonResp<List<ShortVideoBaseInfoResp>> commonResp = feignClientForTanpuroom.getShortVideoBaseInfo(shortVideoIds);
if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getData())) {
shortVideoMap.putAll(commonResp.getData().stream().collect(Collectors.toMap(ShortVideoBaseInfoResp::getSourceId, item -> item)));
}
}
if (!CollectionUtils.isEmpty(curriculumIds)) {
// 课程列表
List<ShortVideoBaseInfoResp> commonResp = feignClientForFatools.getCurriculumByColumnRelId(curriculumIds);
if (commonResp != null && !CollectionUtils.isEmpty(commonResp)) {
curriculumMap.putAll(commonResp.stream().collect(Collectors.toMap(ShortVideoBaseInfoResp::getColumnRelId, item -> item)));
}
}
if (!CollectionUtils.isEmpty(zhiboIds)) {
// 直播列表
CommonResp<List<ZhiboListResp>> commonResp = feignClientForZhibo.simpleList(zhiboIds);
if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getData())) {
zhiboMap.putAll(commonResp.getData().stream().collect(Collectors.toMap(ZhiboListResp::getId, item -> item)));
}
}
if (!CollectionUtils.isEmpty(imageIds)) {
// 直播列表
List<FileRecordEntity> fileRecordEntities = ossFileService.queryByIds(imageIds);
if (!CollectionUtils.isEmpty(fileRecordEntities)) {
imgMap.putAll(fileRecordEntities.stream().collect(Collectors
.toMap(FileRecordEntity::getFileId, FileRecordEntity::getUrl)));
}
}
this.getFundInfo(tanpuFundIds, fundIds, publicFundIds, ifaFundIds, notNetFundIds, fundMap);
}
/**
* 设置产品信息
*
* @param tanpuFundIds
* @param fundIds
* @param publicFundIds
* @param fundMap
*/
private void getFundInfo(List<String> tanpuFundIds,
List<String> fundIds,
List<String> publicFundIds,
List<String> ifaFundIds,
List<String> notNetFundIds,
Map<String, FundInfoBaseResp> fundMap) {
Map<String, FundInfoBaseResp> tampFundMap = null;
Map<String, FundInfoBaseResp> privateFundMap = null;
Map<String, FundInfoBaseResp> publicFundMap = null;
Map<String, FundInfoBaseResp> ifaFundMap = null;
Map<String, FundInfoBaseResp> notNetFundMap = null;
if (!CollectionUtils.isEmpty(tanpuFundIds)) {
// ProductListReq productListReq = ProductListReq.builder()
// .fundIds(Lists.newArrayList(tanpuFundIds))
// .build();
// 探普产品
CommonResp<List<ProductInfoVO>> commonResp = feignForProduct.getProductInfoByIds(tanpuFundIds);
if (commonResp.isSuccess() && !CollectionUtils.isEmpty(commonResp.getData())) {
List<FundInfoBaseResp> fundInfoBaseRespList = commonResp.getData().stream().map(item -> {
FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
BeanUtils.copyProperties(item, fundInfoBaseResp);
return fundInfoBaseResp;
}).collect(Collectors.toList());
tampFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
}
if (tampFundMap != null && tampFundMap.size() > 0) {
fundMap.putAll(tampFundMap);
}
}
// 私募产品
if (!CollectionUtils.isEmpty(fundIds)) {
// 私募产品
CommonResp<List<ProductInfoVO>> fundResult = feignForFund.getProductList(fundIds);
if (fundResult.isSuccess() && !CollectionUtils.isEmpty(fundResult.getData())) {
List<FundInfoBaseResp> fundInfoBaseRespList = fundResult.getData().stream().map(item -> {
FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
BeanUtils.copyProperties(item, fundInfoBaseResp);
return fundInfoBaseResp;
}).collect(Collectors.toList());
privateFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
}
if (privateFundMap != null && privateFundMap.size() > 0) {
fundMap.putAll(privateFundMap);
}
}
// 理财师导入产品
if (!CollectionUtils.isEmpty(ifaFundIds)) {
CommonResp<List<ProductInfoVO>> ifaFundResult = feignForFund.getPrivateFundList(ifaFundIds);
if (ifaFundResult.isSuccess() && !CollectionUtils.isEmpty(ifaFundResult.getData())) {
List<FundInfoBaseResp> fundInfoBaseRespList = ifaFundResult.getData().stream().map(item -> {
FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
BeanUtils.copyProperties(item, fundInfoBaseResp);
return fundInfoBaseResp;
}).collect(Collectors.toList());
ifaFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
}
if (ifaFundMap != null && ifaFundMap.size() > 0) {
fundMap.putAll(ifaFundMap);
}
}
if (!CollectionUtils.isEmpty(publicFundIds)) {
// 公募产品
CommonResp<List<ProductInfoVO>> publicFundResult = feignForPublicFund.getProductList(publicFundIds);
if (publicFundResult.isSuccess() && !CollectionUtils.isEmpty(publicFundResult.getData())) {
List<FundInfoBaseResp> fundInfoBaseRespList = publicFundResult.getData().stream().map(item -> {
FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
BeanUtils.copyProperties(item, fundInfoBaseResp);
return fundInfoBaseResp;
}).collect(Collectors.toList());
publicFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
}
if (publicFundMap != null && publicFundMap.size() > 0) {
fundMap.putAll(publicFundMap);
}
}
if (!CollectionUtils.isEmpty(notNetFundIds)) {
// 无净值产品
CommonResp<List<ProductInfoVO>> notNetInfoResult = feignForFund.getProductListNotNetInfo(notNetFundIds);
if (notNetInfoResult.isSuccess() && !CollectionUtils.isEmpty(notNetInfoResult.getData())) {
List<FundInfoBaseResp> fundInfoBaseRespList = notNetInfoResult.getData().stream().map(item -> {
FundInfoBaseResp fundInfoBaseResp = FundInfoBaseResp.builder().build();
BeanUtils.copyProperties(item, fundInfoBaseResp);
return fundInfoBaseResp;
}).collect(Collectors.toList());
notNetFundMap = fundInfoBaseRespList.stream().collect(Collectors.toMap(FundInfoBaseResp::getFundId, item -> item));
}
if (notNetFundMap != null && notNetFundMap.size() > 0) {
fundMap.putAll(notNetFundMap);
}
}
}
/**
* 设置资源信息
*/
private void setResInfo(List<ThemeQo> themeQos,
Map<String, ShortVideoBaseInfoResp> shortVideoMap,
Map<String, ShortVideoBaseInfoResp> curriculumMap,
Map<String, ZhiboListResp> zhiboMap,
Map<String, FundInfoBaseResp> fundMap,
Map<String, String> imgUrlMap) {
for (ThemeQo themeQo : themeQos) {
for (ThemeContentQo themeContent : themeQo.getContent()) {
if (themeContent.getType().equals(RelTypeEnum.LIVE.type)) {
if (zhiboMap.containsKey(themeContent.getValue())) {
ZhiboListResp zhibo = zhiboMap.get(themeContent.getRemark());
themeContent.setDetail(AttachmentDetailVo.builder().zhibo(zhibo).build());
}
} else if (themeContent.getType().equals(RelTypeEnum.SHORT_VIDEO.type)) {
if (shortVideoMap.containsKey(themeContent.getValue())) {
themeContent.setDetail(AttachmentDetailVo.builder()
.shortVideo(shortVideoMap.get(themeContent.getValue())).build());
}
} else if (themeContent.getType().equals(RelTypeEnum.VIDEO.type) ||
themeContent.getType().equals(RelTypeEnum.AUDIO.type)) {
if (curriculumMap.containsKey(themeContent.getValue())) {
themeContent.setDetail(AttachmentDetailVo.builder()
.curriculum(curriculumMap.get(themeContent.getValue())).build());
}
} else if (themeContent.getType().equals(RelTypeEnum.FUND.type)) {
if (fundMap.containsKey(themeContent.getValue())) {
FundInfoBaseResp product = fundMap.get(themeContent.getValue());
// 推荐语
product.setRemark(themeContent.getRemark());
// 产品类型
product.setProductType(themeContent.getProductType());
themeContent.setDetail(AttachmentDetailVo.builder()
.product(product).build());
}
}
}
}
}
}
......@@ -18,14 +18,19 @@ import java.util.stream.Collectors;
public class ConvertUtil {
public static ThemeQo themeEntityToQo(ThemeEntity themeEntity) {
public static ThemeQo themeEntityToQo2(ThemeEntity themeEntity) {
if (themeEntity==null){
return null;
}
ThemeQo themeQO = new ThemeQo();
BeanUtils.copyProperties(themeEntity, themeQO);
List<ThemeContentQo> themeContentQos = JsonUtil.toBean(themeEntity.getContent(), new TypeReference<List<ThemeContentQo>>() {});
//首页列表使用,限制附件个数为1(1文本+1附件)
if (themeContentQos != null && themeContentQos.size() > 2) {
themeQO.setContent(themeContentQos.subList(0, 2));
}else{
themeQO.setContent(themeContentQos);
}
return themeQO;
}
......@@ -36,8 +41,13 @@ public class ConvertUtil {
return themeEntity;
}
/**
* 首页主题列表,限制附件个数为1(1文本+1附件)
* @param themeEntities
* @return
*/
public static List<ThemeQo> themeEntitiesToDTOs(List<ThemeEntity> themeEntities) {
return themeEntities.stream().map(ConvertUtil::themeEntityToQo).collect(Collectors.toList());
return themeEntities.stream().map(ConvertUtil::themeEntityToQo2).collect(Collectors.toList());
}
......
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