| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using Admin.NET.Plugin.AiDOP.Dto.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/wizard-drafts")]
- [NonUnify]
- public class AdoS8ConfigDraftsController : ControllerBase
- {
- private readonly S8ConfigDraftService _svc;
- private readonly S8TrustedScopeResolver _scope;
- public AdoS8ConfigDraftsController(S8ConfigDraftService svc, S8TrustedScopeResolver scope)
- {
- _svc = svc;
- _scope = scope;
- }
- [HttpGet]
- public async Task<IActionResult> ListAsync([FromQuery] AdoS8ConfigDraftListQueryDto query)
- {
- var scope = await _scope.ResolveAsync();
- query.TenantId = scope.TenantId;
- query.FactoryId = scope.FactoryId;
- return Ok(await _svc.ListAsync(query));
- }
- [HttpGet("{id:long}")]
- public async Task<IActionResult> GetAsync(long id)
- {
- try { return Ok(await _svc.GetAsync(id, await _scope.ResolveAsync())); }
- catch (S8NotFoundException) { return NotFound(); }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- [HttpPost]
- public async Task<IActionResult> CreateAsync([FromBody] AdoS8ConfigDraftCreateDto 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] AdoS8ConfigDraftUpdateDto 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());
- return Ok(new { id, deleted = true });
- }
- catch (S8NotFoundException) { return NotFound(); }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- [HttpPost("{id:long}/generate-rule")]
- public async Task<IActionResult> GenerateRuleAsync(long id, [FromBody] AdoS8ConfigDraftGenerateRuleDto body)
- {
- try { return Ok(await _svc.GenerateRuleAsync(id, body, await _scope.ResolveAsync())); }
- catch (S8NotFoundException) { return NotFound(); }
- catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
- }
- }
|