feat(playlist): 添加歌单编辑功能
- 在前端 PlaylistDetail组件中添加编辑歌单的对话框和相关逻辑 - 在后端 PlaylistServiceImpl 中实现更新歌单信息和封面的方法 - 优化封面上传逻辑,将物理路径转换为相对路径
This commit is contained in:
@@ -36,6 +36,7 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -237,7 +238,8 @@ public class PlaylistServiceImpl implements PlaylistService {
|
||||
// 上传封面
|
||||
String coverUrl = null;
|
||||
if (cover != null && !cover.isEmpty()) {
|
||||
coverUrl = fileService.uploadImage(cover);
|
||||
String coverPhysicalPath = fileService.uploadImage(cover);
|
||||
coverUrl = coverPhysicalPath.replace(System.getProperty("user.dir") + File.separator + "music-houduan", "").replace(File.separator, "/");
|
||||
}
|
||||
|
||||
// 创建歌单实体
|
||||
@@ -286,7 +288,8 @@ public class PlaylistServiceImpl implements PlaylistService {
|
||||
}
|
||||
|
||||
// 上传新封面
|
||||
String coverUrl = fileService.uploadImage(cover);
|
||||
String coverPhysicalPath = fileService.uploadImage(cover);
|
||||
String coverUrl = coverPhysicalPath.replace(System.getProperty("user.dir") + File.separator + "music-houduan", "").replace(File.separator, "/");
|
||||
playlist.setCover(coverUrl);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user