using Admin.NET.Plugin.AiDOP.Dto.S8; 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; public AdoS8ConfigDraftsController(S8ConfigDraftService svc) => _svc = svc; [HttpGet] public async Task ListAsync([FromQuery] AdoS8ConfigDraftListQueryDto query) => Ok(await _svc.ListAsync(query)); [HttpGet("{id:long}")] public async Task GetAsync(long id) { try { return Ok(await _svc.GetAsync(id)); } catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); } } [HttpPost] public async Task CreateAsync([FromBody] AdoS8ConfigDraftCreateDto body) { try { return Ok(await _svc.CreateAsync(body)); } catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); } } [HttpPut("{id:long}")] public async Task UpdateAsync(long id, [FromBody] AdoS8ConfigDraftUpdateDto body) { try { return Ok(await _svc.UpdateAsync(id, body)); } catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); } } [HttpDelete("{id:long}")] public async Task DeleteAsync(long id) { try { await _svc.DeleteAsync(id); return Ok(new { id, deleted = true }); } catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); } } [HttpPost("{id:long}/generate-rule")] public async Task GenerateRuleAsync(long id, [FromBody] AdoS8ConfigDraftGenerateRuleDto body) { try { return Ok(await _svc.GenerateRuleAsync(id, body)); } catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); } } }