🚀 feat(新增): 分页测试完成
This commit is contained in:
parent
5daef21f20
commit
29c1da23d9
|
@ -7,7 +7,6 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Castle.Core" Version="5.1.1"/>
|
||||
<PackageReference Include="log4net" Version="2.0.17"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.6"/>
|
||||
|
@ -22,7 +21,6 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Minio" Version="6.0.3"/>
|
||||
<PackageReference Include="morelinq" Version="4.3.0"/>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
|
||||
<PackageReference Include="StackExchange.Redis" Version="2.8.0"/>
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.0"/>
|
||||
|
|
|
@ -45,9 +45,7 @@ public class EfCoreContext : DbContext
|
|||
/// </summary>
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||
{
|
||||
Log.Info("正在连接数据库。。。");
|
||||
options.UseSqlServer(DbPath);
|
||||
Log.Info("连接数据库完成层。。。");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -7,7 +7,7 @@ public static class GetPagedResultAsync
|
|||
{
|
||||
public static async Task<PageResult<T>> GetPagedListAsync<T>(IQueryable<T> source, int page, int limit)
|
||||
{
|
||||
var total = await source.CountAsync();
|
||||
var total = source.Count();
|
||||
IEnumerable<T> items = await source.Skip((page - 1) * limit).Take(limit).ToListAsync();
|
||||
return new PageResult<T>(page, limit, total, items);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,5 @@ public static class MinioContext
|
|||
MinioClient = new MinioClient().WithEndpoint(endpoint).WithCredentials(accessKey, secretKey)
|
||||
// .WithSSL() // 使用HTTPS
|
||||
.Build();
|
||||
Log.Info($"Minio 初始化...\t初始化桶:{BucketName}");
|
||||
}
|
||||
}
|
|
@ -33,7 +33,5 @@ public static class RedisContext
|
|||
|
||||
// 创建连接对象
|
||||
RedisDatabase = connect.GetDatabase();
|
||||
|
||||
Log.Info("Redis 初始化...");
|
||||
}
|
||||
}
|
|
@ -120,6 +120,7 @@ public class UserService : IUserService
|
|||
public Task<PageResult<Users>> QueryPage(int page, int limit)
|
||||
{
|
||||
var pagedListAsync = GetPagedResultAsync.GetPagedListFromSqlAsync<Users>(DbContext, "select * from System_Users ", page, limit);
|
||||
var listAsync = GetPagedResultAsync.GetPagedListAsync(DbContext.Users.Where(users => users.Username == "admin"), page, limit);
|
||||
return pagedListAsync;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue