| | |
| | | import com.xinquan.common.core.web.domain.BaseModel; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.course.api.domain.OrderCourseVO; |
| | | import com.xinquan.course.api.feign.RemoteCourseService; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.api.feign.RemoteMeditationService; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.AppUserTree; |
| | | import com.xinquan.system.api.domain.AppUserViewingHistory; |
| | | import com.xinquan.system.api.domain.vo.AppUserVO; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.feign.RemoteAppUserService; |
| | | import com.xinquan.user.service.AppUserService; |
| | | import com.xinquan.user.service.AppUserTreeService; |
| | | import com.xinquan.user.service.AppUserViewingHistoryService; |
| | |
| | | import io.swagger.models.auth.In; |
| | | import lombok.Data; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private AppUserTreeService appUserTreeService; |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | |
| | | |
| | | @Resource |
| | | private RemoteMeditationService remoteMeditationService; |
| | | @Resource |
| | | private RemoteCourseService courseUserFavoriteService; |
| | | @Resource |
| | | private RemoteCourseService remoteCourseService; |
| | | private final RemoteAppUserService remoteAppUserService; |
| | | @PostMapping("/lookHistory") |
| | | @ApiOperation(value = "观看历史") |
| | | @ApiImplicitParams({ |
| | |
| | | @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true) |
| | | }) |
| | | public R<PageDTO<OrderCourseVO>> lookHistory(Integer state, Integer pageCurr, Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | public R<List<OrderCourseVO>> lookHistory(Integer state, Integer pageCurr, Integer pageSize) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | List<OrderCourseVO> orderCourseVOS = new ArrayList<>(); |
| | | |
| | | switch (state){ |
| | | case 1: |
| | | List<Long> collect1 = appUserViewingHistoryService.lambdaQuery() |
| | | .eq(AppUserViewingHistory::getAppUserId, userId) |
| | | .eq(AppUserViewingHistory::getViewingType, 1).list() |
| | | .stream().map(AppUserViewingHistory::getBizId).collect(Collectors.toList()); |
| | | List<Long> collect2 = collect1.stream().distinct().collect(Collectors.toList()); |
| | | StringBuilder temp = new StringBuilder(); |
| | | if (collect1.isEmpty()){ |
| | | temp=temp.append("-1"); |
| | | }else{ |
| | | for (Long l : collect2) { |
| | | temp.append(l).append(","); |
| | | } |
| | | temp.deleteCharAt(temp.length() - 1); |
| | | } |
| | | Page<Meditation> data = remoteMeditationService.getMeditationByIds(pageCurr,pageSize,temp.toString()).getData(); |
| | | |
| | | for (Meditation meditation : data.getRecords()) { |
| | | OrderCourseVO orderCourseVO = new OrderCourseVO(); |
| | | orderCourseVO.setBusinessId(meditation.getId()); |
| | | orderCourseVO.setCourseTitle(meditation.getMeditationTitle()); |
| | | orderCourseVO.setDescription(meditation.getDetailDescription()); |
| | | orderCourseVO.setChargeType(meditation.getChargeType()); |
| | | orderCourseVO.setGeneralPrice(meditation.getGeneralPrice()); |
| | | orderCourseVO.setIosPrice(meditation.getIosPrice()); |
| | | orderCourseVO.setCoverUrl(meditation.getCoverUrl()); |
| | | orderCourseVO.setCount(meditation.getRealLearnedNum()+meditation.getVirtualLearnedNum()); |
| | | orderCourseVOS.add(orderCourseVO); |
| | | } |
| | | break; |
| | | case 2: |
| | | |
| | | List<Long> collect3 = appUserViewingHistoryService.lambdaQuery() |
| | | .eq(AppUserViewingHistory::getAppUserId, userId) |
| | | .eq(AppUserViewingHistory::getViewingType, 2).list() |
| | | .stream().map(AppUserViewingHistory::getBizId).collect(Collectors.toList()); |
| | | List<Long> collect4 = collect3.stream().distinct().collect(Collectors.toList()); |
| | | StringBuilder temp1 = new StringBuilder(); |
| | | if (collect4.isEmpty()){ |
| | | temp1=temp1.append("-1"); |
| | | }else{ |
| | | for (Long l : collect4) { |
| | | temp1.append(l).append(","); |
| | | } |
| | | temp1.deleteCharAt(temp1.length() - 1); |
| | | } |
| | | Page<Course> data2 = remoteCourseService.getCourseByIds(pageCurr,pageSize,temp1.toString()).getData(); |
| | | for (Course record : data2.getRecords()) { |
| | | OrderCourseVO orderCourseVO = new OrderCourseVO(); |
| | | orderCourseVO.setBusinessId(record.getId()); |
| | | orderCourseVO.setCourseTitle(record.getCourseTitle()); |
| | | orderCourseVO.setDescription(record.getDescription()); |
| | | orderCourseVO.setChargeType(record.getChargeType()); |
| | | orderCourseVO.setGeneralPrice(record.getGeneralPrice()); |
| | | orderCourseVO.setIosPrice(record.getIosPrice()); |
| | | orderCourseVO.setCoverUrl(record.getCoverUrl()); |
| | | List<AppUser> data1 = remoteAppUserService.getUserByCourseId(record.getId()).getData(); |
| | | orderCourseVO.setCount(data1.size()); |
| | | orderCourseVOS.add(orderCourseVO); |
| | | } |
| | | break; |
| | | } |
| | | return R.ok(); |
| | | return R.ok(orderCourseVOS); |
| | | } |
| | | /** |
| | | * 记录用户观看记录 |
| | | * |
| | | * @param bizId 业务id |
| | | * @param viewingType 观看类型 1=疗愈 2=课程 |
| | | */ |
| | | @PostMapping("/saveViewingHistory") |
| | | @ApiOperation(value = "记录用户观看冥想记录", tags = {"用户端-用户相关接口"}) |
| | |
| | | @ApiImplicitParam(name = "timeLook", value = "播放时长单位秒", dataType = "Integer", required = true) |
| | | }) |
| | | public R<?> saveViewingRecord(@RequestParam("id") Long id, |
| | | @RequestParam("timeLook") Integer timeLook) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | @RequestParam("timeLook") Integer timeLook |
| | | ) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUser byId = appUserService.getById(userId); |
| | | |
| | | AppUserViewingHistory appUserViewingHistory = new AppUserViewingHistory(); |
| | | appUserViewingHistory.setAppUserId(userId); |
| | | appUserViewingHistory.setBizId(id); |
| | |
| | | @RequestParam("secondLook") Integer secondLook, |
| | | @RequestParam("isOver") Integer isOver |
| | | ) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUserViewingHistory one = appUserViewingHistoryService.lambdaQuery() |
| | | .eq(AppUserViewingHistory::getAppUserId, userId) |
| | | .eq(AppUserViewingHistory::getViewingType, 2) |
| | |
| | | } |
| | | @PostMapping("/getCourseStudyHistory") |
| | | public R<AppUserViewingHistory> getCourseStudyHistory(@RequestParam("chapterId") Long chapterId) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | AppUserViewingHistory one = appUserViewingHistoryService.lambdaQuery() |
| | | .eq(AppUserViewingHistory::getAppUserId, userId) |
| | | .eq(AppUserViewingHistory::getViewingType, 2) |
| | |
| | | // @RequestParam(value = "secondLook") Integer secondLook, |
| | | // @RequestParam(value = "isOver") Integer isOver |
| | | // ) { |
| | | // Long userId = SecurityUtils.getUserId(); |
| | | // if (userId == 0)return R.tokenError("登录失效"); |
| | | // Long userId = tokenService.getLoginUser().getUserid(); |
| | | // if(userId ==null || userId == 0)return R.tokenError("登录失效"); |
| | | // AppUserViewingHistory one = appUserViewingHistoryService.lambdaQuery() |
| | | // .eq(AppUserViewingHistory::getAppUserId, userId) |
| | | // .eq(AppUserViewingHistory::getViewingType, 2) |