feat: 新增上传地址管理、答题评分及社区消息功能
1. 新增UploadDomain实体与上传地址分配逻辑,为用户分配可用上传域名 2. 新增绑定期刊消息推送,通过RabbitMQ传递绑定信息 3. 优化答题评分逻辑,新增完成度阈值判定与社区消息插入 4. 新增配置项用于评分阈值配置 5. 补充相关DTO与实体类字段,完善数据传输与存储
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using QYZH.InteractiveMagazine.Infrastructure.RabbitMQ;
|
||||
using QYZH.InteractiveMagazine.IService;
|
||||
using QYZH.InteractiveMagazine.Models.Common;
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
@ -17,9 +18,14 @@ public class UserJournalService(
|
||||
BaseRepository<Users> usersRepository,
|
||||
BaseRepository<Journal> journalRepository,
|
||||
ILogger<UserJournalService> logger,
|
||||
IRabbitMQService rabbitMqService,
|
||||
IPetService petService)
|
||||
: BaseRepository<UserJournal>, IUserJournalService
|
||||
{
|
||||
private const string JournalExchange = "ex.journal";
|
||||
private const string BindJournalQueue = "mq.journal.bindUser";
|
||||
private const string BindJournalRoutingKey = "rk.journal.bindUser";
|
||||
|
||||
/// <summary>
|
||||
/// 用户绑定期刊(扫码绑定)
|
||||
/// </summary>
|
||||
@ -93,6 +99,7 @@ public class UserJournalService(
|
||||
}
|
||||
|
||||
logger.LogInformation("用户绑定期刊成功,UserId: {UserId}, JournalId: {JournalId}, Id: {Id}", userId, input.JournalId, userJournal.Id);
|
||||
await SendBindJournalMessageAsync(user, journal);
|
||||
|
||||
// 首次绑定期刊时激活宠物
|
||||
if (isFirstBind)
|
||||
@ -119,6 +126,36 @@ public class UserJournalService(
|
||||
};
|
||||
}
|
||||
|
||||
private async Task SendBindJournalMessageAsync(Users user, Journal journal)
|
||||
{
|
||||
try
|
||||
{
|
||||
var messageSent = await rabbitMqService.SendAsync(new RabbitMQSendParam
|
||||
{
|
||||
Exchange = JournalExchange,
|
||||
Queue = BindJournalQueue,
|
||||
RoutingKey = BindJournalRoutingKey,
|
||||
Data = new BindJournalMessage
|
||||
{
|
||||
UserId = user.Id,
|
||||
JournalId = journal.Id,
|
||||
StartTime = journal.StartTime,
|
||||
EndTime = journal.EndTime,
|
||||
UploadDomain = user.UploadDomain
|
||||
}
|
||||
});
|
||||
|
||||
if (!messageSent)
|
||||
{
|
||||
logger.LogError("发送绑定期刊消息失败,UserId: {UserId}, JournalId: {JournalId}", user.Id, journal.Id);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "发送绑定期刊消息异常,UserId: {UserId}, JournalId: {JournalId}", user.Id, journal.Id);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户的期刊绑定列表
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user