using Furion.DynamicApiController;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Nirvana.Common;
using Nirvana.Common.ApiBase;
using System.Threading.Tasks;

namespace YBDevice.NApi.Application.BusinessClient.DeviceInfo
{
    /// <summary>
    /// 设备管理接口
    /// </summary>
    [ApiDescriptionSettings("BusinessClient")]
    [AppAuthorize]
    public class DeviceAppService : IDynamicApiController
    {
        private readonly IDeviceService _deviceService;
        public DeviceAppService(IDeviceService deviceService)
        {
            _deviceService = deviceService;
        }

        /// <summary>
        /// 设备激活
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [QueryParameters]
        public async Task<ResultInfo> ActiveAsync(string sn, string code)
        {
            return await _deviceService.ActiveAsync(sn, code);
        }
        /// <summary>
        /// 名下设备列表
        /// </summary>
        /// <param name="queryParams"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetList(QueryParams queryParams)
        {
            return await _deviceService.GetListAsync(queryParams);
        }
        /// <summary>
        /// 设备详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        [QueryParameters]
        public async Task<ResultInfo> DetailAsync(int id)
        {
            return await _deviceService.DetailAsync(id);
        }
        /// <summary>
        /// 获取设备类型列表
        /// </summary>
        /// <param name="appid">小程序appid</param>
        /// <returns></returns>
        [QueryParameters]
        public async Task<ResultInfo> GetDevTypeListAsync(string appid="")
        {
            return await _deviceService.GetDevTypeListAsync(appid);
        }
    }
}
