PowerMatterController.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Mvc;
  6. using PowerMatterServiceReference;
  7. using Microsoft.AspNetCore.Cors;
  8. namespace Winsoft.GOV.PowerMatter.Restful.Controllers
  9. {
  10. [Route("api/[controller]")]
  11. [EnableCors("any")]
  12. public class PowerMatterController : Controller
  13. {
  14. IPowerMettersService _powerMatterService;
  15. public PowerMatterController(IPowerMettersService powerMatterService)
  16. {
  17. _powerMatterService = powerMatterService;
  18. }
  19. [HttpGet("getByBranch/{c:int}/{guid}")]
  20. [Produces(typeof(List<PowerMattersBase>))]
  21. public async Task<IActionResult> Get(County c, string guid)
  22. {
  23. List<PowerMattersBase> ps = await _powerMatterService.GetPowerMattersByBranchGuidExAsync(guid, c);
  24. if (ps == null)
  25. ps = new List<PowerMattersBase>();
  26. return Ok(ps);
  27. }
  28. [HttpGet("detail/{c:int}/{ql_inner_code}")]
  29. [Produces(typeof(PowerMattersDetail))]
  30. public async Task<IActionResult> GetDetail(County c, string ql_inner_code)
  31. {
  32. PowerMattersDetail pd = await _powerMatterService.GetPowerMattersDetailByRowIDExAsync(ql_inner_code, c);
  33. if (pd == null)
  34. return BadRequest();
  35. return Ok(pd);
  36. }
  37. }
  38. }