using Fuel.Application.Authorization;
using Fuel.Application.Service;
using Fuel.Core.Nozzle.Dto;
using Fuel.Core.Transactions.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Fuel.PaymentServer.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
   // [Authorize]
    public class NozzleController : ControllerBase
    {
        private readonly INozzleService InozzleService;
        public NozzleController(INozzleService nozzleService)
        {
            InozzleService = nozzleService;
        }
        /// <summary>
        /// 上传油枪信息
        /// </summary>
        /// <param name="uploadNozzle"></param>
        /// <returns></returns>
        [Permission("Nozzle:UploadNozzle:POST")]
        [Route("UploadNozzle")]
        [HttpPost]
        public async Task<IActionResult> UploadNozzle(UploadNozzle uploadNozzle)
        {
            var serviceResult = await InozzleService.UploadNozzle(uploadNozzle);
            return Ok(serviceResult);
        }
        /// <summary>
        /// 更新油枪信息
        /// </summary>
        /// <param name="uploadNozzle"></param>
        /// <returns></returns>
        [Permission("Nozzle:UpdateNozzle:PUT")]
        [Route("UpdateNozzle")]
        [HttpPut]
        public async Task<IActionResult> UpdateNozzle(UploadNozzle uploadNozzle)
        {
            var serviceResult = await InozzleService.UpdateNozzle(uploadNozzle);
            return Ok(serviceResult);
        }
        /// <summary>
        /// 删除油枪信息
        /// </summary>
        /// <param name="uploadNozzle"></param>
        /// <returns></returns>
        [Permission("Nozzle:DeleteNozzle:Delete")]
        [Route("DeleteNozzle")]
        [HttpDelete]
        public async Task<IActionResult> DeleteNozzle(UploadNozzle uploadNozzle)
        {
            var serviceResult = await InozzleService.DeleteNozzle(uploadNozzle);
            return Ok(serviceResult);
        }
        [Permission("Nozzle:UpdateNozzleStatus:PUT")]
        [Route("UpdateNozzleStatus")]
        [HttpPut]
        public async Task<IActionResult> UpdateNozzleStatus(List<UploadNozzleStatus> uploadNozzleStatuses)
        {
           var serviceResult = await InozzleService.UpdateNozzleStatus(uploadNozzleStatuses);
            return Ok(serviceResult);
        }
        /// <summary>
        /// 获取油枪信息
        /// </summary>
        /// <param name="Nozzleid"></param>
        /// <returns></returns>
        [Permission("Nozzle:GetNozzleInfo:GET")]
        [Route("GetNozzleInfo")]
        [HttpGet]
        public async Task<List<NozzleInfo>> GetNozzleInfo(int Nozzleid)
        {
            var data = await InozzleService.GetNozzleInfo(Nozzleid);
            return data;
        }
        /// <summary>
        /// 上传油品
        /// </summary>
        /// <param name="uploadNozzle"></param>
        /// <returns></returns>
        [Permission("Nozzle:uploadProduct:POST")]
        [Route("uploadProduct")]
        [HttpPost]
        public async Task<IActionResult> uploadProduct(UploadProduct uploadProduct)
        {
            var serviceResult = await InozzleService.UploadProduct(uploadProduct);
            return Ok(serviceResult);
        }
        /// <summary>
        /// 更新油品信息
        /// </summary>
        /// <param name="uploadNozzle"></param>
        /// <returns></returns>
        [Permission("Nozzle:UpdateProduct:Put")]
        [Route("UpdateProduct")]
        [HttpPut]
        public async Task<IActionResult> UpdateProduct(UploadProduct uploadProduct)
        {
            var serviceResult = await InozzleService.UpdateProduct(uploadProduct);
            return Ok(serviceResult);
        }
        /// <summary>
        /// 删除油品信息
        /// </summary>
        /// <param name="uploadNozzle"></param>
        /// <returns></returns>
        [Permission("Nozzle:DeleteProduct:Delete")]
        [Route("DeleteProduct")]
        [HttpDelete]
        public async Task<IActionResult> DeleteProduct(UploadProduct uploadProduct)
        {
            var serviceResult = await InozzleService.DeleteProduct(uploadProduct);
            return Ok(serviceResult);
        }
        /// <summary>
        /// 上传油罐信息
        /// </summary>
        /// <param name="uploadNozzle"></param>
        /// <returns></returns>
        [Permission("Nozzle:uploadTanks:POST")]
        [Route("uploadTanks")]
        [HttpPost]
        public async Task<IActionResult> uploadTanks(UploadTanks uploadTanks)
        {
            var serviceResult = await InozzleService.UploadTanks(uploadTanks);
            return Ok(serviceResult);
        }
        /// <summary>
        /// 更新油罐信息
        /// </summary>
        /// <param name="uploadNozzle"></param>
        /// <returns></returns>
        [Permission("Nozzle:UpdateTanks:Put")]
        [Route("UpdateTanks")]
        [HttpPut]
        public async Task<IActionResult> UpdateTanks(UploadTanks uploadTanks)
        {
            var serviceResult = await InozzleService.UpdateTanks(uploadTanks);
            return Ok(serviceResult);
        }
        /// <summary>
        /// 删除油灌信息
        /// </summary>
        /// <param name="uploadNozzle"></param>
        /// <returns></returns>
        [Permission("Nozzle:DeleteTanks:Delete")]
        [Route("DeleteTanks")]
        [HttpDelete]
        public async Task<IActionResult> DeleteTanks(UploadTanks uploadTanks)
        {
            var serviceResult = await InozzleService.DeleteTanks(uploadTanks);
            return Ok(serviceResult);
        }
    }
}
