using NCC.Common.Core.Manager;
using NCC.Common.Enum;
using NCC.Common.Extension;
using NCC.Common.Filter;
using NCC.Dependency;
using NCC.DynamicApiController;
using NCC.FriendlyException;
using NCC.Extend.Interfaces.TbTest;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NCC.Extend.Entitys.common_extend;
using NCC.Extend.Entitys.Dto.TbTest;
using Yitter.IdGenerator;
using NCC.Common.Helper;
using NCC.JsonSerialization;
using Aspose.Cells.Drawing.Texts;
using NCC.System.Entitys.Permission;
namespace NCC.Extend.TbTest
{
///
/// 测试列表服务
///
[ApiDescriptionSettings(Tag = "测试列表服务", Name = "TbTest", Order = 200)]
[Route("api/Extend/[controller]")]
public class TbTestService : ITbTestService, IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository _tbTestRepository;
private readonly SqlSugarScope _db;
private readonly IUserManager _userManager;
///
/// 初始化一个类型的新实例
///
public TbTestService(
ISqlSugarRepository tbTestRepository,
IUserManager userManager)
{
_tbTestRepository = tbTestRepository;
_db = _tbTestRepository.Context;
_userManager = userManager;
}
///
/// 获取测试列表
///
/// 参数
///
[HttpGet("{id}")]
public async Task GetInfo(string id)
{
var entity = await _db.Queryable().FirstAsync(p => p.Id == id);
var output = entity.Adapt();
return output;
}
///
/// 获取测试列表
///
/// 参数
///
[HttpGet("test")]
public async Task test(string id)
{
//List list = new List { 1, 2, 3, 4, 5, 6 };
//return list.Where(o => o > 3);
//return list.Take(3);
//foreach (var o in list)
//{
//}
//return list.OrderByDescending(o => o);
List list = new List {
new TbTestEntity{ Age=10,Name="test1" },
new TbTestEntity{ Age=11,Name="test2" },
new TbTestEntity{ Age=12,Name="test3" },
new TbTestEntity{ Age=13,Name="test4" },
new TbTestEntity{ Age=14,Name="test5" },
};
var et = new TbTestEntity { Age = 14, Name = "test5" };
TbTestInfoOutput newet = et.Adapt();
List tlist = new List();
return list;
//list.ForEach(item => {
// tlist.Add(new TbTestInfoOutput {
// });
//});
//list.Select(x=> new TbTestInfoOutput { id = x.Id,,, } )
//list = list.Where(item => item.Age > 10).ToList();
//list.Sum(item => item.Age);
//list.Average(item => item.Age);
var entity = await _db.Queryable()
.Where(t=>t.Age >2)
.ToListAsync();
;
var output = entity.Adapt();
//return output;
}
///
/// 获取测试列表列表
///
/// 请求参数
///
[HttpGet("")]
public async Task GetList([FromQuery] TbTestListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
List