|
|
@@ -8,10 +8,12 @@ import cn.reghao.tnb.content.api.constant.PostScope;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoRecord;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoUrl;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoUrls;
|
|
|
+import cn.reghao.tnb.content.app.vod.db.mapper.PlayCompleteMapper;
|
|
|
import cn.reghao.tnb.content.app.vod.db.mapper.PlayRecordMapper;
|
|
|
import cn.reghao.tnb.content.app.vod.db.mapper.VideoPostMapper;
|
|
|
import cn.reghao.tnb.content.app.vod.db.mapper.VideoPostTagMapper;
|
|
|
import cn.reghao.tnb.content.app.vod.db.repository.VideoRepository;
|
|
|
+import cn.reghao.tnb.content.app.vod.model.po.PlayComplete;
|
|
|
import cn.reghao.tnb.content.app.vod.model.po.PlayRecord;
|
|
|
import cn.reghao.tnb.content.app.vod.model.po.VideoPost;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoRecordCard;
|
|
|
@@ -23,6 +25,7 @@ import cn.reghao.tnb.user.api.dto.UserCard;
|
|
|
import cn.reghao.tnb.user.api.iface.UserService;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
@@ -48,16 +51,19 @@ public class VideoPlayServiceImpl implements VideoPlayService {
|
|
|
private final VideoPostTagMapper videoPostTagMapper;
|
|
|
private final UserInterestBased userInterestBased;
|
|
|
private final ContentPermission contentPermission;
|
|
|
+ private PlayCompleteMapper playCompleteMapper;
|
|
|
|
|
|
public VideoPlayServiceImpl(VideoPostMapper videoPostMapper, PlayRecordMapper playRecordMapper,
|
|
|
VideoRepository videoRepository, VideoPostTagMapper videoPostTagMapper,
|
|
|
- UserInterestBased userInterestBased, ContentPermission contentPermission) {
|
|
|
+ UserInterestBased userInterestBased, ContentPermission contentPermission,
|
|
|
+ PlayCompleteMapper playCompleteMapper) {
|
|
|
this.videoPostMapper = videoPostMapper;
|
|
|
this.playRecordMapper = playRecordMapper;
|
|
|
this.videoRepository = videoRepository;
|
|
|
this.videoPostTagMapper = videoPostTagMapper;
|
|
|
this.userInterestBased = userInterestBased;
|
|
|
this.contentPermission = contentPermission;
|
|
|
+ this.playCompleteMapper = playCompleteMapper;
|
|
|
}
|
|
|
|
|
|
public VideoUrls getVideoPlayData(String videoId) {
|
|
|
@@ -119,6 +125,7 @@ public class VideoPlayServiceImpl implements VideoPlayService {
|
|
|
return currentTime != null ? currentTime : 0.0;
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void saveRecord(MediaProgress mediaProgress) {
|
|
|
long userId = mediaProgress.getUserId();
|
|
|
String videoId = mediaProgress.getMediaId();
|
|
|
@@ -135,9 +142,14 @@ public class VideoPlayServiceImpl implements VideoPlayService {
|
|
|
playRecord.setCreateAt(createAt);
|
|
|
playRecord.setEnded(ended);
|
|
|
playRecordMapper.update(playRecord);
|
|
|
- }
|
|
|
|
|
|
- addUserInterest(userId, videoId);
|
|
|
+ if (ended) {
|
|
|
+ PlayComplete playComplete = new PlayComplete(playRecord);
|
|
|
+ playCompleteMapper.save(playComplete);
|
|
|
+
|
|
|
+ addUserInterest(userId, videoId);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void addUserInterest(long userId, String videoId) {
|
|
|
@@ -152,7 +164,7 @@ public class VideoPlayServiceImpl implements VideoPlayService {
|
|
|
return PageScroll.empty();
|
|
|
}
|
|
|
|
|
|
- nextId = maxId + 1;
|
|
|
+ nextId = maxId;
|
|
|
}
|
|
|
|
|
|
int total = playRecordMapper.countUserRecord(userId);
|