using BPA.KitChen.GroupMeal.Core.Common;
using BPA.KitChen.GroupMeal.Core.Entity;
using BPA.KitChen.GroupMeal.SqlSugar;
using Furion.DependencyInjection;
using Furion.FriendlyException;
using SqlSugar;

namespace BPA.KitChen.GroupMeal.Application.Service.AExternalPlatform.Service.ShopService.Service
{
    public class ShopService: IShopService, ITransient
    {

        /// <summary>
        /// 获取店铺信息
        /// </summary>
        /// <returns></returns>
        public async Task<ShopEntity> GetShopInfo()
        {
            var key = CurrentUser.Key;
            var res = await SqlSugarDb.Db.Queryable<ShopEntity , BPA_StoreAuthorization>((a,b) => 
                new JoinQueryInfos(JoinType.Left,a.Id==b.StoreId))
                .Where((a,b)=>b.Key== key)
                .FirstAsync();
            if (res==null)
            {
                throw Oops.Oh("店铺不存在");
            }

            return res;
        }
    }
}
