Commit 1b72f29d authored by 刘基明's avatar 刘基明

添加新课程Feign接口

parent e1d54d59
package com.tanpu.community.api.beans.qo;
import com.tanpu.community.api.beans.vo.feign.*;
import com.tanpu.community.api.beans.vo.feign.FundInfoBaseResp;
import com.tanpu.community.api.beans.vo.feign.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.ZhiboListResp;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
......@@ -23,5 +26,8 @@ public class AttachmentDetailVo {
private ShortVideoBaseInfoResp shortVideo;
@ApiModelProperty("课程")
private ShortVideoBaseInfoResp curriculum;
@ApiModelProperty("新版课程")
private CourseSimpleResp course;
}
package com.tanpu.community.api.beans.vo.feign; import io.swagger.annotations.ApiModelProperty;import lombok.Data;import lombok.EqualsAndHashCode; /** * @author: zyh * @date: 2021-04-13 3:20 下午 * @description: */@EqualsAndHashCode(callSuper = true)@Datapublic class CourseExt extends Course { @ApiModelProperty("章节-小节ID") private String coursePackageId; @Deprecated @ApiModelProperty("相关性知识课程小节类型 - 1:音频 2:视频") private Integer relType; @ApiModelProperty("相关性知识课程小节类型 扩展") private Integer relTypeExt; @Deprecated @ApiModelProperty("章节-小节 音/视频类型 1:音频 2:视频") private Integer type; @ApiModelProperty("章节-小节 音/视频类型 扩展") private Integer typeExt; @ApiModelProperty("章节-小节 音/视频地址") private String url; @ApiModelProperty("相关性知识地址") private String relUrl; @ApiModelProperty("相关性知识 - 课程包ID") private String relPackageId; @ApiModelProperty("相关性知识音/视频时长") private Integer relLengthTime; @ApiModelProperty("多少人已学习") private Integer readNum; @ApiModelProperty("课程时长 单位s") private Integer lengthTime; @ApiModelProperty("讲师信息") private LecturerResp lecturer;}
\ No newline at end of file
package com.tanpu.community.api.beans.vo.feign;
package com.tanpu.community.api.beans.vo.feign.course;
import com.tanpu.community.api.beans.vo.feign.Progression;
import lombok.Data;
import lombok.EqualsAndHashCode;
......
package com.tanpu.community.api.beans.vo.feign;
package com.tanpu.community.api.beans.vo.feign.course;
import com.tanpu.community.api.beans.vo.feign.FileMetadata;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
......
package com.tanpu.community.api.beans.vo.feign.course; import com.tanpu.community.api.beans.vo.feign.LecturerResp;import io.swagger.annotations.ApiModelProperty;import lombok.Data;import lombok.EqualsAndHashCode; /** * @author: zyh * @date: 2021-04-13 3:20 下午 * @description: */@EqualsAndHashCode(callSuper = true)@Datapublic class CourseExt extends Course { @ApiModelProperty("章节-小节ID") private String coursePackageId; @Deprecated @ApiModelProperty("相关性知识课程小节类型 - 1:音频 2:视频") private Integer relType; @ApiModelProperty("相关性知识课程小节类型 扩展") private Integer relTypeExt; @Deprecated @ApiModelProperty("章节-小节 音/视频类型 1:音频 2:视频") private Integer type; @ApiModelProperty("章节-小节 音/视频类型 扩展") private Integer typeExt; @ApiModelProperty("章节-小节 音/视频地址") private String url; @ApiModelProperty("相关性知识地址") private String relUrl; @ApiModelProperty("相关性知识 - 课程包ID") private String relPackageId; @ApiModelProperty("相关性知识音/视频时长") private Integer relLengthTime; @ApiModelProperty("多少人已学习") private Integer readNum; @ApiModelProperty("课程时长 单位s") private Integer lengthTime; @ApiModelProperty("讲师信息") private LecturerResp lecturer;}
\ No newline at end of file
package com.tanpu.community.api.beans.vo.feign;
package com.tanpu.community.api.beans.vo.feign.course;
import com.tanpu.community.api.beans.vo.feign.BaseCoursePackage;
import com.tanpu.community.api.beans.vo.feign.LikeCourse;
import com.tanpu.community.api.beans.vo.feign.pay.GroupBuyConfig;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......
package com.tanpu.community.api.beans.vo.feign;
package com.tanpu.community.api.beans.vo.feign.course;
import lombok.AllArgsConstructor;
import lombok.Builder;
......
package com.tanpu.community.api.beans.vo.feign;
package com.tanpu.community.api.beans.vo.feign.course;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......
package com.tanpu.community.api.beans.vo.feign;
package com.tanpu.community.api.beans.vo.feign.course;
import io.swagger.annotations.ApiModel;
......
package com.tanpu.community.api.beans.vo.feign;
package com.tanpu.community.api.beans.vo.feign.course;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......
package com.tanpu.community.api.beans.vo.feign;
package com.tanpu.community.api.beans.vo.feign.course;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......
package com.tanpu.community.feign.course;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.CourseDetailExt;
import com.tanpu.community.api.beans.vo.feign.CoursePackageDetail;
import com.tanpu.community.api.beans.vo.feign.course.CourseDetailExt;
import com.tanpu.community.api.beans.vo.feign.course.CoursePackageDetail;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
public class FeignBackClientForCourse implements FallbackFactory<FeignClientForCourse> {
......@@ -20,6 +23,13 @@ public class FeignBackClientForCourse implements FallbackFactory<FeignClientForC
return CommonResp.failed("调用getCourseIdDetailInfo失败");
}
@Override
public CommonResp<List<CourseSimpleResp>> getCourseSimpleList(List<String> ids) {
log.error("请求信息", throwable);
log.error("FeignClientForCourse.getCourseSimpleList-查询课程基础信息列表ids:{}", ids);
return CommonResp.failed("调用getCourseSimpleList失败");
}
@Override
public CommonResp<CoursePackageDetail> getCoursePackageDetailInfo(String id) {
log.error("请求信息", throwable);
......
package com.tanpu.community.feign.course;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.CourseDetailExt;
import com.tanpu.community.api.beans.vo.feign.CoursePackageDetail;
import com.tanpu.community.api.beans.vo.feign.course.CourseDetailExt;
import com.tanpu.community.api.beans.vo.feign.course.CoursePackageDetail;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import com.tanpu.community.feign.product.FeignBackClientForProducts;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -10,6 +11,8 @@ 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-course", contextId = "course", fallbackFactory = FeignBackClientForProducts.class, url = "${tamp-course-order-svc:}")
@FeignClient(value = "service-course", contextId = "course", fallbackFactory = FeignBackClientForProducts.class, url = "http://172.20.1.249:8060/course")
......@@ -22,6 +25,10 @@ public interface FeignClientForCourse {
@ApiParam("课程包id") @RequestParam("packageId") String packageId);
@ApiOperation("课程基础信息列表")
@GetMapping("/course/simple/list")
CommonResp<List<CourseSimpleResp>> getCourseSimpleList(@RequestParam("ids") List<String> ids);
@ApiOperation("详情页信息")
@GetMapping("/course/detail")
......
package com.tanpu.community.feign.tanpuroom;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.CurriCulumInfoDetailDto;
import com.tanpu.community.api.beans.vo.feign.CurriculumDetailVo;
import com.tanpu.community.api.beans.vo.feign.course.CurriCulumInfoDetailDto;
import com.tanpu.community.api.beans.vo.feign.course.CurriculumDetailVo;
import com.tanpu.community.api.beans.vo.feign.ShortVideoBaseInfoResp;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
......
package com.tanpu.community.feign.tanpuroom;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.CurriCulumInfoDetailDto;
import com.tanpu.community.api.beans.vo.feign.CurriculumDetailVo;
import com.tanpu.community.api.beans.vo.feign.course.CurriCulumInfoDetailDto;
import com.tanpu.community.api.beans.vo.feign.course.CurriculumDetailVo;
import com.tanpu.community.api.beans.vo.feign.ShortVideoBaseInfoResp;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
......
......@@ -11,9 +11,11 @@ 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.beans.vo.feign.course.CourseSimpleResp;
import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.dao.entity.community.FileRecordEntity;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.feign.course.FeignClientForCourse;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.feign.product.FeignClientForProducts;
import com.tanpu.community.feign.product.FeignForFund;
......@@ -43,6 +45,9 @@ public class ProductService {
@Resource
private FeignClientForProducts feignForProduct;
@Resource
private FeignClientForCourse feignForCourse;
@Resource
private FeignForFund feignForFund;
......@@ -65,6 +70,8 @@ public class ProductService {
Map<String, ShortVideoBaseInfoResp> shortVideoMap = Maps.newHashMap();
// 课程信息
Map<String, ShortVideoBaseInfoResp> curriculumMap = Maps.newHashMap();
// 新课程信息
Map<String, CourseSimpleResp> courseMap = Maps.newHashMap();
// 直播信息
Map<String, ZhiboListResp> zhiboMap = Maps.newHashMap();
// 设置产品信息
......@@ -74,9 +81,9 @@ public class ProductService {
// 话题标题
Map<String, String> topicMap = Maps.newHashMap();
// 批量查询资源信息
this.getResInfo(shortVideoMap, curriculumMap, zhiboMap, fundMap, imgMap, topicMap, themeQos);
this.getResInfo(shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, topicMap, themeQos);
//逐个装入
setResInfo(themeQos, shortVideoMap, curriculumMap, zhiboMap, fundMap, imgMap, topicMap);
setResInfo(themeQos, shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, topicMap);
}
......@@ -91,6 +98,7 @@ public class ProductService {
*/
private void getResInfo(Map<String, ShortVideoBaseInfoResp> shortVideoMap,
Map<String, ShortVideoBaseInfoResp> curriculumMap,
Map<String, CourseSimpleResp> courseMap,
Map<String, ZhiboListResp> zhiboMap,
Map<String, FundInfoBaseResp> fundMap,
Map<String, String> imgMap,
......@@ -113,6 +121,8 @@ public class ProductService {
List<String> zhiboIds = Lists.newArrayList();
// 课程id
List<String> curriculumIds = Lists.newArrayList();
// 新课程id
List<String> courseIds = Lists.newArrayList();
// 图片id
List<String> imageIds = Lists.newArrayList();
// 话题id
......@@ -142,6 +152,9 @@ public class ProductService {
curriculumIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
imageIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_AUDIO.type) ||
c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_VIDEO.type)) {
courseIds.add(c.getValue());
}
}));
themeQos.stream().forEach(o -> {
......@@ -164,6 +177,13 @@ public class ProductService {
curriculumMap.putAll(commonResp.stream().collect(Collectors.toMap(ShortVideoBaseInfoResp::getColumnRelId, item -> item)));
}
}
if (!CollectionUtils.isEmpty(courseIds)) {
// 新版课程列表
CommonResp<List<CourseSimpleResp>> commonResp = feignForCourse.getCourseSimpleList(courseIds);
if (commonResp.isSuccess() & !CollectionUtils.isEmpty(commonResp.getData())) {
courseMap.putAll(commonResp.getData().stream().collect(Collectors.toMap(CourseSimpleResp::getCourseId, item -> item)));
}
}
if (!CollectionUtils.isEmpty(zhiboIds)) {
// 直播列表
CommonResp<List<ZhiboListResp>> commonResp = feignClientForZhibo.simpleList(zhiboIds);
......@@ -302,12 +322,13 @@ public class ProductService {
private void setResInfo(List<ThemeQo> themeQos,
Map<String, ShortVideoBaseInfoResp> shortVideoMap,
Map<String, ShortVideoBaseInfoResp> curriculumMap,
Map<String, CourseSimpleResp> courseMap,
Map<String, ZhiboListResp> zhiboMap,
Map<String, FundInfoBaseResp> fundMap,
Map<String, String> imgUrlMap,
Map<String, String> topicMap) {
for (ThemeQo themeQo : themeQos) {
if (!StringUtils.isEmpty(themeQo.getTopicId()) && topicMap.containsKey(themeQo.getTopicId())){
if (!StringUtils.isEmpty(themeQo.getTopicId()) && topicMap.containsKey(themeQo.getTopicId())) {
themeQo.setTopicTitle(topicMap.get(themeQo.getTopicId()));
}
for (ThemeContentQo themeContent : themeQo.getContent()) {
......@@ -327,6 +348,12 @@ public class ProductService {
themeContent.setDetail(AttachmentDetailVo.builder()
.curriculum(curriculumMap.get(themeContent.getValue())).build());
}
} else if (themeContent.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_VIDEO.type) ||
themeContent.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_AUDIO.type)) {
if (courseMap.containsKey(themeContent.getValue())) {
themeContent.setDetail(AttachmentDetailVo.builder()
.course(courseMap.get(themeContent.getValue())).build());
}
} else if (themeContent.getType().equals(RelTypeEnum.FUND.type)) {
if (fundMap.containsKey(themeContent.getValue())) {
FundInfoBaseResp product = fundMap.get(themeContent.getValue());
......@@ -337,7 +364,7 @@ public class ProductService {
themeContent.setDetail(AttachmentDetailVo.builder()
.product(product).build());
}
}else if (themeContent.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
} else if (themeContent.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
if (imgUrlMap.containsKey(themeContent.getValue())) {
themeContent.setValue(imgUrlMap.get(themeContent.getValue()));
}
......
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