无关风月
2024-11-09 bf9e778330e28916b41002629743546c91e1eb7d
xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserViewingHistoryController.java
@@ -67,6 +67,44 @@
    @Resource
    private RemoteCourseService remoteCourseService;
    private final RemoteAppUserService remoteAppUserService;
    /**
     * 远程调用查询用户观看了哪些课程
     * @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 +148,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 +282,7 @@
                // 如果已经看完了 那么不更新状态 只更新观看时间
                one.setMinuteLook(minuteLook);
                one.setSecondLook(secondLook);
                one.setTimeLook(secondLook);
            }else{
                one.setIsOver(isOver);
            }
@@ -256,6 +296,8 @@
            appUserViewingHistory.setSecondLook(secondLook);
            appUserViewingHistory.setChapterId(chapterId);
            appUserViewingHistory.setIsOver(isOver);
            appUserViewingHistory.setTimeLook(secondLook);
            appUserViewingHistoryService.save(appUserViewingHistory);
        }
        return R.ok();