Skip to content

Commit

Permalink
fix: bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Angular2Guy committed Oct 15, 2023
1 parent 2b30f8f commit 54e6126
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
*/
package ch.xxx.moviemanager.domain.model.dto;

public class SearchStringDto {
import com.fasterxml.jackson.annotation.JsonValue;

public class SearchStringDto {
public static enum Operator {
AND("+"), OR("|"), NOT("-");

Expand All @@ -21,6 +23,11 @@ public static enum Operator {
private Operator(String value) {
this.value = value;
}

@JsonValue
public String value() {
return this.value;
}
}

private String searchString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ export class FilterMoviesComponent implements OnInit {
}

private createSearchStrings(): SearchString[] {
const opsMap = new Map([[Operator.AND.toString(), Operator.AND], [Operator.NOT.toString(), Operator.NOT], [Operator.OR.toString(), Operator.OR]]);
const opsMap = new Map([[Operator.AND.toString(), Operator.AND], [Operator.NOT.toString(), Operator.NOT], [Operator.OR.toString(), Operator.OR]]);
console.log(this.searchWords.split(' '));
const searchWords = this.searchWords.split(' ').map(str => str.trim())
.filter(str => !!opsMap.get(str[0]) && str.length < 4).map(str => new SearchString(str.substring(1).trim(), opsMap.get(str[0])));
.filter(str => !!opsMap.get(str[0]) && str.length > 4).map(str => new SearchString(str.substring(1).trim(), opsMap.get(str[0])));
return searchWords;
}

Expand Down

0 comments on commit 54e6126

Please sign in to comment.