从学习中心章节视频的学习资格,通过远程调用内容服务判断课程收费情况,免费远程调用媒资服务,查询视频URL,返回前端;收费视频判断是否到期等
接口信息
查询Service
public interface LearningService {
R getvideo(String userId, Long courseId, Long teachplanId, String mediaId); }
|
实现该方法
@Service public class LearningServiceImpl implements LearningService { private final MyCourseTablesService myCourseTablesService; private final ContentServerClient contentServerClient; private final MediaServerClient mediaServerClient;
public LearningServiceImpl(MyCourseTablesService myCourseTablesService, ContentServerClient contentServerClient, MediaServerClient mediaServerClient) { this.myCourseTablesService = myCourseTablesService; this.contentServerClient = contentServerClient; this.mediaServerClient = mediaServerClient; }
@Override public R getvideo(String userId, Long courseId, Long teachplanId, String mediaId) { CoursePublish coursePublish = contentServerClient.getCoursePublish(courseId); if (coursePublish == null) { return R.fail(-1, "课程不存在,无法预览"); }
if (StringUtils.isEmpty(userId)) { if (coursePublish.getCharge().equals("201000")) { String url = mediaServerClient.getPlayUrlByMediaId(mediaId); return R.success(url); } return R.fail(-1, "请登陆后选课学习"); } XcCourseTablesVO learningStatus = myCourseTablesService.getLearningStatus(userId, courseId); String learnStatus = learningStatus.getLearnStatus(); if (learnStatus.equals("702002")) { return R.fail(-1, "无法学习,未选课或选课后没有支付"); } else if (learnStatus.equals("702003")) { return R.fail(-1, "已过期需要申请续费或重新支付"); }
String url = mediaServerClient.getPlayUrlByMediaId(mediaId); return R.success(url); } }
|
查询Controller
MyLearningController@Api(value = "学习过程管理接口", tags = "学习过程管理接口") @RestController public class MyLearningController { private final LearningService learningService;
public MyLearningController(LearningService learningService) { this.learningService = learningService; }
@ApiOperation("获取视频") @GetMapping("/open/learn/getvideo/{courseId}/{teachplanId}/{mediaId}") public R getVideo(@PathVariable("courseId") Long courseId, @PathVariable("teachplanId") Long teachplanId, @PathVariable("mediaId") String mediaId) { String userId = null; try { SecurityUtil.XcUser user = SecurityUtil.getUser(); userId = user.getId(); } catch (Exception e) { e.printStackTrace(); } return learningService.getvideo(userId, courseId, teachplanId, mediaId); } }
|