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

namespace Waste.Application
{
    /// <summary>
    /// 设备接口
    /// </summary>
    public class DeviceAppService : IDynamicApiController
    {
        private readonly IDeviceService _deviceService;

        public DeviceAppService(IDeviceService deviceService)
        {
            _deviceService = deviceService;
        }

        /// <summary>
        /// 设备列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageParms<DeviceList>> GetListAsync(QueryParams param)
        {
            return await _deviceService.GetListAsync(param);
        }

        /// <summary>
        /// 信息提交
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public async Task<ResultInfo> SubmitFormAsync(DeviceSubmit role)
        {
            return await _deviceService.SubmitFormAsync(role);
        }

        /// <summary>
        /// 批量操作
        /// </summary>
        /// <param name="deviceBatchModel"></param>
        /// <returns></returns>
        public async Task<ResultInfo> BatchSetAsync(DeviceBatchModel deviceBatchModel)
        {
            return await _deviceService.BatchSetAsync(deviceBatchModel);
        }

        /// <summary>
        /// 设备状态修改
        /// </summary>
        /// <param name="id">设备ID</param>
        /// <param name="status">设备状态,0-停用,1-正常,2-激活</param>
        /// <returns></returns>
        [HttpGet]
        [QueryParameters]
        public async Task<ResultInfo> SetStatusAsync(Guid id, int status)
        {
            return await _deviceService.SetStatusAsync(id, status);
        }

        /// <summary>
        /// 配置设备推送信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<ResultInfo> SetConfigAsync(DeviceConfigC2SDto input)
        {
            return await _deviceService.SetConfigAsync(input);
        }

        /// <summary>
        /// 批量配置千灯镇商户推送
        /// </summary>
        /// <returns></returns>
        [AllowAnonymous]
        public async Task SetQDConfig()
        {
            await _deviceService.SetQDConfig();
        }
    }
}