using Furion.DynamicApiController;
using Furion.JsonSerialization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using SqlSugar;
using System;
using System.Threading.Tasks;

namespace Ewide.NbzsZheliban
{
    [ApiDescriptionSettings(Name = "test")]
    public class TestService : IDynamicApiController
    {
        //private readonly IDapperRepository _dapperRep;
        private readonly ISqlSugarRepository repository;
        private readonly SqlSugarClient db;
        private readonly IJsonSerializerProvider _jsonSerializer;
        //public TestService(ISqlSugarRepository sqlSugarRepository, IDapperRepository dapperRep, IJsonSerializerProvider jsonSerializer)
        // {     //_dapperRep = dapperRep;
        public TestService(ISqlSugarRepository sqlSugarRepository, IJsonSerializerProvider jsonSerializer)
        {
            repository = sqlSugarRepository;
            db = repository.Context;
            _jsonSerializer = jsonSerializer;
        }
        //[HttpGet("/test/list")]
        //[Microsoft.AspNetCore.Authorization.AllowAnonymous]
        //public async Task<dynamic> List([FromQuery] JObject args)
        //{
        //    var asd = _jsonSerializer.Serialize(new { Id = "1", Name = "ASD", dt = DateTime.Now });
        //    return await db.Queryable<Entity.TCodeScore>().ToListAsync();
        //    //return null; 
        //}
        [HttpGet("/test/list2")]
        [Microsoft.AspNetCore.Authorization.AllowAnonymous]
        public async Task<dynamic> List2([FromQuery] JObject args)
        {
            return await repository.Ado.GetDataTableAsync("select * from TCodeScore"); ;
        }
    }
}
