AdoS8ReportsController.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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/reports")]
  6. [NonUnify]
  7. public class AdoS8ReportsController : ControllerBase
  8. {
  9. private readonly S8ManualReportService _svc;
  10. public AdoS8ReportsController(S8ManualReportService svc) => _svc = svc;
  11. [HttpGet("form-options")]
  12. public async Task<IActionResult> FormOptionsAsync([FromQuery] long tenantId = 1, [FromQuery] long factoryId = 1) =>
  13. Ok(await _svc.GetFormOptionsAsync(tenantId, factoryId));
  14. [HttpPost]
  15. public async Task<IActionResult> CreateAsync([FromBody] AdoS8ManualReportCreateDto dto)
  16. {
  17. try { return Ok(await _svc.CreateAsync(dto)); }
  18. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  19. }
  20. [HttpGet("{id:long}")]
  21. public async Task<IActionResult> GetAsync(long id)
  22. {
  23. var e = await _svc.GetAsync(id);
  24. return e == null ? NotFound() : Ok(e);
  25. }
  26. [HttpPost("{id:long}/attachments")]
  27. public async Task<IActionResult> AttachmentsAsync(long id, [FromBody] AdoS8AttachmentCreateDto dto)
  28. {
  29. try { return Ok(await _svc.AddAttachmentAsync(id, dto)); }
  30. catch (S8BizException ex) { return BadRequest(new { message = ex.Message }); }
  31. }
  32. }