| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using Admin.NET.Plugin.AiDOP.Entity.S8;
- using Admin.NET.Plugin.AiDOP.Infrastructure;
- using Admin.NET.Plugin.AiDOP.Service.S8;
- namespace Admin.NET.Plugin.AiDOP.Controllers.S8;
- [ApiController]
- [Route("api/aidop/s8/config/dashboard-cells")]
- [NonUnify]
- public class AdoS8ConfigDashboardCellsController : ControllerBase
- {
- private readonly S8DashboardCellConfigService _svc;
- private readonly S8TrustedScopeResolver _scope;
- public AdoS8ConfigDashboardCellsController(S8DashboardCellConfigService svc, S8TrustedScopeResolver scope)
- {
- _svc = svc;
- _scope = scope;
- }
- [HttpGet]
- public async Task<IActionResult> ListAsync([FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1)
- {
- // Compatibility-only. Security scope is resolved server-side.
- _ = tenantId; _ = factoryId;
- var scope = await _scope.ResolveAsync();
- return Ok(await _svc.ListAsync(scope.TenantId, scope.FactoryId));
- }
- [HttpPost]
- public async Task<IActionResult> CreateAsync([FromBody] AdoS8DashboardCellConfig body)
- {
- try { return Ok(await _svc.CreateAsync(body, await _scope.ResolveAsync())); }
- catch (S8NotFoundException) { return NotFound(); }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- [HttpPut("{id:long}")]
- public async Task<IActionResult> UpdateAsync(long id, [FromBody] AdoS8DashboardCellConfig body)
- {
- try { return Ok(await _svc.UpdateAsync(id, body, await _scope.ResolveAsync())); }
- catch (S8NotFoundException) { return NotFound(); }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- [HttpDelete("{id:long}")]
- public async Task<IActionResult> DeleteAsync(long id)
- {
- try { await _svc.DeleteAsync(id, await _scope.ResolveAsync()); }
- catch (S8NotFoundException) { return NotFound(); }
- return Ok();
- }
- /// <summary>
- /// S8-CONFIG-GLOBAL-ROW-SEMANTICS-AND-KPI-TARGET-1:自定义本工厂。
- /// 入参是<b>平台默认行</b>的 Id;服务端复制其业务字段并盖章可信租户 / 工厂,存为工厂覆盖行。
- /// 平台默认行不被修改。
- /// </summary>
- [HttpPost("{globalId:long}/factory-override")]
- public async Task<IActionResult> CreateFactoryOverrideAsync(long globalId)
- {
- try { return Ok(await _svc.CreateFactoryOverrideAsync(globalId, await _scope.ResolveAsync())); }
- catch (S8NotFoundException) { return NotFound(); }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- /// <summary>
- /// S8-CONFIG-GLOBAL-ROW-SEMANTICS-AND-KPI-TARGET-1:恢复平台默认。
- /// 入参是<b>当前工厂覆盖行</b>的 Id;只删除该覆盖行,平台默认行不受影响。
- /// </summary>
- [HttpDelete("{overrideId:long}/factory-override")]
- public async Task<IActionResult> ResetToGlobalDefaultAsync(long overrideId)
- {
- try { await _svc.ResetToGlobalDefaultAsync(overrideId, await _scope.ResolveAsync()); return Ok(new { overrideId, reset = true }); }
- catch (S8NotFoundException) { return NotFound(); }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- }
|