From 3c6ccba74fbcbe68212c82cff859fb809a6ea76a Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 5 Feb 2026 16:13:57 +0800 Subject: [PATCH] :recycle: Move the lotteries logic to the wallet service --- DysonNetwork.Pass/Startup/ScheduledJobsConfiguration.cs | 6 ------ DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs | 2 -- DysonNetwork.Wallet/AppDatabase.cs | 3 +-- .../Lotteries/LotteryController.cs | 3 +-- .../Lotteries/LotteryDrawJob.cs | 2 +- .../Lotteries/LotteryService.cs | 3 +-- DysonNetwork.Wallet/Startup/ScheduledJobsConfiguration.cs | 8 ++++++++ .../Startup/ServiceCollectionExtensions.cs | 2 ++ 8 files changed, 14 insertions(+), 15 deletions(-) rename {DysonNetwork.Pass => DysonNetwork.Wallet}/Lotteries/LotteryController.cs (96%) rename {DysonNetwork.Pass => DysonNetwork.Wallet}/Lotteries/LotteryDrawJob.cs (93%) rename {DysonNetwork.Pass => DysonNetwork.Wallet}/Lotteries/LotteryService.cs (98%) diff --git a/DysonNetwork.Pass/Startup/ScheduledJobsConfiguration.cs b/DysonNetwork.Pass/Startup/ScheduledJobsConfiguration.cs index e1b4b85a..0de465eb 100644 --- a/DysonNetwork.Pass/Startup/ScheduledJobsConfiguration.cs +++ b/DysonNetwork.Pass/Startup/ScheduledJobsConfiguration.cs @@ -36,12 +36,6 @@ public static class ScheduledJobsConfiguration .RepeatForever()) ); - q.AddJob(opts => opts.WithIdentity("LotteryDraw")); - q.AddTrigger(opts => opts - .ForJob("LotteryDraw") - .WithIdentity("LotteryDrawTrigger") - .WithCronSchedule("0 0 0 * * ?")); - q.AddJob(opts => opts.WithIdentity("SocialCreditValidation")); q.AddTrigger(opts => opts .ForJob("SocialCreditValidation") diff --git a/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs b/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs index 2208e2e5..9facdb98 100644 --- a/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs +++ b/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs @@ -16,7 +16,6 @@ using DysonNetwork.Pass.Auth.OidcProvider.Services; using DysonNetwork.Pass.Credit; using DysonNetwork.Pass.Handlers; using DysonNetwork.Pass.Leveling; -using DysonNetwork.Pass.Lotteries; using DysonNetwork.Pass.Mailer; using DysonNetwork.Pass.Realm; using DysonNetwork.Pass.Rewind; @@ -165,7 +164,6 @@ public static class ServiceCollectionExtensions services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/DysonNetwork.Wallet/AppDatabase.cs b/DysonNetwork.Wallet/AppDatabase.cs index 17cce1a9..106873e2 100644 --- a/DysonNetwork.Wallet/AppDatabase.cs +++ b/DysonNetwork.Wallet/AppDatabase.cs @@ -50,7 +50,7 @@ public class AppDatabase( protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); - + modelBuilder.ApplySoftDeleteFilters(); } @@ -121,4 +121,3 @@ public class AppDatabaseFactory : IDesignTimeDbContextFactory return new AppDatabase(optionsBuilder.Options, configuration); } } - diff --git a/DysonNetwork.Pass/Lotteries/LotteryController.cs b/DysonNetwork.Wallet/Lotteries/LotteryController.cs similarity index 96% rename from DysonNetwork.Pass/Lotteries/LotteryController.cs rename to DysonNetwork.Wallet/Lotteries/LotteryController.cs index 44278c81..a187b4eb 100644 --- a/DysonNetwork.Pass/Lotteries/LotteryController.cs +++ b/DysonNetwork.Wallet/Lotteries/LotteryController.cs @@ -1,13 +1,12 @@ using System.ComponentModel.DataAnnotations; using DysonNetwork.Shared.Models; -using DysonNetwork.Pass.Permission; using DysonNetwork.Shared.Auth; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using NodaTime; -namespace DysonNetwork.Pass.Lotteries; +namespace DysonNetwork.Wallet.Lotteries; [ApiController] [Route("/api/lotteries")] diff --git a/DysonNetwork.Pass/Lotteries/LotteryDrawJob.cs b/DysonNetwork.Wallet/Lotteries/LotteryDrawJob.cs similarity index 93% rename from DysonNetwork.Pass/Lotteries/LotteryDrawJob.cs rename to DysonNetwork.Wallet/Lotteries/LotteryDrawJob.cs index c300ebc0..77cba59e 100644 --- a/DysonNetwork.Pass/Lotteries/LotteryDrawJob.cs +++ b/DysonNetwork.Wallet/Lotteries/LotteryDrawJob.cs @@ -1,6 +1,6 @@ using Quartz; -namespace DysonNetwork.Pass.Lotteries; +namespace DysonNetwork.Wallet.Lotteries; public class LotteryDrawJob(LotteryService lotteryService, ILogger logger) : IJob { diff --git a/DysonNetwork.Pass/Lotteries/LotteryService.cs b/DysonNetwork.Wallet/Lotteries/LotteryService.cs similarity index 98% rename from DysonNetwork.Pass/Lotteries/LotteryService.cs rename to DysonNetwork.Wallet/Lotteries/LotteryService.cs index c2217e07..903025e4 100644 --- a/DysonNetwork.Pass/Lotteries/LotteryService.cs +++ b/DysonNetwork.Wallet/Lotteries/LotteryService.cs @@ -1,9 +1,8 @@ using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; using NodaTime; -namespace DysonNetwork.Pass.Lotteries; +namespace DysonNetwork.Wallet.Lotteries; public class LotteryOrderMetaData { diff --git a/DysonNetwork.Wallet/Startup/ScheduledJobsConfiguration.cs b/DysonNetwork.Wallet/Startup/ScheduledJobsConfiguration.cs index ba1a5cd1..f734da9a 100644 --- a/DysonNetwork.Wallet/Startup/ScheduledJobsConfiguration.cs +++ b/DysonNetwork.Wallet/Startup/ScheduledJobsConfiguration.cs @@ -40,8 +40,16 @@ public static class ScheduledJobsConfiguration .WithSimpleSchedule(o => o .WithIntervalInHours(1) .RepeatForever()) + ); + + q.AddJob(opts => opts.WithIdentity("LotteryDraw")); + q.AddTrigger(opts => opts + .ForJob("LotteryDraw") + .WithIdentity("LotteryDrawTrigger") + .WithCronSchedule("0 0 0 * * ?")); }); + services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true); return services; diff --git a/DysonNetwork.Wallet/Startup/ServiceCollectionExtensions.cs b/DysonNetwork.Wallet/Startup/ServiceCollectionExtensions.cs index b0dd9153..5b714012 100644 --- a/DysonNetwork.Wallet/Startup/ServiceCollectionExtensions.cs +++ b/DysonNetwork.Wallet/Startup/ServiceCollectionExtensions.cs @@ -10,6 +10,7 @@ using DysonNetwork.Shared.Registry; using DysonNetwork.Wallet.Localization; using DysonNetwork.Wallet.Payment; using DysonNetwork.Wallet.Payment.PaymentHandlers; +using DysonNetwork.Wallet.Lotteries; namespace DysonNetwork.Wallet.Startup; @@ -101,6 +102,7 @@ public static class ServiceCollectionExtensions services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddHostedService();