using Infrastructure;
using Infrastructure.Extensions;
using OpenAuth.App.BaseApp.Base;
using OpenAuth.App.Interface;
using OpenAuth.Repository;
using OpenAuth.Repository.Domain;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenAuth.App
{
    public class SysAppSettingApp : SqlSugarBaseApp<SysAppSetting, SugarDbContext>
    {
        public SysAppSettingApp(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<SysAppSetting> repository, IAuth auth) : base(unitWork, repository, auth)
        {
        }

        public async Task<SysAppSetting> Get(long id)
        {
            return await Repository.GetByIdAsync(id);
        }

        public async Task<Response<bool>> Save(SysAppSetting model)
        {
            var flag = await base.UnitWork.Db.Storageable(model).ExecuteCommandAsync();

            return new Response<bool>
            {
                Result = flag > 0,
                Message = flag > 0 ? "success" : "error"
            };
        }
    }
}
