using Admin.NET.Plugin.AiDOP.Dto.S8;
using Admin.NET.Plugin.AiDOP.Infrastructure.S8;
using Admin.NET.Plugin.AiDOP.Service.S8;
namespace Admin.NET.Plugin.AiDOP.Controllers.S8;
///
/// S8 配置页:操作员(员工)↔ 系统账号绑定 / 可绑账号查询。
/// 入口收口在 /aidop/s8/config/roles,与 S8 配置中心同源。
///
[ApiController]
[Route("api/aidop/s8/config")]
[NonUnify]
public class AdoS8ConfigBindingsController : ControllerBase
{
private readonly S8OperatorBindingService _svc;
public AdoS8ConfigBindingsController(S8OperatorBindingService svc) => _svc = svc;
[HttpGet("operator-bindings")]
public async Task ListAsync(
[FromQuery] long? factoryRefId = null,
[FromQuery] string? bindStatus = null,
[FromQuery] string? keyword = null)
=> Ok(await _svc.ListAsync(factoryRefId, bindStatus, keyword));
[HttpPost("operator-bindings")]
public async Task BindAsync([FromBody] AdoS8OperatorBindingCreateDto body)
{
try { return Ok(await _svc.BindAsync(body)); }
catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
}
[HttpDelete("operator-bindings/{employeeId:long}")]
public async Task UnbindAsync(long employeeId)
{
try { await _svc.UnbindAsync(employeeId); return Ok(new { employeeId }); }
catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
}
[HttpGet("sys-users")]
public async Task SysUsersAsync(
[FromQuery] string? keyword = null,
[FromQuery] long? excludeEmployeeId = null)
=> Ok(await _svc.ListSysUsersAsync(keyword, excludeEmployeeId));
}