From a1d67c66945bcf7d5af84dddf7ce25231cbcbc07 Mon Sep 17 00:00:00 2001 From: Valentine Ekechukwu Date: Sat, 10 Dec 2022 20:25:50 +0100 Subject: [PATCH 1/3] Created an updateAvatar method with applicant pics and id as param --- .../java/com/hydraulic/applyforme/service/ApplicantService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/ApplicantService.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/ApplicantService.java index 6d1ca054..34115d1f 100644 --- a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/ApplicantService.java +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/ApplicantService.java @@ -14,4 +14,6 @@ public interface ApplicantService { ApplyForMeResponse getApplicationList(int pageNo, int pageSize, String sortBy, String sortDir); Member getDetails(Long id); + Member updateAvatar(Long applicantId, String newProfilePicture); + } From 9579e26f8d87ea52a85dae87c32c1389e50ca998 Mon Sep 17 00:00:00 2001 From: Valentine Ekechukwu Date: Sat, 10 Dec 2022 20:27:12 +0100 Subject: [PATCH 2/3] Implemented the updateAvatar method. --- .../applyforme/service/impl/ApplicantServiceImpl.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/impl/ApplicantServiceImpl.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/impl/ApplicantServiceImpl.java index 5dfc246e..73b2bfc0 100644 --- a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/impl/ApplicantServiceImpl.java +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/service/impl/ApplicantServiceImpl.java @@ -111,4 +111,12 @@ public Member getDetails(Long id) { return repository.getMyDetailsById(id); } + @Override + public Member updateAvatar(Long applicantId, String newProfilePicture) { + Member applicant = repository.getMyDetailsById(applicantId); + applicant.setAvatar(newProfilePicture); + + return applicant; + } + } From 52edf4d7fb367c7fab5ddd75dc4094bd02fdb46c Mon Sep 17 00:00:00 2001 From: Valentine Ekechukwu Date: Sat, 10 Dec 2022 20:28:20 +0100 Subject: [PATCH 3/3] Created the updateProfileAvatar controller class --- .../applyforme/controller/ApplicantController.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/controller/ApplicantController.java b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/controller/ApplicantController.java index d0a85f67..183fb686 100644 --- a/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/controller/ApplicantController.java +++ b/Apply-For-Me-Api/src/main/java/com/hydraulic/applyforme/controller/ApplicantController.java @@ -52,4 +52,11 @@ public Member getMyDetails(Long id){ return service.getDetails(authenticatedUser.getId()); } + + @PutMapping("/update/{newProfilePicture}") + public Member updateProfileAvatar(@PathVariable String newProfilePicture){ + var applicant = CurrentUserUtil.getCurrentUser(); + return service.updateAvatar(applicant.getId(), newProfilePicture); + + } }