using BPA.Kitchen.Core.Common.RequestAnalysis;
using Furion.FriendlyException;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.KitChen.GroupMeal.SqlSugar
{
    public class SupperRepository: UserAnalysis
    {
        public async Task<T> BaseAction<T>(SqlSugarClient db, Func<T> action, Func<T> defualtActoion, string msg)
        {
            try
            {
                db.BeginTran();
                var res = action.Invoke();
                db.CommitTran();
                return await Task.FromResult(res);
            }
            catch (Exception ex)
            {
                db.RollbackTran();
                //BPALog.WriteLog(msg + ":" + ex.Message, LogEnum.Error, null, ex);
                throw Oops.Oh(ex.Message);
            }
        }
    }
}
