diff --git a/Mikibot.Analyze/Bot/RandomImage/RandomImageService.cs b/Mikibot.Analyze/Bot/RandomImage/RandomImageService.cs index 11ab187..7863b52 100644 --- a/Mikibot.Analyze/Bot/RandomImage/RandomImageService.cs +++ b/Mikibot.Analyze/Bot/RandomImage/RandomImageService.cs @@ -11,18 +11,14 @@ public class RandomImageService(IMiraiService miraiService, ILogger - @@ -28,6 +27,7 @@ + @@ -51,6 +51,12 @@ + + + + + + diff --git a/Mikibot.Analyze/MiraiHttp/IMiraiService.cs b/Mikibot.Analyze/MiraiHttp/IMiraiService.cs index 736fecd..86e8701 100644 --- a/Mikibot.Analyze/MiraiHttp/IMiraiService.cs +++ b/Mikibot.Analyze/MiraiHttp/IMiraiService.cs @@ -7,10 +7,15 @@ namespace Mikibot.Analyze.MiraiHttp public interface IMiraiService { ValueTask Run(); - ValueTask SendMessageToAllGroup(CancellationToken token, params MessageBase[] messages); ValueTask SendMessageToGroup(Group group, CancellationToken token, params MessageBase[] messages); - ValueTask SendMessageToSliceManGroup(CancellationToken token, params MessageBase[] messages); public void SubscribeMessage(Action next, CancellationToken token); + + + [Obsolete("Will be removed in future version")] ValueTask SendMessageToSomeGroup(HashSet groupIds, CancellationToken token, params MessageBase[] messages); + [Obsolete("Will be removed in future version")] + ValueTask SendMessageToSliceManGroup(CancellationToken token, params MessageBase[] messages); + [Obsolete("Will be removed in future version")] + ValueTask SendMessageToAllGroup(CancellationToken token, params MessageBase[] messages); } } \ No newline at end of file diff --git a/Mikibot.Analyze/MiraiHttp/SatoriBotBridge.cs b/Mikibot.Analyze/MiraiHttp/SatoriBotBridge.cs new file mode 100644 index 0000000..779d01d --- /dev/null +++ b/Mikibot.Analyze/MiraiHttp/SatoriBotBridge.cs @@ -0,0 +1,148 @@ +using Microsoft.Extensions.Logging; +using Mirai.Net.Data.Messages; +using Mirai.Net.Data.Messages.Concretes; +using Mirai.Net.Data.Messages.Receivers; +using Mirai.Net.Data.Shared; +using Satori.Client; +using Satori.Client.Extensions; +using Satori.Protocol.Elements; +using Satori.Protocol.Events; + +namespace Mikibot.Analyze.MiraiHttp; + +public class SatoriBotBridge(ILogger logger) : IDisposable, IMiraiService +{ + private static readonly string EnvSatoriEndpoint + = Environment.GetEnvironmentVariable("ENV_SATORI_ENDPOINT") ?? "http://localhost:5500"; + + private static readonly string EnvSatoriToken + = Environment.GetEnvironmentVariable("ENV_SATORI_TOKEN") ?? ""; + + private static Element? ConvertSingleMessageElementToSatori(MessageBase message) + { + return message switch + { + PlainMessage plain => new TextElement() { Text = plain.Text, }, + ImageMessage { Url.Length: > 0 } image => new ImageElement() { Src = image.Url, }, + ImageMessage { Base64.Length: > 0 } image => new ImageElement() { Src = $"blob://{image.Base64}" }, + ImageMessage { Path.Length: > 0 } image => new ImageElement() { Src = $"file://{image.Path}" }, + VoiceMessage { Url.Length: > 0 } image => new AudioElement() { Src = image.Url, }, + VoiceMessage { Base64.Length: > 0 } image => new AudioElement() { Src = $"blob://{image.Base64}" }, + VoiceMessage { Path.Length: > 0 } image => new AudioElement() { Src = $"file://{image.Path}" }, + _ => null + }; + } + + private static IEnumerable ConvertMessageToSatori(IEnumerable messageChain) + { + return messageChain + .Select(ConvertSingleMessageElementToSatori) + .OfType(); + } + + private static MessageBase? ConvertSingleMessageElementToSatori(Element message) + { + return message switch + { + TextElement plain => new PlainMessage() { Text = plain.Text, }, + _ => null + }; + } + private static IEnumerable ConvertMessageToMirai(IEnumerable messages) + { + return messages + .Select(ConvertSingleMessageElementToSatori) + .OfType(); + } + + public async ValueTask SendMessageToGroup(Group group, CancellationToken token, params MessageBase[] messages) + { + ArgumentNullException.ThrowIfNull(Bot); + + await Bot.CreateMessageAsync(group.Id, ConvertMessageToSatori(messages)); + } + + private readonly Dictionary, CancellationTokenRegistration> _subscriber = []; + public void SubscribeMessage(Action next, CancellationToken token) + { + logger.LogInformation("注册消费消息: {}", next); + _subscriber.Add(next, token.Register(() => + { + _subscriber.TryGetValue(next, out var reg); + using var regDispose = reg; + _subscriber.Remove(next); + })); + } + + private SatoriClient? Client { get; set; } + private SatoriBot? Bot { get; set; } + public async ValueTask Run() + { + Client = new SatoriClient(EnvSatoriEndpoint, EnvSatoriToken); + + Bot = await Client.GetBotAsync(); + + Bot.MessageCreated += BotOnMessageCreated; + _ = Client.StartAsync(); + } + + private void BotOnMessageCreated(object? sender, Event e) + { + if (e.Message is not { User: not null, Channel: not null }) return; + + var group = e.Message.Channel is not null + ? new Group() + { + Id = e.Message.Channel.Id, + Name = e.Message.Channel.Name, + Permission = Permissions.Member, + } : null; + var member = new Member() + { + Id = e.Message.User.Id, + Name = e.Message.User.Name, + Group = group, + }; + var type = e.Channel is not null + ? MessageReceivers.Group + : MessageReceivers.Friend; + + var elements = ElementSerializer.Deserialize(e.Message.Content); + var message = new MessageChain(ConvertMessageToMirai(elements)); + + foreach (var (next, _) in _subscriber) + { + next(new GroupMessageReceiver() + { + Type = type, + Sender = member, + MessageChain = message, + }); + } + } + + public void Dispose() + { + Client?.Dispose(); + } + + public async ValueTask SendMessageToSomeGroup(HashSet groupIds, CancellationToken token, params MessageBase[] messages) + { + ArgumentNullException.ThrowIfNull(Bot); + + var elements = ConvertMessageToSatori(messages).ToList(); + foreach (var groupId in groupIds) + { + await Bot.CreateMessageAsync(groupId, elements); + } + } + + public ValueTask SendMessageToAllGroup(CancellationToken token, params MessageBase[] messages) + { + throw new NotImplementedException(); + } + public ValueTask SendMessageToSliceManGroup(CancellationToken token, params MessageBase[] messages) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/Mikibot.Analyze/Program.cs b/Mikibot.Analyze/Program.cs index d364628..d5fb683 100644 --- a/Mikibot.Analyze/Program.cs +++ b/Mikibot.Analyze/Program.cs @@ -19,17 +19,18 @@ appBuilder.RegisterType().AsSelf().InstancePerDependency(); appBuilder.Register((_) => MiraiBotConfig.FromEnviroment()); -#if DEBUG -appBuilder.RegisterType().As().SingleInstance(); -appBuilder.RegisterType().As().SingleInstance(); -// appBuilder.RegisterType().As().SingleInstance(); -appBuilder.RegisterType().As().SingleInstance(); -#else -appBuilder.RegisterType().As().SingleInstance(); +// #if DEBUG +// appBuilder.RegisterType().As().SingleInstance(); +// appBuilder.RegisterType().As().SingleInstance(); +// // appBuilder.RegisterType().As().SingleInstance(); +// // appBuilder.RegisterType().As().SingleInstance(); +// #else +// appBuilder.RegisterType().As().SingleInstance(); // appBuilder.RegisterType().As().SingleInstance(); -appBuilder.RegisterType().As().SingleInstance(); -appBuilder.RegisterType().As().SingleInstance(); -#endif +appBuilder.RegisterType().As().SingleInstance(); +// appBuilder.RegisterType().As().SingleInstance(); +// appBuilder.RegisterType().As().SingleInstance(); +// #endif // appBuilder.RegisterType().AsSelf().SingleInstance(); @@ -38,13 +39,13 @@ // appBuilder.RegisterType().AsSelf().SingleInstance(); // appBuilder.RegisterType().AsSelf().SingleInstance(); // appBuilder.RegisterType().AsSelf().SingleInstance(); -appBuilder.RegisterType().AsSelf().SingleInstance(); -appBuilder.RegisterType().AsSelf().SingleInstance(); +// appBuilder.RegisterType().AsSelf().SingleInstance(); +// appBuilder.RegisterType().AsSelf().SingleInstance(); appBuilder.RegisterType().AsSelf().SingleInstance(); // appBuilder.RegisterType().AsSelf().SingleInstance(); //appBuilder.RegisterType().AsSelf().SingleInstance(); -appBuilder.RegisterType().AsSelf().SingleInstance(); +// appBuilder.RegisterType().AsSelf().SingleInstance(); appBuilder.RegisterType().AsSelf().SingleInstance(); appBuilder.RegisterType().AsSelf().SingleInstance(); appBuilder.RegisterType().AsSelf().SingleInstance(); @@ -66,10 +67,8 @@ logger.LogInformation("Done"); var mirai = app.Resolve(); - logger.LogInformation("Intiializing mirai service..."); + logger.LogInformation("Initializing mirai service..."); await mirai.Run(); - logger.LogInformation("Done"); - var statusCrawler = app.Resolve(); var followerStat = app.Resolve(); @@ -79,11 +78,11 @@ // var danmakuCrawler = app.Resolve(); // var danmakuExportGuard = app.Resolve(); - var aiVoice = app.Resolve(); + // var aiVoice = app.Resolve(); //var aiImage = app.Resolve(); - var bffAnti = app.Resolve(); - var mxmkDanmakuProxy = app.Resolve(); - var mxmkLiveEventProxy = app.Resolve(); + // var bffAnti = app.Resolve(); + // var mxmkDanmakuProxy = app.Resolve(); + // var mxmkLiveEventProxy = app.Resolve(); var biliParser = app.Resolve(); var randomImage = app.Resolve(); var optionaSelector = app.Resolve(); @@ -102,12 +101,12 @@ await Task.WhenAll( statusCrawler.Run(token), followerStat.Run(token), // eventService.Run(token), - bffAnti.Run(token), + // bffAnti.Run(token), biliParser.Run(token), randomImage.Run(token), //aiImage.Run(token), - aiVoice.Run(token), + // aiVoice.Run(token), optionaSelector.Run(token), - // pingti.Run(token), + pingti.Run(token) ]); } diff --git a/Mikibot.Database/Migrations/20241229212006_AddSubscriptionTableAndAlterUserIdType.Designer.cs b/Mikibot.Database/Migrations/20241229212006_AddSubscriptionTableAndAlterUserIdType.Designer.cs new file mode 100644 index 0000000..21dc473 --- /dev/null +++ b/Mikibot.Database/Migrations/20241229212006_AddSubscriptionTableAndAlterUserIdType.Designer.cs @@ -0,0 +1,620 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Mikibot.Database; + +#nullable disable + +namespace Mikibot.Migrations +{ + [DbContext(typeof(MikibotDatabaseContext))] + [Migration("20241229212006_AddSubscriptionTableAndAlterUserIdType")] + partial class AddSubscriptionTableAndAlterUserIdType + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("Mikibot.Database.Model.FollowerStatistic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + + b.Property("FollowerCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Bid", "CreatedAt"); + + b.ToTable("FollowerStatistic"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.LiveBuyGuardLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("BoughtAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + + b.Property("GiftName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("GuardLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Price") + .HasColumnType("int"); + + b.Property("Uid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("Bid", "BoughtAt"); + + b.HasIndex("Bid", "Uid"); + + b.ToTable("LiveBuyGuardLogs"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.LiveDanmaku", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + + b.Property("FansLevel") + .HasColumnType("int"); + + b.Property("FansTag") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FansTagUserId") + .HasColumnType("int"); + + b.Property("FansTagUserName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Msg") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SentAt") + .HasColumnType("datetime(6)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("Bid", "FansTagUserId"); + + b.HasIndex("Bid", "SentAt"); + + b.HasIndex("Bid", "UserId"); + + b.ToTable("LiveDanmakus"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.LiveGift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("CoinType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ComboId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + + b.Property("DiscountPrice") + .HasColumnType("int"); + + b.Property("GiftName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SentAt") + .HasColumnType("datetime(6)"); + + b.Property("Uid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("Bid", "ComboId"); + + b.HasIndex("Bid", "SentAt"); + + b.HasIndex("Bid", "Uid"); + + b.ToTable("LiveGifts"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.LiveGiftCombo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Action") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("ComboId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("ComboNum") + .HasColumnType("int"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + + b.Property("GiftName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TotalCoin") + .HasColumnType("int"); + + b.Property("Uid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("Bid", "ComboId"); + + b.HasIndex("Bid", "CreatedAt"); + + b.HasIndex("Bid", "Uid"); + + b.ToTable("LiveGiftCombos"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.LiveGuardEnterLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .HasColumnType("int"); + + b.Property("CopyWriting") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + + b.Property("EnteredAt") + .HasColumnType("datetime(6)"); + + b.Property("GuardLevel") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Bid", "EnteredAt"); + + b.HasIndex("Bid", "UserId"); + + b.ToTable("LiveGuardEnterLogs"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.LiveStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("Cover") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + + b.Property("FollowerCount") + .HasColumnType("int"); + + b.Property("Notified") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false); + + b.Property("NotifiedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StatusChangedAt") + .HasColumnType("datetime(6)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UpdatedAt") + .ValueGeneratedOnUpdate() + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Bid"); + + b.ToTable("LiveStatuses"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.LiveStreamRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Duration") + .HasColumnType("int"); + + b.Property("LocalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecordStoppedAt") + .HasColumnType("datetime(6)"); + + b.Property("Reserve") + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.HasIndex("Bid", "CreatedAt", "RecordStoppedAt"); + + b.ToTable("LiveStreamRecords"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.LiveSuperChat", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + + b.Property("MedalGuardLevel") + .HasColumnType("int"); + + b.Property("MedalLevel") + .HasColumnType("int"); + + b.Property("MedalName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MedalUserId") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Message") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Price") + .HasColumnType("int"); + + b.Property("SentAt") + .HasColumnType("datetime(6)"); + + b.Property("Uid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("Bid", "Uid"); + + b.ToTable("LiveSuperChats"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.LiveUserInteractiveLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime(6)"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + + b.Property("FansTagUserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("GuardLevel") + .HasColumnType("int"); + + b.Property("InteractedAt") + .HasColumnType("datetime(6)"); + + b.Property("MedalLevel") + .HasColumnType("int"); + + b.Property("MedalName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.HasIndex("Bid", "FansTagUserId"); + + b.HasIndex("Bid", "InteractedAt"); + + b.HasIndex("Bid", "UserId"); + + b.ToTable("LiveUserInteractiveLogs"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.StatisticReportLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.Property("ReportIdentity") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ReportedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Bid"); + + b.ToTable("StatisticReportLogs"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.SubscriptionFansTrends", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("GroupId") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TargetFansCount") + .HasColumnType("int"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("SubscriptionFansTrends"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.SubscriptionLiveStart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("EnabledFansTrendingStatistics") + .HasColumnType("tinyint(1)"); + + b.Property("GroupId") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RoomId") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("SubscriptionLiveStarts"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.VoxList", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("暗杀名单", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Mikibot.Database/Migrations/20241229212006_AddSubscriptionTableAndAlterUserIdType.cs b/Mikibot.Database/Migrations/20241229212006_AddSubscriptionTableAndAlterUserIdType.cs new file mode 100644 index 0000000..1b0565d --- /dev/null +++ b/Mikibot.Database/Migrations/20241229212006_AddSubscriptionTableAndAlterUserIdType.cs @@ -0,0 +1,715 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Mikibot.Migrations +{ + /// + public partial class AddSubscriptionTableAndAlterUserIdType : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Id", + table: "StatisticReportLogs", + type: "bigint", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "LiveUserInteractiveLogs", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "FansTagUserId", + table: "LiveUserInteractiveLogs", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveUserInteractiveLogs", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveUserInteractiveLogs", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveUserInteractiveLogs", + type: "bigint", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Uid", + table: "LiveSuperChats", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "MedalUserId", + table: "LiveSuperChats", + type: "longtext", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveSuperChats", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveSuperChats", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveSuperChats", + type: "bigint", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveStreamRecords", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveStreamRecords", + type: "bigint", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveStatuses", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveStatuses", + type: "bigint", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveGuardEnterLogs", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveGuardEnterLogs", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Uid", + table: "LiveGifts", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveGifts", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveGifts", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveGifts", + type: "bigint", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Uid", + table: "LiveGiftCombos", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveGiftCombos", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveGiftCombos", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveGiftCombos", + type: "bigint", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "LiveDanmakus", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveDanmakus", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveDanmakus", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveDanmakus", + type: "bigint", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Uid", + table: "LiveBuyGuardLogs", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveBuyGuardLogs", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveBuyGuardLogs", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveBuyGuardLogs", + type: "bigint", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "FollowerStatistic", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Id", + table: "FollowerStatistic", + type: "bigint", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.CreateTable( + name: "SubscriptionFansTrends", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + GroupId = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + UserId = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + TargetFansCount = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SubscriptionFansTrends", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "SubscriptionLiveStarts", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + GroupId = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + UserId = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + RoomId = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + EnabledFansTrendingStatistics = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SubscriptionLiveStarts", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "暗杀名单", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Bid = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + CreatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_暗杀名单", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "SubscriptionFansTrends"); + + migrationBuilder.DropTable( + name: "SubscriptionLiveStarts"); + + migrationBuilder.DropTable( + name: "暗杀名单"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "StatisticReportLogs", + type: "int", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "LiveUserInteractiveLogs", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "FansTagUserId", + table: "LiveUserInteractiveLogs", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveUserInteractiveLogs", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveUserInteractiveLogs", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveUserInteractiveLogs", + type: "int", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Uid", + table: "LiveSuperChats", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "MedalUserId", + table: "LiveSuperChats", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "longtext") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveSuperChats", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveSuperChats", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveSuperChats", + type: "int", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveStreamRecords", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveStreamRecords", + type: "int", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveStatuses", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveStatuses", + type: "int", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveGuardEnterLogs", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveGuardEnterLogs", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Uid", + table: "LiveGifts", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveGifts", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveGifts", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveGifts", + type: "int", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Uid", + table: "LiveGiftCombos", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveGiftCombos", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveGiftCombos", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveGiftCombos", + type: "int", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "LiveDanmakus", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveDanmakus", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveDanmakus", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveDanmakus", + type: "int", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Uid", + table: "LiveBuyGuardLogs", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "LiveBuyGuardLogs", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Bid", + table: "LiveBuyGuardLogs", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Id", + table: "LiveBuyGuardLogs", + type: "int", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "CreatedAt", + table: "FollowerStatistic", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTimeOffset), + oldType: "datetime(6)") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "Id", + table: "FollowerStatistic", + type: "int", + nullable: false, + oldClrType: typeof(long), + oldType: "bigint") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + } + } +} diff --git a/Mikibot.Database/Migrations/MikibotDatabaseContextModelSnapshot.cs b/Mikibot.Database/Migrations/MikibotDatabaseContextModelSnapshot.cs index 1792799..c9153a0 100644 --- a/Mikibot.Database/Migrations/MikibotDatabaseContextModelSnapshot.cs +++ b/Mikibot.Database/Migrations/MikibotDatabaseContextModelSnapshot.cs @@ -2,6 +2,7 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Mikibot.Database; @@ -16,14 +17,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("ProductVersion", "9.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 64); + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + modelBuilder.Entity("Mikibot.Database.Model.FollowerStatistic", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); b.Property("Bid") .IsRequired() @@ -33,6 +38,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("datetime(6)"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + b.Property("FollowerCount") .HasColumnType("int"); @@ -45,12 +52,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Mikibot.Database.Model.LiveBuyGuardLog", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("bigint"); - b.Property("Bid") - .HasColumnType("int"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("BoughtAt") .HasColumnType("datetime(6)"); @@ -59,6 +69,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("datetime(6)"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + b.Property("GiftName") .IsRequired() .HasColumnType("longtext"); @@ -70,8 +82,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Price") .HasColumnType("int"); - b.Property("Uid") - .HasColumnType("int"); + b.Property("Uid") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("UserName") .IsRequired() @@ -88,17 +101,22 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Mikibot.Database.Model.LiveDanmaku", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("bigint"); - b.Property("Bid") - .HasColumnType("int"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("datetime(6)"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + b.Property("FansLevel") .HasColumnType("int"); @@ -120,8 +138,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SentAt") .HasColumnType("datetime(6)"); - b.Property("UserId") - .HasColumnType("int"); + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("UserName") .IsRequired() @@ -140,16 +159,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Mikibot.Database.Model.LiveGift", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); b.Property("Action") .IsRequired() .HasColumnType("longtext"); - b.Property("Bid") - .HasColumnType("int"); + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("CoinType") .IsRequired() @@ -163,6 +185,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("datetime(6)"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + b.Property("DiscountPrice") .HasColumnType("int"); @@ -173,8 +197,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SentAt") .HasColumnType("datetime(6)"); - b.Property("Uid") - .HasColumnType("int"); + b.Property("Uid") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("UserName") .IsRequired() @@ -193,16 +218,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Mikibot.Database.Model.LiveGiftCombo", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); b.Property("Action") .IsRequired() .HasColumnType("longtext"); - b.Property("Bid") - .HasColumnType("int"); + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("ComboId") .IsRequired() @@ -215,6 +243,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("datetime(6)"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + b.Property("GiftName") .IsRequired() .HasColumnType("longtext"); @@ -222,8 +252,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TotalCoin") .HasColumnType("int"); - b.Property("Uid") - .HasColumnType("int"); + b.Property("Uid") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("UserName") .IsRequired() @@ -246,6 +277,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("int"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + b.Property("Bid") .HasColumnType("int"); @@ -257,6 +290,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("datetime(6)"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + b.Property("EnteredAt") .HasColumnType("datetime(6)"); @@ -277,9 +312,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Mikibot.Database.Model.LiveStatus", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); b.Property("Bid") .IsRequired() @@ -293,6 +330,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("datetime(6)"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + b.Property("FollowerCount") .HasColumnType("int"); @@ -327,12 +366,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Mikibot.Database.Model.LiveStreamRecord", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("bigint"); - b.Property("Bid") - .HasColumnType("int"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("CreatedAt") .HasColumnType("datetime(6)"); @@ -359,17 +401,22 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Mikibot.Database.Model.LiveSuperChat", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("bigint"); - b.Property("Bid") - .HasColumnType("int"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("datetime(6)"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + b.Property("MedalGuardLevel") .HasColumnType("int"); @@ -380,8 +427,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("longtext"); - b.Property("MedalUserId") - .HasColumnType("int"); + b.Property("MedalUserId") + .IsRequired() + .HasColumnType("longtext"); b.Property("Message") .IsRequired() @@ -393,8 +441,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SentAt") .HasColumnType("datetime(6)"); - b.Property("Uid") - .HasColumnType("int"); + b.Property("Uid") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("UserName") .IsRequired() @@ -409,19 +458,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Mikibot.Database.Model.LiveUserInteractiveLog", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("bigint"); - b.Property("Bid") - .HasColumnType("int"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("datetime(6)"); - b.Property("FansTagUserId") - .HasColumnType("int"); + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CreatedAt")); + + b.Property("FansTagUserId") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("GuardLevel") .HasColumnType("int"); @@ -436,8 +491,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("longtext"); - b.Property("UserId") - .HasColumnType("int"); + b.Property("UserId") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("UserName") .IsRequired() @@ -456,9 +512,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Mikibot.Database.Model.StatisticReportLog", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); b.Property("Bid") .IsRequired() @@ -477,6 +535,82 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("StatisticReportLogs"); }); + + modelBuilder.Entity("Mikibot.Database.Model.SubscriptionFansTrends", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("GroupId") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TargetFansCount") + .HasColumnType("int"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("SubscriptionFansTrends"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.SubscriptionLiveStart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("EnabledFansTrendingStatistics") + .HasColumnType("tinyint(1)"); + + b.Property("GroupId") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RoomId") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("SubscriptionLiveStarts"); + }); + + modelBuilder.Entity("Mikibot.Database.Model.VoxList", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("Id")); + + b.Property("Bid") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Id"); + + b.ToTable("暗杀名单", (string)null); + }); #pragma warning restore 612, 618 } } diff --git a/Mikibot.Database/Mikibot.Database.csproj b/Mikibot.Database/Mikibot.Database.csproj index 19c7193..6a3f266 100644 --- a/Mikibot.Database/Mikibot.Database.csproj +++ b/Mikibot.Database/Mikibot.Database.csproj @@ -12,7 +12,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + \ No newline at end of file diff --git a/Mikibot.Database/MikibotDatabaseContext.cs b/Mikibot.Database/MikibotDatabaseContext.cs index 50e0118..161e57f 100644 --- a/Mikibot.Database/MikibotDatabaseContext.cs +++ b/Mikibot.Database/MikibotDatabaseContext.cs @@ -6,6 +6,8 @@ namespace Mikibot.Database; public class MikibotDatabaseContext : DbContext { + public MikibotDatabaseContext(DbContextOptions options) : base(options) {} + public MikibotDatabaseContext(MySqlConfiguration mySqlConfiguration) { MySqlConfiguration = mySqlConfiguration; diff --git a/Mikibot.Database/MikibotDatabaseDesignTimeFactory.cs b/Mikibot.Database/MikibotDatabaseDesignTimeFactory.cs index 7a960ee..80fcf8e 100644 --- a/Mikibot.Database/MikibotDatabaseDesignTimeFactory.cs +++ b/Mikibot.Database/MikibotDatabaseDesignTimeFactory.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore.Design; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; namespace Mikibot.Database; @@ -8,10 +9,11 @@ public MikibotDatabaseContext CreateDbContext(string[] args) { return new MikibotDatabaseContext(new MySqlConfiguration() { - Host = "localhost", + Host = "192.168.31.75", Database = "mikibot", Port = 3306, - User = "root", + User = "zero_apps", + Password = "1", }); } } \ No newline at end of file diff --git a/Mikibot.sln.DotSettings b/Mikibot.sln.DotSettings index 1d77cae..b6b517d 100644 --- a/Mikibot.sln.DotSettings +++ b/Mikibot.sln.DotSettings @@ -1,3 +1,4 @@  True + True True \ No newline at end of file