main
JH 10 months ago
parent d614fca533
commit 7b10eb03df

@ -23,7 +23,7 @@ public class JournalAddModel {
private String title; private String title;
@ApiModelProperty(value = "关联标签标签ID") @ApiModelProperty(value = "关联标签标签ID")
private List<String> tags; private List<String> tag;
@ApiModelProperty(value = "发布人ID") @ApiModelProperty(value = "发布人ID")
private String userId; private String userId;

@ -12,11 +12,9 @@ import com.luoo.music.response.cms.SongVO;
import com.luoo.music.util.Constants; import com.luoo.music.util.Constants;
import dto.UserLoginDto; import dto.UserLoginDto;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -234,7 +232,7 @@ public class CMSJournalService {
String image = param.getImage(); String image = param.getImage();
String suffix = image.substring(image.lastIndexOf(Constants.DOT)); String suffix = image.substring(image.lastIndexOf(Constants.DOT));
String destKeySuffix = String.format("%05d/00%s", Integer.parseInt(param.getJournalNo()), suffix); 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); int copy = s3Service.copy(Constants.BUCKET, srcKey, destKey);
if (copy > 0) { if (copy > 0) {
return destKeySuffix; return destKeySuffix;
@ -273,9 +271,9 @@ public class CMSJournalService {
*/ */
private void batchSaveJournalRelatesInfo(String journalId, JournalAddModel param) { private void batchSaveJournalRelatesInfo(String journalId, JournalAddModel param) {
// 标签信息 // 标签信息
if (!CollectionUtils.isEmpty(param.getTags())) { if (!CollectionUtils.isEmpty(param.getTag())) {
List<JournalTag> journalTagList = new ArrayList<>(); List<JournalTag> journalTagList = new ArrayList<>();
for (String item : param.getTags()) { for (String item : param.getTag()) {
JournalTag journalTag = new JournalTag(); JournalTag journalTag = new JournalTag();
journalTag.setId(String.valueOf(idWorker.nextId())); journalTag.setId(String.valueOf(idWorker.nextId()));
journalTag.setJournalId(journalId); journalTag.setJournalId(journalId);
@ -292,16 +290,18 @@ public class CMSJournalService {
int num = 0; int num = 0;
for (String item : param.getSongs()) { for (String item : param.getSongs()) {
if (idSongMap.containsKey(item)) { if (idSongMap.containsKey(item)) {
num += 1;
SongInfo song = idSongMap.get(item); SongInfo song = idSongMap.get(item);
JournalSong journalSong = new JournalSong(); JournalSong journalSong = new JournalSong();
journalSong.setId(String.valueOf(idWorker.nextId())); journalSong.setId(String.valueOf(idWorker.nextId()));
journalSong.setName(song.getName()); journalSong.setName(song.getName());
journalSong.setAlbum(song.getAlbum());
journalSong.setArtist(song.getArtist()); journalSong.setArtist(song.getArtist());
journalSong.setUrl(song.getUrl()); journalSong.setUrl(song.getUrl());
journalSong.setImage(song.getImage()); journalSong.setImage(song.getImage());
journalSong.setSongId(item); journalSong.setSongId(item);
journalSong.setJournalNo(param.getJournalNo()); journalSong.setJournalNo(param.getJournalNo());
journalSong.setSongNo(num + 1); journalSong.setSongNo(num);
journalSong.setSongId(song.getId()); journalSong.setSongId(song.getId());
journalSongList.add(journalSong); journalSongList.add(journalSong);
} }

@ -15,7 +15,6 @@ import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.*; import software.amazon.awssdk.services.s3.model.*;
import util.IdWorker; import util.IdWorker;
import javax.annotation.Resource;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -24,7 +23,9 @@ import java.util.List;
@Service @Service
public class S3Service { public class S3Service {
@Resource
@Autowired
private S3Client s3Client; private S3Client s3Client;
@Autowired @Autowired
private IdWorker idWorker; private IdWorker idWorker;
@ -114,9 +115,7 @@ public class S3Service {
return true; return true;
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} /*finally { }
s3Client.close();
}*/
} }
/** /**
@ -140,9 +139,7 @@ public class S3Service {
} }
} catch (Exception e) { } catch (Exception e) {
return -1; return -1;
} /*finally { }
s3Client.close();
}*/
return 1; return 1;
} }
@ -170,9 +167,7 @@ public class S3Service {
} }
} catch (Exception e) { } catch (Exception e) {
return -1; return -1;
} /*finally { }
s3Client.close();
}*/
} }
/** /**
@ -195,9 +190,7 @@ public class S3Service {
} }
} catch(Exception e) { } catch(Exception e) {
return -1; return -1;
} /*finally { }
s3Client.close();
}*/
} }
public void uploadAvatar(String bucket, String key, byte[] buffer) { public void uploadAvatar(String bucket, String key, byte[] buffer) {

Loading…
Cancel
Save