diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Cache/MiaoYuCache.cs b/src/0-core/HuanMeng.MiaoYu.Code/Cache/MiaoYuCache.cs
index 66f5d1f..e81a341 100644
--- a/src/0-core/HuanMeng.MiaoYu.Code/Cache/MiaoYuCache.cs
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Cache/MiaoYuCache.cs
@@ -268,9 +268,9 @@ namespace HuanMeng.MiaoYu.Code.Cache
///
///
///
- public static List GetMiaoYuDataEntityCacheList(CacheBase cacheBase) where T : class
+ public static List GetMiaoYuDataEntityCacheList(CacheBase cacheBase, Expression>? expWhere = null) where T : class
{
- var cache = GetMiaoYuDataEntityCache(cacheBase);
+ var cache = GetMiaoYuDataEntityCache(cacheBase, expWhere);
return cache?.DataList ?? new List();
}
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Music/MusicBLL.cs b/src/0-core/HuanMeng.MiaoYu.Code/Music/MusicBLL.cs
new file mode 100644
index 0000000..9c0a76d
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Music/MusicBLL.cs
@@ -0,0 +1,82 @@
+using HuanMeng.MiaoYu.Code.Cache.Contract;
+using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
+using HuanMeng.MiaoYu.Model.Dto.Music;
+
+using StackExchange.Redis;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HuanMeng.MiaoYu.Code.Music
+{
+ ///
+ /// ai音乐逻辑类
+ ///
+ public class MusicBLL : MiaoYuBase
+ {
+ public MusicBLL(IServiceProvider serviceProvider) : base(serviceProvider)
+ {
+ }
+
+ ///
+ /// 获取音乐分类
+ ///
+ ///
+ public Task>> GetMusicGenresList()
+ {
+ //图片
+ var genresList = MiaoYuCacheExtend.GetMiaoYuDataEntityCacheList(this, it => it.IsEnabled);
+ var list = Mapper.Map>(genresList);
+ list.Insert(0, new MusicGenresDto()
+ {
+ Id = 0,
+ GenreName = "推荐"
+ });
+ return Task.FromResult(new BaseResponse>(ResonseCode.Success, "", list));
+ }
+
+ ///
+ /// 分类下详情列表,每次只显示50个
+ ///
+ ///
+ ///
+ public async Task>> GetMusicGenresInfo(int genresId)
+ {
+ List list = new List();
+ if (genresId == 0)
+ {
+ list = await Dao.daoDbMiaoYu.context.M_Songs.Where(it => it.IsPublic)
+ .OrderByDescending(it => it.CreationTimestamp).Take(50)
+ .ToListAsync();
+ }
+ else
+ {
+ list = await Dao.daoDbMiaoYu.context.M_Songs.Where(it => it.GenreId == genresId && it.IsPublic)
+ .OrderByDescending(it => it.CreationTimestamp).Take(50)
+ .ToListAsync();
+ }
+ var data = Mapper.Map>(list);
+ return new BaseResponse>(ResonseCode.Success, "", data);
+ }
+
+ ///
+ /// 创作页面音乐标签
+ ///
+ ///
+ public async Task>> GetUserMusicGenresList()
+ {
+ List musicUserGenresDtos = new List();
+ //图片
+ var genresList = MiaoYuCacheExtend.GetMiaoYuDataEntityCacheList(this, it => it.IsEnabled)?.Select(it => new MusicUserGenresDto() { GenreName = it.GenreName, GenreType = 0, OrderId = it.OrderId }).ToList();
+ musicUserGenresDtos.AddRange(genresList ?? new List());
+ var _userList = await Dao.daoDbMiaoYu.context.M_UserGenres.Where(it => it.UserId == _UserId).ToListAsync();
+ var userGenresList = _userList?.Select(it => new MusicUserGenresDto() { GenreName = it.GenreName, GenreType = 1, OrderId = it.Id }).ToList();
+ musicUserGenresDtos.AddRange(userGenresList ?? new List());
+ musicUserGenresDtos = musicUserGenresDtos.OrderBy(it => it.GenreType).ThenBy(it => it.OrderId).ToList();
+ return new BaseResponse>(ResonseCode.Success, "", musicUserGenresDtos);
+ }
+ }
+}
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs b/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs
index 87961ea..583f070 100644
--- a/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs
@@ -25,6 +25,7 @@ namespace HuanMeng.MiaoYu.Code.Payment
{
private static WechatTenpayClientOptions wechatTenpayClientOptions { get; set; } = new WechatTenpayClientOptions();
private static WeChatConfig weChatConfig { get; set; }
+ private static WechatTenpayClient wxClient { get; set; }
///
/// 支付
///
@@ -50,7 +51,7 @@ namespace HuanMeng.MiaoYu.Code.Payment
MerchantCertificatePrivateKey = weChatConfig.MerchantCertificatePrivateKey,
PlatformCertificateManager = manager
};
-
+ wxClient = new WechatTenpayClient(wechatTenpayClientOptions);
return builder;
}
@@ -99,7 +100,7 @@ namespace HuanMeng.MiaoYu.Code.Payment
{
return new AlipayPayment();
}
- return new WeChatPayment(wechatTenpayClientOptions, weChatConfig);
+ return new WeChatPayment(wxClient, weChatConfig);
}
///
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Payment/WeChat/WeChatPayment.cs b/src/0-core/HuanMeng.MiaoYu.Code/Payment/WeChat/WeChatPayment.cs
index 467a970..3b98225 100644
--- a/src/0-core/HuanMeng.MiaoYu.Code/Payment/WeChat/WeChatPayment.cs
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Payment/WeChat/WeChatPayment.cs
@@ -9,12 +9,12 @@ namespace HuanMeng.MiaoYu.Code.Payment.WeChat
///
/// 微信支付
///
- public class WeChatPayment(WechatTenpayClientOptions wechatTenpayClientOptions, WeChatConfig weChatConfig) : IPayment
+ public class WeChatPayment(WechatTenpayClient client, WeChatConfig weChatConfig) : IPayment
{
public async Task<(string orderId, string order)> CreateOrder(string productName, decimal price, params object[] args)
{
var orderId = GenerateTimestampIdWithOffset();
- var client = new WechatTenpayClient(wechatTenpayClientOptions);
+ //var client = new WechatTenpayClient(wechatTenpayClientOptions);
/* 以 JSAPI 统一下单接口为例 */
var request = new CreatePayTransactionAppRequest()
{
@@ -28,7 +28,7 @@ namespace HuanMeng.MiaoYu.Code.Payment.WeChat
Total = (int)(price * 100)
},
};
- var response = client.ExecuteCreatePayTransactionAppAsync(request).Result;
+ var response = await client.ExecuteCreatePayTransactionAppAsync(request);
if (response.IsSuccessful())
{
var paramMap = client.GenerateParametersForAppPayRequest(request.AppId, response.PrepayId);
diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Downloads.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Downloads.cs
new file mode 100644
index 0000000..47b407a
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Downloads.cs
@@ -0,0 +1,31 @@
+using System;
+
+namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
+
+///
+/// 存储用户下载歌曲的记录。
+///
+public partial class M_Downloads: MultiTenantEntity
+{
+ ///
+ /// 下载记录唯一标识
+ ///
+ public virtual int Id { get; set; }
+
+ ///
+ /// 被下载的歌曲ID (未设置外键)
+ ///
+ public virtual int SongId { get; set; }
+
+ ///
+ /// 下载的用户ID (未设置外键)
+ ///
+ public virtual int UserId { get; set; }
+
+ ///
+ /// 下载时间
+ ///
+ public virtual DateTime DownloadedAt { get; set; }
+
+ public override Guid TenantId { get; set; }
+ }
diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Favorites.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Favorites.cs
new file mode 100644
index 0000000..e4778ce
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Favorites.cs
@@ -0,0 +1,31 @@
+using System;
+
+namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
+
+///
+/// 存储用户收藏的歌曲信息。
+///
+public partial class M_Favorites: MultiTenantEntity
+{
+ ///
+ /// 收藏记录唯一标识
+ ///
+ public virtual int Id { get; set; }
+
+ ///
+ /// 收藏的歌曲ID (未设置外键)
+ ///
+ public virtual int SongId { get; set; }
+
+ ///
+ /// 收藏的用户ID (未设置外键)
+ ///
+ public virtual int UserId { get; set; }
+
+ ///
+ /// 收藏时间
+ ///
+ public virtual DateTime FavoritedAt { get; set; }
+
+ public override Guid TenantId { get; set; }
+ }
diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Likes.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Likes.cs
new file mode 100644
index 0000000..0935103
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Likes.cs
@@ -0,0 +1,31 @@
+using System;
+
+namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
+
+///
+/// 存储用户对歌曲的点赞记录。
+///
+public partial class M_Likes: MultiTenantEntity
+{
+ ///
+ /// 点赞唯一标识
+ ///
+ public virtual int Id { get; set; }
+
+ ///
+ /// 被点赞的歌曲ID (未设置外键)
+ ///
+ public virtual int SongId { get; set; }
+
+ ///
+ /// 点赞的用户ID (未设置外键)
+ ///
+ public virtual int UserId { get; set; }
+
+ ///
+ /// 点赞时间
+ ///
+ public virtual DateTime LikedAt { get; set; }
+
+ public override Guid TenantId { get; set; }
+ }
diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_MusicGenres.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_MusicGenres.cs
new file mode 100644
index 0000000..b82dcf3
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_MusicGenres.cs
@@ -0,0 +1,35 @@
+
+namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
+
+///
+/// 存储不同音乐风格的信息。
+///
+public partial class M_MusicGenres: MultiTenantEntity
+{
+ ///
+ /// 音乐风格唯一标识
+ ///
+ public virtual int Id { get; set; }
+
+ ///
+ /// 音乐风格名称
+ ///
+ public virtual string GenreName { get; set; } = null!;
+
+ ///
+ /// 音乐风格描述
+ ///
+ public virtual string? Description { get; set; }
+
+ public override Guid TenantId { get; set; }
+
+ ///
+ /// 排序
+ ///
+ public virtual int OrderId { get; set; }
+
+ ///
+ /// 是否启用
+ ///
+ public virtual bool IsEnabled { get; set; }
+}
diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_PlayRecords.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_PlayRecords.cs
new file mode 100644
index 0000000..1176cb0
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_PlayRecords.cs
@@ -0,0 +1,31 @@
+using System;
+
+namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
+
+///
+/// 存储用户的歌曲播放记录。
+///
+public partial class M_PlayRecords: MultiTenantEntity
+{
+ ///
+ /// 播放记录唯一标识
+ ///
+ public virtual int Id { get; set; }
+
+ ///
+ /// 播放用户ID
+ ///
+ public virtual int UserId { get; set; }
+
+ ///
+ /// 播放歌曲ID
+ ///
+ public virtual int SongId { get; set; }
+
+ ///
+ /// 播放时间
+ ///
+ public virtual DateTime PlayedAt { get; set; }
+
+ public override Guid TenantId { get; set; }
+ }
diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Reports.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Reports.cs
new file mode 100644
index 0000000..c27588f
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Reports.cs
@@ -0,0 +1,41 @@
+using System;
+
+namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
+
+///
+/// 存储用户对歌曲或评论的举报记录。
+///
+public partial class M_Reports: MultiTenantEntity
+{
+ ///
+ /// 举报记录唯一标识
+ ///
+ public virtual int Id { get; set; }
+
+ ///
+ /// 被举报的类型(歌曲或评论)
+ ///
+ public virtual string ReportedItemType { get; set; } = null!;
+
+ ///
+ /// 被举报的项目标识(对应歌曲或评论的ID)
+ ///
+ public virtual int ReportedItemId { get; set; }
+
+ ///
+ /// 举报的用户ID (未设置外键)
+ ///
+ public virtual int UserId { get; set; }
+
+ ///
+ /// 举报理由
+ ///
+ public virtual string? ReportReason { get; set; }
+
+ ///
+ /// 举报时间
+ ///
+ public virtual DateTime ReportedAt { get; set; }
+
+ public override Guid TenantId { get; set; }
+ }
diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_SongComments.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_SongComments.cs
new file mode 100644
index 0000000..08381de
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_SongComments.cs
@@ -0,0 +1,36 @@
+using System;
+
+namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
+
+///
+/// 存储用户对歌曲的评论。
+///
+public partial class M_SongComments: MultiTenantEntity
+{
+ ///
+ /// 评论唯一标识
+ ///
+ public virtual int Id { get; set; }
+
+ ///
+ /// 关联的歌曲ID
+ ///
+ public virtual int SongId { get; set; }
+
+ ///
+ /// 评论用户ID
+ ///
+ public virtual int UserId { get; set; }
+
+ ///
+ /// 评论内容
+ ///
+ public virtual string CommentText { get; set; } = null!;
+
+ ///
+ /// 评论创建时间
+ ///
+ public virtual DateTime CreatedAt { get; set; }
+
+ public override Guid TenantId { get; set; }
+ }
diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Songs.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Songs.cs
new file mode 100644
index 0000000..a5ea316
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_Songs.cs
@@ -0,0 +1,81 @@
+using System;
+
+namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
+
+///
+/// 存储所有生成的歌曲的信息。
+///
+public partial class M_Songs: MultiTenantEntity
+{
+ ///
+ /// 歌曲唯一标识
+ ///
+ public virtual int Id { get; set; }
+
+ public override Guid TenantId { get; set; }
+
+ ///
+ /// 歌曲名称
+ ///
+ public virtual string Title { get; set; } = null!;
+
+ ///
+ /// 歌曲作者ID
+ ///
+ public virtual int AuthorId { get; set; }
+
+ ///
+ /// 音乐风格
+ ///
+ public virtual string? Genre { get; set; }
+
+ ///
+ /// 歌词内容
+ ///
+ public virtual string? Lyrics { get; set; }
+
+ ///
+ /// 歌曲是否公开展示
+ ///
+ public virtual bool IsPublic { get; set; }
+
+ ///
+ /// 歌曲创建时间
+ ///
+ public virtual DateTime CreationTimestamp { get; set; }
+
+ ///
+ /// 歌曲时长
+ ///
+ public virtual TimeOnly? Duration { get; set; }
+
+ ///
+ /// 播放次数
+ ///
+ public virtual int PlayCount { get; set; }
+
+ ///
+ /// 点赞次数
+ ///
+ public virtual int LikeCount { get; set; }
+
+ ///
+ /// 下载次数
+ ///
+ public virtual int DownloadCount { get; set; }
+
+ ///
+ /// 音乐下载地址
+ ///
+ public virtual string MusicAddress { get; set; } = null!;
+
+ ///
+ /// 封面图
+ ///
+ public virtual string CoverImage { get; set; } = null!;
+
+ ///
+ /// 音乐风格Id
+ ///
+ public virtual int? GenreId { get; set; }
+}
diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_UserGenres.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_UserGenres.cs
new file mode 100644
index 0000000..e460c30
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/M_UserGenres.cs
@@ -0,0 +1,28 @@
+using System;
+
+namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
+
+///
+/// 用户音乐风格表
+///
+public partial class M_UserGenres: MultiTenantEntity
+{
+ public virtual int Id { get; set; }
+
+ public override Guid TenantId { get; set; }
+
+ ///
+ /// 音乐风格名称
+ ///
+ public virtual string? GenreName { get; set; }
+
+ ///
+ /// 用户Id
+ ///
+ public virtual int UserId { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public virtual DateTime CreateAt { get; set; }
+}
diff --git a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/MiaoYuContext.cs b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/MiaoYuContext.cs
index 71e0fe7..32d6eb0 100644
--- a/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/MiaoYuContext.cs
+++ b/src/0-core/HuanMeng.MiaoYu.Model/DbSqlServer/Db_MiaoYu/MiaoYuContext.cs
@@ -38,6 +38,51 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
}
+ ///
+ /// 存储用户下载歌曲的记录。
+ ///
+ public virtual DbSet M_Downloads { get; set; }
+
+ ///
+ /// 存储用户收藏的歌曲信息。
+ ///
+ public virtual DbSet M_Favorites { get; set; }
+
+ ///
+ /// 存储用户对歌曲的点赞记录。
+ ///
+ public virtual DbSet M_Likes { get; set; }
+
+ ///
+ /// 存储不同音乐风格的信息。
+ ///
+ public virtual DbSet M_MusicGenres { get; set; }
+
+ ///
+ /// 存储用户的歌曲播放记录。
+ ///
+ public virtual DbSet M_PlayRecords { get; set; }
+
+ ///
+ /// 存储用户对歌曲或评论的举报记录。
+ ///
+ public virtual DbSet M_Reports { get; set; }
+
+ ///
+ /// 存储用户对歌曲的评论。
+ ///
+ public virtual DbSet M_SongComments { get; set; }
+
+ ///
+ /// 存储所有生成的歌曲的信息。
+ ///
+ public virtual DbSet M_Songs { get; set; }
+
+ ///
+ /// 用户音乐风格表
+ ///
+ public virtual DbSet M_UserGenres { get; set; }
+
///
/// 发现页类别菜单
///
@@ -173,6 +218,211 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("PK__Download__73D5A7104D95E3E9");
+
+ entity.ToTable(tb => tb.HasComment("存储用户下载歌曲的记录。"));
+
+ entity.Property(e => e.Id).HasComment("下载记录唯一标识");
+ entity.Property(e => e.DownloadedAt)
+ .HasDefaultValueSql("(getdate())")
+ .HasComment("下载时间")
+ .HasColumnType("datetime");
+ entity.Property(e => e.SongId).HasComment("被下载的歌曲ID (未设置外键)");
+ entity.Property(e => e.UserId).HasComment("下载的用户ID (未设置外键)");
+ //添加全局筛选器
+ if (this.TenantInfo != null)
+ {
+ entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
+ }
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("PK__Favorite__CE74FAF5BF2A7819");
+
+ entity.ToTable(tb => tb.HasComment("存储用户收藏的歌曲信息。"));
+
+ entity.Property(e => e.Id).HasComment("收藏记录唯一标识");
+ entity.Property(e => e.FavoritedAt)
+ .HasDefaultValueSql("(getdate())")
+ .HasComment("收藏时间")
+ .HasColumnType("datetime");
+ entity.Property(e => e.SongId).HasComment("收藏的歌曲ID (未设置外键)");
+ entity.Property(e => e.UserId).HasComment("收藏的用户ID (未设置外键)");
+ //添加全局筛选器
+ if (this.TenantInfo != null)
+ {
+ entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
+ }
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("PK__Likes__A2922CF4CB853B69");
+
+ entity.ToTable(tb => tb.HasComment("存储用户对歌曲的点赞记录。"));
+
+ entity.Property(e => e.Id).HasComment("点赞唯一标识");
+ entity.Property(e => e.LikedAt)
+ .HasDefaultValueSql("(getdate())")
+ .HasComment("点赞时间")
+ .HasColumnType("datetime");
+ entity.Property(e => e.SongId).HasComment("被点赞的歌曲ID (未设置外键)");
+ entity.Property(e => e.UserId).HasComment("点赞的用户ID (未设置外键)");
+ //添加全局筛选器
+ if (this.TenantInfo != null)
+ {
+ entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
+ }
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("PK__MusicGen__0385055E360A596F");
+
+ entity.ToTable(tb => tb.HasComment("存储不同音乐风格的信息。"));
+
+ entity.Property(e => e.Id).HasComment("音乐风格唯一标识");
+ entity.Property(e => e.Description)
+ .HasMaxLength(500)
+ .HasComment("音乐风格描述");
+ entity.Property(e => e.GenreName)
+ .HasMaxLength(100)
+ .HasComment("音乐风格名称");
+ entity.Property(e => e.IsEnabled).HasComment("是否启用");
+ entity.Property(e => e.OrderId).HasComment("排序");
+ //添加全局筛选器
+ if (this.TenantInfo != null)
+ {
+ entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
+ }
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("PK__PlayReco__FAA8BADE7D0B98DF");
+
+ entity.ToTable(tb => tb.HasComment("存储用户的歌曲播放记录。"));
+
+ entity.Property(e => e.Id).HasComment("播放记录唯一标识");
+ entity.Property(e => e.PlayedAt)
+ .HasDefaultValueSql("(getdate())")
+ .HasComment("播放时间")
+ .HasColumnType("datetime");
+ entity.Property(e => e.SongId).HasComment("播放歌曲ID");
+ entity.Property(e => e.UserId).HasComment("播放用户ID");
+ //添加全局筛选器
+ if (this.TenantInfo != null)
+ {
+ entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
+ }
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("PK__Reports__D5BD48E5522A3B94");
+
+ entity.ToTable(tb => tb.HasComment("存储用户对歌曲或评论的举报记录。"));
+
+ entity.Property(e => e.Id).HasComment("举报记录唯一标识");
+ entity.Property(e => e.ReportReason)
+ .HasMaxLength(500)
+ .HasComment("举报理由");
+ entity.Property(e => e.ReportedAt)
+ .HasDefaultValueSql("(getdate())")
+ .HasComment("举报时间")
+ .HasColumnType("datetime");
+ entity.Property(e => e.ReportedItemId).HasComment("被举报的项目标识(对应歌曲或评论的ID)");
+ entity.Property(e => e.ReportedItemType)
+ .HasMaxLength(50)
+ .HasComment("被举报的类型(歌曲或评论)");
+ entity.Property(e => e.UserId).HasComment("举报的用户ID (未设置外键)");
+ //添加全局筛选器
+ if (this.TenantInfo != null)
+ {
+ entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
+ }
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("PK__SongComm__C3B4DFAAB1D1E4FA");
+
+ entity.ToTable(tb => tb.HasComment("存储用户对歌曲的评论。"));
+
+ entity.Property(e => e.Id).HasComment("评论唯一标识");
+ entity.Property(e => e.CommentText)
+ .HasMaxLength(1000)
+ .HasComment("评论内容");
+ entity.Property(e => e.CreatedAt)
+ .HasDefaultValueSql("(getdate())")
+ .HasComment("评论创建时间")
+ .HasColumnType("datetime");
+ entity.Property(e => e.SongId).HasComment("关联的歌曲ID");
+ entity.Property(e => e.UserId).HasComment("评论用户ID");
+ //添加全局筛选器
+ if (this.TenantInfo != null)
+ {
+ entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
+ }
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("PK__Songs__3214EC0728D42B46");
+
+ entity.ToTable(tb => tb.HasComment("存储所有生成的歌曲的信息。"));
+
+ entity.Property(e => e.Id).HasComment("歌曲唯一标识");
+ entity.Property(e => e.AuthorId).HasComment("歌曲作者ID");
+ entity.Property(e => e.CoverImage).HasComment("封面图");
+ entity.Property(e => e.CreationTimestamp)
+ .HasDefaultValueSql("(getdate())")
+ .HasComment("歌曲创建时间")
+ .HasColumnType("datetime");
+ entity.Property(e => e.DownloadCount).HasComment("下载次数");
+ entity.Property(e => e.Duration).HasComment("歌曲时长");
+ entity.Property(e => e.Genre)
+ .HasMaxLength(50)
+ .HasComment("音乐风格");
+ entity.Property(e => e.GenreId).HasComment("音乐风格Id");
+ entity.Property(e => e.IsPublic).HasComment("歌曲是否公开展示");
+ entity.Property(e => e.LikeCount).HasComment("点赞次数");
+ entity.Property(e => e.Lyrics).HasComment("歌词内容");
+ entity.Property(e => e.MusicAddress).HasComment("音乐下载地址");
+ entity.Property(e => e.PlayCount).HasComment("播放次数");
+ entity.Property(e => e.Title)
+ .HasMaxLength(200)
+ .HasComment("歌曲名称");
+ //添加全局筛选器
+ if (this.TenantInfo != null)
+ {
+ entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
+ }
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("PK__M_UserGe__3214EC07B5C45EB7");
+
+ entity.ToTable(tb => tb.HasComment("用户音乐风格表"));
+
+ entity.Property(e => e.CreateAt)
+ .HasComment("创建时间")
+ .HasColumnType("datetime");
+ entity.Property(e => e.GenreName)
+ .HasMaxLength(50)
+ .HasComment("音乐风格名称");
+ entity.Property(e => e.UserId).HasComment("用户Id");
+ //添加全局筛选器
+ if (this.TenantInfo != null)
+ {
+ entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
+ }
+ });
+
modelBuilder.Entity(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__T_Catego__3214EC07464F6CD1");
diff --git a/src/0-core/HuanMeng.MiaoYu.Model/Dto/Music/MusicGenresDto.cs b/src/0-core/HuanMeng.MiaoYu.Model/Dto/Music/MusicGenresDto.cs
new file mode 100644
index 0000000..a35db07
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Model/Dto/Music/MusicGenresDto.cs
@@ -0,0 +1,48 @@
+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
+{
+ ///
+ ///
+ ///
+ [AutoMap(typeof(M_MusicGenres))]
+ public class MusicGenresDto
+ {
+ ///
+ /// 音乐风格唯一标识
+ ///
+ public virtual int Id { get; set; }
+
+ ///
+ /// 音乐风格名称
+ ///
+ public virtual string GenreName { get; set; }
+ }
+ ///
+ ///
+ ///
+ public class MusicUserGenresDto
+ {
+
+ ///
+ /// 音乐风格名称
+ ///
+ public string GenreName { get; set; }
+ ///
+ ///
+ ///
+ public int OrderId { get; set; }
+ ///
+ /// 音乐风格
+ ///
+ public int GenreType { get; set; }
+ }
+}
diff --git a/src/0-core/HuanMeng.MiaoYu.Model/Dto/Music/MusicSongInfoDto.cs b/src/0-core/HuanMeng.MiaoYu.Model/Dto/Music/MusicSongInfoDto.cs
new file mode 100644
index 0000000..14843c6
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Model/Dto/Music/MusicSongInfoDto.cs
@@ -0,0 +1,81 @@
+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
+{
+ [AutoMap(typeof(M_Songs))]
+ public class MusicSongInfoDto
+ {
+ ///
+ /// 歌曲唯一标识
+ ///
+ public int Id { get; set; }
+
+ ///
+ /// 歌曲名称
+ ///
+ public string Title { get; set; }
+
+ ///
+ /// 歌曲作者ID
+ ///
+ public int AuthorId { get; set; }
+
+ ///
+ /// 音乐风格
+ ///
+ public string? Genre { get; set; }
+
+ ///
+ /// 歌词内容
+ ///
+ public string? Lyrics { get; set; }
+
+ ///
+ /// 歌曲是否公开展示
+ ///
+ public bool IsPublic { get; set; }
+
+ ///
+ /// 歌曲创建时间
+ ///
+ public DateTime CreationTimestamp { get; set; }
+
+ ///
+ /// 歌曲时长
+ ///
+ public TimeOnly? Duration { get; set; }
+
+ ///
+ /// 播放次数
+ ///
+ public int PlayCount { get; set; }
+
+ ///
+ /// 点赞次数
+ ///
+ public int LikeCount { get; set; }
+
+ ///
+ /// 下载次数
+ ///
+ public int DownloadCount { get; set; }
+
+ ///
+ /// 音乐下载地址
+ ///
+ public string MusicAddress { get; set; }
+
+ ///
+ /// 封面图
+ ///
+ public string CoverImage { get; set; }
+ }
+}
diff --git a/src/2-api/HuanMeng.MiaoYu.WebApi/Controllers/MusicController.cs b/src/2-api/HuanMeng.MiaoYu.WebApi/Controllers/MusicController.cs
new file mode 100644
index 0000000..80ab856
--- /dev/null
+++ b/src/2-api/HuanMeng.MiaoYu.WebApi/Controllers/MusicController.cs
@@ -0,0 +1,55 @@
+using HuanMeng.DotNetCore.Base;
+using HuanMeng.MiaoYu.Code.Cache;
+using HuanMeng.MiaoYu.Code.Music;
+using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
+using HuanMeng.MiaoYu.Model.Dto.Music;
+using HuanMeng.MiaoYu.WebApi.Base;
+
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+
+namespace HuanMeng.MiaoYu.WebApi.Controllers
+{
+ [Route("api/[controller]/[action]")]
+ [ApiController]
+ public class MusicController : MiaoYuControllerBase
+ {
+ public MusicController(IServiceProvider _serviceProvider) : base(_serviceProvider)
+ {
+ }
+
+ ///
+ /// 获取音乐分类
+ ///
+ ///
+ [HttpGet]
+ public async Task>> GetMusicGenresList()
+ {
+ MusicBLL musicBLL = new MusicBLL(ServiceProvider);
+ return await musicBLL.GetMusicGenresList();
+ }
+ ///
+ /// 分类下详情列表,每次只显示50个
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task>> GetMusicGenresInfo(int genresId)
+ {
+ MusicBLL musicBLL = new MusicBLL(ServiceProvider);
+ return await musicBLL.GetMusicGenresInfo(genresId);
+ }
+
+ ///
+ /// 创作页面音乐标签
+ ///
+ ///
+ [HttpGet]
+ public async Task>> GetUserMusicGenresList()
+ {
+ MusicBLL musicBLL = new MusicBLL(ServiceProvider);
+ return await musicBLL.GetUserMusicGenresList();
+ }
+ }
+}