using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Nirvana.Common.ApiBase;
using System.Threading.Tasks;
using YBDevice.Entity;
using YBDevice.NApi.Application.MeasureInfo;

namespace YBDevice.NApi.Controllers
{
    /// <summary>
    /// 测量接口
    /// </summary>
    public class ResultController : BaseController
    {
        private readonly IResultService _resultService;

        public ResultController(IResultService resultService)
        {
            _resultService = resultService;
        }

        /// <summary>
        /// 增加测量记录,用于蓝牙传输,适用于F01PRO
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> MeasureDataAsync(MeasureDataSubmitModel model)
        {
            return await _resultService.MeasureDataAsync(model);
        }

        /// <summary>
        /// 增加测量记录,用于蓝牙传输
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> MeasureAsync([FromBody] MeasureSubmitModel data)
        {
            return await _resultService.MeasureAsync(data);
        }

        /// <summary>
        /// 增加测量记录,用于蓝牙传输,身高带有单位(cm/ft)
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> MeasureOfUnitAsync([FromBody] MeasureOfUnitSubmitModel data)
        {
            return await _resultService.MeasureOfUnitAsync(data);
        }

        /// <summary>
        /// 添加测量记录,针对八电极
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> InsertBodyMeasureAsync(MeasureBodySubmitC2SDto data)
        {
            return await _resultService.InsertBodyMeasureAsync(data);
        }

        /// <summary>
        /// 添加测量记录,针对八电极,不激活
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> InsertBodyMeasureNoActiveAsync(MeasureBodySubmitC2SDto data)
        {
            return await _resultService.InsertBodyMeasureNoActiveAsync(data);
        }

        /// <summary>
        /// 手动增加测量记录
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> InsertMeasureAsync([FromBody] UserMeasureSubmitModel data)
        {
            return await _resultService.InsertMeasureAsync(data);
        }

        /// <summary>
        /// 检测设备状态
        /// </summary>
        /// <param name="sn">设备机器码</param>
        /// <param name="type">类型,0-检测设备是否存在,1-不检测</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultInfo> CheckDevStatus(string sn, int type = 0)
        {
            return await _resultService.CheckDevStatus(sn, type);
        }

        /// <summary>
        /// 两次测量记录对比
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> ResultDiff(ResultDiffC2SDto data)
        {
            return await _resultService.ResultDiff(data);
        }

        /// <summary>
        /// 删除测量记录
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> DeleteAsync(DeleteResultC2SDto data)
        {
            return await _resultService.DeleteAsync(data);
        }

        /// <summary>
        /// 测量记录详情
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> DetailAsync(ResultDetailC2SDto input)
        {
            return await _resultService.DetailAsync(input);
        }
    }
}