diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 298cedf97..39aa5df43 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,7 @@ name: "Publish" on: push: - branches: [ rel-8.2.1 ] + branches: [ rel-8.2.2 ] env: DOTNET_VERSION: "8.0.200" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f79607f8c..a145049b0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: "Tagged Release" on: push: - branches: [ rel-8.2.1 ] + branches: [ rel-8.2.2 ] jobs: tagged-release: @@ -14,4 +14,4 @@ jobs: with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false - automatic_release_tag: "8.2.1" + automatic_release_tag: "8.2.2" diff --git a/Directory.Packages.props b/Directory.Packages.props index 10c4af09f..ca0339a4c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -2,8 +2,8 @@ 8.2.0 2.14.1 - 8.2.1 - 8.2.1 + 8.2.2 + 8.2.2 8.0.0 8.0.0 8.0.0 diff --git a/apps/vue/src/components/Table/src/BasicTable.vue b/apps/vue/src/components/Table/src/BasicTable.vue index 03e2a5d33..67b714ffc 100644 --- a/apps/vue/src/components/Table/src/BasicTable.vue +++ b/apps/vue/src/components/Table/src/BasicTable.vue @@ -15,14 +15,15 @@ @@ -55,7 +56,7 @@ ref="advancedSearchRef" @register="registerAdSearchModal" v-bind="getAdvancedSearchProps" - @change="handleAdvanceSearchChange" + @change="handleAdvanceSearchChanged" @search="handleAdvanceSearchInfoChange" /> @@ -70,13 +71,14 @@ } from './types/table'; import { defineComponent, ref, reactive, computed, unref, toRaw, inject, watchEffect, nextTick } from 'vue'; - import { Button, Table } from 'ant-design-vue'; + import { Badge, Button, Table } from 'ant-design-vue'; import { BasicForm, useForm } from '/@/components/Form/index'; import { useModal } from '/@/components/Modal/index'; import { PageWrapperFixedHeightKey } from '/@/components/Page'; import HeaderCell from './components/HeaderCell.vue'; import AdvancedSearch from './components/AdvancedSearch.vue'; import { InnerHandlers } from './types/table'; + import { DynamicQueryable } from './types/advancedSearch'; import { usePagination } from './hooks/usePagination'; import { useColumns } from './hooks/useColumns'; @@ -105,6 +107,7 @@ name: 'BasicTable', components: { Table, + Badge, BasicForm, Button, HeaderCell, @@ -137,6 +140,7 @@ const wrapRef = ref(null); const formRef = ref(null); const advancedSearchRef = ref(null); + const advancedSearchInput = ref(); const innerPropsRef = ref>(); const { prefixCls } = useDesign('basic-table'); @@ -276,6 +280,11 @@ getDataSourceRef, ); + function handleAdvanceSearchChanged(queryable: DynamicQueryable) { + advancedSearchInput.value = queryable; + handleAdvanceSearchChange(queryable); + } + const { getFormProps, getAdvancedSearchProps, @@ -401,12 +410,13 @@ formRef, tableElRef, advancedSearchRef, + advancedSearchInput, getBindValues, getLoading, registerForm, handleSearchInfoChange, registerAdSearchModal, - handleAdvanceSearchChange, + handleAdvanceSearchChanged, handleAdvanceSearchInfoChange, handleSearchInfoReset, handleAdvanceSearch, diff --git a/apps/vue/src/components/Table/src/components/AdvancedSearch.vue b/apps/vue/src/components/Table/src/components/AdvancedSearch.vue index 0456a8b4f..4793c2d4b 100644 --- a/apps/vue/src/components/Table/src/components/AdvancedSearch.vue +++ b/apps/vue/src/components/Table/src/components/AdvancedSearch.vue @@ -330,7 +330,7 @@ function handleDelField(paramter) { const index = formMdel.paramters.findIndex(p => p.field === paramter.field); formMdel.paramters.splice(index, 1); - emits('change', getSearchInput()); + emits('change', formMdel); } function handleFieldChange(field, record) { @@ -344,26 +344,18 @@ if (defineParam.javaScriptType === 'boolean') { record.value = false; } - emits('change', getSearchInput()); + emits('change', formMdel); } } function handleSubmit() { - emits('search', getSearchInput()); + emits('search', formMdel); closeModal(); } function resetFields() { formMdel.paramters = []; - emits('change', getSearchInput()); - } - - function getSearchInput() { - const searchInput = { - // 过滤未定义值 - paramters: formMdel.paramters.filter(p => p.value !== undefined) - }; - return searchInput; + emits('change', formMdel); } function setLoading(loading: boolean) { diff --git a/apps/vue/src/components/Table/src/hooks/useDataSource.ts b/apps/vue/src/components/Table/src/hooks/useDataSource.ts index b7e4a099f..b098ad42f 100644 --- a/apps/vue/src/components/Table/src/hooks/useDataSource.ts +++ b/apps/vue/src/components/Table/src/hooks/useDataSource.ts @@ -242,12 +242,17 @@ export function useDataSource( } = unref(propsRef); let fetchApi = api; // 高级查询条件支持 + const searchInput = cloneDeep(getFieldsValue()); if (advancedSearchConfig?.useAdvancedSearch) { - const searchInput = getFieldsValue(); - if (Reflect.has(searchInput, 'queryable') && - Array.isArray(searchInput.queryable?.paramters) && - searchInput.queryable.paramters.length > 0) - fetchApi = advancedSearchConfig?.fetchApi; + if (Reflect.has(searchInput, 'queryable') + && searchInput?.queryable?.paramters + && Array.isArray(searchInput.queryable?.paramters)) { + searchInput.queryable.paramters = searchInput.queryable.paramters + .filter((p) => p.value !== undefined); + if (searchInput.queryable.paramters.length > 0) { + fetchApi = advancedSearchConfig?.fetchApi; + } + } } if (!fetchApi || !isFunction(fetchApi)) return; try { @@ -275,7 +280,7 @@ export function useDataSource( let params: Recordable = merge( pageParams, - useSearchForm ? getFieldsValue() : {}, + useSearchForm ? searchInput : {}, searchInfo, opt?.searchInfo ?? {}, defSort, diff --git a/aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/IDynamicQueryableAppService.cs b/aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/IDynamicQueryableAppService.cs index 5f98228b0..95b90b043 100644 --- a/aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/IDynamicQueryableAppService.cs +++ b/aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/IDynamicQueryableAppService.cs @@ -15,5 +15,5 @@ public interface IDynamicQueryableAppService /// /// /// - Task> GetListAsync(GetListByDynamicQueryableInput dynamicInput); + Task> SearchAsync(GetListByDynamicQueryableInput dynamicInput); } diff --git a/aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableAppService.cs b/aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableAppService.cs index 03029e51b..d6c8e0fae 100644 --- a/aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableAppService.cs +++ b/aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableAppService.cs @@ -84,7 +84,7 @@ public virtual Task> GetAvailableFieldsAsync() /// /// /// - public async virtual Task> GetListAsync(GetListByDynamicQueryableInput dynamicInput) + public async virtual Task> SearchAsync(GetListByDynamicQueryableInput dynamicInput) { Expression> condition = (e) => true; diff --git a/aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableControllerBase.cs b/aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableControllerBase.cs index 8043804e4..f8cb86fef 100644 --- a/aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableControllerBase.cs +++ b/aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableControllerBase.cs @@ -24,8 +24,8 @@ public Task> GetAvailableFieldsAsync() [HttpPost] [Route("search")] - public Task> GetListAsync(GetListByDynamicQueryableInput dynamicInput) + public Task> SearchAsync(GetListByDynamicQueryableInput dynamicInput) { - return DynamicQueryableAppService.GetListAsync(dynamicInput); + return DynamicQueryableAppService.SearchAsync(dynamicInput); } } diff --git a/aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Application.Contracts/LINGYUN/Abp/LocalizationManagement/LanguageCreateOrUpdateDto.cs b/aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Application.Contracts/LINGYUN/Abp/LocalizationManagement/LanguageCreateOrUpdateDto.cs index 58da1f5cc..c1bfc3d0b 100644 --- a/aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Application.Contracts/LINGYUN/Abp/LocalizationManagement/LanguageCreateOrUpdateDto.cs +++ b/aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Application.Contracts/LINGYUN/Abp/LocalizationManagement/LanguageCreateOrUpdateDto.cs @@ -7,7 +7,4 @@ public abstract class LanguageCreateOrUpdateDto [Required] [DynamicStringLength(typeof(LanguageConsts), nameof(LanguageConsts.MaxDisplayNameLength))] public string DisplayName { get; set; } - - [DynamicStringLength(typeof(LanguageConsts), nameof(LanguageConsts.MaxTwoLetterISOLanguageNameLength))] - public string FlagIcon { get; set; } } diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN/Abp/Saas/Tenants/TenantAppService.cs b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN/Abp/Saas/Tenants/TenantAppService.cs index b5564d8fa..b18b9cee6 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN/Abp/Saas/Tenants/TenantAppService.cs +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Application/LINGYUN/Abp/Saas/Tenants/TenantAppService.cs @@ -39,7 +39,8 @@ public async virtual Task GetAsync(Guid id) var tenant = await TenantRepository.FindAsync(id); if (tenant == null) { - throw new UserFriendlyException(L["TenantNotFoundById", id]); + throw new BusinessException(AbpSaasErrorCodes.TenantIdOrNameNotFound) + .WithData("Tenant", id); } return ObjectMapper.Map(tenant); @@ -50,7 +51,8 @@ public async virtual Task GetAsync(string name) var tenant = await TenantRepository.FindByNameAsync(name); if (tenant == null) { - throw new UserFriendlyException(L["TenantNotFoundByName", name]); + throw new BusinessException(AbpSaasErrorCodes.TenantIdOrNameNotFound) + .WithData("Tenant", name); } return ObjectMapper.Map(tenant); } diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/AbpSaasErrorCodes.cs b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/AbpSaasErrorCodes.cs index 851e4642d..ed946d9a7 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/AbpSaasErrorCodes.cs +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/AbpSaasErrorCodes.cs @@ -3,11 +3,23 @@ public static class AbpSaasErrorCodes { public const string Namespace = "Saas"; - + /// + /// 已经存在名为 {DisplayName} 的版本! + /// public const string DuplicateEditionDisplayName = Namespace + ":010001"; + /// + /// 试图删除正在使用的版本: {DisplayName}! + /// public const string DeleteUsedEdition = Namespace + ":010002"; + /// + /// 已经存在名为 {Name} 的租户! + /// public const string DuplicateTenantName = Namespace + ":020001"; /// + /// 租户: {Tenant} 不存在! + /// + public const string TenantIdOrNameNotFound = Namespace + ":020002"; + /// /// 无效的默认连接字符串 /// public const string InvalidDefaultConnectionString = Namespace + ":020101"; diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/en.json b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/en.json index 1f6f1d75c..e6cc69449 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/en.json +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/en.json @@ -4,6 +4,7 @@ "Saas:010001": "Unable to create duplicate editions {DisplayName}!", "Saas:010002": "Tried to delete the edition in use: {DisplayName}!", "Saas:020001": "Unable to create duplicate tenants {Name}!", + "Saas:020002": "Tenant: {Tenant} not found!", "Saas:020101": "The default connection string cannot open a connection to the database!", "Saas:020102": "The database pointed to by the default connection string already exists!", "Saas:020103": "Unable to open the database connection pointed to by {Name}!", @@ -47,8 +48,6 @@ "Features:ExpirationReminderDaysDesc": "Send a reminder to the administrator when the resource has how many days left to expire", "Features:ExpiredRecoveryTime": "Expired Recovery Time", "Features:ExpiredRecoveryTimeDesc": "If the resource expiration is not handled for a long time, tenant resources will be reclaimed", - "TenantNotFoundById": "Tenant: {0} not found!", - "TenantNotFoundByName": "Tenant: {0} not found!", "UnActived": "UnActived", "RecycleStrategy:Reserve": "Reserve", "RecycleStrategy:Recycle": "Recycle" diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/zh-Hans.json b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/zh-Hans.json index 4f974c1ef..684aa2ec5 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain.Shared/LINGYUN/Abp/Saas/Localization/Resources/zh-Hans.json @@ -4,6 +4,7 @@ "Saas:010001": "已经存在名为 {DisplayName} 的版本!", "Saas:010002": "试图删除正在使用的版本: {DisplayName}!", "Saas:020001": "已经存在名为 {Name} 的租户!", + "Saas:020002": "租户: {Tenant} 不存在!", "Saas:020101": "无法打开默认连接字符串指向的数据库连接!", "Saas:020102": "默认连接字符串指向的数据库已经存在!", "Saas:020103": "无法打开 {Name} 指向的数据库连接!", @@ -47,8 +48,6 @@ "Features:ExpirationReminderDaysDesc": "当资源还有多少天过期时, 给管理员发送提醒", "Features:ExpiredRecoveryTime": "过期回收时长", "Features:ExpiredRecoveryTimeDesc": "当资源超期多久没有处理, 将回收租户资源", - "TenantNotFoundById": "租户: {0} 不存在!", - "TenantNotFoundByName": "租户: {0} 不存在!", "UnActived": "未启用", "RecycleStrategy:Reserve": "保留", "RecycleStrategy:Recycle": "回收" diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/BackgroundJobLogAppService.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/BackgroundJobLogAppService.cs index 837e68f8c..447e6b09a 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/BackgroundJobLogAppService.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/BackgroundJobLogAppService.cs @@ -1,6 +1,8 @@ using LINGYUN.Abp.TaskManagement.Permissions; using Microsoft.AspNetCore.Authorization; +using System; using System.Collections.Generic; +using System.Linq.Expressions; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; @@ -32,22 +34,38 @@ public async virtual Task GetAsync(long id) public async virtual Task> GetListAsync(BackgroundJobLogGetListInput input) { - var filter = new BackgroundJobLogFilter - { - BeginRunTime = input.BeginRunTime, - EndRunTime = input.EndRunTime, - HasExceptions = input.HasExceptions, - Filter = input.Filter, - Group = input.Group, - Name = input.Name, - Type = input.Type - }; - - var totalCount = await BackgroundJobLogRepository.GetCountAsync(filter, input.JobId); + var specification = new BackgroundJobLogGetListSpecification(input); + + var totalCount = await BackgroundJobLogRepository.GetCountAsync(specification); var backgroundJobLogs = await BackgroundJobLogRepository.GetListAsync( - filter, input.JobId, input.Sorting, input.MaxResultCount, input.SkipCount); + specification, input.Sorting, input.MaxResultCount, input.SkipCount); return new PagedResultDto(totalCount, - ObjectMapper.Map, List>(backgroundJobLogs)); + ObjectMapper.Map, List>(backgroundJobLogs)); + } + + private class BackgroundJobLogGetListSpecification : Volo.Abp.Specifications.Specification + { + protected BackgroundJobLogGetListInput Input { get; } + public BackgroundJobLogGetListSpecification(BackgroundJobLogGetListInput input) + { + Input = input; + } + + public override Expression> ToExpression() + { + Expression> expression = _ => true; + + return expression + .AndIf(!Input.JobId.IsNullOrWhiteSpace(), x => x.JobId.Equals(Input.JobId)) + .AndIf(!Input.Type.IsNullOrWhiteSpace(), x => x.JobType.Contains(Input.Type)) + .AndIf(!Input.Group.IsNullOrWhiteSpace(), x => x.JobGroup.Equals(Input.Group)) + .AndIf(!Input.Name.IsNullOrWhiteSpace(), x => x.JobName.Equals(Input.Name)) + .AndIf(!Input.Filter.IsNullOrWhiteSpace(), x => x.JobName.Contains(Input.Filter) || + x.JobGroup.Contains(Input.Filter) || x.JobType.Contains(Input.Filter) || x.Message.Contains(Input.Filter)) + .AndIf(Input.HasExceptions.HasValue, x => !string.IsNullOrWhiteSpace(x.Exception)) + .AndIf(Input.BeginRunTime.HasValue, x => x.RunTime >= Input.BeginRunTime) + .AndIf(Input.EndRunTime.HasValue, x => x.RunTime <= Input.EndRunTime); + } } } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/System/Linq/Expressions/ExpressionFuncExtensions.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/System/Linq/Expressions/ExpressionFuncExtensions.cs new file mode 100644 index 000000000..fd7a017ea --- /dev/null +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/System/Linq/Expressions/ExpressionFuncExtensions.cs @@ -0,0 +1,32 @@ +using Volo.Abp.Specifications; + +namespace System.Linq.Expressions; + +internal static class ExpressionFuncExtensions +{ + public static Expression> AndIf( + this Expression> first, + bool condition, + Expression> second) + { + if (condition) + { + return ExpressionFuncExtender.And(first, second); + } + + return first; + } + + public static Expression> OrIf( + this Expression> first, + bool condition, + Expression> second) + { + if (condition) + { + return ExpressionFuncExtender.Or(first, second); + } + + return first; + } +} diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobLogFilter.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobLogFilter.cs deleted file mode 100644 index 99bbdd984..000000000 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobLogFilter.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; - -namespace LINGYUN.Abp.TaskManagement; - -public class BackgroundJobLogFilter -{ - /// - /// 其他过滤条件 - /// - public string Filter { get; set; } - /// - /// 存在异常 - /// - public bool? HasExceptions { get; set; } - /// - /// 任务名称 - /// - public string Name { get; set; } - /// - /// 任务分组 - /// - public string Group { get; set; } - /// - /// 任务类型 - /// - public string Type { get; set; } - /// - /// 开始触发时间 - /// - public DateTime? BeginRunTime { get; set; } - /// - /// 结束触发时间 - /// - public DateTime? EndRunTime { get; set; } -} diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/IBackgroundJobLogRepository.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/IBackgroundJobLogRepository.cs index bc11de3cf..9a517f173 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/IBackgroundJobLogRepository.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/IBackgroundJobLogRepository.cs @@ -1,8 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; +using Volo.Abp.Specifications; namespace LINGYUN.Abp.TaskManagement; @@ -11,28 +11,24 @@ public interface IBackgroundJobLogRepository : IRepository /// 获取过滤后的任务日志数量 /// - /// - /// + /// /// /// Task GetCountAsync( - BackgroundJobLogFilter filter, - string jobId = null, + ISpecification specification, CancellationToken cancellationToken = default); /// /// 获取过滤后的任务日志列表 /// - /// - /// + /// /// /// /// /// /// Task> GetListAsync( - BackgroundJobLogFilter filter, - string jobId = null, - string sorting = nameof(BackgroundJobLog.RunTime), + ISpecification specification, + string sorting = $"{nameof(BackgroundJobLog.RunTime)} DESC", int maxResultCount = 10, int skipCount = 0, CancellationToken cancellationToken = default); diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobLogRepository.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobLogRepository.cs index 94e35ce0d..a22494057 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobLogRepository.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobLogRepository.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Specifications; namespace LINGYUN.Abp.TaskManagement.EntityFrameworkCore; @@ -21,45 +22,27 @@ public EfCoreBackgroundJobLogRepository( } public async virtual Task GetCountAsync( - BackgroundJobLogFilter filter, - string jobId = null, + ISpecification specification, CancellationToken cancellationToken = default) { return await (await GetDbSetAsync()) - .WhereIf(!jobId.IsNullOrWhiteSpace(), x => x.JobId.Equals(jobId)) - .WhereIf(!filter.Type.IsNullOrWhiteSpace(), x => x.JobType.Contains(filter.Type)) - .WhereIf(!filter.Group.IsNullOrWhiteSpace(), x => x.JobGroup.Equals(filter.Group)) - .WhereIf(!filter.Name.IsNullOrWhiteSpace(), x => x.JobName.Equals(filter.Name)) - .WhereIf(!filter.Filter.IsNullOrWhiteSpace(), x => x.JobName.Contains(filter.Filter) || - x.JobGroup.Contains(filter.Filter) || x.JobType.Contains(filter.Filter) || x.Message.Contains(filter.Filter)) - .WhereIf(filter.HasExceptions.HasValue, x => !string.IsNullOrWhiteSpace(x.Exception)) - .WhereIf(filter.BeginRunTime.HasValue, x => x.RunTime.CompareTo(filter.BeginRunTime.Value) >= 0) - .WhereIf(filter.EndRunTime.HasValue, x => x.RunTime.CompareTo(filter.EndRunTime.Value) <= 0) + .Where(specification.ToExpression()) .CountAsync(GetCancellationToken(cancellationToken)); } public async virtual Task> GetListAsync( - BackgroundJobLogFilter filter, - string jobId = null, - string sorting = nameof(BackgroundJobLog.RunTime), + ISpecification specification, + string sorting = $"{nameof(BackgroundJobLog.RunTime)} DESC", int maxResultCount = 10, int skipCount = 0, CancellationToken cancellationToken = default) { if (sorting.IsNullOrWhiteSpace()) { - sorting = $"{nameof(BackgroundJobLog.RunTime)}"; + sorting = $"{nameof(BackgroundJobLog.RunTime)} DESC"; } return await (await GetDbSetAsync()) - .WhereIf(!jobId.IsNullOrWhiteSpace(), x => x.JobId.Equals(jobId)) - .WhereIf(!filter.Type.IsNullOrWhiteSpace(), x => x.JobType.Contains(filter.Type)) - .WhereIf(!filter.Group.IsNullOrWhiteSpace(), x => x.JobGroup.Equals(filter.Group)) - .WhereIf(!filter.Name.IsNullOrWhiteSpace(), x => x.JobName.Equals(filter.Name)) - .WhereIf(!filter.Filter.IsNullOrWhiteSpace(), x => x.JobName.Contains(filter.Filter) || - x.JobGroup.Contains(filter.Filter) || x.JobType.Contains(filter.Filter) || x.Message.Contains(filter.Filter)) - .WhereIf(filter.HasExceptions.HasValue, x => !string.IsNullOrWhiteSpace(x.Exception)) - .WhereIf(filter.BeginRunTime.HasValue, x => x.RunTime.CompareTo(filter.BeginRunTime.Value) >= 0) - .WhereIf(filter.EndRunTime.HasValue, x => x.RunTime.CompareTo(filter.EndRunTime.Value) <= 0) + .Where(specification.ToExpression()) .OrderBy(sorting) .PageBy(skipCount, maxResultCount) .ToListAsync(GetCancellationToken(cancellationToken)); diff --git a/common.props b/common.props index c299ae39b..49e6ba98f 100644 --- a/common.props +++ b/common.props @@ -1,12 +1,12 @@ latest - 8.2.1 + 8.2.2 colin $(NoWarn);CS1591;CS0436;CS8618;NU1803 https://github.com/colinin/abp-next-admin $(SolutionDir)LocalNuget - 8.2.1 + 8.2.2 MIT git https://github.com/colinin/abp-next-admin