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 } /// - /// 获取我的收藏 + /// 获取我的点赞 /// /// ///