提交代码
This commit is contained in:
parent
90e4e32b22
commit
fa81bfd853
|
|
@ -268,9 +268,9 @@ namespace HuanMeng.MiaoYu.Code.Cache
|
|||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="cacheBase"></param>
|
||||
/// <returns></returns>
|
||||
public static List<T> GetMiaoYuDataEntityCacheList<T>(CacheBase cacheBase) where T : class
|
||||
public static List<T> GetMiaoYuDataEntityCacheList<T>(CacheBase cacheBase, Expression<Func<T, bool>>? expWhere = null) where T : class
|
||||
{
|
||||
var cache = GetMiaoYuDataEntityCache<T>(cacheBase);
|
||||
var cache = GetMiaoYuDataEntityCache<T>(cacheBase, expWhere);
|
||||
return cache?.DataList ?? new List<T>();
|
||||
}
|
||||
|
||||
|
|
|
|||
82
src/0-core/HuanMeng.MiaoYu.Code/Music/MusicBLL.cs
Normal file
82
src/0-core/HuanMeng.MiaoYu.Code/Music/MusicBLL.cs
Normal file
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// ai音乐逻辑类
|
||||
/// </summary>
|
||||
public class MusicBLL : MiaoYuBase
|
||||
{
|
||||
public MusicBLL(IServiceProvider serviceProvider) : base(serviceProvider)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取音乐分类
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<BaseResponse<List<MusicGenresDto>>> GetMusicGenresList()
|
||||
{
|
||||
//图片
|
||||
var genresList = MiaoYuCacheExtend.GetMiaoYuDataEntityCacheList<M_MusicGenres>(this, it => it.IsEnabled);
|
||||
var list = Mapper.Map<List<MusicGenresDto>>(genresList);
|
||||
list.Insert(0, new MusicGenresDto()
|
||||
{
|
||||
Id = 0,
|
||||
GenreName = "推荐"
|
||||
});
|
||||
return Task.FromResult(new BaseResponse<List<MusicGenresDto>>(ResonseCode.Success, "", list));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分类下详情列表,每次只显示50个
|
||||
/// </summary>
|
||||
/// <param name="genresId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<BaseResponse<List<MusicSongInfoDto>>> GetMusicGenresInfo(int genresId)
|
||||
{
|
||||
List<M_Songs> list = new List<M_Songs>();
|
||||
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<MusicSongInfoDto>>(list);
|
||||
return new BaseResponse<List<MusicSongInfoDto>>(ResonseCode.Success, "", data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创作页面音乐标签
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<BaseResponse<List<MusicUserGenresDto>>> GetUserMusicGenresList()
|
||||
{
|
||||
List<MusicUserGenresDto> musicUserGenresDtos = new List<MusicUserGenresDto>();
|
||||
//图片
|
||||
var genresList = MiaoYuCacheExtend.GetMiaoYuDataEntityCacheList<M_MusicGenres>(this, it => it.IsEnabled)?.Select(it => new MusicUserGenresDto() { GenreName = it.GenreName, GenreType = 0, OrderId = it.OrderId }).ToList();
|
||||
musicUserGenresDtos.AddRange(genresList ?? new List<MusicUserGenresDto>());
|
||||
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<MusicUserGenresDto>());
|
||||
musicUserGenresDtos = musicUserGenresDtos.OrderBy(it => it.GenreType).ThenBy(it => it.OrderId).ToList();
|
||||
return new BaseResponse<List<MusicUserGenresDto>>(ResonseCode.Success, "", musicUserGenresDtos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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; }
|
||||
/// <summary>
|
||||
/// 支付
|
||||
/// </su0mmary>
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ namespace HuanMeng.MiaoYu.Code.Payment.WeChat
|
|||
/// <summary>
|
||||
/// 微信支付
|
||||
/// </summary>
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户下载歌曲的记录。
|
||||
/// </summary>
|
||||
public partial class M_Downloads: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 下载记录唯一标识
|
||||
/// </summary>
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 被下载的歌曲ID (未设置外键)
|
||||
/// </summary>
|
||||
public virtual int SongId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下载的用户ID (未设置外键)
|
||||
/// </summary>
|
||||
public virtual int UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下载时间
|
||||
/// </summary>
|
||||
public virtual DateTime DownloadedAt { get; set; }
|
||||
|
||||
public override Guid TenantId { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户收藏的歌曲信息。
|
||||
/// </summary>
|
||||
public partial class M_Favorites: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 收藏记录唯一标识
|
||||
/// </summary>
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 收藏的歌曲ID (未设置外键)
|
||||
/// </summary>
|
||||
public virtual int SongId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 收藏的用户ID (未设置外键)
|
||||
/// </summary>
|
||||
public virtual int UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 收藏时间
|
||||
/// </summary>
|
||||
public virtual DateTime FavoritedAt { get; set; }
|
||||
|
||||
public override Guid TenantId { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户对歌曲的点赞记录。
|
||||
/// </summary>
|
||||
public partial class M_Likes: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 点赞唯一标识
|
||||
/// </summary>
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 被点赞的歌曲ID (未设置外键)
|
||||
/// </summary>
|
||||
public virtual int SongId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点赞的用户ID (未设置外键)
|
||||
/// </summary>
|
||||
public virtual int UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点赞时间
|
||||
/// </summary>
|
||||
public virtual DateTime LikedAt { get; set; }
|
||||
|
||||
public override Guid TenantId { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 存储不同音乐风格的信息。
|
||||
/// </summary>
|
||||
public partial class M_MusicGenres: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 音乐风格唯一标识
|
||||
/// </summary>
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 音乐风格名称
|
||||
/// </summary>
|
||||
public virtual string GenreName { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 音乐风格描述
|
||||
/// </summary>
|
||||
public virtual string? Description { get; set; }
|
||||
|
||||
public override Guid TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public virtual int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public virtual bool IsEnabled { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户的歌曲播放记录。
|
||||
/// </summary>
|
||||
public partial class M_PlayRecords: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 播放记录唯一标识
|
||||
/// </summary>
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 播放用户ID
|
||||
/// </summary>
|
||||
public virtual int UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 播放歌曲ID
|
||||
/// </summary>
|
||||
public virtual int SongId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 播放时间
|
||||
/// </summary>
|
||||
public virtual DateTime PlayedAt { get; set; }
|
||||
|
||||
public override Guid TenantId { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户对歌曲或评论的举报记录。
|
||||
/// </summary>
|
||||
public partial class M_Reports: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 举报记录唯一标识
|
||||
/// </summary>
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 被举报的类型(歌曲或评论)
|
||||
/// </summary>
|
||||
public virtual string ReportedItemType { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 被举报的项目标识(对应歌曲或评论的ID)
|
||||
/// </summary>
|
||||
public virtual int ReportedItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 举报的用户ID (未设置外键)
|
||||
/// </summary>
|
||||
public virtual int UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 举报理由
|
||||
/// </summary>
|
||||
public virtual string? ReportReason { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 举报时间
|
||||
/// </summary>
|
||||
public virtual DateTime ReportedAt { get; set; }
|
||||
|
||||
public override Guid TenantId { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户对歌曲的评论。
|
||||
/// </summary>
|
||||
public partial class M_SongComments: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 评论唯一标识
|
||||
/// </summary>
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联的歌曲ID
|
||||
/// </summary>
|
||||
public virtual int SongId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 评论用户ID
|
||||
/// </summary>
|
||||
public virtual int UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 评论内容
|
||||
/// </summary>
|
||||
public virtual string CommentText { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 评论创建时间
|
||||
/// </summary>
|
||||
public virtual DateTime CreatedAt { get; set; }
|
||||
|
||||
public override Guid TenantId { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 存储所有生成的歌曲的信息。
|
||||
/// </summary>
|
||||
public partial class M_Songs: MultiTenantEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 歌曲唯一标识
|
||||
/// </summary>
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
public override Guid TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲名称
|
||||
/// </summary>
|
||||
public virtual string Title { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲作者ID
|
||||
/// </summary>
|
||||
public virtual int AuthorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 音乐风格
|
||||
/// </summary>
|
||||
public virtual string? Genre { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌词内容
|
||||
/// </summary>
|
||||
public virtual string? Lyrics { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲是否公开展示
|
||||
/// </summary>
|
||||
public virtual bool IsPublic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲创建时间
|
||||
/// </summary>
|
||||
public virtual DateTime CreationTimestamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲时长
|
||||
/// </summary>
|
||||
public virtual TimeOnly? Duration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 播放次数
|
||||
/// </summary>
|
||||
public virtual int PlayCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点赞次数
|
||||
/// </summary>
|
||||
public virtual int LikeCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下载次数
|
||||
/// </summary>
|
||||
public virtual int DownloadCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 音乐下载地址
|
||||
/// </summary>
|
||||
public virtual string MusicAddress { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 封面图
|
||||
/// </summary>
|
||||
public virtual string CoverImage { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 音乐风格Id
|
||||
/// </summary>
|
||||
public virtual int? GenreId { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 用户音乐风格表
|
||||
/// </summary>
|
||||
public partial class M_UserGenres: MultiTenantEntity
|
||||
{
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
public override Guid TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 音乐风格名称
|
||||
/// </summary>
|
||||
public virtual string? GenreName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户Id
|
||||
/// </summary>
|
||||
public virtual int UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public virtual DateTime CreateAt { get; set; }
|
||||
}
|
||||
|
|
@ -38,6 +38,51 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户下载歌曲的记录。
|
||||
/// </summary>
|
||||
public virtual DbSet<M_Downloads> M_Downloads { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户收藏的歌曲信息。
|
||||
/// </summary>
|
||||
public virtual DbSet<M_Favorites> M_Favorites { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户对歌曲的点赞记录。
|
||||
/// </summary>
|
||||
public virtual DbSet<M_Likes> M_Likes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存储不同音乐风格的信息。
|
||||
/// </summary>
|
||||
public virtual DbSet<M_MusicGenres> M_MusicGenres { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户的歌曲播放记录。
|
||||
/// </summary>
|
||||
public virtual DbSet<M_PlayRecords> M_PlayRecords { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户对歌曲或评论的举报记录。
|
||||
/// </summary>
|
||||
public virtual DbSet<M_Reports> M_Reports { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存储用户对歌曲的评论。
|
||||
/// </summary>
|
||||
public virtual DbSet<M_SongComments> M_SongComments { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存储所有生成的歌曲的信息。
|
||||
/// </summary>
|
||||
public virtual DbSet<M_Songs> M_Songs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户音乐风格表
|
||||
/// </summary>
|
||||
public virtual DbSet<M_UserGenres> M_UserGenres { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发现页类别菜单
|
||||
/// </summary>
|
||||
|
|
@ -173,6 +218,211 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
|||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<M_Downloads>(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<M_Favorites>(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<M_Likes>(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<M_MusicGenres>(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<M_PlayRecords>(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<M_Reports>(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<M_SongComments>(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<M_Songs>(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<M_UserGenres>(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<T_Category_Child_Menu>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_Catego__3214EC07464F6CD1");
|
||||
|
|
|
|||
48
src/0-core/HuanMeng.MiaoYu.Model/Dto/Music/MusicGenresDto.cs
Normal file
48
src/0-core/HuanMeng.MiaoYu.Model/Dto/Music/MusicGenresDto.cs
Normal file
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[AutoMap(typeof(M_MusicGenres))]
|
||||
public class MusicGenresDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 音乐风格唯一标识
|
||||
/// </summary>
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 音乐风格名称
|
||||
/// </summary>
|
||||
public virtual string GenreName { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class MusicUserGenresDto
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 音乐风格名称
|
||||
/// </summary>
|
||||
public string GenreName { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
/// <summary>
|
||||
/// 音乐风格
|
||||
/// </summary>
|
||||
public int GenreType { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <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 string? Lyrics { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲是否公开展示
|
||||
/// </summary>
|
||||
public bool IsPublic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌曲创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTimestamp { 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 MusicAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 封面图
|
||||
/// </summary>
|
||||
public string CoverImage { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取音乐分类
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<BaseResponse<List<MusicGenresDto>>> GetMusicGenresList()
|
||||
{
|
||||
MusicBLL musicBLL = new MusicBLL(ServiceProvider);
|
||||
return await musicBLL.GetMusicGenresList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 分类下详情列表,每次只显示50个
|
||||
/// </summary>
|
||||
/// <param name="genresId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<BaseResponse<List<MusicSongInfoDto>>> GetMusicGenresInfo(int genresId)
|
||||
{
|
||||
MusicBLL musicBLL = new MusicBLL(ServiceProvider);
|
||||
return await musicBLL.GetMusicGenresInfo(genresId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创作页面音乐标签
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<BaseResponse<List<MusicUserGenresDto>>> GetUserMusicGenresList()
|
||||
{
|
||||
MusicBLL musicBLL = new MusicBLL(ServiceProvider);
|
||||
return await musicBLL.GetUserMusicGenresList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user