| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- 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/scenes")]
- [NonUnify]
- public class AdoS8ConfigScenesController : ControllerBase
- {
- private readonly S8SceneConfigService _svc;
- private readonly S8TrustedScopeResolver _scope;
- public AdoS8ConfigScenesController(S8SceneConfigService 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] AdoS8SceneConfig 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] AdoS8SceneConfig 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();
- }
- }
|