From 37d54eccbbfeece8acf57d0a166dfb0b1a9cdf62 Mon Sep 17 00:00:00 2001 From: zpc Date: Sun, 29 Sep 2024 14:30:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HuanMeng.MiaoYu.Code/Music/MusicBLL.cs | 25 ++++++++++++++++--- .../Controllers/MusicController.cs | 13 +++++++++- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Music/MusicBLL.cs b/src/0-core/HuanMeng.MiaoYu.Code/Music/MusicBLL.cs index 2832680..5a3411b 100644 --- a/src/0-core/HuanMeng.MiaoYu.Code/Music/MusicBLL.cs +++ b/src/0-core/HuanMeng.MiaoYu.Code/Music/MusicBLL.cs @@ -279,6 +279,25 @@ namespace HuanMeng.MiaoYu.Code.Music return new BaseResponse(ResonseCode.Success, "音乐正在生成", m_SongInfo.Id) { }; } + + /// + /// 删除音乐 + /// + /// + /// + public async Task> DelMusic(int id) + { + var s = await Dao.daoDbMiaoYu.context.M_Songs.Where(it => it.Id == id && it.AuthorId == _UserId).FirstOrDefaultAsync(); + + if (s == null) + { + return new BaseResponse(ResonseCode.Success, "未找到音乐", false); + } + s.State = -2; + s.IsPublic = false; + await Dao.daoDbMiaoYu.context.SaveChangesAsync(); + return new BaseResponse(ResonseCode.Success, "删除成功", false); + } /// /// 获取音乐生成进度 /// @@ -373,7 +392,7 @@ namespace HuanMeng.MiaoYu.Code.Music { throw new Exception("歌曲不存在"); } - if (songs.State == 0) + if (songs.State <= 0) { throw new Exception("请等待歌曲生成成功"); } @@ -418,7 +437,7 @@ namespace HuanMeng.MiaoYu.Code.Music { throw new Exception("歌曲不存在"); } - if (songs.State == 0) + if (songs.State <= 0) { throw new Exception("请等待歌曲生成成功"); } @@ -498,7 +517,7 @@ namespace HuanMeng.MiaoYu.Code.Music var data = Mapper.Map>(list); return new BaseResponse>(ResonseCode.Success, "", data); } - + /// /// /// diff --git a/src/2-api/HuanMeng.MiaoYu.WebApi/Controllers/MusicController.cs b/src/2-api/HuanMeng.MiaoYu.WebApi/Controllers/MusicController.cs index 46325a3..97e66e4 100644 --- a/src/2-api/HuanMeng.MiaoYu.WebApi/Controllers/MusicController.cs +++ b/src/2-api/HuanMeng.MiaoYu.WebApi/Controllers/MusicController.cs @@ -83,6 +83,17 @@ namespace HuanMeng.MiaoYu.WebApi.Controllers MusicBLL musicBLL = new MusicBLL(ServiceProvider); return await musicBLL.CreateMusic(musicCreateRequest); } + /// + /// 删除音乐 + /// + /// + /// + [HttpPost] + public async Task> DelMusic([FromBody] MusicReviewRequest musicReviewRequest) + { + MusicBLL musicBLL = new MusicBLL(ServiceProvider); + return await musicBLL.DelMusic(musicReviewRequest.Id); + } /// /// 获取音乐生成进度 @@ -198,7 +209,7 @@ namespace HuanMeng.MiaoYu.WebApi.Controllers } /// - /// 获取我的收藏 + /// 获取我的点赞 /// /// ///