using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
using Nirvana.Common;
using Nirvana.Common.ApiBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YBDevice.Application.AdInfo;
using YBDevice.Entity;

namespace YBDevice.Application
{
    /// <summary>
    /// 广告管理接口
    /// </summary>
    public class InfoAppService : IDynamicApiController
    {
        private readonly IAdService _adService;
        private readonly IInfoService _infoService;
        public InfoAppService(IAdService adService, IInfoService infoService)
        {
            _adService = adService;
            _infoService = infoService;
        }

        /// <summary>
        /// 获取轮播图、开屏广告列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetListAsync(QueryParams param)
        {
            var result = await _adService.GetListAsync(param);
            return new ResultInfo(ResultState.SUCCESS, "success", result);
        }
        /// <summary>
        /// 信息提交
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<ResultInfo> SubmitAsync(BannerSubmitModel model)
        {
            return await _adService.SubmitAsync(model);
        }
        /// <summary>
        /// 状态修改
        /// </summary>
        /// <param name="id">记录ID</param>
        /// <param name="status">状态</param>
        /// <param name="remark">状态描述</param>
        /// <returns></returns>
        [HttpGet]
        [QueryParameters]
        public async Task<ResultInfo> SetStatusAsync(int id, AdStatus status, string remark)
        {
            return await _adService.SetStatusAsync(id, status, remark);
        }
        /// <summary>
        /// 获取轮播图设备列表
        /// </summary>
        /// <param name="orderid">轮播图ID</param>
        /// <param name="page">页码</param>
        /// <param name="pagesize">每页显示的数量</param>
        /// <param name="code">设备序列号</param>
        /// <param name="type">设备类型</param>
        /// <returns></returns>
        [HttpGet]
        [QueryParameters]
        public async Task<ResultInfo> GetOrderEquListAsync(int orderid, int page = 1, int pagesize = 50, string code = "", int type = 0)
        {
            var data = await _adService.GetOrderEquListAsync(orderid, page, pagesize, code, type);
            return new ResultInfo(ResultState.SUCCESS, "success", data);
        }
        /// <summary>
        /// 资讯列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetInfoListAsync(QueryParams param)
        {
            var result = await _infoService.GetListAsync(param);
            return new ResultInfo(ResultState.SUCCESS, "success", result);
        }

        /// <summary>
        /// 资讯信息提交
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<ResultInfo> SubmitInfoAsync(SecInfoSubmitModel model)
        {
            return await _infoService.SubmitAsync(model);
        }
        /// <summary>
        /// 状态修改
        /// </summary>
        /// <param name="id">记录ID</param>
        /// <param name="status">状态</param>
        /// <param name="remark">状态描述</param>
        /// <returns></returns>
        [HttpGet]
        [QueryParameters]
        public async Task<ResultInfo> SetInfoStatusAsync(Guid id, AdStatus status, string remark)
        {
            return await _infoService.SetStatusAsync(id, status, remark);
        }
        /// <summary>
        /// 类型列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetTypeListAsync(QueryParams param)
        {
            var result = await _infoService.GetTypeListAsync(param);
            return new ResultInfo(ResultState.SUCCESS, "success", result);
        }
        /// <summary>
        /// 类型信息修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<ResultInfo> SubmitTypeAsync(SecInfoTypeCS2Dto model)
        {
            return await _infoService.SubmitTypeAsync(model);
        }

        /// <summary>
        /// 类型状态修改
        /// </summary>
        /// <param name="id">记录ID</param>
        /// <param name="status">状态</param>
        /// <returns></returns>
        [HttpGet]
        [QueryParameters]
        public async Task<ResultInfo> SetTypeStatusAsync(int id, StatusType status)
        {
            return await _infoService.SetTypeStatusAsync(id, status);
        }
    }
}
