From 7b10eb03dfb5c3e92898c6725abd6d5d6b75a201 Mon Sep 17 00:00:00 2001 From: JH <935007339@qq.com> Date: Wed, 7 Feb 2024 00:17:52 +0800 Subject: [PATCH] fix bug --- .../music/request/cms/JournalAddModel.java | 2 +- .../luoo/music/service/CMSJournalService.java | 12 +++++------ .../com/luoo/music/service/S3Service.java | 21 +++++++------------ 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/luoo_music/src/main/java/com/luoo/music/request/cms/JournalAddModel.java b/luoo_music/src/main/java/com/luoo/music/request/cms/JournalAddModel.java index c38cd0d..1de764c 100644 --- a/luoo_music/src/main/java/com/luoo/music/request/cms/JournalAddModel.java +++ b/luoo_music/src/main/java/com/luoo/music/request/cms/JournalAddModel.java @@ -23,7 +23,7 @@ public class JournalAddModel { private String title; @ApiModelProperty(value = "关联标签,标签ID") - private List tags; + private List tag; @ApiModelProperty(value = "发布人ID") private String userId; diff --git a/luoo_music/src/main/java/com/luoo/music/service/CMSJournalService.java b/luoo_music/src/main/java/com/luoo/music/service/CMSJournalService.java index 030216b..9344bf0 100644 --- a/luoo_music/src/main/java/com/luoo/music/service/CMSJournalService.java +++ b/luoo_music/src/main/java/com/luoo/music/service/CMSJournalService.java @@ -12,11 +12,9 @@ import com.luoo.music.response.cms.SongVO; import com.luoo.music.util.Constants; import dto.UserLoginDto; import org.apache.commons.lang.StringUtils; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -234,7 +232,7 @@ public class CMSJournalService { String image = param.getImage(); String suffix = image.substring(image.lastIndexOf(Constants.DOT)); String destKeySuffix = String.format("%05d/00%s", Integer.parseInt(param.getJournalNo()), suffix); - String destKey = Constants.MUSIC_RESOURCE_PREFIX + destKeySuffix; + String destKey = Constants.MUSIC_KEY_PREFIX + destKeySuffix; int copy = s3Service.copy(Constants.BUCKET, srcKey, destKey); if (copy > 0) { return destKeySuffix; @@ -273,9 +271,9 @@ public class CMSJournalService { */ private void batchSaveJournalRelatesInfo(String journalId, JournalAddModel param) { // 标签信息 - if (!CollectionUtils.isEmpty(param.getTags())) { + if (!CollectionUtils.isEmpty(param.getTag())) { List journalTagList = new ArrayList<>(); - for (String item : param.getTags()) { + for (String item : param.getTag()) { JournalTag journalTag = new JournalTag(); journalTag.setId(String.valueOf(idWorker.nextId())); journalTag.setJournalId(journalId); @@ -292,16 +290,18 @@ public class CMSJournalService { int num = 0; for (String item : param.getSongs()) { if (idSongMap.containsKey(item)) { + num += 1; SongInfo song = idSongMap.get(item); JournalSong journalSong = new JournalSong(); journalSong.setId(String.valueOf(idWorker.nextId())); journalSong.setName(song.getName()); + journalSong.setAlbum(song.getAlbum()); journalSong.setArtist(song.getArtist()); journalSong.setUrl(song.getUrl()); journalSong.setImage(song.getImage()); journalSong.setSongId(item); journalSong.setJournalNo(param.getJournalNo()); - journalSong.setSongNo(num + 1); + journalSong.setSongNo(num); journalSong.setSongId(song.getId()); journalSongList.add(journalSong); } diff --git a/luoo_music/src/main/java/com/luoo/music/service/S3Service.java b/luoo_music/src/main/java/com/luoo/music/service/S3Service.java index 1573218..bcca2c8 100644 --- a/luoo_music/src/main/java/com/luoo/music/service/S3Service.java +++ b/luoo_music/src/main/java/com/luoo/music/service/S3Service.java @@ -15,7 +15,6 @@ import software.amazon.awssdk.services.s3.S3Client; import software.amazon.awssdk.services.s3.model.*; import util.IdWorker; -import javax.annotation.Resource; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.List; @@ -24,7 +23,9 @@ import java.util.List; @Service public class S3Service { - @Resource + + + @Autowired private S3Client s3Client; @Autowired private IdWorker idWorker; @@ -114,9 +115,7 @@ public class S3Service { return true; } catch (Exception e) { return false; - } /*finally { - s3Client.close(); - }*/ + } } /** @@ -140,9 +139,7 @@ public class S3Service { } } catch (Exception e) { return -1; - } /*finally { - s3Client.close(); - }*/ + } return 1; } @@ -170,9 +167,7 @@ public class S3Service { } } catch (Exception e) { return -1; - } /*finally { - s3Client.close(); - }*/ + } } /** @@ -195,9 +190,7 @@ public class S3Service { } } catch(Exception e) { return -1; - } /*finally { - s3Client.close(); - }*/ + } } public void uploadAvatar(String bucket, String key, byte[] buffer) {