无关风月
2024-11-11 185f5dc7c3c49f565da51cd9c2f7750f30990d4a
xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserViewingHistoryController.java
@@ -67,6 +67,64 @@
    @Resource
    private RemoteCourseService remoteCourseService;
    private final RemoteAppUserService remoteAppUserService;
    /**
     * 远程调用 根据章节id和用户id查询是否观看完毕
     * @param id
     * @return
     */
    @PostMapping("/getCourseChapterHistoryState/{id}/{chapterId}")
    public R<Integer> getCourseChapterHistoryState(@PathVariable("id") Long id,@PathVariable("chapterId") Long chapterId) {
        List<AppUserViewingHistory> list = appUserViewingHistoryService.lambdaQuery()
                .eq(AppUserViewingHistory::getChapterId, chapterId)
                .eq(AppUserViewingHistory::getAppUserId, id)
                .eq(AppUserViewingHistory::getViewingType, 2)
                .list();
        for (AppUserViewingHistory appUserViewingHistory : list) {
            if (appUserViewingHistory.getIsOver()!=null && appUserViewingHistory.getIsOver()==1){
                return R.ok(1);
            }
        }
        return R.ok(2);
    }
    /**
     * 远程调用查询用户观看了哪些课程
     * @return
     */
    @PostMapping("/getCourseHistoryByUserId/{id}")
    public R<List<Long>> getCourseHistoryByUserId(@PathVariable("id") Long id) {
        List<Long> one = appUserViewingHistoryService.lambdaQuery()
                .eq(AppUserViewingHistory::getAppUserId, id)
                .eq(AppUserViewingHistory::getViewingType, 2)
                .list().stream().map(AppUserViewingHistory::getBizId)
                .collect(Collectors.toList());
        return R.ok(one);
    }
    @PostMapping("/getMeditationHistoryCount/{id}")
    public R<Long> getMeditationHistoryCount(@PathVariable("id") Long id) {
        List<AppUserViewingHistory> list = appUserViewingHistoryService.lambdaQuery()
                .eq(AppUserViewingHistory::getBizId, id)
                .eq(AppUserViewingHistory::getViewingType, 1)
                .list();
        return R.ok(Long.valueOf(list.size()));
    }
    @PostMapping("/getCourseHistoryCount/{id}")
    public R<Long> getCourseHistoryCount(@PathVariable("id") Long id) {
        List<AppUserViewingHistory> list = appUserViewingHistoryService.lambdaQuery()
                .eq(AppUserViewingHistory::getBizId, id)
                .eq(AppUserViewingHistory::getViewingType, 2)
                .list();
        return R.ok(Long.valueOf(list.size()));
    }
    @PostMapping("/getCourseChapterHistoryCount/{id}")
    public R<Long> getCourseChapterHistoryCount(@PathVariable("id") Long id) {
        List<AppUserViewingHistory> list = appUserViewingHistoryService.lambdaQuery()
                .eq(AppUserViewingHistory::getChapterId, id)
                .eq(AppUserViewingHistory::getViewingType, 2)
                .list();
        return R.ok(Long.valueOf(list.size()));
    }
    @PostMapping("/lookHistory")
    @ApiOperation(value = "观看历史")
    @ApiImplicitParams({
@@ -110,6 +168,7 @@
                    orderCourseVO.setIosPrice(meditation.getIosPrice());
                    orderCourseVO.setCoverUrl(meditation.getCoverUrl());
                    orderCourseVO.setCount(meditation.getRealLearnedNum()+meditation.getVirtualLearnedNum());
                    orderCourseVO.setCoverDescription(meditation.getCoverDescription());
                    orderCourseVOS.add(orderCourseVO);
                }
                break;
@@ -243,6 +302,7 @@
                // 如果已经看完了 那么不更新状态 只更新观看时间
                one.setMinuteLook(minuteLook);
                one.setSecondLook(secondLook);
                one.setTimeLook(secondLook);
            }else{
                one.setIsOver(isOver);
            }
@@ -256,6 +316,8 @@
            appUserViewingHistory.setSecondLook(secondLook);
            appUserViewingHistory.setChapterId(chapterId);
            appUserViewingHistory.setIsOver(isOver);
            appUserViewingHistory.setTimeLook(secondLook);
            appUserViewingHistoryService.save(appUserViewingHistory);
        }
        return R.ok();