Browse Source

Merge pull request #22122 from abpframework/auto-merge/rel-9-0/3470

Merge branch rel-9.1 with rel-9.0
pull/22123/head
maliming 2 years ago
committed by GitHub
parent
commit
fc15b3da86
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 14
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs
  2. 12
      npm/ng-packs/packages/schematics/src/utils/model.ts

14
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs

@ -58,6 +58,12 @@ public class EfCoreBlogPostRepository : EfCoreRepository<ICmsKitDbContext, BlogP
BlogPostStatus? statusFilter = null,
CancellationToken cancellationToken = default)
{
List<Guid> entityIdFilters = null;
if (tagId.HasValue)
{
entityIdFilters = (await _entityTagManager.GetEntityIdsFilteredByTagAsync(tagId.Value, CurrentTenant.Id, cancellationToken)).Select(Guid.Parse).ToList();
}
var tagFilteredEntityIds = tagId.HasValue
? await _entityTagManager.GetEntityIdsFilteredByTagAsync(tagId.Value, CurrentTenant.Id, cancellationToken)
: null;
@ -67,6 +73,7 @@ public class EfCoreBlogPostRepository : EfCoreRepository<ICmsKitDbContext, BlogP
: null;
var queryable = (await GetDbSetAsync())
.WhereIf(entityIdFilters != null, x => entityIdFilters.Contains(x.Id))
.WhereIf(tagFilteredEntityIds != null, x => tagFilteredEntityIds.Contains(x.Id.ToString()))
.WhereIf(favoriteUserFilteredEntityIds != null, x => favoriteUserFilteredEntityIds.Contains(x.Id.ToString()))
.WhereIf(blogId.HasValue, x => x.BlogId == blogId)
@ -95,6 +102,12 @@ public class EfCoreBlogPostRepository : EfCoreRepository<ICmsKitDbContext, BlogP
var blogPostsDbSet = dbContext.Set<BlogPost>();
var usersDbSet = dbContext.Set<CmsUser>();
List<Guid> entityIdFilters = null;
if (tagId.HasValue)
{
entityIdFilters = (await _entityTagManager.GetEntityIdsFilteredByTagAsync(tagId.Value, CurrentTenant.Id, cancellationToken)).Select(Guid.Parse).ToList();
}
var tagFilteredEntityIds = tagId.HasValue
? await _entityTagManager.GetEntityIdsFilteredByTagAsync(tagId.Value, CurrentTenant.Id, cancellationToken)
: null;
@ -104,6 +117,7 @@ public class EfCoreBlogPostRepository : EfCoreRepository<ICmsKitDbContext, BlogP
: null;
var queryable = (await GetDbSetAsync())
.WhereIf(entityIdFilters != null, x => entityIdFilters.Contains(x.Id))
.WhereIf(tagFilteredEntityIds != null, x => tagFilteredEntityIds.Contains(x.Id.ToString()))
.WhereIf(favoriteUserFilteredEntityIds != null, x => favoriteUserFilteredEntityIds.Contains(x.Id.ToString()))
.WhereIf(blogId.HasValue, x => x.BlogId == blogId)

12
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.isRequired;
return (
prop.typeSimple.endsWith('?') ||
((prop.typeSimple === 'string' || prop.typeSimple.includes('enum')) && !prop.isRequired)
);
}
export function parseBaseTypeWithGenericTypes(type: string): string[] {

Loading…
Cancel
Save