From 95690651236a343a8d7c2399d68f4fcb6f2e625c Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 11 Feb 2025 11:19:19 +0800 Subject: [PATCH 1/4] Fix Blog post tag filtering problem --- .../Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs index 266a04a910..58527c00de 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs @@ -53,14 +53,14 @@ public class EfCoreBlogPostRepository : EfCoreRepository entityIdFilters = null; + List entityIdFilters = null; if (tagId.HasValue) { - entityIdFilters = await _entityTagManager.GetEntityIdsFilteredByTagAsync(tagId.Value, CurrentTenant.Id, cancellationToken); + entityIdFilters = (await _entityTagManager.GetEntityIdsFilteredByTagAsync(tagId.Value, CurrentTenant.Id, cancellationToken)).Select(Guid.Parse).ToList(); } var queryable = (await GetDbSetAsync()) - .WhereIf(entityIdFilters != null, x => entityIdFilters.Contains(x.Id.ToString())) + .WhereIf(entityIdFilters != null, x => entityIdFilters.Contains(x.Id)) .WhereIf(blogId.HasValue, x => x.BlogId == blogId) .WhereIf(authorId.HasValue, x => x.AuthorId == authorId) .WhereIf(statusFilter.HasValue, x => x.Status == statusFilter) @@ -86,14 +86,14 @@ public class EfCoreBlogPostRepository : EfCoreRepository(); var usersDbSet = dbContext.Set(); - List entityIdFilters = null; + List entityIdFilters = null; if (tagId.HasValue) { - entityIdFilters = await _entityTagManager.GetEntityIdsFilteredByTagAsync(tagId.Value, CurrentTenant.Id, cancellationToken); + entityIdFilters = (await _entityTagManager.GetEntityIdsFilteredByTagAsync(tagId.Value, CurrentTenant.Id, cancellationToken)).Select(Guid.Parse).ToList(); } var queryable = (await GetDbSetAsync()) - .WhereIf(entityIdFilters != null, x => entityIdFilters.Contains(x.Id.ToString())) + .WhereIf(entityIdFilters != null, x => entityIdFilters.Contains(x.Id)) .WhereIf(blogId.HasValue, x => x.BlogId == blogId) .WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)) .WhereIf(authorId.HasValue, x => x.AuthorId == authorId) From 5867842d4a84a7ad87043e67e68aae03fc0cfc47 Mon Sep 17 00:00:00 2001 From: sumeyye Date: Tue, 11 Feb 2025 11:30:29 +0300 Subject: [PATCH 2/4] update: nullability and type checks on models --- npm/ng-packs/packages/schematics/src/utils/model.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/schematics/src/utils/model.ts b/npm/ng-packs/packages/schematics/src/utils/model.ts index 119323e95d..a46eff612d 100644 --- a/npm/ng-packs/packages/schematics/src/utils/model.ts +++ b/npm/ng-packs/packages/schematics/src/utils/model.ts @@ -148,7 +148,12 @@ export function createImportRefToInterfaceReducerCreator(params: ModelGeneratorP typeDef.properties?.forEach(prop => { let name = prop.jsonName || camel(prop.name); name = shouldQuote(name) ? `'${name}'` : name; - const type = simplifyType(prop.type); + + let type = simplifyType(prop.typeSimple); + if (prop.typeSimple.includes('enum')) { + type = simplifyType(prop.type); + } + const refs = parseType(prop.type).reduce( (acc: string[], r) => acc.concat(parseGenerics(r).toGenerics()), [], @@ -182,7 +187,10 @@ export function createRefToImportReducerCreator(params: ModelGeneratorParams) { } function isOptionalProperty(prop: PropertyDef) { - return prop.typeSimple.endsWith('?') || (prop.typeSimple === 'string' && !prop.isRequired); + return ( + prop.typeSimple.endsWith('?') || + ((prop.typeSimple === 'string' || prop.typeSimple.includes('enum')) && !prop.isRequired) + ); } export function parseBaseTypeWithGenericTypes(type: string): string[] { From afc6454ea7b9acca3154b8554924fb84e8bc14c9 Mon Sep 17 00:00:00 2001 From: sumeyye Date: Tue, 11 Feb 2025 11:40:42 +0300 Subject: [PATCH 3/4] update: readability --- npm/ng-packs/packages/schematics/src/utils/model.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/npm/ng-packs/packages/schematics/src/utils/model.ts b/npm/ng-packs/packages/schematics/src/utils/model.ts index a46eff612d..c1d8423c58 100644 --- a/npm/ng-packs/packages/schematics/src/utils/model.ts +++ b/npm/ng-packs/packages/schematics/src/utils/model.ts @@ -187,10 +187,12 @@ export function createRefToImportReducerCreator(params: ModelGeneratorParams) { } function isOptionalProperty(prop: PropertyDef) { - return ( - prop.typeSimple.endsWith('?') || - ((prop.typeSimple === 'string' || prop.typeSimple.includes('enum')) && !prop.isRequired) - ); + const { isRequired, typeSimple } = prop; + if (typeSimple === 'string' || typeSimple.includes('enum')) { + return !isRequired; + } else { + return typeSimple.endsWith('?'); + } } export function parseBaseTypeWithGenericTypes(type: string): string[] { From e996cf907e8d98ea15b44793abd001d0b9528338 Mon Sep 17 00:00:00 2001 From: sumeyye Date: Tue, 11 Feb 2025 11:44:14 +0300 Subject: [PATCH 4/4] rollback: readability --- npm/ng-packs/packages/schematics/src/utils/model.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/npm/ng-packs/packages/schematics/src/utils/model.ts b/npm/ng-packs/packages/schematics/src/utils/model.ts index c1d8423c58..a46eff612d 100644 --- a/npm/ng-packs/packages/schematics/src/utils/model.ts +++ b/npm/ng-packs/packages/schematics/src/utils/model.ts @@ -187,12 +187,10 @@ export function createRefToImportReducerCreator(params: ModelGeneratorParams) { } function isOptionalProperty(prop: PropertyDef) { - const { isRequired, typeSimple } = prop; - if (typeSimple === 'string' || typeSimple.includes('enum')) { - return !isRequired; - } else { - return typeSimple.endsWith('?'); - } + return ( + prop.typeSimple.endsWith('?') || + ((prop.typeSimple === 'string' || prop.typeSimple.includes('enum')) && !prop.isRequired) + ); } export function parseBaseTypeWithGenericTypes(type: string): string[] {