using Microsoft.AspNetCore.Mvc;
using Nirvana.Common.ApiBase;
using System.Threading.Tasks;
using YBDevice.Entity;

namespace YBDevice.NApi.Controllers.Api
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DeviceController : ControllerBase
    {
        private readonly IDeviceService _deviceService;
        public DeviceController(IDeviceService deviceService)
        {
            _deviceService = deviceService;
        }
        /// <summary> 
        /// 设备注册
        /// </summary>
        /// <param name="yB_Device"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetInfoAsync(YB_Device yB_Device)
        {
            return await _deviceService.RegAsync(yB_Device);
        }
        /// <summary>
        /// 获取设备类型列表
        /// </summary>
        /// <param name="appid">小程序appid</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultInfo> GetTypeListAsync(string appid)
        {
            return await _deviceService.GetTypeListAsync(appid);
        }

        /// <summary>
        /// 根据扫码的设备列表导出EXCEL
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> ExportExcelByScanListAsync(ScanListC2SDto data)
        {
            return await _deviceService.ExportExcelByScanListAsync(data);
        }
    }
}
