| | |
| | | import cc.mrbird.febs.video.conversion.VideoConversion; |
| | | import cc.mrbird.febs.video.conversion.VideoMemberConversion; |
| | | import cc.mrbird.febs.video.dto.ApiVideoCollectionDto; |
| | | import cc.mrbird.febs.video.dto.ApiVideoHistoryDto; |
| | | import cc.mrbird.febs.video.dto.ApiVideoLikeDto; |
| | | import cc.mrbird.febs.video.dto.VideoListDto; |
| | | import cc.mrbird.febs.video.entity.*; |
| | | import cc.mrbird.febs.video.mapper.*; |
| | | import cc.mrbird.febs.video.service.IVideoMasterDataService; |
| | | import cc.mrbird.febs.video.service.IVideoMasterInfoService; |
| | | import cc.mrbird.febs.video.vo.VideoInfoItemVo; |
| | | import cc.mrbird.febs.video.vo.VideoInfoVo; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private final VideoCollectionMapper videoCollectionMapper; |
| | | private final VideoCommentInfoMapper videoCommentInfoMapper; |
| | | private final VideoCommentLikeMapper videoCommentLikeMapper; |
| | | private final VideoHistoryMapper videoHistoryMapper; |
| | | private final VideoMemberMapper videoMemberMapper; |
| | | private final IVideoMasterDataService videoMasterDataService; |
| | | |
| | | @Override |
| | | public IPage<VideoMasterInfoEntity> findInPage(VideoMasterInfoEntity info, QueryRequest request) { |
| | |
| | | throw new FebsException("视频不存在"); |
| | | } |
| | | |
| | | VideoMemberEntity loginUser = LoginUserUtil.getLoginUser(); |
| | | VideoInfoVo videoInfoVo = VideoConversion.INSTANCE.videoInfoEntityToInfoVo(videoInfoEntity); |
| | | List<VideoInfoItemVo> items = VideoConversion.INSTANCE.videoItemEntitiesToItemVoes(videoInfoEntity.getItems()); |
| | | videoInfoVo.setItems(items); |
| | |
| | | videoInfoVo.setCollectCnt(data.getCollectCnt()); |
| | | videoInfoVo.setStarCnt(data.getStarCnt()); |
| | | |
| | | VideoMemberEntity loginUser = LoginUserUtil.getLoginUser(); |
| | | if (loginUser == null) { |
| | | videoInfoVo.setNotLogin(AppContants.FLAG_INT_N); |
| | | return videoInfoVo; |
| | | if (loginUser != null) { |
| | | // 是否点赞 |
| | | VideoCommentLikeEntity commentLike = this.videoCommentLikeMapper.selectCommentLikeByMemberIdAndRelateId(loginUser.getId(), videoInfoEntity.getId()); |
| | | if (commentLike != null) { |
| | | videoInfoVo.setIsLike(1); |
| | | } else { |
| | | videoInfoVo.setIsLike(2); |
| | | } |
| | | |
| | | // 是否收藏 |
| | | VideoCollectionEntity collection = this.videoCollectionMapper.selectVideoCollectionByVideoIdAndMemberId(videoInfoEntity.getId(), loginUser.getId()); |
| | | if (collection != null) { |
| | | videoInfoVo.setIsCollect(1); |
| | | } else { |
| | | videoInfoVo.setIsCollect(2); |
| | | } |
| | | } |
| | | |
| | | // 视频是否需要vip |
| | | if (AppContants.FLAG_INT_N.equals(videoInfoEntity.getIsFree())) { |
| | | // 判断用户是否登录 |
| | | if (loginUser == null) { |
| | | videoInfoVo.setNotLogin(AppContants.FLAG_INT_N); |
| | | return videoInfoVo; |
| | | } |
| | | |
| | | // 判断用户是否为vip |
| | | VideoMemberEntity member = this.videoMemberMapper.selectById(loginUser.getId()); |
| | | if (AppContants.FLAG_INT_N.equals(member.getIsVip())) { |
| | | videoInfoVo.setNotVip(AppContants.FLAG_INT_N); |
| | | return videoInfoVo; |
| | | } |
| | | } |
| | | |
| | | |
| | | VideoMasterItemsEntity currentItem = this.videoMasterItemsMapper.selectItemByVideoIdAndItemId(videoId, itemId); |
| | | if (currentItem == null) { |
| | |
| | | videoInfoVo.setThumb(currentItem.getThumb()); |
| | | videoInfoVo.setItemId(currentItem.getId()); |
| | | videoInfoVo.setTimeLength(currentItem.getTimeLength()); |
| | | |
| | | // 增加播放量 |
| | | this.videoMasterDataService.modifyVideoData(videoInfoEntity.getId(), 1, 1); |
| | | |
| | | // 历史记录 |
| | | if (loginUser != null) { |
| | | VideoHistoryEntity history = this.videoHistoryMapper.selectByMemberIdAndVideoId(loginUser.getId(), videoInfoEntity.getId()); |
| | | if (history == null) { |
| | | history = new VideoHistoryEntity(); |
| | | history.setVideoId(videoInfoEntity.getId()); |
| | | history.setMemberId(loginUser.getId()); |
| | | history.setVideoItemId(currentItem.getId()); |
| | | this.videoHistoryMapper.insert(history); |
| | | } else { |
| | | history.setUpdatedTime(new Date()); |
| | | history.setVideoItemId(currentItem.getId()); |
| | | this.videoHistoryMapper.updateById(history); |
| | | } |
| | | } |
| | | |
| | | return videoInfoVo; |
| | | } |
| | | |
| | |
| | | videoCollectionMapper.deleteById(videoCollection.getId()); |
| | | |
| | | //收藏数-1 |
| | | VideoMasterDataEntity videoMasterDataEntity = videoMasterDataMapper.selectDataByMasterId(videoId); |
| | | int collectCnt = videoMasterDataEntity.getCollectCnt(); |
| | | videoMasterDataEntity.setCollectCnt((collectCnt - 1) <= 0 ? 0:(collectCnt - 1)); |
| | | videoMasterDataMapper.updateById(videoMasterDataEntity); |
| | | this.videoMasterDataService.modifyVideoData(videoMasterInfoEntity.getId(), -1, 2); |
| | | // VideoMasterDataEntity videoMasterDataEntity = videoMasterDataMapper.selectDataByMasterId(videoId); |
| | | // int collectCnt = videoMasterDataEntity.getCollectCnt(); |
| | | // videoMasterDataEntity.setCollectCnt((collectCnt - 1) <= 0 ? 0:(collectCnt - 1)); |
| | | // videoMasterDataMapper.updateById(videoMasterDataEntity); |
| | | return new FebsResponse().success().message("已取消收藏"); |
| | | }else{ |
| | | VideoCollectionEntity videoCollectionEntity = new VideoCollectionEntity(); |
| | |
| | | videoCollectionEntity.setVideoId(videoId); |
| | | videoCollectionMapper.insert(videoCollectionEntity); |
| | | //收藏数+1 |
| | | VideoMasterDataEntity videoMasterDataEntity = videoMasterDataMapper.selectDataByMasterId(videoId); |
| | | int collectCnt = videoMasterDataEntity.getCollectCnt(); |
| | | videoMasterDataEntity.setCollectCnt((collectCnt + 1) <= 0 ? 0:(collectCnt + 1)); |
| | | videoMasterDataMapper.updateById(videoMasterDataEntity); |
| | | |
| | | this.videoMasterDataService.modifyVideoData(videoMasterInfoEntity.getId(), 1, 2); |
| | | // VideoMasterDataEntity videoMasterDataEntity = videoMasterDataMapper.selectDataByMasterId(videoId); |
| | | // int collectCnt = videoMasterDataEntity.getCollectCnt(); |
| | | // videoMasterDataEntity.setCollectCnt((collectCnt + 1) <= 0 ? 0:(collectCnt + 1)); |
| | | // videoMasterDataMapper.updateById(videoMasterDataEntity); |
| | | return new FebsResponse().success().message("已收藏"); |
| | | } |
| | | } |
| | |
| | | Integer type = apiVideoLikeDto.getType(); |
| | | Long relateId = apiVideoLikeDto.getRelateId(); |
| | | VideoCommentLikeEntity videoCommentLikeEntity = videoCommentLikeMapper.selectCommentLikeByMemberIdAndRelateId(id,relateId); |
| | | |
| | | VideoMasterInfoEntity videoMasterInfoEntity = this.baseMapper.selectById(relateId); |
| | | if(videoCommentLikeEntity != null){ |
| | | if(1 == type){ |
| | | //视频 |
| | | VideoMasterInfoEntity videoMasterInfoEntity = this.baseMapper.selectById(relateId); |
| | | if(videoMasterInfoEntity == null){ |
| | | throw new FebsException("视频不存在"); |
| | | } |
| | | videoCommentLikeMapper.deleteById(videoCommentLikeEntity.getId()); |
| | | //点赞数-1 |
| | | VideoMasterDataEntity videoMasterDataEntity = videoMasterDataMapper.selectDataByMasterId(relateId); |
| | | int starCnt = videoMasterDataEntity.getStarCnt(); |
| | | videoMasterDataEntity.setCollectCnt((starCnt - 1) <= 0 ? 0:(starCnt - 1)); |
| | | videoMasterDataMapper.updateById(videoMasterDataEntity); |
| | | this.videoMasterDataService.modifyVideoData(videoMasterInfoEntity.getId(), -1, 3); |
| | | // VideoMasterDataEntity videoMasterDataEntity = videoMasterDataMapper.selectDataByMasterId(relateId); |
| | | // int starCnt = videoMasterDataEntity.getStarCnt(); |
| | | // videoMasterDataEntity.setStarCnt((starCnt - 1) <= 0 ? 0:(starCnt - 1)); |
| | | // videoMasterDataMapper.updateById(videoMasterDataEntity); |
| | | return new FebsResponse().success().message("已取消点赞"); |
| | | }else if(2 == type){ |
| | | //评论 |
| | |
| | | videoCommentLike.setMemberId(id); |
| | | videoCommentLikeMapper.insert(videoCommentLike); |
| | | //点赞数+1 |
| | | VideoMasterDataEntity videoMasterDataEntity = videoMasterDataMapper.selectDataByMasterId(relateId); |
| | | int starCnt = videoMasterDataEntity.getStarCnt(); |
| | | videoMasterDataEntity.setCollectCnt((starCnt + 1) <= 0 ? 0:(starCnt + 1)); |
| | | videoMasterDataMapper.updateById(videoMasterDataEntity); |
| | | |
| | | this.videoMasterDataService.modifyVideoData(videoMasterInfoEntity.getId(), 1, 3); |
| | | // VideoMasterDataEntity videoMasterDataEntity = videoMasterDataMapper.selectDataByMasterId(relateId); |
| | | // int starCnt = videoMasterDataEntity.getStarCnt(); |
| | | // videoMasterDataEntity.setStarCnt((starCnt + 1) <= 0 ? 0:(starCnt + 1)); |
| | | // videoMasterDataMapper.updateById(videoMasterDataEntity); |
| | | return new FebsResponse().success().message("已点赞"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse delVideoHistory(ApiVideoHistoryDto apiVideoHistoryDto) { |
| | | Long id = LoginUserUtil.getLoginUser().getId(); |
| | | String ids = apiVideoHistoryDto.getIds(); |
| | | List<String> idList = StrUtil.split(ids, ','); |
| | | videoHistoryMapper.delVideoHistoryByIdsAndMemberId(idList,id); |
| | | return new FebsResponse().success().message("成功"); |
| | | } |
| | | } |