feat(playlist): 添加歌单编辑功能

- 在前端 PlaylistDetail组件中添加编辑歌单的对话框和相关逻辑
- 在后端 PlaylistServiceImpl 中实现更新歌单信息和封面的方法
- 优化封面上传逻辑,将物理路径转换为相对路径
This commit is contained in:
ikmkj
2025-07-27 15:55:44 +08:00
parent ced0a0931d
commit e024184bbd
2 changed files with 98 additions and 5 deletions

View File

@@ -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);
}