use of com.buguagaoshu.porntube.entity.PlayRecordingEntity in project PornTube by PuZhiweizuishuai.
the class PlayRecordingServiceImpl method queryPage.
@Override
public IPage<PlayRecordingEntity> queryPage(Map<String, Object> params, HttpServletRequest request) {
Claims user = JwtUtil.getUser(request);
Long userId = Long.parseLong(user.getId());
QueryWrapper<PlayRecordingEntity> wrapper = new QueryWrapper<>();
wrapper.eq("user_id", userId);
wrapper.orderByDesc("update_time");
IPage<PlayRecordingEntity> page = this.page(new Query<PlayRecordingEntity>().getPage(params), wrapper);
return page;
}
use of com.buguagaoshu.porntube.entity.PlayRecordingEntity in project PornTube by PuZhiweizuishuai.
the class PlayRecordingWithArticleServiceImpl method playRecordingList.
@Override
public PageUtils playRecordingList(Map<String, Object> params, HttpServletRequest request) {
IPage<PlayRecordingEntity> page = playRecordingService.queryPage(params, request);
Set<Long> aids = page.getRecords().stream().map(PlayRecordingEntity::getArticleId).collect(Collectors.toSet());
List<ArticleEntity> articleEntities = articleService.listByIds(aids);
List<PlayRecordingWithArticleVo> play = new LinkedList<>();
if (articleEntities != null && articleEntities.size() != 0) {
Map<Long, ArticleEntity> articleEntityMap = articleEntities.stream().collect(Collectors.toMap(ArticleEntity::getId, a -> a));
for (PlayRecordingEntity playRecordingEntity : page.getRecords()) {
PlayRecordingWithArticleVo playRecordingWithArticleVo = new PlayRecordingWithArticleVo();
playRecordingWithArticleVo.setPlayRecordingEntity(playRecordingEntity);
ArticleEntity articleEntity = articleEntityMap.get(playRecordingEntity.getArticleId());
playRecordingWithArticleVo.setArticleEntity(articleEntity);
play.add(playRecordingWithArticleVo);
}
}
IPage<PlayRecordingWithArticleVo> iPage = new IPage<PlayRecordingWithArticleVo>() {
@Override
public List<OrderItem> orders() {
return null;
}
@Override
public List<PlayRecordingWithArticleVo> getRecords() {
return play;
}
@Override
public IPage<PlayRecordingWithArticleVo> setRecords(List<PlayRecordingWithArticleVo> records) {
return null;
}
@Override
public long getTotal() {
return page.getTotal();
}
@Override
public IPage<PlayRecordingWithArticleVo> setTotal(long total) {
return null;
}
@Override
public long getSize() {
return page.getSize();
}
@Override
public IPage<PlayRecordingWithArticleVo> setSize(long size) {
return null;
}
@Override
public long getCurrent() {
return page.getCurrent();
}
@Override
public IPage<PlayRecordingWithArticleVo> setCurrent(long current) {
return null;
}
};
return new PageUtils(iPage);
}
use of com.buguagaoshu.porntube.entity.PlayRecordingEntity in project PornTube by PuZhiweizuishuai.
the class PlayRecordingServiceImpl method saveHistory.
@Override
public long saveHistory(FileTableEntity file, Long userId, String ua) {
long time = System.currentTimeMillis();
// TODO 此处有并发bug,请求时间相近的情况下会写入两条相同的播放记录
// 尤其是使用qq浏览器的时候
PlayRecordingEntity playRecordingEntity = findPlayRecordingEntityByArticleIdAndVideoId(file.getArticleId(), file.getId(), userId);
if (playRecordingEntity != null) {
playRecordingEntity.setUpdateTime(time);
playRecordingEntity.setUa(ua);
this.updateById(playRecordingEntity);
return 0;
} else {
playRecordingEntity = new PlayRecordingEntity();
playRecordingEntity.setArticleId(file.getArticleId());
playRecordingEntity.setCreateTime(time);
playRecordingEntity.setUpdateTime(time);
playRecordingEntity.setUserId(userId);
playRecordingEntity.setVideoId(file.getId());
playRecordingEntity.setUa(ua);
// TODO 采用缓存
// articleService.addViewCount(file.getArticleId(), 1L);
// TODO 播放时间戳,视频个数
this.save(playRecordingEntity);
return file.getArticleId();
}
}
Aggregations