feat: 完成多模块功能迭代与代码重构
本次提交包含多方面更新: 1. 新增消息类型枚举、杂志标题字段与AI提示词状态管理 2. 重构杂志服务,新增创建杂志接口并统一OSS路径命名规范 3. 调整题库任务结构,将答案解析迁移至独立表并优化关联查询 4. 新增AI提示词无分页查询与状态切换接口 5. 精简任务添加输入DTO,移除冗余字段 6. 修复控制器路由命名大小写不一致问题
This commit is contained in:
@ -78,6 +78,7 @@ public class AiBasePromptService(
|
||||
Description = entity.Description,
|
||||
Priority = entity.Priority,
|
||||
IsDefault = entity.IsDefault,
|
||||
Status = entity.Status,
|
||||
CreatedBy = entity.CreatedBy,
|
||||
CreatedAt = entity.CreatedAt,
|
||||
UpdatedBy = entity.UpdatedBy,
|
||||
@ -148,6 +149,7 @@ public class AiBasePromptService(
|
||||
Description = entity.Description,
|
||||
Priority = entity.Priority,
|
||||
IsDefault = entity.IsDefault,
|
||||
Status = entity.Status,
|
||||
CreatedBy = entity.CreatedBy,
|
||||
CreatedAt = entity.CreatedAt,
|
||||
UpdatedBy = entity.UpdatedBy,
|
||||
@ -202,6 +204,7 @@ public class AiBasePromptService(
|
||||
Description = entity.Description,
|
||||
Priority = entity.Priority,
|
||||
IsDefault = entity.IsDefault,
|
||||
Status = entity.Status,
|
||||
CreatedBy = entity.CreatedBy,
|
||||
CreatedAt = entity.CreatedAt,
|
||||
UpdatedBy = entity.UpdatedBy,
|
||||
@ -243,6 +246,7 @@ public class AiBasePromptService(
|
||||
Description = p.Description,
|
||||
Priority = p.Priority,
|
||||
IsDefault = p.IsDefault,
|
||||
Status = p.Status,
|
||||
CreatedBy = p.CreatedBy,
|
||||
CreatedAt = p.CreatedAt,
|
||||
UpdatedBy = p.UpdatedBy,
|
||||
@ -251,4 +255,61 @@ public class AiBasePromptService(
|
||||
|
||||
return new PageListModel<AiBasePromptOutput>(result, input.PageIndex, input.PageSize, totalNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取全部Prompt配置(无分页)
|
||||
/// </summary>
|
||||
public async Task<List<AiBasePromptOutput>> GetAllAsync()
|
||||
{
|
||||
logger.LogInformation("正在查询全部Prompt配置");
|
||||
|
||||
var list = await promptRepository.Queryable()
|
||||
.OrderBy(p => p.Priority)
|
||||
.OrderByDescending(p => p.CreatedAt)
|
||||
.ToListAsync();
|
||||
|
||||
return list.Select(p => new AiBasePromptOutput
|
||||
{
|
||||
Id = p.Id,
|
||||
PromptKey = p.PromptKey,
|
||||
PromptName = p.PromptName,
|
||||
PromptTemplate = p.PromptTemplate,
|
||||
Description = p.Description,
|
||||
Priority = p.Priority,
|
||||
IsDefault = p.IsDefault,
|
||||
Status = p.Status,
|
||||
CreatedBy = p.CreatedBy,
|
||||
CreatedAt = p.CreatedAt,
|
||||
UpdatedBy = p.UpdatedBy,
|
||||
UpdatedAt = p.UpdatedAt
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换Prompt启用/禁用状态
|
||||
/// </summary>
|
||||
public async Task ToggleStatusAsync(long id)
|
||||
{
|
||||
logger.LogInformation("正在切换Prompt配置状态,ID: {Id}", id);
|
||||
|
||||
var entity = await promptRepository.GetByIdAsync(id);
|
||||
if (entity == null)
|
||||
{
|
||||
logger.LogWarning("未找到要切换状态的Prompt配置,ID: {Id}", id);
|
||||
throw new BusinessException("Prompt配置不存在", 404);
|
||||
}
|
||||
|
||||
entity.Status = entity.Status == 1 ? 0 : 1;
|
||||
entity.UpdatedBy = "System";
|
||||
entity.UpdatedAt = DateTime.Now;
|
||||
|
||||
var result = await promptRepository.UpdateAsync(entity);
|
||||
if (!result)
|
||||
{
|
||||
logger.LogError("Prompt配置状态切换失败,ID: {Id}", id);
|
||||
throw new BusinessException("切换Prompt状态失败", 500);
|
||||
}
|
||||
|
||||
logger.LogInformation("Prompt配置状态切换成功,ID: {Id}, Status: {Status}", id, entity.Status);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user