feat: 精简模板代码

This commit is contained in:
ccnetcore
2026-01-10 17:11:37 +08:00
parent 05b81b710f
commit 699fc54885
402 changed files with 75 additions and 16599 deletions

View File

@@ -3,8 +3,6 @@
<ItemGroup>
<ProjectReference Include="..\..\framework\Yi.Framework.Ddd.Application.Contracts\Yi.Framework.Ddd.Application.Contracts.csproj" />
<ProjectReference Include="..\..\module\bbs\Yi.Framework.Bbs.Application.Contracts\Yi.Framework.Bbs.Application.Contracts.csproj" />
<ProjectReference Include="..\..\module\chat-hub\Yi.Framework.ChatHub.Application.Contracts\Yi.Framework.ChatHub.Application.Contracts.csproj" />
<ProjectReference Include="..\..\module\rbac\Yi.Framework.Rbac.Application.Contracts\Yi.Framework.Rbac.Application.Contracts.csproj" />
<ProjectReference Include="..\..\module\tenant-management\Yi.Framework.TenantManagement.Application.Contracts\Yi.Framework.TenantManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\Yi.Abp.Domain.Shared\Yi.Abp.Domain.Shared.csproj" />

View File

@@ -1,7 +1,5 @@
using Volo.Abp.SettingManagement;
using Yi.Abp.Domain.Shared;
using Yi.Framework.Bbs.Application.Contracts;
using Yi.Framework.ChatHub.Application.Contracts;
using Yi.Framework.Ddd.Application.Contracts;
using Yi.Framework.Rbac.Application.Contracts;
using Yi.Framework.TenantManagement.Application.Contracts;
@@ -12,8 +10,6 @@ namespace Yi.Abp.Application.Contracts
typeof(YiAbpDomainSharedModule),
typeof(YiFrameworkRbacApplicationContractsModule),
typeof(YiFrameworkBbsApplicationContractsModule),
typeof(YiFrameworkChatHubApplicationContractsModule),
typeof(AbpSettingManagementApplicationContractsModule),
typeof(YiFrameworkTenantManagementApplicationContractsModule),

View File

@@ -1,17 +1,14 @@
using System.Xml.Linq;
using Mapster;
using Mapster;
using Medallion.Threading;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.RateLimiting;
using Volo.Abp.Application.Services;
using Volo.Abp.DistributedLocking;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Settings;
using Volo.Abp.Uow;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Banner;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Rbac.Domain.Authorization;
using Yi.Framework.Rbac.Domain.Entities;
using Yi.Framework.Rbac.Domain.Extensions;
using Yi.Framework.SettingManagement.Domain;
using Yi.Framework.SqlSugarCore.Abstractions;
@@ -23,11 +20,11 @@ namespace Yi.Abp.Application.Services
/// </summary>
public class TestService : ApplicationService
{
/// <summary>
/// 属性注入
/// 不推荐,坑太多,容易把自己玩死,简单的东西可以用一用
/// </summary>
public ISqlSugarRepository<BannerAggregateRoot> sqlSugarRepository { get; set; }
// /// <summary>
// /// 属性注入
// /// 不推荐,坑太多,容易把自己玩死,简单的东西可以用一用
// /// </summary>
public ISqlSugarRepository<ConfigAggregateRoot> sqlSugarRepository { get; set; }
/// <summary>
/// </summary>
@@ -86,11 +83,11 @@ namespace Yi.Abp.Application.Services
//await sqlSugarRepository.InsertAsync(new BannerAggregateRoot { Name = "插入2" });
using (var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
{
await sqlSugarRepository.InsertAsync(new BannerAggregateRoot { Name = "插入1" });
await sqlSugarRepository.InsertAsync(new ConfigAggregateRoot { ConfigKey = "插入1" });
await uow.CompleteAsync();
}
}));
await sqlSugarRepository.InsertAsync(new BannerAggregateRoot { Name = "插入3" });
await sqlSugarRepository.InsertAsync(new ConfigAggregateRoot { ConfigKey = "插入3" });
i--;
}
@@ -136,8 +133,8 @@ namespace Yi.Abp.Application.Services
public void GetMapper()
{
//直接无脑Adapt无需配置
var entity = new BannerAggregateRoot();
var dto = entity.Adapt<BannerGetListOutputDto>();
var entity = new ConfigAggregateRoot();
var dto = entity.Adapt<ConfigAggregateRoot>();
}
private static int RequestNumber { get; set; } = 0;
@@ -218,7 +215,7 @@ namespace Yi.Abp.Application.Services
}
public ICurrentTenant CurrentTenant { get; set; }
public IRepository<BannerAggregateRoot> repository { get; set; }
public IRepository<ConfigAggregateRoot> repository { get; set; }
/// <summary>
/// 多租户
/// </summary>
@@ -232,31 +229,31 @@ namespace Yi.Abp.Application.Services
using (CurrentTenant.Change(null,"Default"))
{
var defautTenantData2= await repository.GetListAsync();
await repository.InsertAsync(new BannerAggregateRoot
await repository.InsertAsync(new ConfigAggregateRoot
{
Name = "default",
ConfigKey = "default",
});
var defautTenantData3= await repository.GetListAsync(x=>x.Name=="default");
var defautTenantData3= await repository.GetListAsync(x=>x.ConfigKey=="default");
}
//此处会实例化一个新的db连接MES
using (CurrentTenant.Change(null,"Mes"))
{
var otherTenantData1= await repository.GetListAsync();
await repository.InsertAsync(new BannerAggregateRoot
await repository.InsertAsync(new ConfigAggregateRoot
{
Name = "Mes1",
ConfigKey = "Mes1",
});
var otherTenantData2= await repository.GetListAsync(x=>x.Name=="Mes1");
var otherTenantData2= await repository.GetListAsync(x=>x.ConfigKey=="Mes1");
}
//此处会复用Mesdb不会实例化新的db
using (CurrentTenant.Change(Guid.Parse("33333333-3d72-4339-9adc-845151f8ada0")))
{
var otherTenantData1= await repository.GetListAsync();
await repository.InsertAsync(new BannerAggregateRoot
await repository.InsertAsync(new ConfigAggregateRoot
{
Name = "Mes2",
ConfigKey = "Mes2",
});
var otherTenantData2= await repository.GetListAsync(x=>x.Name=="Mes2");
var otherTenantData2= await repository.GetListAsync(x=>x.ConfigKey=="Mes2");
}
//此处会将多库进行一起提交,前面的操作有报错,全部回滚
await uow.CompleteAsync();

View File

@@ -4,13 +4,8 @@
<ItemGroup>
<ProjectReference Include="..\..\framework\Yi.Framework.Ddd.Application\Yi.Framework.Ddd.Application.csproj" />
<ProjectReference Include="..\..\module\bbs\Yi.Framework.Bbs.Application\Yi.Framework.Bbs.Application.csproj" />
<ProjectReference Include="..\..\module\chat-hub\Yi.Framework.ChatHub.Application\Yi.Framework.ChatHub.Application.csproj" />
<ProjectReference Include="..\..\module\code-gen\Yi.Framework.CodeGen.Application\Yi.Framework.CodeGen.Application.csproj" />
<ProjectReference Include="..\..\module\digital-collectibles\Yi.Framework.DigitalCollectibles.Application\Yi.Framework.DigitalCollectibles.Application.csproj" />
<ProjectReference Include="..\..\module\rbac\Yi.Framework.Rbac.Application\Yi.Framework.Rbac.Application.csproj" />
<ProjectReference Include="..\..\module\setting-management\Yi.Framework.SettingManagement.Application\Yi.Framework.SettingManagement.Application.csproj" />
<ProjectReference Include="..\..\module\ai-stock\Yi.Framework.Stock.Application\Yi.Framework.Stock.Application.csproj" />
<ProjectReference Include="..\..\module\tenant-management\Yi.Framework.TenantManagement.Application\Yi.Framework.TenantManagement.Application.csproj" />
<ProjectReference Include="..\Yi.Abp.Application.Contracts\Yi.Abp.Application.Contracts.csproj" />
<ProjectReference Include="..\Yi.Abp.Domain\Yi.Abp.Domain.csproj" />

View File

@@ -1,14 +1,8 @@
using Volo.Abp.SettingManagement;
using Yi.Abp.Application.Contracts;
using Yi.Abp.Application.Contracts;
using Yi.Abp.Domain;
using Yi.Framework.Bbs.Application;
using Yi.Framework.ChatHub.Application;
using Yi.Framework.CodeGen.Application;
using Yi.Framework.Ddd.Application;
using Yi.Framework.DigitalCollectibles.Application;
using Yi.Framework.Rbac.Application;
using Yi.Framework.SettingManagement.Application;
using Yi.Framework.Stock.Application;
using Yi.Framework.TenantManagement.Application;
namespace Yi.Abp.Application
@@ -19,13 +13,8 @@ namespace Yi.Abp.Application
typeof(YiFrameworkRbacApplicationModule),
typeof(YiFrameworkBbsApplicationModule),
typeof(YiFrameworkDigitalCollectiblesApplicationModule),
typeof(YiFrameworkChatHubApplicationModule),
typeof(YiFrameworkStockApplicationModule),
typeof(YiFrameworkTenantManagementApplicationModule),
typeof(YiFrameworkCodeGenApplicationModule),
typeof (YiFrameworkSettingManagementApplicationModule),
typeof(YiFrameworkDddApplicationModule)

View File

@@ -7,8 +7,6 @@
<ItemGroup>
<ProjectReference Include="..\..\module\audit-logging\Yi.Framework.AuditLogging.Domain.Shared\Yi.Framework.AuditLogging.Domain.Shared.csproj" />
<ProjectReference Include="..\..\module\bbs\Yi.Framework.Bbs.Domain.Shared\Yi.Framework.Bbs.Domain.Shared.csproj" />
<ProjectReference Include="..\..\module\chat-hub\Yi.Framework.ChatHub.Domain.Shared\Yi.Framework.ChatHub.Domain.Shared.csproj" />
<ProjectReference Include="..\..\module\rbac\Yi.Framework.Rbac.Domain.Shared\Yi.Framework.Rbac.Domain.Shared.csproj" />
</ItemGroup>

View File

@@ -1,16 +1,12 @@
using Volo.Abp.Domain;
using Volo.Abp.SettingManagement;
using Yi.Framework.AuditLogging.Domain.Shared;
using Yi.Framework.Bbs.Domain.Shared;
using Yi.Framework.ChatHub.Domain.Shared;
using Yi.Framework.Rbac.Domain.Shared;
namespace Yi.Abp.Domain.Shared
{
[DependsOn(
typeof(YiFrameworkRbacDomainSharedModule),
typeof(YiFrameworkBbsDomainSharedModule),
typeof(YiFrameworkChatHubDomainSharedModule),
typeof(YiFrameworkAuditLoggingDomainSharedModule),
typeof(AbpSettingManagementDomainSharedModule),

View File

@@ -10,8 +10,6 @@
<ProjectReference Include="..\..\framework\Yi.Framework.Mapster\Yi.Framework.Mapster.csproj" />
<ProjectReference Include="..\..\framework\Yi.Framework.SqlSugarCore.Abstractions\Yi.Framework.SqlSugarCore.Abstractions.csproj" />
<ProjectReference Include="..\..\module\audit-logging\Yi.Framework.AuditLogging.Domain\Yi.Framework.AuditLogging.Domain.csproj" />
<ProjectReference Include="..\..\module\bbs\Yi.Framework.Bbs.Domain\Yi.Framework.Bbs.Domain.csproj" />
<ProjectReference Include="..\..\module\chat-hub\Yi.Framework.ChatHub.Domain\Yi.Framework.ChatHub.Domain.csproj" />
<ProjectReference Include="..\..\module\rbac\Yi.Framework.Rbac.Domain\Yi.Framework.Rbac.Domain.csproj" />
<ProjectReference Include="..\..\module\setting-management\Yi.Framework.SettingManagement.Domain\Yi.Framework.SettingManagement.Domain.csproj" />
<ProjectReference Include="..\..\module\tenant-management\Yi.Framework.TenantManagement.Domain\Yi.Framework.TenantManagement.Domain.csproj" />

View File

@@ -1,10 +1,7 @@
using Volo.Abp.Caching;
using Volo.Abp.Domain;
using Volo.Abp.Modularity;
using Yi.Abp.Domain.Shared;
using Yi.Framework.AuditLogging.Domain;
using Yi.Framework.Bbs.Domain;
using Yi.Framework.ChatHub.Domain;
using Yi.Framework.Mapster;
using Yi.Framework.Rbac.Domain;
using Yi.Framework.SettingManagement.Domain;
@@ -17,8 +14,6 @@ namespace Yi.Abp.Domain
typeof(YiFrameworkTenantManagementDomainModule),
typeof(YiFrameworkRbacDomainModule),
typeof(YiFrameworkBbsDomainModule),
typeof(YiFrameworkChatHubDomainModule),
typeof(YiFrameworkAuditLoggingDomainModule),
typeof(YiFrameworkSettingManagementDomainModule),

View File

@@ -5,10 +5,6 @@
<ProjectReference Include="..\..\framework\Yi.Framework.Mapster\Yi.Framework.Mapster.csproj" />
<ProjectReference Include="..\..\framework\Yi.Framework.SqlSugarCore\Yi.Framework.SqlSugarCore.csproj" />
<ProjectReference Include="..\..\module\audit-logging\Yi.Framework.AuditLogging.SqlSugarCore\Yi.Framework.AuditLogging.SqlSugarCore.csproj" />
<ProjectReference Include="..\..\module\bbs\Yi.Framework.Bbs.SqlSugarCore\Yi.Framework.Bbs.SqlSugarCore.csproj" />
<ProjectReference Include="..\..\module\chat-hub\Yi.Framework.ChatHub.SqlSugarCore\Yi.Framework.ChatHub.SqlSugarCore.csproj" />
<ProjectReference Include="..\..\module\code-gen\Yi.Framework.CodeGen.SqlSugarCore\Yi.Framework.CodeGen.SqlSugarCore.csproj" />
<ProjectReference Include="..\..\module\digital-collectibles\Yi.Framework.DigitalCollectibles.SqlSugarCore\Yi.Framework.DigitalCollectibles.SqlSugarCore.csproj" />
<ProjectReference Include="..\..\module\rbac\Yi.Framework.Rbac.SqlSugarCore\Yi.Framework.Rbac.SqlSugarCore.csproj" />
<ProjectReference Include="..\..\module\setting-management\Yi.Framework.SettingManagement.SqlSugarCore\Yi.Framework.SettingManagement.SqlSugarCore.csproj" />
<ProjectReference Include="..\..\module\ai-stock\Yi.Framework.Stock.SqlSugarCore\Yi.Framework.Stock.SqlSugarCore.csproj" />

View File

@@ -1,18 +1,10 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
using Yi.Abp.Domain;
using Yi.Abp.Domain;
using Yi.Abp.SqlSugarCore;
using Yi.Framework.AuditLogging.SqlSugarCore;
using Yi.Framework.Bbs.SqlSugarCore;
using Yi.Framework.ChatHub.SqlSugarCore;
using Yi.Framework.CodeGen.SqlSugarCore;
using Yi.Framework.DigitalCollectibles.SqlsugarCore;
using Yi.Framework.Mapster;
using Yi.Framework.Rbac.SqlSugarCore;
using Yi.Framework.SettingManagement.SqlSugarCore;
using Yi.Framework.SqlSugarCore;
using Yi.Framework.SqlSugarCore.Abstractions;
using Yi.Framework.Stock.SqlsugarCore;
using Yi.Framework.TenantManagement.SqlSugarCore;
namespace Yi.Abp.SqlsugarCore
@@ -20,11 +12,6 @@ namespace Yi.Abp.SqlsugarCore
[DependsOn(
typeof(YiAbpDomainModule),
typeof(YiFrameworkRbacSqlSugarCoreModule),
typeof(YiFrameworkDigitalCollectiblesSqlSugarCoreModule),
typeof(YiFrameworkBbsSqlSugarCoreModule),
typeof(YiFrameworkCodeGenSqlSugarCoreModule),
typeof(YiFrameworkChatHubSqlSugarCoreModule),
typeof(YiFrameworkStockSqlSugarCoreModule),
typeof(YiFrameworkSettingManagementSqlSugarCoreModule),
typeof(YiFrameworkAuditLoggingSqlSugarCoreModule),
typeof(YiFrameworkTenantManagementSqlSugarCoreModule),

View File

@@ -1,34 +0,0 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.BackgroundWorkers.Hangfire;
using Yi.Framework.Stock.Domain.Managers;
namespace Yi.Abp.Web.Jobs.ai_stock
{
public class GenerateNewsJob : HangfireBackgroundWorkerBase
{
private NewsManager _newsManager;
public GenerateNewsJob(NewsManager newsManager)
{
_newsManager = newsManager;
RecurringJobId = "AI股票新闻生成";
//每个小时整点执行一次
CronExpression = "0 0 * * * ?";
}
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
{
// 每次触发只有2/24的概率执行生成新闻
var random = new Random();
var probability = random.Next(0, 24);
if (probability < 2)
{
await _newsManager.GenerateNewsAsync();
}
}
}
}

View File

@@ -1,26 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.BackgroundWorkers.Hangfire;
using Yi.Framework.Stock.Domain.Managers;
namespace Yi.Abp.Web.Jobs.ai_stock
{
public class GenerateStockPricesJob : HangfireBackgroundWorkerBase
{
private readonly StockMarketManager _stockMarketManager;
public GenerateStockPricesJob(StockMarketManager stockMarketManager)
{
_stockMarketManager = stockMarketManager;
RecurringJobId = "AI股票价格生成";
//每天凌晨1点执行一次
CronExpression = "0 0 1 * * ?";
}
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
{
await _stockMarketManager.GenerateStocksAsync();
}
}
}

View File

@@ -1,31 +0,0 @@
using Volo.Abp.BackgroundWorkers.Hangfire;
using Volo.Abp.EventBus.Local;
using Yi.Framework.Bbs.Domain.Shared.Etos;
namespace Yi.Abp.Web.Jobs.bbs;
public class AccessLogCacheJob : HangfireBackgroundWorkerBase
{
private readonly ILocalEventBus _localEventBus;
public AccessLogCacheJob(ILocalEventBus localEventBus)
{
_localEventBus = localEventBus;
RecurringJobId = "访问日志写入缓存";
//每分钟执行一次将本地缓存转入redis防止丢数据
CronExpression = "0 * * * * ?";
//
// JobDetail = JobBuilder.Create<AccessLogCacheJob>().WithIdentity(nameof(AccessLogCacheJob))
// .Build();
//每10秒执行一次将本地缓存转入redis防止丢数据
// Trigger = TriggerBuilder.Create().WithIdentity(nameof(AccessLogCacheJob))
// .WithSimpleSchedule((schedule) => { schedule.WithInterval(TimeSpan.FromSeconds(10)).RepeatForever();; })
// .Build();
}
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
{
await _localEventBus.PublishAsync(new AccessLogResetArgs());
}
}

View File

@@ -1,89 +0,0 @@
using FreeRedis;
using Microsoft.Extensions.Options;
using Volo.Abp.BackgroundWorkers.Hangfire;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Shared.Caches;
using Yi.Framework.Bbs.Domain.Shared.Enums;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Abp.Web.Jobs.bbs;
public class AccessLogStoreJob : HangfireBackgroundWorkerBase
{
private readonly ISqlSugarRepository<AccessLogAggregateRoot> _repository;
/// <summary>
/// 缓存前缀
/// </summary>
private string CacheKeyPrefix => LazyServiceProvider.LazyGetRequiredService<IOptions<AbpDistributedCacheOptions>>()
.Value.KeyPrefix;
/// <summary>
/// 使用懒加载防止报错
/// </summary>
private IRedisClient RedisClient => LazyServiceProvider.LazyGetRequiredService<IRedisClient>();
/// <summary>
/// 属性注入
/// </summary>
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
private bool EnableRedisCache
{
get
{
var redisEnabled = LazyServiceProvider.LazyGetRequiredService<IConfiguration>()["Redis:IsEnabled"];
return redisEnabled.IsNullOrEmpty() || bool.Parse(redisEnabled);
}
}
public AccessLogStoreJob(ISqlSugarRepository<AccessLogAggregateRoot> repository)
{
_repository = repository;
RecurringJobId = "访问日志写入数据库";
//每小时执行一次
CronExpression = "0 0 * * * ?";
// JobDetail = JobBuilder.Create<AccessLogStoreJob>().WithIdentity(nameof(AccessLogStoreJob))
// .Build();
// //每分钟执行一次
// Trigger = TriggerBuilder.Create().WithIdentity(nameof(AccessLogStoreJob))
// .WithCronSchedule("0 * * * * ?")
// .Build();
}
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
{
if (EnableRedisCache)
{
//当天的访问量
var number =
await RedisClient.GetAsync<long>($"{CacheKeyPrefix}{AccessLogCacheConst.Key}:{DateTime.Now.Date:yyyyMMdd}");
var entity = await _repository._DbQueryable.Where(x => x.AccessLogType == AccessLogTypeEnum.Request)
.Where(x => x.CreationTime.Date == DateTime.Today)
.FirstAsync();
if (entity is not null)
{
entity.Number = number+1;
await _repository.UpdateAsync(entity);
}
else
{
await _repository.InsertAsync((new AccessLogAggregateRoot() { Number = number,AccessLogType = AccessLogTypeEnum.Request}));
}
//删除前一天的缓存
await RedisClient.DelAsync($"{CacheKeyPrefix}{AccessLogCacheConst.Key}:{DateTime.Now.Date.AddDays(-1):yyyyMMdd}");
}
}
}

View File

@@ -1,31 +0,0 @@
using Volo.Abp.BackgroundWorkers.Hangfire;
using Yi.Framework.Bbs.Domain.Managers;
namespace Yi.Abp.Web.Jobs.bbs;
/// <summary>
/// 每日任务job
/// </summary>
public class AssignmentExpireTimeOutJob : HangfireBackgroundWorkerBase
{
private readonly AssignmentManager _assignmentManager;
public AssignmentExpireTimeOutJob(AssignmentManager assignmentManager)
{
_assignmentManager = assignmentManager;
RecurringJobId = "每日任务系统超时检测";
//每分钟执行一次
CronExpression = "0 * * * * ?";
//
// JobDetail = JobBuilder.Create<AssignmentExpireTimeOutJob>().WithIdentity(nameof(AssignmentExpireTimeOutJob)).Build();
// //每个小时整点执行一次
// Trigger = TriggerBuilder.Create().WithIdentity(nameof(AssignmentExpireTimeOutJob)).WithCronSchedule("0 0 * * * ?")
// .Build();
}
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
{
await _assignmentManager.ExpireTimeoutAsync();
}
}

View File

@@ -1,37 +0,0 @@
using Volo.Abp.BackgroundWorkers.Hangfire;
using Yi.Framework.Bbs.Domain.Managers;
namespace Yi.Abp.Web.Jobs.bbs
{
public class InterestRecordsJob : HangfireBackgroundWorkerBase
{
private BankManager _bankManager;
public InterestRecordsJob(BankManager bankManager)
{
_bankManager = bankManager;
RecurringJobId = "银行利息积分刷新";
//每个小时整点执行一次
CronExpression = "0 0 * * * ?";
// JobDetail = JobBuilder.Create<InterestRecordsJob>().WithIdentity(nameof(InterestRecordsJob)).Build();
//
// //每个小时整点执行一次
//
// Trigger = TriggerBuilder.Create().WithIdentity(nameof(InterestRecordsJob)).WithCronSchedule("0 0 * * * ?").Build();
//测试
// Trigger = TriggerBuilder.Create().WithIdentity(nameof(InterestRecordsJob))
//.WithSimpleSchedule(x => x
// .WithIntervalInSeconds(10)
// .RepeatForever())
//.Build();
}
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
{
//创建一个记录,莫得了
await _bankManager.GetCurrentInterestRate();
}
}
}

View File

@@ -1,37 +0,0 @@
using Volo.Abp.BackgroundWorkers.Hangfire;
using Yi.Framework.DigitalCollectibles.Domain.Managers;
namespace Yi.Abp.Web.Jobs.digital_collectibles;
/// <summary>
/// 自动下架商品
/// </summary>
public class AutoPassInGoodsJob: HangfireBackgroundWorkerBase
{
private readonly MarketManager _marketManager;
private readonly ILogger<AutoPassInGoodsJob> _logger;
public AutoPassInGoodsJob(MarketManager marketManager, ILogger<AutoPassInGoodsJob> logger)
{
_marketManager = marketManager;
_logger = logger;
RecurringJobId = "交易市场自动流拍";
//每小时,第10分钟执行一次
CronExpression = "0 10 * * * ?";
//
// JobDetail = JobBuilder.Create<AutoPassInGoodsJob>().WithIdentity(nameof(AutoPassInGoodsJob))
// .Build();
//
// //每小时,第10分钟执行一次
// Trigger = TriggerBuilder.Create().WithIdentity(nameof(AutoPassInGoodsJob))
// // .WithSimpleSchedule((builer) =>
// // {
// // builer.WithIntervalInHours(10);
// // })
// // .StartNow()
// .WithCronSchedule("0 10 * * * ?")
// .Build();
}
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
{
await _marketManager.AutoPassInGoodsAsync();
}
}

View File

@@ -1,46 +0,0 @@
using Volo.Abp.BackgroundWorkers.Hangfire;
using Yi.Framework.DigitalCollectibles.Domain.Managers;
namespace Yi.Abp.Web.Jobs.digital_collectibles;
/// <summary>
/// 自动刷新填满矿池
/// </summary>
public class AutoRefreshMiningPoolJob : HangfireBackgroundWorkerBase
{
private readonly MiningPoolManager _miningPoolManager;
public AutoRefreshMiningPoolJob(MiningPoolManager miningPoolManager)
{
_miningPoolManager = miningPoolManager;
RecurringJobId = "刷新矿池和用户限制";
//每天早上10点执行一次
CronExpression = "0 0 10 * * ?";
//
// JobDetail = JobBuilder.Create<AutoRefreshMiningPoolJob>().WithIdentity(nameof(AutoRefreshMiningPoolJob))
// .Build();
//
// //每天早上10点执行一次
// Trigger = TriggerBuilder.Create().WithIdentity(nameof(AutoRefreshMiningPoolJob))
// .WithCronSchedule("0 0 10 * * ?")
// .Build();
//
// Trigger = TriggerBuilder.Create().WithIdentity(nameof(AutoRefreshMiningPoolJob))
// .WithSimpleSchedule((schedule) =>
// {
// schedule.WithInterval(TimeSpan.FromHours(1));
// })
// .StartNow()
// .Build();
}
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
{
//刷新矿池
await _miningPoolManager.RefreshMiningPoolAsync();
//刷新用户限制
await _miningPoolManager.RefreshMiningUserLimitAsync();
}
}

View File

@@ -1,25 +0,0 @@
using Volo.Abp.BackgroundWorkers.Hangfire;
using Yi.Framework.DigitalCollectibles.Domain.Managers;
namespace Yi.Abp.Web.Jobs.digital_collectibles;
/// <summary>
/// 自动更新藏品价值
/// </summary>
public class AutoUpdateCollectiblesValueJob : HangfireBackgroundWorkerBase
{
private readonly CollectiblesManager _collectiblesManager;
public AutoUpdateCollectiblesValueJob(CollectiblesManager collectiblesManager)
{
_collectiblesManager = collectiblesManager;
RecurringJobId = "更新藏品价值";
//每天早上9点执行一次
CronExpression = "0 0 9 * * ?";
}
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
{
await _collectiblesManager.UpdateAllValueAsync();
}
}

View File

@@ -1,36 +0,0 @@
using Volo.Abp.BackgroundWorkers.Hangfire;
using Yi.Framework.DigitalCollectibles.Domain.Managers;
namespace Yi.Abp.Web.Jobs.digital_collectibles;
/// <summary>
/// 处理挂机挖矿定时任务
/// </summary>
public class OnHookAutoMiningJob : HangfireBackgroundWorkerBase
{
private readonly MiningPoolManager _miningPoolManager;
private readonly ILogger<OnHookAutoMiningJob> _logger;
public OnHookAutoMiningJob(MiningPoolManager miningPoolManager, ILogger<OnHookAutoMiningJob> logger)
{
_miningPoolManager = miningPoolManager;
_logger = logger;
RecurringJobId = "自动挂机挖矿";
//每小时执行一次
CronExpression = "0 0 * * * ?";
//
// JobDetail = JobBuilder.Create<OnHookAutoMiningJob>().WithIdentity(nameof(OnHookAutoMiningJob))
// .Build();
//
// //每小时执行一次
// Trigger = TriggerBuilder.Create().WithIdentity(nameof(OnHookAutoMiningJob))
// // .WithCronSchedule("10 * * * * ?")
// .WithCronSchedule("0 0 * * * ?")
// .Build();
}
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
{
await _miningPoolManager.OnHookMiningAsync();
}
}

View File

@@ -9,10 +9,7 @@ using Hangfire.Redis.StackExchange;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using StackExchange.Redis;
@@ -23,10 +20,8 @@ using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.AspNetCore.VirtualFileSystem;
using Volo.Abp.Auditing;
using Volo.Abp.Autofac;
using Volo.Abp.BackgroundJobs.Hangfire;
using Volo.Abp.BackgroundWorkers;
using Volo.Abp.Caching;
using Volo.Abp.MultiTenancy;
@@ -41,17 +36,11 @@ using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder;
using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection;
using Yi.Framework.AspNetCore.UnifyResult;
using Yi.Framework.BackgroundWorkers.Hangfire;
using Yi.Framework.Bbs.Application;
using Yi.Framework.Bbs.Application.Extensions;
using Yi.Framework.ChatHub.Application;
using Yi.Framework.CodeGen.Application;
using Yi.Framework.Core.Json;
using Yi.Framework.DigitalCollectibles.Application;
using Yi.Framework.Rbac.Application;
using Yi.Framework.Rbac.Domain.Authorization;
using Yi.Framework.Rbac.Domain.Shared.Consts;
using Yi.Framework.Rbac.Domain.Shared.Options;
using Yi.Framework.Stock.Application;
using Yi.Framework.TenantManagement.Application;
namespace Yi.Abp.Web
@@ -85,18 +74,8 @@ namespace Yi.Abp.Web
options => options.RemoteServiceName = "default");
options.ConventionalControllers.Create(typeof(YiFrameworkRbacApplicationModule).Assembly,
options => options.RemoteServiceName = "rbac");
options.ConventionalControllers.Create(typeof(YiFrameworkBbsApplicationModule).Assembly,
options => options.RemoteServiceName = "bbs");
options.ConventionalControllers.Create(typeof(YiFrameworkChatHubApplicationModule).Assembly,
options => options.RemoteServiceName = "chat-hub");
options.ConventionalControllers.Create(typeof(YiFrameworkTenantManagementApplicationModule).Assembly,
options => options.RemoteServiceName = "tenant-management");
options.ConventionalControllers.Create(typeof(YiFrameworkCodeGenApplicationModule).Assembly,
options => options.RemoteServiceName = "code-gen");
options.ConventionalControllers.Create(typeof(YiFrameworkDigitalCollectiblesApplicationModule).Assembly,
options => options.RemoteServiceName = "digital-collectibles");
options.ConventionalControllers.Create(typeof(YiFrameworkStockApplicationModule).Assembly,
options => options.RemoteServiceName = "ai-stock");
//统一前缀
options.ConventionalControllers.ConventionalControllerSettings.ForEach(x => x.RootPath = "api/app");
});
@@ -374,10 +353,7 @@ namespace Yi.Abp.Web
//swagger
app.UseYiSwagger();
//流量访问统计,需redis支持否则不生效
app.UseAccessLog();
//请求处理
app.UseApiInfoHandling();