SiteWeatherInfoController.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using Microsoft.AspNetCore.Mvc;
  7. using Microsoft.Extensions.Logging;
  8. using FMSAdmin.Models;
  9. using System.Security.Claims;
  10. using Microsoft.AspNetCore.Authentication;
  11. using Microsoft.AspNetCore.Authentication.Cookies;
  12. using Microsoft.AspNetCore.Authorization;
  13. using FMSAdmin.Data;
  14. using System.Net.Http;
  15. using System.Xml.Linq;
  16. using FMSAdmin.Helpers;
  17. using FMSAdmin.Entities;
  18. using System.ComponentModel.DataAnnotations;
  19. using System.Net;
  20. using FMSAdmin.Services;
  21. namespace FMSAdmin.Controllers {
  22. [Authorize]
  23. [ApiController]
  24. [ApiVersion("1")]
  25. [Route("api/[controller]")]
  26. public class SiteWeatherInfoController : Controller {
  27. private readonly ILogger<SiteWeatherInfoController> _logger;
  28. private readonly FMSContext _context;
  29. private readonly SiteWeatherInfoService _service;
  30. public SiteWeatherInfoController(
  31. ILogger<SiteWeatherInfoController> logger,
  32. FMSContext context,
  33. SiteWeatherInfoService service
  34. ) {
  35. _logger = logger;
  36. _context = context;
  37. _service = service;
  38. }
  39. [HttpGet]
  40. public IActionResult Api(int? siteId, string sido, string sigun) {
  41. if (siteId == null) {
  42. siteId = User.GetSiteId();
  43. }
  44. var weatherInfo = _service.GetInfo(siteId.Value, sido, sigun);
  45. return Ok(weatherInfo);
  46. }
  47. [AllowAnonymous]
  48. [HttpGet("[action]")]
  49. public IActionResult NxNyList() {
  50. var list = _context.WeatherRegionNxNy.ToList();
  51. return Ok(list);
  52. }
  53. [AllowAnonymous]
  54. [HttpGet("[action]")]
  55. public IActionResult WeatherStat() {
  56. var table = _service.WeatherStat();
  57. return Ok(table);
  58. }
  59. }
  60. }