using Edge.Core.Domain.FccNozzleInfo.Input;
using Edge.Core.Domain.FccNozzleInfo.Output;
using Edge.Core.Domain.FccTankInfo.Input;
using Edge.Core.Domain.FccTankInfo.Output;
using FccLite.Web.Services.FccNozzleInfo;
using FccLite.Web.Services.FccTankInfo;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace FccLite.Web.Controller
{
    [Route("qrFueling/tank")]
    [ApiController]
    public class TankController : ControllerBase
    {
        private readonly ITankInfoService _tankInfoService;
        private readonly INozzleInfnService _nozzleInfnService;
        public TankController(ITankInfoService tankInfoService,INozzleInfnService nozzleInfnService) 
        {
            _tankInfoService = tankInfoService;
            _nozzleInfnService = nozzleInfnService;
        }


        [HttpGet("getBaseTankInfo")]
        public async Task<IActionResult> GetBaseTankInfo(long id)
        {
            List<BaseTankInfoOutput> baseTankInfos = await _tankInfoService.GetBaseTankByStationIdAsync(id);
            return Ok(baseTankInfos);
        }

        [HttpGet("getDetailsTankInfo")]
        public async Task<IActionResult> GetDetailsTankInfo(long id)
        {
            DetailsTankInfoOutput detailsTankInfoOutput = await _tankInfoService.GetDetailsTankByTankIdAsync(id);
            return Ok(detailsTankInfoOutput);
        }

        [HttpPost("addDetailsTankInfo")]
        public async Task<IActionResult> AddDetailsTankInfo(AddTankInput addTankInput)
        {
            SetTankInfoOutput result = await _tankInfoService.AddDetailsTankAsync(addTankInput);
            return Ok(result);
        }

        [HttpPost("updateDetailsTankInfo")]
        public async Task<IActionResult> UpdateDetailsTankInfo(UpdateTankInput updateTankInput)
        {
            SetTankInfoOutput result = await _tankInfoService.UpdateDetailsTankAsync(updateTankInput);
            return Ok(result);
        }

        [HttpPost("deleteTank")]
        public async Task<IActionResult> DeleteTank(long id)
        {
            SetTankInfoOutput result = await _tankInfoService.DeleteTankById(id);
            return Ok(result);
        }

        [HttpGet("getDetailsNozzleInfo")]
        public async Task<IActionResult> GetDetailsNozzleInfo(long id)
        {
            DetailsNozzleInfoOutput? result = await _nozzleInfnService.GetDetailsNozzleInfoById(id);
            if (result == null) return Ok("查找不到该油枪信息");
            return Ok(result);
        }

        [HttpPost("uploadDetailsNozzleInfo")]
        public async Task<IActionResult> UploadDetailsNozzleInfo(UploadNozzleInfoInput uploadNozzleInfoInput)
        {
            SetNozzleInfoOutput result = await _nozzleInfnService.UploadDetailsNozzleInfo(uploadNozzleInfoInput);
            return Ok(result);
        }

        [HttpPost("deleteNozzle")]
        public async Task<IActionResult> DeleteNozzle(long id)
        {
            SetNozzleInfoOutput result = await _nozzleInfnService.DeleteNozzleInfoByID(id);
            return Ok(result);
        }
    }
}
