using Microsoft.AspNetCore.Http; using Admin.NET.Plugin.AiDOP.Const.S8; using Admin.NET.Plugin.AiDOP.Infrastructure; using Admin.NET.Plugin.AiDOP.Infrastructure.S8; using Admin.NET.Plugin.AiDOP.Service.S8; namespace Admin.NET.Plugin.AiDOP.Controllers.S8; /// /// S8 主数据下拉:优先复用 S0 已落库主数据语义(部门等),无则返回空列表,不把「下拉查询」误建成独立业务表。 /// /// S8-P0-3-MASTERDATA-TRUSTED-SCOPE-1:本控制器原先是 KNOWN-ISSUES I-001 里 /// 「6 个未接入可信作用域解析」之一。GET /master-data/employees?factoryRefId=<任意工厂> /// 实测可返回 500 条其它租户员工的工号与真实姓名,现已接入 /// /// 入参语义factoryRefId 已从所有 Action 签名移除;客户端继续携带也不产生授权效果。 /// [ApiController] [Route("api/aidop/s8/master-data")] [NonUnify] public class AdoS8MasterDataController : ControllerBase { private readonly S8MasterDataAdapter _svc; private readonly S8TrustedScopeResolver _scope; public AdoS8MasterDataController(S8MasterDataAdapter svc, S8TrustedScopeResolver scope) { _svc = svc; _scope = scope; } [HttpGet("departments")] [S8Permission(S8PermissionCatalog.ExceptionRead)] public async Task DepartmentsAsync() { try { return Ok(await _svc.GetDepartmentsAsync(await _scope.ResolveAsync())); } catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); } } /// S8 人员选择器:当前租户的启用系统账号。 [HttpGet("users")] [S8Permission(S8PermissionCatalog.ExceptionRead)] public async Task UsersAsync([FromQuery] string? requiredAction = null) { try { return Ok(await _svc.GetOperatorUsersAsync(await _scope.ResolveAsync(), requiredAction)); } catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); } } /// /// 已退役(S8-SYSUSER-ONLY-1)。S8 不再有"员工"这个身份维度,请改用 GET master-data/users。 /// 保留路由并返回 410,是为了让还在调用旧地址的客户端立刻拿到明确错误, /// 而不是收到 404 后以为只是路径写错。 /// [HttpGet("employees")] [S8Permission(S8PermissionCatalog.ExceptionRead)] public IActionResult EmployeesRetiredAsync() => StatusCode(StatusCodes.Status410Gone, new { message = "该接口已退役:S8 人员身份统一为系统账号,请改用 GET /api/aidop/s8/master-data/users", replacedBy = "/api/aidop/s8/master-data/users" }); [HttpGet("lines")] [S8Permission(S8PermissionCatalog.ExceptionRead)] public async Task LinesAsync() { try { return Ok(await _svc.GetLinesAsync(await _scope.ResolveAsync())); } catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); } } }