AdoS8ConfigBindingsController.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Admin.NET.Plugin.AiDOP.Dto.S8;
  2. using Admin.NET.Plugin.AiDOP.Infrastructure.S8;
  3. using Admin.NET.Plugin.AiDOP.Service.S8;
  4. namespace Admin.NET.Plugin.AiDOP.Controllers.S8;
  5. /// <summary>
  6. /// S8 配置页:操作员(员工)↔ 系统账号绑定 / 可绑账号查询。
  7. /// 入口收口在 /aidop/s8/config/roles,与 S8 配置中心同源。
  8. /// </summary>
  9. [ApiController]
  10. [Route("api/aidop/s8/config")]
  11. [NonUnify]
  12. public class AdoS8ConfigBindingsController : ControllerBase
  13. {
  14. private readonly S8OperatorBindingService _svc;
  15. public AdoS8ConfigBindingsController(S8OperatorBindingService svc) => _svc = svc;
  16. [HttpGet("operator-bindings")]
  17. public async Task<IActionResult> ListAsync(
  18. [FromQuery] long? factoryRefId = null,
  19. [FromQuery] string? bindStatus = null,
  20. [FromQuery] string? keyword = null)
  21. => Ok(await _svc.ListAsync(factoryRefId, bindStatus, keyword));
  22. [HttpPost("operator-bindings")]
  23. public async Task<IActionResult> BindAsync([FromBody] AdoS8OperatorBindingCreateDto body)
  24. {
  25. try { return Ok(await _svc.BindAsync(body)); }
  26. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  27. }
  28. [HttpDelete("operator-bindings/{employeeId:long}")]
  29. public async Task<IActionResult> UnbindAsync(long employeeId)
  30. {
  31. try { await _svc.UnbindAsync(employeeId); return Ok(new { employeeId }); }
  32. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  33. }
  34. [HttpGet("sys-users")]
  35. public async Task<IActionResult> SysUsersAsync(
  36. [FromQuery] string? keyword = null,
  37. [FromQuery] long? excludeEmployeeId = null)
  38. => Ok(await _svc.ListSysUsersAsync(keyword, excludeEmployeeId));
  39. }