临时数据提交

This commit is contained in:
2026-07-01 08:18:51 +08:00
33 changed files with 1659 additions and 523 deletions

View File

@ -24,6 +24,7 @@ public class JournalPageTaskService(BaseRepository<Journal> journalRepository, O
var map = input.Adapt<JournalPageTask>();
map.Id = YitIdHelper.NextId();
map.GroupId = map.Id;
map.NeedAiProcess = input.NeedAiProcess;
var no = input.No.Split('-').Select(int.Parse).ToArray();
if (no.Last() >= 2)
{
@ -59,7 +60,6 @@ public class JournalPageTaskService(BaseRepository<Journal> journalRepository, O
task.Type = input.Type;
task.Task = input.Task;
task.No = input.No;
task.Points = input.Points;
task.GrowthPoint = (int?)input.GrowthPoint;
task.Comprehension = input.Comprehension;
@ -68,6 +68,7 @@ public class JournalPageTaskService(BaseRepository<Journal> journalRepository, O
task.Persuasiveness = input.Persuasiveness;
task.AnswerTime = input.AnswerTime;
task.Prompt = input.Prompt;
task.NeedAiProcess = input.NeedAiProcess;
var no = input.No.Split('-').Select(int.Parse).ToArray();
@ -104,7 +105,8 @@ public class JournalPageTaskService(BaseRepository<Journal> journalRepository, O
Expression = task.Expression,
Persuasiveness = task.Persuasiveness,
AnswerTime = task.AnswerTime,
Prompt = task.Prompt
Prompt = task.Prompt,
NeedAiProcess = task.NeedAiProcess
};
// 查询答案列表

View File

@ -21,8 +21,17 @@ public class JournalService(BaseRepository<JournalPage> JournalPageRepository,
BaseRepository<JournalPageTaskAnswer> JournalPageTaskAnswerRepository,
BaseRepository<JournalCatalog> JournalCatalogRepository,
BaseRepository<DotFile> dotFileRepository,
BaseRepository<DotFileDetail> dotFileDetailRepository, OssService ossService, ILogger<JournalService> logger) : BaseRepository<Journal>, IJournalService
BaseRepository<DotFileDetail> dotFileDetailRepository,
OssService ossService,
IRabbitMQService rabbitMqService,
ILogger<JournalService> logger) : BaseRepository<Journal>, IJournalService
{
private const string JournalExchange = "ex.journal";
private const string PublishBookQueue = "mq.journal.publish.book";
private const string PublishBookRoutingKey = "rk.journal.publish.book";
private const string PublishBookPageQueue = "mq.journal.publish.bookpage";
private const string PublishBookPageRoutingKey = "rk.journal.publish.bookpage";
/// <summary>
/// 查询List
/// </summary>
@ -82,6 +91,8 @@ public class JournalService(BaseRepository<JournalPage> JournalPageRepository,
Cover = input.Cover?.RemoveDomain(),
BackCover = input.BackCover?.RemoveDomain(),
PdfPreviewUrl = input.PdfPreviewUrl?.RemoveDomain(),
StartTime = input.StartTime,
EndTime = input.EndTime,
CreatedBy = "System",
UpdatedBy = "System",
CreatedAt = DateTime.Now,
@ -167,6 +178,9 @@ public class JournalService(BaseRepository<JournalPage> JournalPageRepository,
Journal.Height = input.Height;
Journal.Name = input.Name;
Journal.Title = input.Title;
Journal.StartTime = input.StartTime;
Journal.EndTime = input.EndTime;
Journal.UpdatedAt = DateTime.Now;
var res = await UseTranAsync(async () =>
{
@ -320,4 +334,59 @@ public class JournalService(BaseRepository<JournalPage> JournalPageRepository,
var res = await base.Updateable().SetColumns(s => s.Status, status).Where(w => w.Id == id).ExecuteCommandAsync() > 0;
return res;
}
}
public async Task<bool> PublishAsync(long id)
{
var book = await base.GetByIdAsync(id);
BusinessException.ThrowIf(book == null || book.IsDeleted, "杂志不存在", ResultCode.NOT_FOUND);
var pages = await JournalPageRepository.Queryable()
.Where(x => x.JournalId == id && !x.IsDeleted)
.OrderBy(x => x.PageNum)
.OrderBy(x => x.Sort)
.ToListAsync();
BusinessException.ThrowIf(pages.Count == 0, "书籍未添加任何书页,无法发布", ResultCode.UNPROCESSABLE_ENTITY);
BusinessException.ThrowIf(!book.StartTime.HasValue, "发布开始时间不能为空", ResultCode.UNPROCESSABLE_ENTITY);
BusinessException.ThrowIf(!book.EndTime.HasValue, "发布结束时间不能为空", ResultCode.UNPROCESSABLE_ENTITY);
BusinessException.ThrowIf(book.EndTime < book.StartTime, "发布结束时间不能早于开始时间", ResultCode.UNPROCESSABLE_ENTITY);
var bookMessageSent = await rabbitMqService.SendAsync(new RabbitMQSendParam
{
Exchange = JournalExchange,
Queue = PublishBookQueue,
RoutingKey = PublishBookRoutingKey,
Data = new JournalPublishBookMessage
{
BookId = id,
StartTime = book.StartTime.Value,
EndTime = book.EndTime.Value
}
});
BusinessException.ThrowIf(!bookMessageSent, "发布书籍消息发送失败", ResultCode.GLOBAL_ERROR);
foreach (var page in pages)
{
var pageMessageSent = await rabbitMqService.SendAsync(new RabbitMQSendParam
{
Exchange = JournalExchange,
Queue = PublishBookPageQueue,
RoutingKey = PublishBookPageRoutingKey,
Data = new JournalPublishBookPageMessage
{
BookId = id,
PageId = page.Id,
PageNo = page.PageNo,
Layout = page.Layout
}
});
BusinessException.ThrowIf(!pageMessageSent, $"发布书页消息发送失败PageId: {page.Id}", ResultCode.GLOBAL_ERROR);
}
return await base.Updateable()
.SetColumns(s => s.Status, JournalStatusEnum.Published)
.SetColumns(s => s.UpdatedAt, DateTime.Now)
.Where(w => w.Id == id)
.ExecuteCommandAsync() > 0;
}
}