Skip to content
Merged

Dev #99

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions DFApp.LotteryProxy/DFApp.LotteryProxy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
<PackageReference Include="Microsoft.OpenApi" Version="2.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.7" />
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion client/src/api/bookkeeping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class BookkeepingExpenditureApi {
async getExpenditures(
params?: GetExpendituresRequestDto
): Promise<PagedResultDto<BookkeepingExpenditureDto>> {
return http.get(`${this.baseUrl}/paged`, { params });
return http.get(`${this.baseUrl}/filtered`, { params });
}

/**
Expand Down
26 changes: 13 additions & 13 deletions src/DFApp.Web/DFApp.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@

<ItemGroup>
<PackageReference Include="BencodeNET" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.7" />
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="2.1.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.7.2" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="SqlSugarCore" Version="5.1.4.160" />
<PackageReference Include="Quartz" Version="3.15.0" />
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.15.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.0.0" />
<PackageReference Include="Riok.Mapperly" Version="4.3.0" />
<PackageReference Include="WTelegramClient" Version="4.3.12" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.71" />
<PackageReference Include="AngleSharp" Version="1.1.2" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.214" />
<PackageReference Include="Quartz" Version="3.18.1" />
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.18.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
<PackageReference Include="Riok.Mapperly" Version="4.3.1" />
<PackageReference Include="WTelegramClient" Version="4.4.3" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.7" />
<PackageReference Include="HtmlAgilityPack" Version="1.12.4" />
<PackageReference Include="AngleSharp" Version="1.4.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.4" />
<PackageReference Include="SixLabors.Fonts" Version="2.0.8" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.7" />
<PackageReference Include="SixLabors.Fonts" Version="2.1.3" />
</ItemGroup>
</Project>
16 changes: 5 additions & 11 deletions src/DFApp.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using System.Text.Json;
Expand All @@ -10,7 +11,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;
using Quartz;
using Serilog;
using Serilog.Events;
Expand Down Expand Up @@ -222,18 +223,11 @@ public async static Task<int> Main(string[] args)
Scheme = "Bearer"
});

options.AddSecurityRequirement(new OpenApiSecurityRequirement
options.AddSecurityRequirement(document => new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
}
},
Array.Empty<string>()
new OpenApiSecuritySchemeReference("Bearer", document),
new List<string>()
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public async Task<List<ConfigurationInfoDto>> GetAllParametersInModule(string mo
public async Task<string> GetRemainingDiskSpaceAsync()
{
string saveDrive = await _configurationInfoRepository.GetConfigurationInfoValue("SaveDrive", string.Empty);
return StorageUnitConversionHelper.ByteToGB(SpaceHelper.GetAnyDriveAvailable(saveDrive)).ToString("F2") + "GB";
return SpaceHelper.GetAnyDriveAvailable(saveDrive).ToString("F2") + "GB";
}

/// <summary>
Expand Down
56 changes: 48 additions & 8 deletions src/DFApp.Web/Services/CrudServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using DFApp.Web.Domain;
using DFApp.Web.Infrastructure;
using DFApp.Web.Permissions;
using SqlSugar;

namespace DFApp.Web.Services;

Expand Down Expand Up @@ -75,20 +76,30 @@ public virtual async Task<List<TGetOutputDto>> GetListAsync(Expression<Func<TEnt
}

/// <summary>
/// 分页查询
/// 分页查询(默认按创建时间倒序)
/// </summary>
/// <param name="pageIndex">页码(从 1 开始)</param>
/// <param name="pageSize">每页大小</param>
/// <returns>分页结果</returns>
public virtual async Task<(List<TGetOutputDto> Items, int TotalCount)> GetPagedListAsync(int pageIndex, int pageSize)
{
var (items, totalCount) = await Repository.GetPagedListAsync(pageIndex, pageSize);
var dtos = await MapToGetOutputDtoAsync(items);
return (dtos, totalCount);
if (HasCreationTimeProperty())
{
var (items, totalCount) = await Repository.GetPagedListAsync(
pageIndex, pageSize,
BuildCreationTimeOrderExpression(),
OrderByType.Desc);
var dtos = await MapToGetOutputDtoAsync(items);
return (dtos, totalCount);
}

var (defaultItems, defaultTotalCount) = await Repository.GetPagedListAsync(pageIndex, pageSize);
var defaultDtos = await MapToGetOutputDtoAsync(defaultItems);
return (defaultDtos, defaultTotalCount);
}

/// <summary>
/// 根据条件分页查询
/// 根据条件分页查询(默认按创建时间倒序)
/// </summary>
/// <param name="expression">查询条件</param>
/// <param name="pageIndex">页码(从 1 开始)</param>
Expand All @@ -99,9 +110,38 @@ public virtual async Task<List<TGetOutputDto>> GetListAsync(Expression<Func<TEnt
int pageIndex,
int pageSize)
{
var (items, totalCount) = await Repository.GetPagedListAsync(expression, pageIndex, pageSize);
var dtos = await MapToGetOutputDtoAsync(items);
return (dtos, totalCount);
if (HasCreationTimeProperty())
{
var (items, totalCount) = await Repository.GetPagedListAsync(
expression, pageIndex, pageSize,
BuildCreationTimeOrderExpression(),
OrderByType.Desc);
var dtos = await MapToGetOutputDtoAsync(items);
return (dtos, totalCount);
}

var (defaultItems, defaultTotalCount) = await Repository.GetPagedListAsync(expression, pageIndex, pageSize);
var defaultDtos = await MapToGetOutputDtoAsync(defaultItems);
return (defaultDtos, defaultTotalCount);
}

/// <summary>
/// 检查实体是否有 CreationTime 属性
/// </summary>
private static bool HasCreationTimeProperty()
{
return typeof(TEntity).GetProperty("CreationTime") != null;
}

/// <summary>
/// 构建 CreationTime 排序表达式
/// </summary>
private static Expression<Func<TEntity, object>> BuildCreationTimeOrderExpression()
{
var parameter = Expression.Parameter(typeof(TEntity), "x");
var property = Expression.PropertyOrField(parameter, "CreationTime");
var converted = Expression.Convert(property, typeof(object));
return Expression.Lambda<Func<TEntity, object>>(converted, parameter);
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions test/DFApp.Web.Tests/DFApp.Web.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4" />
<PackageReference Include="FluentAssertions" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="coverlet.collector" Version="10.0.0" />
<PackageReference Include="FluentAssertions" Version="8.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading