AdoS8ConfigBindingsController.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Admin.NET.Plugin.AiDOP.Const.S8;
  2. using Admin.NET.Plugin.AiDOP.Dto.S8;
  3. using Admin.NET.Plugin.AiDOP.Infrastructure;
  4. using Admin.NET.Plugin.AiDOP.Infrastructure.S8;
  5. using Admin.NET.Plugin.AiDOP.Service.S8;
  6. namespace Admin.NET.Plugin.AiDOP.Controllers.S8;
  7. /// <summary>
  8. /// S8 配置页:操作员(员工)↔ 系统账号绑定 / 可绑账号查询。
  9. /// 入口收口在 /aidop/s8/config/roles,与 S8 配置中心同源。
  10. ///
  11. /// <para><b>S8-P0-3-MASTERDATA-TRUSTED-SCOPE-1</b>:本控制器原先是
  12. /// KNOWN-ISSUES I-001 里「6 个未接入可信作用域解析」之一,且是其中**唯一被实测利用**的越权面
  13. /// —— 普通租户账号调 <c>GET /config/operator-bindings</c>(不带任何参数)可拿到 500 条
  14. /// 其它租户员工的工号与真实姓名。现已接入 <see cref="S8TrustedScopeResolver"/>。</para>
  15. ///
  16. /// <para><b>入参语义</b>:<c>factoryRefId</c> 已从所有 Action 签名移除。客户端(含前端
  17. /// <c>withAidopTenantFactoryParams</c>)仍可能继续携带该 query/body 字段,ASP.NET 会直接丢弃,
  18. /// **不产生任何授权效果**。Body 里的 <c>AdoS8OperatorBindingCreateDto.FactoryRefId</c> 同理不被读取。</para>
  19. /// </summary>
  20. [ApiController]
  21. [Route("api/aidop/s8/config")]
  22. [NonUnify]
  23. public class AdoS8ConfigBindingsController : ControllerBase
  24. {
  25. private readonly S8OperatorBindingService _svc;
  26. private readonly S8TrustedScopeResolver _scope;
  27. public AdoS8ConfigBindingsController(S8OperatorBindingService svc, S8TrustedScopeResolver scope)
  28. {
  29. _svc = svc;
  30. _scope = scope;
  31. }
  32. [HttpGet("operator-bindings")]
  33. [S8Permission(S8PermissionCatalog.ConfigRead)]
  34. public async Task<IActionResult> ListAsync(
  35. [FromQuery] string? bindStatus = null,
  36. [FromQuery] string? keyword = null)
  37. {
  38. try { return Ok(await _svc.ListAsync(await _scope.ResolveAsync(), bindStatus, keyword)); }
  39. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  40. }
  41. [HttpPost("operator-bindings")]
  42. [S8Permission(S8PermissionCatalog.ConfigOperatorBind)]
  43. public async Task<IActionResult> BindAsync([FromBody] AdoS8OperatorBindingCreateDto body)
  44. {
  45. try { return Ok(await _svc.BindAsync(await _scope.ResolveAsync(), body)); }
  46. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  47. }
  48. [HttpDelete("operator-bindings/{employeeId:long}")]
  49. [S8Permission(S8PermissionCatalog.ConfigOperatorBind)]
  50. public async Task<IActionResult> UnbindAsync(long employeeId)
  51. {
  52. try { await _svc.UnbindAsync(await _scope.ResolveAsync(), employeeId); return Ok(new { employeeId }); }
  53. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  54. }
  55. [HttpGet("sys-users")]
  56. [S8Permission(S8PermissionCatalog.ConfigRead)]
  57. public async Task<IActionResult> SysUsersAsync(
  58. [FromQuery] string? keyword = null,
  59. [FromQuery] long? excludeEmployeeId = null)
  60. {
  61. try { return Ok(await _svc.ListSysUsersAsync(await _scope.ResolveAsync(), keyword, excludeEmployeeId)); }
  62. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  63. }
  64. }