AdoS8ConfigDraftsController.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using Admin.NET.Plugin.AiDOP.Dto.S8;
  2. using Admin.NET.Plugin.AiDOP.Service.S8;
  3. namespace Admin.NET.Plugin.AiDOP.Controllers.S8;
  4. [ApiController]
  5. [Route("api/aidop/s8/config/wizard-drafts")]
  6. [NonUnify]
  7. public class AdoS8ConfigDraftsController : ControllerBase
  8. {
  9. private readonly S8ConfigDraftService _svc;
  10. public AdoS8ConfigDraftsController(S8ConfigDraftService svc) => _svc = svc;
  11. [HttpGet]
  12. public async Task<IActionResult> ListAsync([FromQuery] AdoS8ConfigDraftListQueryDto query) =>
  13. Ok(await _svc.ListAsync(query));
  14. [HttpGet("{id:long}")]
  15. public async Task<IActionResult> GetAsync(long id)
  16. {
  17. try { return Ok(await _svc.GetAsync(id)); }
  18. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  19. }
  20. [HttpPost]
  21. public async Task<IActionResult> CreateAsync([FromBody] AdoS8ConfigDraftCreateDto body)
  22. {
  23. try { return Ok(await _svc.CreateAsync(body)); }
  24. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  25. }
  26. [HttpPut("{id:long}")]
  27. public async Task<IActionResult> UpdateAsync(long id, [FromBody] AdoS8ConfigDraftUpdateDto body)
  28. {
  29. try { return Ok(await _svc.UpdateAsync(id, body)); }
  30. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  31. }
  32. [HttpDelete("{id:long}")]
  33. public async Task<IActionResult> DeleteAsync(long id)
  34. {
  35. try
  36. {
  37. await _svc.DeleteAsync(id);
  38. return Ok(new { id, deleted = true });
  39. }
  40. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  41. }
  42. [HttpPost("{id:long}/generate-rule")]
  43. public async Task<IActionResult> GenerateRuleAsync(long id, [FromBody] AdoS8ConfigDraftGenerateRuleDto body)
  44. {
  45. try { return Ok(await _svc.GenerateRuleAsync(id, body)); }
  46. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  47. }
  48. }