Skip to content

Commit

Permalink
try generating a RangeFilter supporting custom filter
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarHawk committed Jan 14, 2025
1 parent 7d3a985 commit 0bce02e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions generators/server/support/build-specification-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
ZONED_DATE_TIME: TYPE_ZONED_DATE_TIME,
INSTANT: TYPE_INSTANT,
DURATION: TYPE_DURATION,
LOCAL_TIME: TYPE_LOCAL_TIME,
} = fieldTypes.CommonDBTypes;

/**
Expand All @@ -30,6 +31,7 @@ export const getSpecificationBuildForType = (fieldType: FieldType) => {
TYPE_ZONED_DATE_TIME,
TYPE_INSTANT,
TYPE_DURATION,
TYPE_LOCAL_TIME,
].includes(fieldType)
) {
return 'buildRangeSpecification';
Expand Down
4 changes: 4 additions & 0 deletions generators/spring-boot/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ public void set${javaBeanCase(propertyName)}(${propertyType} ${propertyName}) {
field.fieldTypeBoolean
) {
field.propertyJavaFilterType = `${fieldType}Filter`;
} else if (field.fieldTypeLocalDate) {
const filterType = `${fieldType}Filter`;
field.propertyJavaFilterType = filterType;
field.propertyJavaCustomFilter = { type: filterType, superType: `RangeFilter<${fieldType}>`, fieldType };
} else {
field.propertyJavaFilterType = `Filter<${fieldType}>`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import java.util.function.BiFunction;

import org.springdoc.core.annotations.ParameterObject;
import tech.jhipster.service.Criteria;
<%_ for (const field of fields) { if (field.fieldIsEnum === true) { _%>
<%_ for (const field of fields) { _%>
<%_ if (field.fieldIsEnum === true) { _%>
import <%- entityAbsolutePackage %>.domain.enumeration.<%- field.fieldType %>;
<%_ } } _%>
<%_ } _%>
<%_ } _%>
<%_ if (anyFieldIsLocalTime) { _%>
import java.time.<%- field.fieldType %>;
<%_ } _%>
import tech.jhipster.service.filter.*;

/**
Expand Down

0 comments on commit 0bce02e

Please sign in to comment.