From a7ca0f5443c0c6225f43cf225a9ee3f390ecfc20 Mon Sep 17 00:00:00 2001 From: Marc Itzenthaler Date: Tue, 15 Aug 2023 23:26:17 +0200 Subject: [PATCH] feat: added ability to search consultants and admins by id --- api/useradminservice.yaml | 2 +- api/userservice.yaml | 2 +- .../cob/userservice/api/port/out/AdminRepository.java | 3 ++- .../cob/userservice/api/port/out/ConsultantRepository.java | 6 ++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/api/useradminservice.yaml b/api/useradminservice.yaml index 0d0a9e07f..09abd0001 100644 --- a/api/useradminservice.yaml +++ b/api/useradminservice.yaml @@ -568,7 +568,7 @@ paths: parameters: - name: query in: query - description: URL-encoded infix to search for in first name, last name, or email. + description: URL-encoded infix to search for in id first name, last name, or email. A non-encoded star symbol searches for all. required: true schema: diff --git a/api/userservice.yaml b/api/userservice.yaml index 16f530277..bfbd73996 100644 --- a/api/userservice.yaml +++ b/api/userservice.yaml @@ -1002,7 +1002,7 @@ paths: parameters: - name: query in: query - description: URL-encoded infix to search for in first name, last name, or email. + description: URL-encoded infix to search for in id, first name, last name, or email. A non-encoded star symbol searches for all. required: true schema: diff --git a/src/main/java/de/caritas/cob/userservice/api/port/out/AdminRepository.java b/src/main/java/de/caritas/cob/userservice/api/port/out/AdminRepository.java index 46f097717..d64db027a 100644 --- a/src/main/java/de/caritas/cob/userservice/api/port/out/AdminRepository.java +++ b/src/main/java/de/caritas/cob/userservice/api/port/out/AdminRepository.java @@ -21,7 +21,8 @@ public interface AdminRepository extends CrudRepository { + "AND (" + " ?1 = '*' " + " OR (" - + " UPPER(a.firstName) LIKE CONCAT('%', UPPER(?1), '%')" + + " UPPER(a.adminId) = UPPER(?1)" + + " OR UPPER(a.firstName) LIKE CONCAT('%', UPPER(?1), '%')" + " OR UPPER(a.lastName) LIKE CONCAT('%', UPPER(?1), '%')" + " OR UPPER(a.email) LIKE CONCAT('%', UPPER(?1), '%')" + " OR CONVERT(a.tenantId,char) LIKE CONCAT('%', UPPER(?1), '%')" diff --git a/src/main/java/de/caritas/cob/userservice/api/port/out/ConsultantRepository.java b/src/main/java/de/caritas/cob/userservice/api/port/out/ConsultantRepository.java index 8d207262f..a6104476e 100644 --- a/src/main/java/de/caritas/cob/userservice/api/port/out/ConsultantRepository.java +++ b/src/main/java/de/caritas/cob/userservice/api/port/out/ConsultantRepository.java @@ -36,7 +36,8 @@ public interface ConsultantRepository extends CrudRepository + "WHERE" + " ?1 = '*' " + " OR (" - + " UPPER(c.firstName) LIKE CONCAT('%', UPPER(?1), '%')" + + " UPPER(c.consulantId) = UPPER(?1)" + + " OR UPPER(c.firstName) LIKE CONCAT('%', UPPER(?1), '%')" + " OR UPPER(c.lastName) LIKE CONCAT('%', UPPER(?1), '%')" + " OR UPPER(c.email) LIKE CONCAT('%', UPPER(?1), '%')" + " )") @@ -52,7 +53,8 @@ public interface ConsultantRepository extends CrudRepository + " AND (" + " ?1 = '*' " + " OR (" - + " UPPER(c.firstName) LIKE CONCAT('%', UPPER(?1), '%')" + + " UPPER(c.consulantId) = UPPER(?1) + + " OR UPPER(c.firstName) LIKE CONCAT('%', UPPER(?1), '%')" + " OR UPPER(c.lastName) LIKE CONCAT('%', UPPER(?1), '%')" + " OR UPPER(c.email) LIKE CONCAT('%', UPPER(?1), '%')" + " )"