From 54e61266e3a94ee6d743e9a293917d7c46d27bf8 Mon Sep 17 00:00:00 2001 From: Angular2guy Date: Sun, 15 Oct 2023 07:59:15 +0200 Subject: [PATCH] fix: bug --- .../moviemanager/domain/model/dto/SearchStringDto.java | 9 ++++++++- .../src/app/filter-movies/filter-movies.component.ts | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/ch/xxx/moviemanager/domain/model/dto/SearchStringDto.java b/backend/src/main/java/ch/xxx/moviemanager/domain/model/dto/SearchStringDto.java index 2c15675..77a276e 100644 --- a/backend/src/main/java/ch/xxx/moviemanager/domain/model/dto/SearchStringDto.java +++ b/backend/src/main/java/ch/xxx/moviemanager/domain/model/dto/SearchStringDto.java @@ -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("-"); @@ -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; diff --git a/frontend/src/angular/src/app/filter-movies/filter-movies.component.ts b/frontend/src/angular/src/app/filter-movies/filter-movies.component.ts index 6c616ee..dabef68 100644 --- a/frontend/src/angular/src/app/filter-movies/filter-movies.component.ts +++ b/frontend/src/angular/src/app/filter-movies/filter-movies.component.ts @@ -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; }