Skip to content

Commit fc15b3d

Browse files
authored
Merge pull request #22122 from abpframework/auto-merge/rel-9-0/3470
Merge branch rel-9.1 with rel-9.0
2 parents 8097cf7 + 5b8adc5 commit fc15b3d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public virtual async Task<int> GetCountAsync(
5858
BlogPostStatus? statusFilter = null,
5959
CancellationToken cancellationToken = default)
6060
{
61+
List<Guid> entityIdFilters = null;
62+
if (tagId.HasValue)
63+
{
64+
entityIdFilters = (await _entityTagManager.GetEntityIdsFilteredByTagAsync(tagId.Value, CurrentTenant.Id, cancellationToken)).Select(Guid.Parse).ToList();
65+
}
66+
6167
var tagFilteredEntityIds = tagId.HasValue
6268
? await _entityTagManager.GetEntityIdsFilteredByTagAsync(tagId.Value, CurrentTenant.Id, cancellationToken)
6369
: null;
@@ -67,6 +73,7 @@ public virtual async Task<int> GetCountAsync(
6773
: null;
6874

6975
var queryable = (await GetDbSetAsync())
76+
.WhereIf(entityIdFilters != null, x => entityIdFilters.Contains(x.Id))
7077
.WhereIf(tagFilteredEntityIds != null, x => tagFilteredEntityIds.Contains(x.Id.ToString()))
7178
.WhereIf(favoriteUserFilteredEntityIds != null, x => favoriteUserFilteredEntityIds.Contains(x.Id.ToString()))
7279
.WhereIf(blogId.HasValue, x => x.BlogId == blogId)
@@ -95,6 +102,12 @@ public virtual async Task<List<BlogPost>> GetListAsync(
95102
var blogPostsDbSet = dbContext.Set<BlogPost>();
96103
var usersDbSet = dbContext.Set<CmsUser>();
97104

105+
List<Guid> entityIdFilters = null;
106+
if (tagId.HasValue)
107+
{
108+
entityIdFilters = (await _entityTagManager.GetEntityIdsFilteredByTagAsync(tagId.Value, CurrentTenant.Id, cancellationToken)).Select(Guid.Parse).ToList();
109+
}
110+
98111
var tagFilteredEntityIds = tagId.HasValue
99112
? await _entityTagManager.GetEntityIdsFilteredByTagAsync(tagId.Value, CurrentTenant.Id, cancellationToken)
100113
: null;
@@ -104,6 +117,7 @@ public virtual async Task<List<BlogPost>> GetListAsync(
104117
: null;
105118

106119
var queryable = (await GetDbSetAsync())
120+
.WhereIf(entityIdFilters != null, x => entityIdFilters.Contains(x.Id))
107121
.WhereIf(tagFilteredEntityIds != null, x => tagFilteredEntityIds.Contains(x.Id.ToString()))
108122
.WhereIf(favoriteUserFilteredEntityIds != null, x => favoriteUserFilteredEntityIds.Contains(x.Id.ToString()))
109123
.WhereIf(blogId.HasValue, x => x.BlogId == blogId)

npm/ng-packs/packages/schematics/src/utils/model.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ export function createImportRefToInterfaceReducerCreator(params: ModelGeneratorP
148148
typeDef.properties?.forEach(prop => {
149149
let name = prop.jsonName || camel(prop.name);
150150
name = shouldQuote(name) ? `'${name}'` : name;
151-
const type = simplifyType(prop.type);
151+
152+
let type = simplifyType(prop.typeSimple);
153+
if (prop.typeSimple.includes('enum')) {
154+
type = simplifyType(prop.type);
155+
}
156+
152157
const refs = parseType(prop.type).reduce(
153158
(acc: string[], r) => acc.concat(parseGenerics(r).toGenerics()),
154159
[],
@@ -182,7 +187,10 @@ export function createRefToImportReducerCreator(params: ModelGeneratorParams) {
182187
}
183188

184189
function isOptionalProperty(prop: PropertyDef) {
185-
return prop.typeSimple.endsWith('?') || !prop.isRequired;
190+
return (
191+
prop.typeSimple.endsWith('?') ||
192+
((prop.typeSimple === 'string' || prop.typeSimple.includes('enum')) && !prop.isRequired)
193+
);
186194
}
187195

188196
export function parseBaseTypeWithGenericTypes(type: string): string[] {

0 commit comments

Comments
 (0)