feat(interaction): 新增分集计数统计接口
This commit is contained in:
1 parent
15b540cdd6
commit
2fe24b9db7
10 files changed
+299
-2
No files matched your search
+25
@@ -17,9 +17,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/** 收藏:切换、列表、批量删除;收藏数在同一事务内同步维护。 */
|
||||
@Service
|
||||
@@ -63,6 +66,28 @@ public class FavoriteService {
|
||||
return count != null && count > 0;
|
||||
}
|
||||
|
||||
/** 批量判断用户是否已收藏,一次查询覆盖多部剧。 */
|
||||
public Set<Long> favoriteDramaIds(Long userId, Collection<Long> dramaIds) {
|
||||
if (userId == null || dramaIds == null || dramaIds.isEmpty()) {
|
||||
return Set.of();
|
||||
}
|
||||
Set<Long> normalized = new HashSet<>();
|
||||
for (Long dramaId : dramaIds) {
|
||||
if (dramaId != null) {
|
||||
normalized.add(dramaId);
|
||||
}
|
||||
}
|
||||
if (normalized.isEmpty()) {
|
||||
return Set.of();
|
||||
}
|
||||
return favoriteMapper.selectList(Wrappers.<UserFavorite>lambdaQuery()
|
||||
.eq(UserFavorite::getUserId, userId)
|
||||
.in(UserFavorite::getDramaId, normalized))
|
||||
.stream()
|
||||
.map(UserFavorite::getDramaId)
|
||||
.collect(java.util.stream.Collectors.toSet());
|
||||
}
|
||||
|
||||
/** 分页查询收藏短剧,保持收藏时间与 dramaId 稳定排序。 */
|
||||
public PageResult<Drama> page(Long userId, int pageIndex, int pageSize) {
|
||||
int safeIndex = Math.max(pageIndex, 1);
|
||||
|
||||
Reference in new issue
Block a user