using Admin.NET.Plugin.AiDOP.Dto.S8;
using Admin.NET.Plugin.AiDOP.Infrastructure;
using Admin.NET.Plugin.AiDOP.Service.S8;
namespace Admin.NET.Plugin.AiDOP.Controllers.S8;
///
/// G-06 最小问题台账只读查询接口。仅一个只读 GET,鉴权走现有中间件。
/// state 仅接受 discovered / processing / closed / 空;不接受别名、不兼容 hold / suspend / pending / all。
///
[ApiController]
[Route("api/aidop/s8/issues/ledger")]
[NonUnify]
public class AdoS8IssueLedgerController : ControllerBase
{
private readonly S8IssueLedgerService _svc;
private readonly S8TrustedScopeResolver _scope;
public AdoS8IssueLedgerController(S8IssueLedgerService svc, S8TrustedScopeResolver scope)
{
_svc = svc;
_scope = scope;
}
[HttpGet]
public async Task QueryAsync([FromQuery] AdoS8IssueLedgerQueryDto q)
{
try
{
var scope = await _scope.ResolveAsync();
q.TenantId = scope.TenantId;
q.FactoryId = scope.FactoryId;
var (total, list) = await _svc.QueryAsync(q);
return Ok(new { total, list });
}
catch (S8BizException ex)
{
return BadRequest(new { message = ex.Message });
}
}
}