From 4521212a90d69dfdf2fdbe2eacd9e870364ade1c Mon Sep 17 00:00:00 2001 From: chenchun Date: Thu, 6 Nov 2025 11:29:21 +0800 Subject: [PATCH 01/23] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=BC=93=E5=AD=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 Yi.Framework.Rbac.Application.Services.FileService 中注入 IMemoryCache,用于缓存文件元数据,减少对仓储的重复读取。 - 在 Get 方法中通过 key "File:{code}" 缓存 FileCacheItem,设置绝对过期时间为 1 天。 - 缓存项使用 Mapster 适配为 FileCacheItem,再适配回 FileAggregateRoot(保留现有逻辑判断和路径获取)。 - 新增缓存模型 Yi.Framework.Rbac.Domain.Shared.Caches.FileCacheItem(包含 Id、FileSize、FileName、FilePath、创建/修改信息等)。 - 增加并调整相关 using 引用(Microsoft.Extensions.Caching.Memory、Volo.Abp.Caching、Domain.Shared.Caches)。 - 同时修复了保存多文件时的缩进/空格格式(不影响功能)。 --- .../Services/FileService.cs | 27 ++++++++++++----- .../Caches/FileCacheItem.cs | 29 +++++++++++++++++++ 2 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Caches/FileCacheItem.cs diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/FileService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/FileService.cs index 90d6b5ef..7a67e6ae 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/FileService.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/FileService.cs @@ -6,8 +6,10 @@ using System.Threading.Tasks; using Mapster; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Caching.Memory; using Volo.Abp; using Volo.Abp.Application.Services; +using Volo.Abp.Caching; using Volo.Abp.Domain.Repositories; using Volo.Abp.Guids; using Yi.Framework.Core.Enums; @@ -16,6 +18,7 @@ using Yi.Framework.Rbac.Application.Contracts.Dtos.FileManager; using Yi.Framework.Rbac.Application.Contracts.IServices; using Yi.Framework.Rbac.Domain.Entities; using Yi.Framework.Rbac.Domain.Managers; +using Yi.Framework.Rbac.Domain.Shared.Caches; namespace Yi.Framework.Rbac.Application.Services { @@ -23,11 +26,13 @@ namespace Yi.Framework.Rbac.Application.Services { private readonly IRepository _repository; private readonly FileManager _fileManager; + private readonly IMemoryCache _memoryCache; - public FileService(IRepository repository, FileManager fileManager) + public FileService(IRepository repository, FileManager fileManager, IMemoryCache memoryCache) { _repository = repository; _fileManager = fileManager; + _memoryCache = memoryCache; } /// @@ -37,7 +42,14 @@ namespace Yi.Framework.Rbac.Application.Services [Route("file/{code}/{isThumbnail?}")] public async Task Get([FromRoute] Guid code, [FromRoute] bool? isThumbnail) { - var file = await _repository.GetAsync(x => x.Id == code); + var fileCache = await _memoryCache.GetOrCreateAsync($"File:{code}", async (options) => + { + options.AbsoluteExpiration = DateTime.Now.AddDays(1); + var file = await _repository.GetAsync(x => x.Id == code); + if (file == null!) return null; + return file.Adapt(); + }); + var file = fileCache?.Adapt(); var path = file?.GetQueryFileSavePath(isThumbnail); if (path is null || !File.Exists(path)) { @@ -58,12 +70,13 @@ namespace Yi.Framework.Rbac.Application.Services for (int i = 0; i < file.Count; i++) { - var entity= entities[i]; - using (var steam = file[i].OpenReadStream()) - { - await _fileManager.SaveFileAsync(entity,steam); - } + var entity = entities[i]; + using (var steam = file[i].OpenReadStream()) + { + await _fileManager.SaveFileAsync(entity, steam); + } } + return entities.Adapt>(); } } diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Caches/FileCacheItem.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Caches/FileCacheItem.cs new file mode 100644 index 00000000..a8bfe3ab --- /dev/null +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Caches/FileCacheItem.cs @@ -0,0 +1,29 @@ +namespace Yi.Framework.Rbac.Domain.Shared.Caches; + +public class FileCacheItem +{ + public Guid Id { get; set; } + + /// + /// 文件大小 + /// + public decimal FileSize { get; set; } + + /// + /// 文件名 + /// + public string FileName { get; set; } + + /// + /// 文件路径 + /// + public string FilePath { get; set; } + + public DateTime CreationTime { get; set; } + + public Guid? CreatorId { get; set; } + + public Guid? LastModifierId { get; set; } + + public DateTime? LastModificationTime { get; set; } +} \ No newline at end of file From cb49059e84fdbaa918c7d9419675c2904b48145a Mon Sep 17 00:00:00 2001 From: chenchun Date: Fri, 7 Nov 2025 21:31:18 +0800 Subject: [PATCH 02/23] =?UTF-8?q?feat:=20=E7=BF=BB=E7=89=8C=E4=B8=8E?= =?UTF-8?q?=E9=82=80=E8=AF=B7=E7=A0=81=E9=80=BB=E8=BE=91=E9=87=8D=E6=9E=84?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=B8=AD=E5=A5=96=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E4=B8=8E=E5=89=8D7=E6=AC=A1=E4=B8=AD=E5=A5=96=E6=A6=82?= =?UTF-8?q?=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CardFlipTaskAggregateRoot.cs - 用 WinRecords(Dictionary) 替代原先第8/9/10次的各自字段,且以 JSON 存库(SugarColumn IsJson)。 - 构造函数初始化 WinRecords。 - 新增 SetWinReward(int flipCount, long amount) 统一记录中奖。 - CardFlipService.cs - 读取并展示 WinRecords,按翻牌顺序映射中奖信息(不再依赖单独的第8/9/10字段)。 - CardFlipManager.cs - 重构中奖逻辑: - 前7次翻牌改为 50% 概率可中奖,奖励范围 1w–3w(新增配置常量 FREE_*)。 - 统一通过 SetWinReward 记录任意次的中奖金额。 - GenerateRandomReward 根据最小值自动选单位(1w 或 100w)。 - 邀请类型翻牌校验由“仅统计被填写次数”改为“统计本周作为邀请人或被邀请人的邀请记录数量”(双方都计入),并据此判断是否可解锁邀请翻牌次数。 - InviteCodeManager.cs - 使用邀请码时: - 验证规则调整:一个账号只能填写别人的邀请码一次(hasUsedOthersCode 检查)。 - 邀请记录的语义变化:当使用邀请码时,邀请记录同时代表邀请人和被邀请人各增加一次翻牌机会。 - 不再将邀请码标记为单次已用;改为增加 UsedCount(一个邀请码可以被多人使用)。 - 优化日志与提示信息。 - InviteCodeAggregateRoot.cs - 移除 IsUsed、UsedTime、UsedByUserId、MarkAsUsed 等单次使用相关字段/方法。 - 保留 IsUserInvited(被邀请后不能再作为被邀请者使用)和 UsedCount(统计多人使用次数)。 注意事项 - 这是数据结构与业务逻辑的变更,数据库表结构发生变化(新增 WinRecords JSON 字段,移除若干字段)。上线前请准备相应的迁移脚本或数据迁移方案,确保历史中奖数据平滑迁移到 WinRecords。 - 变更会影响相关单元/集成测试、前端展示字段,需同步更新对应测试与界面展示逻辑。 --- .../Services/CardFlipService.cs | 21 ++---- .../Entities/CardFlipTaskAggregateRoot.cs | 65 ++++------------- .../Entities/InviteCodeAggregateRoot.cs | 30 +------- .../Managers/CardFlipManager.cs | 70 +++++++++++-------- .../Managers/InviteCodeManager.cs | 34 ++++----- 5 files changed, 72 insertions(+), 148 deletions(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/CardFlipService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/CardFlipService.cs index d7bb6ba8..4adc8dfc 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/CardFlipService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/CardFlipService.cs @@ -183,6 +183,9 @@ public class CardFlipService : ApplicationService, ICardFlipService var flippedOrder = task != null ? _cardFlipManager.GetFlippedOrder(task) : new List(); var flippedNumbers = new HashSet(flippedOrder); + // 获取中奖记录 + var winRecords = task?.WinRecords ?? new Dictionary(); + // 构建记录,按照原始序号1-10排列 for (int i = 1; i <= CardFlipManager.TOTAL_MAX_FLIPS; i++) { @@ -202,23 +205,11 @@ public class CardFlipService : ApplicationService, ICardFlipService { var flipOrderIndex = flippedOrder.IndexOf(i) + 1; // 第几次翻的(1-based) - // 第8次翻的卡中奖 - if (flipOrderIndex == 8) + // 检查这次翻牌是否中奖 + if (winRecords.TryGetValue(flipOrderIndex, out var rewardAmount)) { record.IsWin = true; - record.RewardAmount = task.EighthRewardAmount; - } - // 第9次翻的卡中奖 - else if (flipOrderIndex == 9) - { - record.IsWin = true; - record.RewardAmount = task.NinthRewardAmount; - } - // 第10次翻的卡中奖 - else if (flipOrderIndex == 10) - { - record.IsWin = true; - record.RewardAmount = task.TenthRewardAmount; + record.RewardAmount = rewardAmount; } } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/CardFlipTaskAggregateRoot.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/CardFlipTaskAggregateRoot.cs index 3adaba7e..9f51870e 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/CardFlipTaskAggregateRoot.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/CardFlipTaskAggregateRoot.cs @@ -25,9 +25,8 @@ public class CardFlipTaskAggregateRoot : FullAuditedAggregateRoot BonusFlipsUsed = 0; InviteFlipsUsed = 0; IsFirstFlipDone = false; - HasNinthReward = false; - HasTenthReward = false; FlippedOrder = new List(); + WinRecords = new Dictionary(); } /// @@ -66,34 +65,10 @@ public class CardFlipTaskAggregateRoot : FullAuditedAggregateRoot public bool IsFirstFlipDone { get; set; } /// - /// 是否已获得第8次奖励 + /// 中奖记录(以翻牌顺序为key,例如第1次翻牌中奖则key为1,奖励金额为value) /// - public bool HasEighthReward { get; set; } - - /// - /// 第8次奖励金额(100-300w) - /// - public long? EighthRewardAmount { get; set; } - - /// - /// 是否已获得第9次奖励 - /// - public bool HasNinthReward { get; set; } - - /// - /// 第9次奖励金额(100-500w) - /// - public long? NinthRewardAmount { get; set; } - - /// - /// 是否已获得第10次奖励 - /// - public bool HasTenthReward { get; set; } - - /// - /// 第10次奖励金额(100-1000w) - /// - public long? TenthRewardAmount { get; set; } + [SugarColumn(IsJson = true, IsNullable = true)] + public Dictionary? WinRecords { get; set; } /// /// 备注信息 @@ -135,33 +110,17 @@ public class CardFlipTaskAggregateRoot : FullAuditedAggregateRoot } /// - /// 记录第8次奖励 + /// 记录中奖 /// + /// 第几次翻牌(1-10) /// 奖励金额 - public void SetEighthReward(long amount) + public void SetWinReward(int flipCount, long amount) { - HasEighthReward = true; - EighthRewardAmount = amount; - } - - /// - /// 记录第9次奖励 - /// - /// 奖励金额 - public void SetNinthReward(long amount) - { - HasNinthReward = true; - NinthRewardAmount = amount; - } - - /// - /// 记录第10次奖励 - /// - /// 奖励金额 - public void SetTenthReward(long amount) - { - HasTenthReward = true; - TenthRewardAmount = amount; + if (WinRecords == null) + { + WinRecords = new Dictionary(); + } + WinRecords[flipCount] = amount; } } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/InviteCodeAggregateRoot.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/InviteCodeAggregateRoot.cs index de569b49..44346b23 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/InviteCodeAggregateRoot.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/InviteCodeAggregateRoot.cs @@ -19,7 +19,6 @@ public class InviteCodeAggregateRoot : FullAuditedAggregateRoot { UserId = userId; Code = code; - IsUsed = false; IsUserInvited = false; UsedCount = 0; } @@ -35,49 +34,22 @@ public class InviteCodeAggregateRoot : FullAuditedAggregateRoot [SugarColumn(Length = 50)] public string Code { get; set; } = string.Empty; - /// - /// 是否已被使用(一个邀请码只能被使用一次) - /// - public bool IsUsed { get; set; } - /// /// 邀请码拥有者是否已被他人邀请(被邀请后不可再提供邀请码) /// public bool IsUserInvited { get; set; } /// - /// 被使用次数(统计用) + /// 被使用次数(统计用,一个邀请码可以被多人使用) /// public int UsedCount { get; set; } - /// - /// 使用时间 - /// - public DateTime? UsedTime { get; set; } - - /// - /// 使用人ID - /// - public Guid? UsedByUserId { get; set; } - /// /// 备注信息 /// [SugarColumn(Length = 500, IsNullable = true)] public string? Remark { get; set; } - /// - /// 标记邀请码已被使用 - /// - /// 使用者ID - public void MarkAsUsed(Guid usedByUserId) - { - IsUsed = true; - UsedTime = DateTime.Now; - UsedByUserId = usedByUserId; - UsedCount++; - } - /// /// 标记用户已被邀请 /// diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/CardFlipManager.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/CardFlipManager.cs index 0eae034c..96ae5d1d 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/CardFlipManager.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/CardFlipManager.cs @@ -24,6 +24,11 @@ public class CardFlipManager : DomainService private const int NINTH_FLIP = 9; // 第9次翻牌 private const int TENTH_FLIP = 10; // 第10次翻牌 + // 前7次免费翻牌奖励配置 + private const long FREE_MIN_REWARD = 10000; // 前7次最小奖励 1w + private const long FREE_MAX_REWARD = 30000; // 前7次最大奖励 3w + private const double FREE_WIN_RATE = 0.5; // 前7次中奖概率 50% + private const long EIGHTH_MIN_REWARD = 1000000; // 第8次最小奖励 100w private const long EIGHTH_MAX_REWARD = 3000000; // 第8次最大奖励 300w private const long NINTH_MIN_REWARD = 1000000; // 第9次最小奖励 100w @@ -112,23 +117,23 @@ public class CardFlipManager : DomainService throw new UserFriendlyException(GetFlipTypeErrorMessage(flipType)); } - // 如果是邀请类型翻牌,必须验证用户本周填写的邀请码数量足够 + // 如果是邀请类型翻牌,必须验证用户本周的邀请记录数量足够(包括填写别人的邀请码和别人填写我的邀请码) if (flipType == FlipType.Invite) { - // 查询本周已使用的邀请码数量 - var weeklyInviteCodeUsedCount = await _invitationRecordRepository._DbQueryable - .Where(x => x.InvitedUserId == userId) + // 查询本周作为邀请人或被邀请人的记录数量(双方都会增加翻牌次数) + var weeklyInviteRecordCount = await _invitationRecordRepository._DbQueryable + .Where(x => x.InviterId == userId || x.InvitedUserId == userId) .Where(x => x.InvitationTime >= weekStart) .CountAsync(); - // 本周填写的邀请码数量必须 >= 即将使用的邀请翻牌次数 - // 例如: 要翻第8次(InviteFlipsUsed=0->1), 需要至少填写了1个邀请码 - // 要翻第9次(InviteFlipsUsed=1->2), 需要至少填写了2个邀请码 - // 要翻第10次(InviteFlipsUsed=2->3), 需要至少填写了3个邀请码 - var requiredInviteCodeCount = task.InviteFlipsUsed + 1; - if (weeklyInviteCodeUsedCount < requiredInviteCodeCount) + // 本周邀请记录数量必须 >= 即将使用的邀请翻牌次数 + // 例如: 要翻第8次(InviteFlipsUsed=0->1), 需要至少有1条邀请记录(我邀请别人或别人邀请我) + // 要翻第9次(InviteFlipsUsed=1->2), 需要至少有2条邀请记录 + // 要翻第10次(InviteFlipsUsed=2->3), 需要至少有3条邀请记录 + var requiredInviteRecordCount = task.InviteFlipsUsed + 1; + if (weeklyInviteRecordCount < requiredInviteRecordCount) { - throw new UserFriendlyException($"需本周累积使用{requiredInviteCodeCount}个他人邀请码才能解锁第{task.TotalFlips + 1}次翻牌,您还差一个~"); + throw new UserFriendlyException($"需本周累积{requiredInviteRecordCount}次邀请记录(填写别人的邀请码或别人填写你的邀请码)才能解锁第{task.TotalFlips + 1}次翻牌"); } } @@ -152,18 +157,7 @@ public class CardFlipManager : DomainService // 如果中奖,记录奖励金额(用于后续查询显示) if (result.IsWin) { - if (flipCount == EIGHTH_FLIP) - { - task.SetEighthReward(result.RewardAmount); - } - else if (flipCount == NINTH_FLIP) - { - task.SetNinthReward(result.RewardAmount); - } - else if (flipCount == TENTH_FLIP) - { - task.SetTenthReward(result.RewardAmount); - } + task.SetWinReward(flipCount, result.RewardAmount); } await _cardFlipTaskRepository.UpdateAsync(task); @@ -223,11 +217,24 @@ public class CardFlipManager : DomainService IsWin = false }; - // 前7次固定失败 + var random = new Random(); + + // 前7次: 50%概率中奖,奖励1w-3w if (flipCount <= 7) { - result.IsWin = false; - result.RewardDesc = "很遗憾,未中奖"; + // 50%概率中奖 + if (random.NextDouble() < FREE_WIN_RATE) + { + var rewardAmount = GenerateRandomReward(FREE_MIN_REWARD, FREE_MAX_REWARD); + result.IsWin = true; + result.RewardAmount = rewardAmount; + result.RewardDesc = $"恭喜获得尊享包 {rewardAmount / 10000m:0.##}w tokens!"; + } + else + { + result.IsWin = false; + result.RewardDesc = "很遗憾,未中奖"; + } } // 第8次中奖 (邀请码解锁) else if (flipCount == EIGHTH_FLIP) @@ -271,21 +278,24 @@ public class CardFlipManager : DomainService } /// - /// 生成随机奖励金额 (最小单位100w) + /// 生成随机奖励金额 /// private long GenerateRandomReward(long min, long max) { var random = new Random(); - const long unit = 1000000; // 100w的单位 - // 将min和max转换为100w的倍数 + // 根据最小值判断单位 + // 如果min小于100000,则使用1w(10000)作为单位;否则使用100w(1000000)作为单位 + long unit = min < 100000 ? 10000 : 1000000; + + // 将min和max转换为单位的倍数 long minUnits = min / unit; long maxUnits = max / unit; // 在倍数范围内随机 long randomUnits = random.Next((int)minUnits, (int)maxUnits + 1); - // 返回100w的倍数 + // 返回单位的倍数 return randomUnits * unit; } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/InviteCodeManager.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/InviteCodeManager.cs index 1deed773..95057111 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/InviteCodeManager.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/InviteCodeManager.cs @@ -63,12 +63,12 @@ public class InviteCodeManager : DomainService } /// - /// 统计用户本周邀请人数 + /// 统计用户本周邀请人数(别人填写我的邀请码的次数) /// public async Task GetWeeklyInvitationCountAsync(Guid userId, DateTime weekStart) { return await _invitationRecordRepository._DbQueryable - .Where(x => x.InvitedUserId == userId) + .Where(x => x.InviterId == userId) .Where(x => x.InvitationTime >= weekStart) .CountAsync(); } @@ -91,7 +91,7 @@ public class InviteCodeManager : DomainService } /// - /// 使用邀请码 + /// 使用邀请码(双方都增加翻牌次数) /// /// 使用者ID /// 邀请码 @@ -119,28 +119,20 @@ public class InviteCodeManager : DomainService throw new UserFriendlyException("不能使用自己的邀请码"); } - // 验证邀请码是否已被使用 - if (inviteCodeEntity.IsUsed) - { - throw new UserFriendlyException("该邀请码已被使用"); - } - // 验证邀请码拥有者是否已被邀请 if (inviteCodeEntity.IsUserInvited) { throw new UserFriendlyException("该用户已被邀请,邀请码无效"); } - // 验证本周邀请码使用次数 - var weekStart = CardFlipManager.GetWeekStartDate(DateTime.Now); - var weeklyUseCount = await _invitationRecordRepository._DbQueryable + // 检查当前用户是否已经填写过别人的邀请码(一辈子只能填写一次) + var hasUsedOthersCode = await _invitationRecordRepository._DbQueryable .Where(x => x.InvitedUserId == userId) - .Where(x => x.InvitationTime >= weekStart) - .CountAsync(); + .AnyAsync(); - if (weeklyUseCount >= CardFlipManager.MAX_INVITE_FLIPS) + if (hasUsedOthersCode) { - throw new UserFriendlyException($"本周邀请码使用次数已达上限({CardFlipManager.MAX_INVITE_FLIPS}次),请下周再来"); + throw new UserFriendlyException("您已经填写过别人的邀请码了,每个账号只能填写一次"); } // 检查当前用户的邀请码信息 @@ -148,11 +140,11 @@ public class InviteCodeManager : DomainService .Where(x => x.UserId == userId) .FirstAsync(); - // 标记邀请码为已使用 - inviteCodeEntity.MarkAsUsed(userId); + // 增加邀请码被使用次数 + inviteCodeEntity.UsedCount++; await _inviteCodeRepository.UpdateAsync(inviteCodeEntity); - // 标记当前用户已被邀请(仅第一次使用邀请码时标记) + // 标记当前用户已被邀请(一辈子只能填写一次) if (myInviteCode == null) { myInviteCode = new InviteCodeAggregateRoot(userId, GenerateUniqueInviteCode()); @@ -165,14 +157,14 @@ public class InviteCodeManager : DomainService await _inviteCodeRepository.UpdateAsync(myInviteCode); } - // 创建邀请记录 + // 创建邀请记录(双方都会因为这条记录增加一次翻牌机会) var invitationRecord = new InvitationRecordAggregateRoot( inviteCodeEntity.UserId, userId, inviteCode); await _invitationRecordRepository.InsertAsync(invitationRecord); - _logger.LogInformation($"用户 {userId} 使用邀请码 {inviteCode} 成功"); + _logger.LogInformation($"用户 {userId} 使用邀请码 {inviteCode} 成功,邀请人 {inviteCodeEntity.UserId} 和被邀请人 {userId} 都增加一次翻牌机会"); return inviteCodeEntity.UserId; } From b7756e2112e71403f3dbbdc21ca38d8ffdfad25b Mon Sep 17 00:00:00 2001 From: chenchun Date: Mon, 10 Nov 2025 15:03:02 +0800 Subject: [PATCH 03/23] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 概要 - 重构并扩展公告相关模型、DTO、服务,新增公告类型、图片与时间字段,调整缓存与查询处理。 - 新增枚举 AnnouncementTypeEnum。 - 主要改动(简要) - Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementLogDto.cs - 新增 ImageUrl、StartTime、EndTime、Type 字段,移除 Date 字段,Title 不再默认空串。 - Yi.Framework.AiHub.Domain/Entities - 重命名 AnnouncementLogAggregateRoot -> AnnouncementAggregateRoot - 表名由 Ai_AnnouncementLog 改为 Ai_Announcement(SugarTable 标注) - 新增 ImageUrl、StartTime、EndTime、Type、Remark 字段(Remark 已存在,保持) - Yi.Framework.AiHub.Domain.Shared/Enums/AnnouncementTypeEnum.cs - 新增枚举文件(Activity=1, System=2) - Yi.Framework.AiHub.Application.Contracts/IServices/IAnnouncementService.cs - GetAsync 返回类型由 AnnouncementOutput 改为 List - Yi.Framework.AiHub.Application/Services/AnnouncementService.cs - 使用 Mapster 进行 DTO 映射 - 查询按 StartTime 降序,返回 List,缓存结构简化 - Yi.Abp.Web/YiAbpWebModule.cs - 改为初始化 AnnouncementAggregateRoot 的表(Ai_Announcement) - Yi.Ai.Vue3/types/import_meta.d.ts - 移除 VITE_BUILD_COMPRESS 环境变量声明 - 重要注意/兼容性提示 - 接口变更:IAnnouncementService.GetAsync 返回类型已改变,调用方需同步更新(之前返回 AnnouncementOutput 的代码需调整)。 - 数据库表变更:表名从 Ai_AnnouncementLog -> Ai_Announcement,若需保留历史数据,请在部署前做好数据迁移(重命名表或迁移数据到新表结构),或使用 CodeFirst 初始化新表(当前代码在启动时会 InitTables())。 - 新增 Mapster 适配(确保项目有 Mapster 依赖)。 - 前端类型声明移除环境变量后,前端构建/运行脚本若依赖 VITE_BUILD_COMPRESS 需同步调整。 - 若有缓存结构(AnnouncementCacheDto)或序列化相关约定变更,确认兼容性。 - 建议操作 - 更新所有使用 IAnnouncementService 的代码(API 层/前端适配返回结构)。 - 在非生产环境先执行数据迁移验证(保留旧表数据或写迁移脚本)。 - 确认 Mapster 包已安装并编译通过。 - 前端项目检查并同步 import_meta.d.ts 变更。 --- .../Dtos/Announcement/AnnouncementLogDto.cs | 29 ++++++++--- .../IServices/IAnnouncementService.cs | 2 +- .../Services/AnnouncementService.cs | 27 +++------- .../Enums/AnnouncementTypeEnum.cs | 7 +++ .../Entities/AnnouncementAggregateRoot.cs | 52 +++++++++++++++++++ .../Entities/AnnouncementLogAggregateRoot.cs | 44 ---------------- Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs | 6 ++- Yi.Ai.Vue3/types/import_meta.d.ts | 1 - 8 files changed, 94 insertions(+), 74 deletions(-) create mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/AnnouncementTypeEnum.cs create mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/AnnouncementAggregateRoot.cs delete mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/AnnouncementLogAggregateRoot.cs diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementLogDto.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementLogDto.cs index 0a7ef430..fdb7a59d 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementLogDto.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementLogDto.cs @@ -1,3 +1,5 @@ +using Yi.Framework.AiHub.Domain.Shared.Enums; + namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Announcement; /// @@ -5,18 +7,33 @@ namespace Yi.Framework.AiHub.Application.Contracts.Dtos.Announcement; /// public class AnnouncementLogDto { - /// - /// 日期 - /// - public string Date { get; set; } = string.Empty; - /// /// 标题 /// - public string Title { get; set; } = string.Empty; + public string Title { get; set; } /// /// 内容列表 /// public List Content { get; set; } = new List(); + + /// + /// 图片url + /// + public string? ImageUrl { get; set; } + + /// + /// 开始时间(系统公告时间、活动开始时间) + /// + public DateTime StartTime { get; set; } + + /// + /// 活动结束时间 + /// + public DateTime? EndTime { get; set; } + + /// + /// 公告类型(系统、活动) + /// + public AnnouncementTypeEnum Type{ get; set; } } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/IServices/IAnnouncementService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/IServices/IAnnouncementService.cs index 77d4d29a..acdda549 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/IServices/IAnnouncementService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/IServices/IAnnouncementService.cs @@ -11,5 +11,5 @@ public interface IAnnouncementService /// 获取公告信息 /// /// 公告信息 - Task GetAsync(); + Task> GetAsync(); } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/AnnouncementService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/AnnouncementService.cs index 8914cd25..2399070e 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/AnnouncementService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/AnnouncementService.cs @@ -1,3 +1,4 @@ +using Mapster; using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Configuration; using Volo.Abp.Application.Services; @@ -14,13 +15,13 @@ namespace Yi.Framework.AiHub.Application.Services; /// public class AnnouncementService : ApplicationService, IAnnouncementService { - private readonly ISqlSugarRepository _announcementRepository; + private readonly ISqlSugarRepository _announcementRepository; private readonly IConfiguration _configuration; private readonly IDistributedCache _announcementCache; private const string AnnouncementCacheKey = "AiHub:Announcement"; public AnnouncementService( - ISqlSugarRepository announcementRepository, + ISqlSugarRepository announcementRepository, IConfiguration configuration, IDistributedCache announcementCache) { @@ -32,7 +33,7 @@ public class AnnouncementService : ApplicationService, IAnnouncementService /// /// 获取公告信息 /// - public async Task GetAsync() + public async Task> GetAsync() { // 使用 GetOrAddAsync 从缓存获取或添加数据,缓存1小时 var cacheData = await _announcementCache.GetOrAddAsync( @@ -44,11 +45,7 @@ public class AnnouncementService : ApplicationService, IAnnouncementService } ); - return new AnnouncementOutput - { - Version = cacheData?.Version ?? "v1.0.0", - Logs = cacheData?.Logs ?? new List() - }; + return cacheData?.Logs ?? new List(); } /// @@ -56,25 +53,15 @@ public class AnnouncementService : ApplicationService, IAnnouncementService /// private async Task LoadAnnouncementDataAsync() { - // 从配置文件读取版本号,如果没有配置则使用默认值 - var version = _configuration["AiHubVersion"] ?? "v1.0.0"; - // 查询所有公告日志,按日期降序排列 var logs = await _announcementRepository._DbQueryable - .OrderByDescending(x => x.Date) + .OrderByDescending(x => x.StartTime) .ToListAsync(); // 转换为 DTO - var logDtos = logs.Select(log => new AnnouncementLogDto - { - Date = log.Date.ToString("yyyy-MM-dd"), - Title = log.Title, - Content = log.Content - }).ToList(); - + var logDtos = logs.Adapt>(); return new AnnouncementCacheDto { - Version = version, Logs = logDtos }; } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/AnnouncementTypeEnum.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/AnnouncementTypeEnum.cs new file mode 100644 index 00000000..fa898e18 --- /dev/null +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain.Shared/Enums/AnnouncementTypeEnum.cs @@ -0,0 +1,7 @@ +namespace Yi.Framework.AiHub.Domain.Shared.Enums; + +public enum AnnouncementTypeEnum +{ + Activity=1, + System=2 +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/AnnouncementAggregateRoot.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/AnnouncementAggregateRoot.cs new file mode 100644 index 00000000..e2e05b0d --- /dev/null +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/AnnouncementAggregateRoot.cs @@ -0,0 +1,52 @@ +using SqlSugar; +using Volo.Abp.Domain.Entities.Auditing; +using Yi.Framework.AiHub.Domain.Shared.Enums; + +namespace Yi.Framework.AiHub.Domain.Entities; + +/// +/// 公告日志 +/// +[SugarTable("Ai_Announcement")] +public class AnnouncementAggregateRoot : FullAuditedAggregateRoot +{ + public AnnouncementAggregateRoot() + { + } + + /// + /// 标题 + /// + public string Title { get; set; } = string.Empty; + + /// + /// 内容列表(JSON格式存储) + /// + [SugarColumn(IsJson = true, IsNullable = false)] + public List Content { get; set; } = new List(); + + /// + /// 备注 + /// + public string? Remark { get; set; } + + /// + /// 图片url + /// + public string? ImageUrl { get; set; } + + /// + /// 开始时间(系统公告时间、活动开始时间) + /// + public DateTime StartTime { get; set; } + + /// + /// 活动结束时间 + /// + public DateTime? EndTime { get; set; } + + /// + /// 公告类型(系统、活动) + /// + public AnnouncementTypeEnum Type{ get; set; } +} diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/AnnouncementLogAggregateRoot.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/AnnouncementLogAggregateRoot.cs deleted file mode 100644 index ec890394..00000000 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/AnnouncementLogAggregateRoot.cs +++ /dev/null @@ -1,44 +0,0 @@ -using SqlSugar; -using Volo.Abp.Domain.Entities.Auditing; - -namespace Yi.Framework.AiHub.Domain.Entities; - -/// -/// 公告日志 -/// -[SugarTable("Ai_AnnouncementLog")] -[SugarIndex($"index_{nameof(Date)}", nameof(Date), OrderByType.Desc)] -public class AnnouncementLogAggregateRoot : FullAuditedAggregateRoot -{ - public AnnouncementLogAggregateRoot() - { - } - - public AnnouncementLogAggregateRoot(DateTime date, string title, List content) - { - Date = date; - Title = title; - Content = content; - } - - /// - /// 日期 - /// - public DateTime Date { get; set; } - - /// - /// 标题 - /// - public string Title { get; set; } = string.Empty; - - /// - /// 内容列表(JSON格式存储) - /// - [SugarColumn(IsJson = true, IsNullable = false)] - public List Content { get; set; } = new List(); - - /// - /// 备注 - /// - public string? Remark { get; set; } -} diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs index 1e701178..2149f1b5 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs @@ -29,6 +29,7 @@ using Volo.Abp.Swashbuckle; using Yi.Abp.Application; using Yi.Abp.SqlsugarCore; using Yi.Framework.AiHub.Application; +using Yi.Framework.AiHub.Application.Services; using Yi.Framework.AiHub.Domain.Entities; using Yi.Framework.AspNetCore; using Yi.Framework.AspNetCore.Authentication.OAuth; @@ -354,8 +355,9 @@ namespace Yi.Abp.Web var app = context.GetApplicationBuilder(); app.UseRouting(); - //app.ApplicationServices.GetRequiredService().SqlSugarClient.CodeFirst.InitTables(); - + app.ApplicationServices.GetRequiredService().SqlSugarClient.CodeFirst.InitTables(); + // app.ApplicationServices.GetRequiredService().SqlSugarClient.CodeFirst.InitTables(); + //跨域 app.UseCors(DefaultCorsPolicyName); diff --git a/Yi.Ai.Vue3/types/import_meta.d.ts b/Yi.Ai.Vue3/types/import_meta.d.ts index d8a60d41..b3e9d275 100644 --- a/Yi.Ai.Vue3/types/import_meta.d.ts +++ b/Yi.Ai.Vue3/types/import_meta.d.ts @@ -6,7 +6,6 @@ interface ImportMetaEnv { readonly VITE_WEB_ENV: string; readonly VITE_WEB_BASE_API: string; readonly VITE_API_URL: string; - readonly VITE_BUILD_COMPRESS: string; readonly VITE_SSO_SEVER_URL: string; readonly VITE_APP_VERSION: string; } From 1b4c3cbb8ded234db63ef40bd87414a1230b0e12 Mon Sep 17 00:00:00 2001 From: chenchun Date: Mon, 10 Nov 2025 15:18:05 +0800 Subject: [PATCH 04/23] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=B0=8A?= =?UTF-8?q?=E4=BA=AB=E5=8C=85=E7=94=A8=E9=87=8F=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PremiumTokenUsageGetListOutput.cs | 54 +++++++++++++++++++ .../Services/{ => Chat}/AiChatService.cs | 0 .../Services/{ => Chat}/MessageService.cs | 0 .../Services/{ => Chat}/SessionService.cs | 0 .../Services/{ => Chat}/TokenService.cs | 0 .../Services/UsageStatisticsService.cs | 20 +++++++ Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs | 2 +- 7 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/UsageStatistics/PremiumTokenUsageGetListOutput.cs rename Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/{ => Chat}/AiChatService.cs (100%) rename Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/{ => Chat}/MessageService.cs (100%) rename Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/{ => Chat}/SessionService.cs (100%) rename Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/{ => Chat}/TokenService.cs (100%) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/UsageStatistics/PremiumTokenUsageGetListOutput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/UsageStatistics/PremiumTokenUsageGetListOutput.cs new file mode 100644 index 00000000..09a41902 --- /dev/null +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/UsageStatistics/PremiumTokenUsageGetListOutput.cs @@ -0,0 +1,54 @@ +namespace Yi.Framework.AiHub.Application.Contracts.Dtos.UsageStatistics; + +public class PremiumTokenUsageGetListOutput +{ + /// + /// id + /// + public Guid Id { get; set; } + + /// + /// 用户ID + /// + public Guid UserId { get; set; } + + /// + /// 包名称 + /// + public string PackageName { get; set; } + + /// + /// 总用量(总token数) + /// + public long TotalTokens { get; set; } + + /// + /// 剩余用量(剩余token数) + /// + public long RemainingTokens { get; set; } + + /// + /// 已使用token数 + /// + public long UsedTokens { get; set; } + + /// + /// 到期时间 + /// + public DateTime? ExpireDateTime { get; set; } + + /// + /// 是否激活 + /// + public bool IsActive { get; set; } + + /// + /// 购买金额 + /// + public decimal PurchaseAmount { get; set; } + + /// + /// 备注 + /// + public string? Remark { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/AiChatService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiChatService.cs similarity index 100% rename from Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/AiChatService.cs rename to Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/AiChatService.cs diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/MessageService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/MessageService.cs similarity index 100% rename from Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/MessageService.cs rename to Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/MessageService.cs diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/SessionService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/SessionService.cs similarity index 100% rename from Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/SessionService.cs rename to Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/SessionService.cs diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/TokenService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/TokenService.cs similarity index 100% rename from Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/TokenService.cs rename to Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/Chat/TokenService.cs diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs index 05d6eaeb..72d549d8 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs @@ -1,5 +1,8 @@ +using Mapster; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using SqlSugar; +using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.Users; using Yi.Framework.AiHub.Application.Contracts.Dtos.UsageStatistics; @@ -7,6 +10,7 @@ using Yi.Framework.AiHub.Application.Contracts.IServices; using Yi.Framework.AiHub.Domain.Entities; using Yi.Framework.AiHub.Domain.Entities.Chat; using Yi.Framework.AiHub.Domain.Extensions; +using Yi.Framework.Ddd.Application.Contracts; using Yi.Framework.SqlSugarCore.Abstractions; namespace Yi.Framework.AiHub.Application.Services; @@ -137,4 +141,20 @@ public class UsageStatisticsService : ApplicationService, IUsageStatisticsServic return result; } + + /// + /// 获取当前用户尊享服务token用量统计列表 + /// + /// + [HttpGet("usage-statistics/premium-token-usage/list")] + public async Task> GetPremiumTokenUsageListAsync(PagedAllResultRequestDto input) + { + var userId = CurrentUser.GetId(); + RefAsync total = 0; + // 获取尊享包Token信息 + var entities = await _premiumPackageRepository._DbQueryable + .Where(x => x.UserId == userId) + .ToPageListAsync(input.SkipCount, input.MaxResultCount, total); + return new PagedResultDto(total, entities.Adapt>()); + } } \ No newline at end of file diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs index 2149f1b5..922d0f61 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs @@ -355,7 +355,7 @@ namespace Yi.Abp.Web var app = context.GetApplicationBuilder(); app.UseRouting(); - app.ApplicationServices.GetRequiredService().SqlSugarClient.CodeFirst.InitTables(); + //app.ApplicationServices.GetRequiredService().SqlSugarClient.CodeFirst.InitTables(); // app.ApplicationServices.GetRequiredService().SqlSugarClient.CodeFirst.InitTables(); //跨域 From eecdf442fbda2355eec62f410b1c3a945ebe4c02 Mon Sep 17 00:00:00 2001 From: chenchun Date: Wed, 12 Nov 2025 21:49:31 +0800 Subject: [PATCH 05/23] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=85=AC?= =?UTF-8?q?=E5=91=8A=E8=B7=B3=E8=BD=AC=E9=93=BE=E6=8E=A5=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=20Url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 AnnouncementAggregateRoot、AnnouncementLogDto、AnnouncementCacheDto 中新增 string? Url 属性,用于存储公告的跳转链接。 - 如果需要持久化到数据库,请同步添加对应的迁移/映射配置。 --- .../Dtos/Announcement/AnnouncementCacheDto.cs | 5 +++++ .../Dtos/Announcement/AnnouncementLogDto.cs | 5 +++++ .../Entities/AnnouncementAggregateRoot.cs | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementCacheDto.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementCacheDto.cs index 5b8cd6c7..b1e1e30c 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementCacheDto.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementCacheDto.cs @@ -14,4 +14,9 @@ public class AnnouncementCacheDto /// 公告日志列表 /// public List Logs { get; set; } = new List(); + + /// + /// 跳转链接 + /// + public string? Url { get; set; } } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementLogDto.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementLogDto.cs index fdb7a59d..6014896c 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementLogDto.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/Announcement/AnnouncementLogDto.cs @@ -36,4 +36,9 @@ public class AnnouncementLogDto /// 公告类型(系统、活动) /// public AnnouncementTypeEnum Type{ get; set; } + + /// + /// 跳转链接 + /// + public string? Url { get; set; } } diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/AnnouncementAggregateRoot.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/AnnouncementAggregateRoot.cs index e2e05b0d..4488d985 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/AnnouncementAggregateRoot.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Entities/AnnouncementAggregateRoot.cs @@ -49,4 +49,9 @@ public class AnnouncementAggregateRoot : FullAuditedAggregateRoot /// 公告类型(系统、活动) /// public AnnouncementTypeEnum Type{ get; set; } + + /// + /// 跳转链接 + /// + public string? Url { get; set; } } From d21f61646ae101a90ff59572ada9b28d010fe530 Mon Sep 17 00:00:00 2001 From: Gsh <15170702455@163.com> Date: Wed, 12 Nov 2025 23:08:52 +0800 Subject: [PATCH 06/23] =?UTF-8?q?fix:=20=E7=B3=BB=E7=BB=9F=E5=85=AC?= =?UTF-8?q?=E5=91=8A=E4=B8=8E=E5=B0=8A=E4=BA=AB=E9=A2=9D=E5=BA=A6=E6=98=8E?= =?UTF-8?q?=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Yi.Ai.Vue3/src/App.vue | 44 +- Yi.Ai.Vue3/src/api/announcement/index.ts | 31 +- Yi.Ai.Vue3/src/api/announcement/types.ts | 63 +- Yi.Ai.Vue3/src/api/user/index.ts | 108 ++ .../src/components/ModelSelect/index.vue | 3 + .../SystemAnnouncementDialog/index.vue | 1202 +++++++++++++---- .../components/PremiumPackageInfo.vue | 590 ++++++++ .../components/PremiumService.vue | 509 +------ .../components/PremiumUsageList.vue | 948 +++++++++++++ .../Header/components/AnnouncementBtn.vue | 43 +- Yi.Ai.Vue3/src/stores/modules/announcement.ts | 73 +- Yi.Ai.Vue3/types/components.d.ts | 7 + Yi.Ai.Vue3/系统公告API接口文档.md | 232 ---- Yi.Ai.Vue3/系统公告功能使用说明.md | 337 ----- Yi.Ai.Vue3/系统公告功能更新日志.md | 177 --- 15 files changed, 2739 insertions(+), 1628 deletions(-) create mode 100644 Yi.Ai.Vue3/src/components/userPersonalCenter/components/PremiumPackageInfo.vue create mode 100644 Yi.Ai.Vue3/src/components/userPersonalCenter/components/PremiumUsageList.vue delete mode 100644 Yi.Ai.Vue3/系统公告API接口文档.md delete mode 100644 Yi.Ai.Vue3/系统公告功能使用说明.md delete mode 100644 Yi.Ai.Vue3/系统公告功能更新日志.md diff --git a/Yi.Ai.Vue3/src/App.vue b/Yi.Ai.Vue3/src/App.vue index e1bab0c5..ac1b0a53 100644 --- a/Yi.Ai.Vue3/src/App.vue +++ b/Yi.Ai.Vue3/src/App.vue @@ -1,28 +1,58 @@ @@ -86,7 +80,7 @@ function formatTime(time: string) { v-model="isDialogVisible" title="系统公告" :width="dialogWidth" - :close-on-click-modal="false" + :close-on-click-modal="true" class="announcement-dialog" >
@@ -95,61 +89,71 @@ function formatTime(time: string) {
- - - - - - - - -
+
-
-

{{ activity.title }}

- - 进行中 - - - 已结束 - + +
+ + +
+ + 进行中 + + + 已结束 + +
-

{{ activity.description }}

-
+
@@ -158,70 +162,45 @@ function formatTime(time: string) {
- -
-

最新公告

-
-
-

- - - - {{ announcement.title }} -

- {{ formatTime(announcement.publishTime) }} -
-

{{ announcement.content.substring(0, 100) }}...

- - 查看详情 - -
-
- - -
-

历史公告

+ +
-
-

{{ announcement.title }}

-

{{ announcement.content.substring(0, 80) }}...

- - 查看详情 - +
+
+

+ {{ announcement.title }} +

+
+ + +
+

+ {{ line }} +

+
+
- +
diff --git a/Yi.Ai.Vue3/src/components/userPersonalCenter/components/PremiumPackageInfo.vue b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/PremiumPackageInfo.vue new file mode 100644 index 00000000..5dff94eb --- /dev/null +++ b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/PremiumPackageInfo.vue @@ -0,0 +1,590 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/components/userPersonalCenter/components/PremiumService.vue b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/PremiumService.vue index 7032219d..70828b77 100644 --- a/Yi.Ai.Vue3/src/components/userPersonalCenter/components/PremiumService.vue +++ b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/PremiumService.vue @@ -1,7 +1,7 @@ - diff --git a/Yi.Ai.Vue3/src/components/userPersonalCenter/components/PremiumUsageList.vue b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/PremiumUsageList.vue new file mode 100644 index 00000000..f3b21e3a --- /dev/null +++ b/Yi.Ai.Vue3/src/components/userPersonalCenter/components/PremiumUsageList.vue @@ -0,0 +1,948 @@ + + + + + diff --git a/Yi.Ai.Vue3/src/layouts/components/Header/components/AnnouncementBtn.vue b/Yi.Ai.Vue3/src/layouts/components/Header/components/AnnouncementBtn.vue index 5502fddc..37ae05a7 100644 --- a/Yi.Ai.Vue3/src/layouts/components/Header/components/AnnouncementBtn.vue +++ b/Yi.Ai.Vue3/src/layouts/components/Header/components/AnnouncementBtn.vue @@ -1,30 +1,33 @@