From 167e16fb0b8f17a1c597a758ec15aa1534da5d2a Mon Sep 17 00:00:00 2001 From: N1KO Date: Mon, 16 Dec 2024 17:06:07 +0800 Subject: [PATCH] download --- .../baogutang/music/service/AbstractMusicService.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/top/baogutang/music/service/AbstractMusicService.java b/src/main/java/top/baogutang/music/service/AbstractMusicService.java index 451eb1c..f6670d3 100644 --- a/src/main/java/top/baogutang/music/service/AbstractMusicService.java +++ b/src/main/java/top/baogutang/music/service/AbstractMusicService.java @@ -118,13 +118,18 @@ public abstract class AbstractMusicService 100) { - throw new BusinessException("单次下载限制最多100首"); + if (!ADMIN_ID_LIST.contains(userId) && idList.size() > 10) { + throw new BusinessException("单次下载限制最多10首"); } ChannelEnum channelEnum = getChannelEnum(); ChannelClient channelClient = channelClientFactory.getClient(channelEnum); String batchNo = UUID.randomUUID().toString(); - idList.forEach(id -> { + idList.parallelStream().forEach(id -> { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + log.error(">>>>>>>>>>download error:{}<<<<<<<<<<", e.getMessage(), e); + } MusicRecordEntity entity = channelClient.queryByPlatform(id); if (Objects.nonNull(entity)) { channelClient.saveDownloadRecord(userId, batchNo, id);