Skip to content

Commit

Permalink
Still on this code
Browse files Browse the repository at this point in the history
  • Loading branch information
Abolaji2K21 committed May 3, 2024
1 parent 84f8586 commit 00f9523
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/main/java/africa/semicolon/controller/ContactController.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package africa.semicolon.controller;

import africa.semicolon.contactException.BigContactException;
import africa.semicolon.contactException.ContactNotFoundException;
import africa.semicolon.contactException.UserNotFoundException;
import africa.semicolon.data.models.Contact;
import africa.semicolon.data.repositories.ContactRepository;
import africa.semicolon.dtos.requests.CreateContactRequest;
import africa.semicolon.dtos.requests.DeleteContactRequest;
import africa.semicolon.dtos.requests.EditContactRequest;
import africa.semicolon.dtos.response.ApiResponse;
import africa.semicolon.dtos.response.CreateContactResponse;
import africa.semicolon.dtos.response.DeleteContactResponse;
import africa.semicolon.dtos.response.EditContactResponse;
import africa.semicolon.dtos.response.*;
import africa.semicolon.services.ContactService;
import africa.semicolon.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -83,6 +81,17 @@ public ResponseEntity<?> getAllContactsByCategory(@PathVariable(name = "userId")
}
}

@GetMapping("/suggest/{phoneNumber}")
public ResponseEntity<?> suggestContactsByPhoneNumber(@PathVariable String phoneNumber) {
try {
SuggestContactResponse result = contactService.suggestContactsByPhoneNumber(phoneNumber);
return new ResponseEntity<>(new ApiResponse(true, result),OK);
} catch (BigContactException message) {
return new ResponseEntity<>(new ApiResponse(false, message.getMessage()),BAD_REQUEST);
}
}


@GetMapping("/partialFirstName/{userId}/{partialFirstName}")
public ResponseEntity<?> findContactsByPartialFirstName(@PathVariable (name = "userId")String userId, @PathVariable(name = "partialFirstName") String partialFirstName) {
try {
Expand Down

0 comments on commit 00f9523

Please sign in to comment.