ConfigController.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using Edge.Core.Domain.FccOilInfo.Input;
  2. using Edge.Core.Domain.FccOilInfo.Ouput;
  3. using Edge.Core.Domain.FccStationInfo.Input;
  4. using Edge.Core.Domain.FccStationInfo.Output;
  5. using FccLite.Web.Services.FccOilInfo;
  6. using FccLite.Web.Services.FccStaionInfo;
  7. using Microsoft.AspNetCore.Http;
  8. using Microsoft.AspNetCore.Mvc;
  9. using Microsoft.AspNetCore.Mvc.RazorPages;
  10. using System.Drawing;
  11. using System.Text.Json;
  12. using System.Xml.Linq;
  13. namespace FccLite.Web.Controller
  14. {
  15. [Route("qrFueling/config")]
  16. [ApiController]
  17. public class ConfigController : ControllerBase
  18. {
  19. static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
  20. private readonly IStationService _stationService;
  21. private readonly IOilInfoService _oilInfoService;
  22. public ConfigController(IStationService stationService,IOilInfoService oilInfoService)
  23. {
  24. _stationService = stationService;
  25. _oilInfoService = oilInfoService;
  26. }
  27. /// <summary>
  28. /// 新增、更改站点信息
  29. /// </summary>
  30. /// <param name="stationInfoInput">站点信息</param>
  31. /// <returns></returns>
  32. [HttpPost("upLoadBaseInfo")]
  33. public async Task<StationSetOutput> UpLoadBaseInfo(StationInfoInput stationInfoInput)
  34. {
  35. logger.Info($"add or update station info,{JsonSerializer.Serialize(stationInfoInput)}");
  36. return await _stationService.UploadBaseInfo(stationInfoInput);
  37. }
  38. /// <summary>
  39. /// 分页获取站点信息
  40. /// </summary>
  41. /// <param name="page">页码</param>
  42. /// <param name="size">页数</param>
  43. /// <param name="id">过滤信息——id</param>
  44. /// <param name="name">过滤信息——站点名</param>
  45. /// <param name="longitude">过滤信息——经度</param>
  46. /// <param name="latitude">过滤信息——纬度</param>
  47. /// <returns></returns>
  48. [HttpGet("getBaseInfo")]
  49. public async Task<IActionResult> GetBaseInfo(int page, int size,long? id,string? name, decimal? longitude,decimal? latitude)
  50. {
  51. logger.Info($"get page of station info:page = {page},size = {size}, id = {id},name = {name},longitude = {longitude},latitude = {latitude}");
  52. var response = await _stationService.GetBaseInfo(page, size, id,name,longitude,latitude);
  53. return Ok(response);
  54. }
  55. /// <summary>
  56. /// 通过 id 删除站点信息
  57. /// </summary>
  58. /// <param name="id">站点id</param>
  59. /// <returns></returns>
  60. [HttpPost("deleteBaseInfo")]
  61. public async Task<IActionResult> DeleteBaseInfo(long id)
  62. {
  63. logger.Info($"delete station info by id:{id}");
  64. var response = await _stationService.DeleteBaseInfo(id);
  65. return Ok(response);
  66. }
  67. /// <summary>
  68. /// 获取订单过滤条件
  69. /// </summary>
  70. /// <returns></returns>
  71. [HttpGet("getOrderFilter")]
  72. public async Task<IActionResult> GetOrderFilter()
  73. {
  74. OrderFilterOutput orderFilterOutput = await _stationService.GetOrderFilter();
  75. return Ok(orderFilterOutput);
  76. }
  77. /// <summary>
  78. /// 分页获取油品信息
  79. /// </summary>
  80. /// <param name="page">页数</param>
  81. /// <param name="size">页码</param>
  82. /// <param name="id">过滤条件——id</param>
  83. /// <param name="name">过滤条件——油品名</param>
  84. /// <param name="code">过滤条件——油品码</param>
  85. /// <returns></returns>
  86. [HttpGet("getOilInfo")]
  87. public async Task<IActionResult> GetOilInfo(int page,int size,long? id,string? name,string? code)
  88. {
  89. logger.Info($"get page of oil info,page = {page},size = {size},id = {id},name = {name},code = {code}");
  90. var response = await _oilInfoService.GetPage(page, size, id, name, code);
  91. return Ok(response);
  92. }
  93. /// <summary>
  94. /// 新增、修改油品信息
  95. /// </summary>
  96. /// <param name="oilInfoInput">油品信息</param>
  97. /// <returns></returns>
  98. [HttpPost("upLoadOilInfo")]
  99. public async Task<OilInfoSetOutput> UpLoadOilInfo(OilInfoInput oilInfoInput)
  100. {
  101. logger.Info($"add or update oil info,{JsonSerializer.Serialize(oilInfoInput)}");
  102. return await _oilInfoService.Save(oilInfoInput);
  103. }
  104. /// <summary>
  105. /// 通过 id 删除油品信息
  106. /// </summary>
  107. /// <param name="id">id</param>
  108. /// <returns></returns>
  109. [HttpPost("deleteOilInfo")]
  110. public async Task<IActionResult> DeleteOilInfo(long id)
  111. {
  112. logger.Info($"delete oil info by id:{id}");
  113. var response = await _oilInfoService.DeleteById(id);
  114. return Ok(response);
  115. }
  116. }
  117. }