using BPA.SAAS.Manage.Application.Device.Dtos.Device;
using BPA.SAAS.Manage.Comm.Const;
using BPA.SAAS.Manage.Core.Base;
using Furion.RemoteRequest.Extensions;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SAAS.Manage.Application
{
    [ApiDescriptionSettings("Stop", Tag = "获取场景")]
    public class StoreServers: IDynamicApiController
    {
        public StoreServers()
        {

        }
        private  string BaseServerUrl = App.GetConfig<string>("baseurl");
        [HttpGet("/api/stop/getstop")]
        public  async  Task<List<StoreDto>> GetStop()
        {
            var getStoreurl = BaseServerUrl + "api/shop/alllist";
            var responseGoodsAttribute = await getStoreurl.SetHeaders(new
            {
                groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value
            }).SetHttpMethod(HttpMethod.Get).GetAsStringAsync();
            var resStore = JsonConvert.DeserializeObject<ResponDataBase>(responseGoodsAttribute);
            if (resStore?.statusCode != "200") throw Oops.Oh("获取场景数据失败");
            var dataStore = JsonConvert.DeserializeObject<List<StoreDto>>(resStore.data.ToString());
            return dataStore;
        }
    }
}
