添加音乐接口
This commit is contained in:
parent
f2d219897f
commit
3badd0c692
|
|
@ -11,7 +11,11 @@ docker push 123.207.203.228:92/miaoyuapi:latest
|
|||
docker tag miaoyuapi:dev-1.2.7 123.207.203.228:92/miaoyuapi:dev-1.2.7
|
||||
docker push 123.207.203.228:92/miaoyuapi:dev-1.2.7
|
||||
//docker build -t myregistry.com/myusername/myapp:v1.0 .
|
||||
docker build -t miaoyuapi:dev-1.3.31 -t miaoyuapi:latest -t 123.207.203.228:92/miaoyuapi:dev-1.3.31 -t 123.207.203.228:92/miaoyuapi:latest --build-arg VERSION=1.3.31 --build-arg TARGET=dev -f src/2-api/HuanMeng.MiaoYu.WebApi/Dockerfile .
|
||||
docker push 123.207.203.228:92/miaoyuapi:dev-1.3.31
|
||||
docker push 123.207.203.228:92/miaoyuapi:latest
|
||||
|
||||
docker build -t miaoyu:dev-1.3.31 -f src/2-api/HuanMeng.MiaoYu.WebApi/Dockerfile .
|
||||
docker build --no-cache --progress=plain -t hm-admin:dev-1.0.3 -t hm-admin:latest -t 123.207.203.228:92/hm-admin:dev-1.0.3 -t 123.207.203.228:92/hm-admin:latest -f MiaoYu.Api.Admin/Dockerfile .
|
||||
docker tag hm-admin:dev-1.0.0
|
||||
docker build -t hm-admin:v1.0 -t hm-admin:latest .
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ using Microsoft.IdentityModel.Protocols;
|
|||
using SKIT.FlurlHttpClient.Wechat.TenpayV3.Models;
|
||||
using HuanMeng.MiaoYu.Code.Payment;
|
||||
using System.Collections.Frozen;
|
||||
using HuanMeng.MiaoYu.Code.Music;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.AppExtend
|
||||
{
|
||||
|
|
@ -124,6 +125,8 @@ namespace HuanMeng.MiaoYu.Code.AppExtend
|
|||
AppConfigInit(builder.Configuration);
|
||||
builder.Services.AddScoped<AppConfig>();
|
||||
builder.Services.AddHostedService<AppConfigExtendServer>();
|
||||
builder.Services.AddHostedService<MusicService>();
|
||||
|
||||
return builder;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ using Newtonsoft.Json.Serialization;
|
|||
using Newtonsoft.Json;
|
||||
using HuanMeng.MiaoYu.Code.Chat.Contract;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
using HuanMeng.MiaoYu.Code.Users;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using HuanMeng.MiaoYu.Model.Dto;
|
||||
using HuanMeng.MiaoYu.Code.DataAccess;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.Music
|
||||
{
|
||||
|
|
@ -44,6 +48,37 @@ namespace HuanMeng.MiaoYu.Code.Music
|
|||
return Task.FromResult(new BaseResponse<List<MusicGenresDto>>(ResonseCode.Success, "", list));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<BaseResponse<MusicUserDto>> GetUserInfo()
|
||||
{
|
||||
var user = await Dao.daoDbMiaoYu.context.T_User.FirstOrDefaultAsync(it => it.Id == _UserId);
|
||||
if (user == null)
|
||||
{
|
||||
throw new Exception("用户不存在");
|
||||
}
|
||||
//获取用户余额
|
||||
UserInfoBLL userInfoBLL = new UserInfoBLL(Dao, _UserId);
|
||||
var Currency = userInfoBLL[UserCurrencyType.生成音乐点数]?.CurrencyMoney;
|
||||
string sqlString = $@"select isnull(sum(PlayCount),0) PlayCount,isnull(sum(LikeCount),0) LikeCount,isnull(sum(DownloadCount),0) DownloadCount from M_Songs where AuthorId={_UserId}";
|
||||
var info = Dao.daoDbMiaoYu.context.Database.SqlQueryRaw<MusicSongsInfo>(sqlString).FirstOrDefault();
|
||||
|
||||
List<CreateCharacterInfo> characters = new List<CreateCharacterInfo>();
|
||||
return new BaseResponse<MusicUserDto>(ResonseCode.Success, "请求成功", new MusicUserDto
|
||||
{
|
||||
NickName = user.NickName,
|
||||
UserId = user.Id,
|
||||
UserIconUrl = string.IsNullOrEmpty(user?.UserIconUrl) ? "https://cos.shhuanmeng.com/default.png" : user?.UserIconUrl,
|
||||
Vip = 0,
|
||||
DownloadCount = info.DownloadCount,
|
||||
LikeCount = info.LikeCount,
|
||||
PlayCount = info.PlayCount,
|
||||
MusicPoints = (int)Currency
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分类下详情列表,每次只显示50个
|
||||
/// </summary>
|
||||
|
|
@ -86,12 +121,51 @@ namespace HuanMeng.MiaoYu.Code.Music
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 创建我的音乐风格
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<BaseResponse<bool>> CreateUserMusicGenres(string genresName)
|
||||
{
|
||||
var genresCount = MiaoYuCacheExtend.GetMiaoYuDataEntityCacheList<M_MusicGenres>(this, it => it.IsEnabled)?.Where(it => it.GenreName == genresName).Count();
|
||||
if (genresCount > 0)
|
||||
{
|
||||
throw new Exception("音乐风格名称重复");
|
||||
}
|
||||
var c = Dao.daoDbMiaoYu.context.M_UserGenres.Where(it => it.UserId == _UserId && it.GenreName == genresName).Count();
|
||||
if (c > 0)
|
||||
{
|
||||
throw new Exception("音乐风格名称重复");
|
||||
}
|
||||
M_UserGenres m_UserGenres = new M_UserGenres()
|
||||
{
|
||||
CreateAt = DateTime.Now,
|
||||
GenreName = genresName,
|
||||
UserId = _UserId,
|
||||
};
|
||||
Dao.daoDbMiaoYu.context.Add(m_UserGenres);
|
||||
await Dao.daoDbMiaoYu.context.SaveChangesAsync();
|
||||
return new BaseResponse<bool>(ResonseCode.Success, "创建成功", true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 我的音乐列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<BaseResponse<List<MusicSongInfoDto>>> GetMyMusicList()
|
||||
{
|
||||
var list = await Dao.daoDbMiaoYu.context.M_Songs.Where(it => it.AuthorId == _UserId && it.State >= 0).ToListAsync();
|
||||
var data = Mapper.Map<List<MusicSongInfoDto>>(list);
|
||||
return new BaseResponse<List<MusicSongInfoDto>>(ResonseCode.Success, "", data);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建音乐
|
||||
/// </summary>
|
||||
/// <param name="musicCreateRequest"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public async Task<BaseResponse<bool>> CreateMusic(MusicCreateRequest musicCreateRequest)
|
||||
public async Task<BaseResponse<int>> CreateMusic(MusicCreateRequest musicCreateRequest)
|
||||
{
|
||||
if (_UserId == 0)
|
||||
{
|
||||
|
|
@ -102,6 +176,14 @@ namespace HuanMeng.MiaoYu.Code.Music
|
|||
{
|
||||
throw new Exception("音乐点数不足");
|
||||
}
|
||||
bool isGenresId = false;
|
||||
var genresId = MiaoYuCacheExtend.GetMiaoYuDataEntityCacheList<M_MusicGenres>(this, it => it.IsEnabled)?.FirstOrDefault(it => it.GenreName == musicCreateRequest.GenreName)?.Id;
|
||||
if (genresId == null || genresId <= 0)
|
||||
{
|
||||
isGenresId = true;
|
||||
genresId = Dao.daoDbMiaoYu.context.M_UserGenres.Where(it => it.UserId == _UserId && it.GenreName == musicCreateRequest.GenreName).FirstOrDefault()?.Id;
|
||||
|
||||
}
|
||||
Dictionary<string, object> keyValuePairs = new Dictionary<string, object>();
|
||||
keyValuePairs.Add("gpt_description_prompt", $"歌曲风格:{musicCreateRequest.GenreName}");
|
||||
keyValuePairs.Add("make_instrumental", false);
|
||||
|
|
@ -135,8 +217,9 @@ namespace HuanMeng.MiaoYu.Code.Music
|
|||
GetUrl = url,
|
||||
RequestInfo = requestBody,
|
||||
ResonseInfo = responseContent,
|
||||
Status = "已完成",
|
||||
Status = "正在生成",
|
||||
UpdateAt = DateTime.Now,
|
||||
UserId = _UserId
|
||||
};
|
||||
Dao.daoDbMiaoYu.context.Add(m_SongInfo);
|
||||
Dao.daoDbMiaoYu.context.SaveChanges();
|
||||
|
|
@ -146,20 +229,115 @@ namespace HuanMeng.MiaoYu.Code.Music
|
|||
}
|
||||
if (!string.IsNullOrEmpty(musicId1))
|
||||
{
|
||||
var song1 = GetSong(musicCreateRequest.GenreName, musicCreateRequest.Name, musicId1, m_SongInfo.Id);
|
||||
var song1 = GetSong(musicCreateRequest.GenreName, musicCreateRequest.Name, musicId1, m_SongInfo.Id, genresId);
|
||||
song1.AuthorName = userInfoBLL.UserName;
|
||||
song1.IsUserGenre = isGenresId;
|
||||
Dao.daoDbMiaoYu.context.Add(song1);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(musicId2))
|
||||
{
|
||||
var song2 = GetSong(musicCreateRequest.GenreName, musicCreateRequest.Name, musicId2, m_SongInfo.Id);
|
||||
var song2 = GetSong(musicCreateRequest.GenreName, musicCreateRequest.Name, musicId2, m_SongInfo.Id, genresId);
|
||||
song2.AuthorName = userInfoBLL.UserName;
|
||||
song2.IsUserGenre = isGenresId;
|
||||
Dao.daoDbMiaoYu.context.Add(song2);
|
||||
}
|
||||
//扣除货币
|
||||
userInfoBLL[UserCurrencyType.生成音乐点数].ConsumeMoneyNoWork(-10, Dao);
|
||||
return new BaseResponse<bool>(ResonseCode.Success, "音乐正在生成", true) { };
|
||||
Dao.daoDbMiaoYu.context.SaveChanges();
|
||||
return new BaseResponse<int>(ResonseCode.Success, "音乐正在生成", m_SongInfo.Id) { };
|
||||
}
|
||||
|
||||
private M_Songs GetSong(string genreName, string name, string? musicId1, int songInfoId)
|
||||
/// <summary>
|
||||
/// 获取音乐生成进度
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<BaseResponse<bool>> GetMusicSchedule(int id)
|
||||
{
|
||||
var s = await Dao.daoDbMiaoYu.context.M_SongInfo.Where(it => it.Id == id).FirstOrDefaultAsync();
|
||||
|
||||
if (s?.Status == "已完成")
|
||||
{
|
||||
return new BaseResponse<bool>(ResonseCode.Success, "", true);
|
||||
}
|
||||
return new BaseResponse<bool>(ResonseCode.Success, "", false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲审核
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<BaseResponse<bool>> MusicSongsReview(int id)
|
||||
{
|
||||
var songs = await Dao.daoDbMiaoYu.context.M_Songs.Where(it => it.Id == id).FirstOrDefaultAsync();
|
||||
if (songs == null)
|
||||
{
|
||||
throw new Exception("歌曲不存在");
|
||||
}
|
||||
if (songs.State == 0)
|
||||
{
|
||||
throw new Exception("请等待歌曲生成成功");
|
||||
}
|
||||
if (songs.State == -3)
|
||||
{
|
||||
throw new Exception("歌曲审核失败");
|
||||
}
|
||||
if (songs.State == 3 && songs.IsPublic)
|
||||
{
|
||||
throw new Exception("歌曲已经在公开状态中");
|
||||
}
|
||||
if (songs.State == 3 && !songs.IsPublic)
|
||||
{
|
||||
songs.IsPublic = true;
|
||||
await Dao.daoDbMiaoYu.context.SaveChangesAsync();
|
||||
return new BaseResponse<bool>(ResonseCode.Success, "歌曲已公开", true);
|
||||
}
|
||||
songs.State = 2;
|
||||
await Dao.daoDbMiaoYu.context.SaveChangesAsync();
|
||||
return new BaseResponse<bool>(ResonseCode.Success, "歌曲已提交审核", true);
|
||||
}
|
||||
/// <summary>
|
||||
/// 取消审核
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
|
||||
public async Task<BaseResponse<bool>> MusicCancelSongsReview(int id)
|
||||
{
|
||||
var songs = await Dao.daoDbMiaoYu.context.M_Songs.Where(it => it.Id == id).FirstOrDefaultAsync();
|
||||
if (songs == null)
|
||||
{
|
||||
throw new Exception("歌曲不存在");
|
||||
}
|
||||
if (songs.State == 0)
|
||||
{
|
||||
throw new Exception("请等待歌曲生成成功");
|
||||
}
|
||||
if (songs.State == 2)
|
||||
{
|
||||
songs.State = 1;
|
||||
}
|
||||
if (songs.State == 3)
|
||||
{
|
||||
songs.IsPublic = false;
|
||||
}
|
||||
|
||||
await Dao.daoDbMiaoYu.context.SaveChangesAsync();
|
||||
return new BaseResponse<bool>(ResonseCode.Success, "歌曲已取消公开", true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="genreName"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="musicId1"></param>
|
||||
/// <param name="songInfoId"></param>
|
||||
/// <param name="genresId"></param>
|
||||
/// <returns></returns>
|
||||
private M_Songs GetSong(string genreName, string name, string musicId1, int songInfoId, int? genresId)
|
||||
{
|
||||
M_Songs m_Songs = new M_Songs()
|
||||
{
|
||||
|
|
@ -171,14 +349,14 @@ namespace HuanMeng.MiaoYu.Code.Music
|
|||
PlayCount = 0,
|
||||
Duration = TimeOnly.MinValue,
|
||||
Genre = genreName,
|
||||
GenreId = 0,
|
||||
GenreId = genresId,
|
||||
ImageLargeUrl = "https://cos.shhuanmeng.com/yinyue/fengmian.png",
|
||||
IsPublic = false,
|
||||
Lyrics = "",
|
||||
MusicAddress = "",
|
||||
SongInfoId = songInfoId,
|
||||
SpecialId = musicId1,
|
||||
State = 1,
|
||||
State = 0,
|
||||
Title = name
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ using System.Net.Http;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.Music
|
||||
{
|
||||
|
|
@ -26,6 +27,7 @@ namespace HuanMeng.MiaoYu.Code.Music
|
|||
MusicProcessor? musicProcessor = null;
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
musicProcessor = new MusicProcessor(serviceProvider);
|
||||
musicProcessor.Run();
|
||||
return Task.CompletedTask;
|
||||
|
|
@ -51,16 +53,18 @@ namespace HuanMeng.MiaoYu.Code.Music
|
|||
{
|
||||
protected override async void Proc_Do()
|
||||
{
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
foreach (var item in AppConfigurationExtend.AppConfigs.Values)
|
||||
{
|
||||
|
||||
var service = serviceProvider.CreateScope();
|
||||
var temantInfo = serviceProvider.GetRequiredService<ITenantInfo>();
|
||||
item.ToITenantInfo(temantInfo);
|
||||
DAO dao = new DAO(serviceProvider);
|
||||
using var service = serviceProvider.CreateScope();
|
||||
var _serviceProvider = service.ServiceProvider;
|
||||
var temantInfo = _serviceProvider.GetService<ITenantInfo>();
|
||||
var t = item.ToITenantInfo();
|
||||
DAO dao = new DAO(_serviceProvider, t);
|
||||
var list = dao.daoDbMiaoYu.context.M_Songs.Where(it => it.State == 1).ToList();
|
||||
if (list.Count > 0)
|
||||
{
|
||||
|
|
@ -75,11 +79,15 @@ namespace HuanMeng.MiaoYu.Code.Music
|
|||
if (response == null || !response.IsSuccessStatusCode)
|
||||
{
|
||||
//throw new Exception("创建音乐失败");
|
||||
songs.State = -1;
|
||||
dao.daoDbMiaoYu.context.SaveChanges();
|
||||
continue;
|
||||
}
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
if (string.IsNullOrEmpty(responseContent))
|
||||
{
|
||||
songs.State = -1;
|
||||
dao.daoDbMiaoYu.context.SaveChanges();
|
||||
continue;
|
||||
}
|
||||
var obj = JsonConvert.DeserializeObject<JArray>(responseContent);
|
||||
|
|
@ -87,8 +95,6 @@ namespace HuanMeng.MiaoYu.Code.Music
|
|||
var status = obj?.SelectToken("[0].status")?.ToString();
|
||||
if (status == "complete")
|
||||
{
|
||||
//obj.SelectToken("[0].video_url")?.ToString();
|
||||
|
||||
songs.MusicAddress = obj?.SelectToken("[0].audio_url")?.ToString() ?? "";
|
||||
songs.CoverImage = obj?.SelectToken("[0].image_url")?.ToString() ?? "";
|
||||
songs.ImageLargeUrl = obj?.SelectToken("[0].image_large_url")?.ToString() ?? "";
|
||||
|
|
@ -96,9 +102,18 @@ namespace HuanMeng.MiaoYu.Code.Music
|
|||
var duration = obj?.SelectToken("[0].metadata.duration")?.ToString() ?? "";
|
||||
if (!string.IsNullOrEmpty(duration))
|
||||
{
|
||||
if (int.TryParse(duration, out var d))
|
||||
if (decimal.TryParse(duration, out var d))
|
||||
{
|
||||
songs.Duration = new TimeOnly(0, 0, d);
|
||||
songs.Duration = TimeOnly.FromTimeSpan(new TimeSpan(0, 0, (int)d));
|
||||
}
|
||||
}
|
||||
songs.State = 1;
|
||||
var songInfo = await dao.daoDbMiaoYu.context.M_SongInfo.Where(it => it.Id == songs.SongInfoId).FirstOrDefaultAsync();
|
||||
if (songInfo != null)
|
||||
{
|
||||
if (songInfo.Status == "正在生成")
|
||||
{
|
||||
songInfo.Status = "已完成";
|
||||
}
|
||||
}
|
||||
dao.daoDbMiaoYu.context.SaveChanges();
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
public async Task<BaseResponse<ResponseUserInfo>> GetUserInfo()
|
||||
{
|
||||
var user = await Dao.daoDbMiaoYu.context.T_User.FirstOrDefaultAsync(it => it.Id == _UserId);
|
||||
var userData = await Dao.daoDbMiaoYu.context.T_User_Data.FirstOrDefaultAsync(it => it.UserId == _UserId);
|
||||
//var userData = await Dao.daoDbMiaoYu.context.T_User_Data.FirstOrDefaultAsync(it => it.UserId == _UserId);
|
||||
//获取用户余额
|
||||
UserInfoBLL userInfoBLL = new UserInfoBLL(Dao, _UserId);
|
||||
var Currency = userInfoBLL[UserCurrencyType.语珠]?.CurrencyMoney;
|
||||
|
|
@ -134,7 +134,7 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
NickName = user.NickName,
|
||||
UserId = user.Id,
|
||||
Currency = (int)Currency,
|
||||
UserIconUrl = string.IsNullOrEmpty(userData?.UserIconUrl) ? "https://cos.shhuanmeng.com/default.png" : userData?.UserIconUrl,
|
||||
UserIconUrl = string.IsNullOrEmpty(user?.UserIconUrl) ? "https://cos.shhuanmeng.com/default.png" : user?.UserIconUrl,
|
||||
RemainingChatCount = (int)RemainingChatCount,//这里先写1,我不会decimal转int
|
||||
HasTalked = hasTalked,
|
||||
Photographs = 0,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,17 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户名称
|
||||
/// </summary>
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return User.NickName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 货币
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -45,4 +45,6 @@ public partial class M_SongInfo: MultiTenantEntity
|
|||
/// 修改时间
|
||||
/// </summary>
|
||||
public virtual DateTime UpdateAt { get; set; }
|
||||
|
||||
public virtual int? UserId { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,4 +98,14 @@ public partial class M_Songs: MultiTenantEntity
|
|||
/// 特殊Id
|
||||
/// </summary>
|
||||
public virtual string SpecialId { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 作者
|
||||
/// </summary>
|
||||
public virtual string? AuthorName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否用户自定义风格
|
||||
/// </summary>
|
||||
public virtual bool? IsUserGenre { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -420,6 +420,9 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
|||
|
||||
entity.Property(e => e.Id).HasComment("歌曲唯一标识");
|
||||
entity.Property(e => e.AuthorId).HasComment("歌曲作者ID");
|
||||
entity.Property(e => e.AuthorName)
|
||||
.HasMaxLength(50)
|
||||
.HasComment("作者");
|
||||
entity.Property(e => e.CoverImage).HasComment("封面图");
|
||||
entity.Property(e => e.CreationTimestamp)
|
||||
.HasDefaultValueSql("(getdate())")
|
||||
|
|
@ -433,6 +436,7 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
|||
entity.Property(e => e.GenreId).HasComment("音乐风格Id");
|
||||
entity.Property(e => e.ImageLargeUrl).HasComment("封面缩略图");
|
||||
entity.Property(e => e.IsPublic).HasComment("歌曲是否公开展示");
|
||||
entity.Property(e => e.IsUserGenre).HasComment("是否用户自定义风格");
|
||||
entity.Property(e => e.LikeCount).HasComment("点赞次数");
|
||||
entity.Property(e => e.Lyrics).HasComment("歌词内容");
|
||||
entity.Property(e => e.MusicAddress).HasComment("音乐下载地址");
|
||||
|
|
@ -1073,6 +1077,7 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
|||
entity.Property(e => e.UpdatedAt)
|
||||
.HasComment("修改时间")
|
||||
.HasColumnType("datetime");
|
||||
entity.Property(e => e.UserIconUrl).HasMaxLength(300);
|
||||
entity.Property(e => e.UserName)
|
||||
.HasMaxLength(100)
|
||||
.HasComment("用户姓名");
|
||||
|
|
|
|||
|
|
@ -78,4 +78,6 @@ public partial class T_User: MultiTenantEntity
|
|||
/// 是否是测试账号
|
||||
/// </summary>
|
||||
public virtual bool? IsTest { get; set; }
|
||||
|
||||
public virtual string? UserIconUrl { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||
namespace HuanMeng.MiaoYu.Model.Dto.Music
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建音乐
|
||||
/// 创建音乐
|
||||
/// </summary>
|
||||
public class MusicCreateRequest
|
||||
{
|
||||
|
|
@ -27,4 +27,24 @@ namespace HuanMeng.MiaoYu.Model.Dto.Music
|
|||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class MusicUserGenresRequest()
|
||||
{
|
||||
/// <summary>
|
||||
/// 音乐风格
|
||||
/// </summary>
|
||||
public string GenreName { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲审核
|
||||
/// </summary>
|
||||
public class MusicReviewRequest()
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,14 @@ namespace HuanMeng.MiaoYu.Model.Dto.Music
|
|||
/// </summary>
|
||||
public TimeOnly? Duration { get; set; }
|
||||
|
||||
public string? DurationS
|
||||
{
|
||||
get
|
||||
{
|
||||
return Duration?.ToString("mm:ss");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 播放次数
|
||||
/// </summary>
|
||||
|
|
@ -77,5 +85,20 @@ namespace HuanMeng.MiaoYu.Model.Dto.Music
|
|||
/// 封面图
|
||||
/// </summary>
|
||||
public string CoverImage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 音乐状态,0生成功,1生成中
|
||||
/// </summary>
|
||||
public virtual int State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 作者名称
|
||||
/// </summary>
|
||||
public virtual string? AuthorName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否用户自定义风格
|
||||
/// </summary>
|
||||
public virtual bool? IsUserGenre { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
31
src/0-core/HuanMeng.MiaoYu.Model/Dto/Music/MusicSongsInfo.cs
Normal file
31
src/0-core/HuanMeng.MiaoYu.Model/Dto/Music/MusicSongsInfo.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.Dto.Music
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class MusicSongsInfo
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int PlayCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int LikeCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int DownloadCount { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
using AutoMapper;
|
||||
|
||||
using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.Dto.Music
|
||||
{
|
||||
/// <summary>
|
||||
/// 音乐列表
|
||||
/// </summary>
|
||||
[AutoMap(typeof(M_Songs))]
|
||||
public class MusicSongsListDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 歌曲是否公开展示
|
||||
/// </summary>
|
||||
public virtual bool IsPublic { get; set; }
|
||||
/// <summary>
|
||||
/// 歌曲唯一标识
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲名称
|
||||
/// </summary>
|
||||
public string? Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲作者ID
|
||||
/// </summary>
|
||||
public int AuthorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 音乐风格
|
||||
/// </summary>
|
||||
public string? Genre { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲时长
|
||||
/// </summary>
|
||||
public TimeOnly? Duration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 播放次数
|
||||
/// </summary>
|
||||
public int PlayCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点赞次数
|
||||
/// </summary>
|
||||
public int LikeCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下载次数
|
||||
/// </summary>
|
||||
public int DownloadCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 封面图
|
||||
/// </summary>
|
||||
public string? CoverImage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 封面缩略图
|
||||
/// </summary>
|
||||
public string? ImageLargeUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 音乐状态,0生成功,1生成中
|
||||
/// </summary>
|
||||
public int State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 作者名称
|
||||
/// </summary>
|
||||
public string? AuthorName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 音乐下载地址
|
||||
/// </summary>
|
||||
public string? MusicAddress { get; set; }
|
||||
}
|
||||
}
|
||||
40
src/0-core/HuanMeng.MiaoYu.Model/Dto/Music/MusicUserDto.cs
Normal file
40
src/0-core/HuanMeng.MiaoYu.Model/Dto/Music/MusicUserDto.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.Dto.Music
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class MusicUserDto : MusicSongsInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户头像
|
||||
/// </summary>
|
||||
public string? UserIconUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户Id
|
||||
/// </summary>
|
||||
public int UserId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用户昵称
|
||||
/// </summary>
|
||||
public string? NickName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 剩余音乐点数
|
||||
/// </summary>
|
||||
public int MusicPoints { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否有Vip
|
||||
/// </summary>
|
||||
public int Vip { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
using HuanMeng.DotNetCore.Base;
|
||||
using HuanMeng.MiaoYu.Code.Cache;
|
||||
using HuanMeng.MiaoYu.Code.Music;
|
||||
using HuanMeng.MiaoYu.Code.Users;
|
||||
using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Character;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Music;
|
||||
using HuanMeng.MiaoYu.Model.EnumModel.User;
|
||||
using HuanMeng.MiaoYu.WebApi.Base;
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
|
@ -51,16 +54,86 @@ namespace HuanMeng.MiaoYu.WebApi.Controllers
|
|||
MusicBLL musicBLL = new MusicBLL(ServiceProvider);
|
||||
return await musicBLL.GetUserMusicGenresList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建我的音乐风格
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<BaseResponse<bool>> CreateUserMusicGenres([FromBody] MusicUserGenresRequest musicUserGenresRequest)
|
||||
{
|
||||
MusicBLL musicBLL = new MusicBLL(ServiceProvider);
|
||||
return await musicBLL.CreateUserMusicGenres(musicUserGenresRequest.GenreName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创作音乐
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<BaseResponse<bool>> CreateMusic([FromBody] MusicCreateRequest musicCreateRequest)
|
||||
public async Task<BaseResponse<int>> CreateMusic([FromBody] MusicCreateRequest musicCreateRequest)
|
||||
{
|
||||
MusicBLL musicBLL = new MusicBLL(ServiceProvider);
|
||||
return await musicBLL.CreateMusic(musicCreateRequest); ;
|
||||
return await musicBLL.CreateMusic(musicCreateRequest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取音乐生成进度
|
||||
/// </summary>
|
||||
/// <param name="id">创作音乐选出的Id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<BaseResponse<bool>> GetMusicSchedule(int id)
|
||||
{
|
||||
MusicBLL musicBLL = new MusicBLL(ServiceProvider);
|
||||
return await musicBLL.GetMusicSchedule(id);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 我的音乐列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<BaseResponse<List<MusicSongInfoDto>>> GetMyMusicList()
|
||||
{
|
||||
MusicBLL musicBLL = new MusicBLL(ServiceProvider);
|
||||
return await musicBLL.GetMyMusicList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<BaseResponse<MusicUserDto>> GetUserInfo()
|
||||
{
|
||||
MusicBLL musicBLL = new MusicBLL(ServiceProvider);
|
||||
return await musicBLL.GetUserInfo();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲审核
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<BaseResponse<bool>> MusicSongsReview([FromBody] MusicReviewRequest musicReviewRequest)
|
||||
{
|
||||
MusicBLL musicBLL = new MusicBLL(ServiceProvider);
|
||||
return await musicBLL.MusicSongsReview(musicReviewRequest.Id);
|
||||
}
|
||||
/// <summary>
|
||||
/// 取消审核
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
[HttpPost]
|
||||
|
||||
public async Task<BaseResponse<bool>> MusicCancelSongsReview([FromBody] MusicReviewRequest musicReviewRequest)
|
||||
{
|
||||
MusicBLL musicBLL = new MusicBLL(ServiceProvider);
|
||||
return await musicBLL.MusicCancelSongsReview(musicReviewRequest.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user