refactor: 调整期刊实体字段与用户期刊输出映射
1. 移除Journal实体冗余的Title字段,统一使用Name字段 2. 更新UserDto和UsersService中的期刊标题映射逻辑 3. 新增JournalPageTask的四项能力评分字段 4. 新增AI提示词管理的完整服务、控制器与相关DTO 5. 新增用户作答记录实体JournalPageTaskUserAnswer
This commit is contained in:
@ -0,0 +1,151 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using QYZH.InteractiveMagazine.IService;
|
||||
using QYZH.InteractiveMagazine.Models.Common;
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
using QYZH.InteractiveMagazine.Models.Enum;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.WebApi.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// AIPrompt配置管理控制器
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[ApiExplorerSettings(GroupName = nameof(ApiVersionEnum.Platform))]
|
||||
public class AiBasePromptController : BaseController
|
||||
{
|
||||
private readonly IAiBasePromptService _aiBasePromptService;
|
||||
private readonly ILogger<AiBasePromptController> _logger;
|
||||
|
||||
public AiBasePromptController(IAiBasePromptService aiBasePromptService, ILogger<AiBasePromptController> logger)
|
||||
{
|
||||
_aiBasePromptService = aiBasePromptService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建Prompt配置
|
||||
/// </summary>
|
||||
/// <param name="input">Prompt配置信息</param>
|
||||
/// <returns>创建的Prompt配置信息</returns>
|
||||
[HttpPost]
|
||||
public async Task<BaseResponse<AiBasePromptOutput>> CreateAsync([FromBody] AiBasePromptInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _aiBasePromptService.CreateAsync(input);
|
||||
return Success(result, "创建Prompt配置成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "创建Prompt配置业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<AiBasePromptOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "创建Prompt配置系统异常,参数:{Input}", input);
|
||||
return BaseResponse<AiBasePromptOutput>.Fail("创建Prompt配置失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新Prompt配置
|
||||
/// </summary>
|
||||
/// <param name="id">Prompt配置ID</param>
|
||||
/// <param name="input">Prompt配置信息</param>
|
||||
/// <returns>更新后的Prompt配置信息</returns>
|
||||
[HttpPut("{id}")]
|
||||
public async Task<BaseResponse<AiBasePromptOutput>> UpdateAsync(long id, [FromBody] AiBasePromptInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _aiBasePromptService.UpdateAsync(id, input);
|
||||
return Success(result, "更新Prompt配置成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "更新Prompt配置业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<AiBasePromptOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "更新Prompt配置系统异常,ID:{Id},参数:{Input}", id, input);
|
||||
return BaseResponse<AiBasePromptOutput>.Fail("更新Prompt配置失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除Prompt配置
|
||||
/// </summary>
|
||||
/// <param name="id">Prompt配置ID</param>
|
||||
/// <returns>操作结果</returns>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<BaseResponse<object>> DeleteAsync(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _aiBasePromptService.DeleteAsync(id);
|
||||
return Success(new object(), "删除Prompt配置成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "删除Prompt配置业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<object>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "删除Prompt配置系统异常,ID:{Id}", id);
|
||||
return BaseResponse<object>.Fail("删除Prompt配置失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取Prompt配置
|
||||
/// </summary>
|
||||
/// <param name="id">Prompt配置ID</param>
|
||||
/// <returns>Prompt配置信息</returns>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<BaseResponse<AiBasePromptOutput>> GetByIdAsync(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _aiBasePromptService.GetByIdAsync(id);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "获取Prompt配置业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<AiBasePromptOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "获取Prompt配置系统异常,ID:{Id}", id);
|
||||
return BaseResponse<AiBasePromptOutput>.Fail("获取Prompt配置信息失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询Prompt配置列表
|
||||
/// </summary>
|
||||
/// <param name="input">查询条件</param>
|
||||
/// <returns>分页结果</returns>
|
||||
[HttpPost("list")]
|
||||
public async Task<BaseResponse<PageListModel<AiBasePromptOutput>>> GetListAsync([FromBody] AiBasePromptQueryInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _aiBasePromptService.GetListAsync(input);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "查询Prompt配置列表业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PageListModel<AiBasePromptOutput>>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "查询Prompt配置列表系统异常,参数:{Input}", input);
|
||||
return BaseResponse<PageListModel<AiBasePromptOutput>>.Fail("查询Prompt配置列表失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user