Skip to content

Commit

Permalink
fix: search contact (pageNo to page and add city and phone)
Browse files Browse the repository at this point in the history
  • Loading branch information
BettyB979 committed Mar 13, 2024
1 parent a1dc36a commit 8e9f22a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ public ResponseEntity<Page<SearchContactDto>> searchContacts(
@RequestParam(required = false) String identifier,
@RequestParam(required = false) String name,
@RequestParam(required = false) String email,
@RequestParam(defaultValue = "0") Integer pageNo,
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer pageSize) {

log.info(
"Search contact: identifier = {}, name= {}, email= {}, pageNo= {}, pageSize= {} ",
identifier, name, email, pageNo, pageSize);
"Search contact: identifier = {}, name= {}, email= {}, page= {}, pageSize= {} ",
identifier, name, email, page, pageSize);

Pageable pageable = PageRequest.of(pageNo, pageSize);
Pageable pageable = PageRequest.of(page, pageSize);

Page<SearchContactDto> page = searchContactService.searchContactCrossDomain(identifier, name, email,
Page<SearchContactDto> pageSearchContact = searchContactService.searchContactCrossDomain(identifier, name, email,
pageable);
return new ResponseEntity<>(page, HttpStatus.OK);
return new ResponseEntity<>(pageSearchContact, HttpStatus.OK);


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class SearchContactDto {
private String firstName;
private String lastName;
private String email;
private String phone;
private String city;
private String function;
private List<String> listSurveyUnitNames;
private List<String> listSourcesId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Page<SearchContactDto> searchContactCrossDomain(

if (!StringUtils.isEmpty(identifier)) {
Contact c = contactService.findByIdentifier(identifier.toUpperCase());
pageContact = new PageImpl<>(Collections.singletonList(c),pageable,1);
pageContact = new PageImpl<>(Collections.singletonList(c), pageable, 1);
} else if (!StringUtils.isEmpty(email)) {
pageContact = contactService.findByEmail(email, pageable);

Expand All @@ -65,6 +65,8 @@ private SearchContactDto transformContactTSearchContactDto(Contact c) {
searchContact.setFirstName(c.getFirstName());
searchContact.setLastName(c.getLastName());
searchContact.setEmail(c.getEmail());
searchContact.setPhone(c.getPhone());
searchContact.setCity(c.getAddress() != null ? c.getAddress().getCityName() : "");
searchContact.setFunction(c.getFunction());
List<QuestioningAccreditation> listAccreditations = questioningAccreditationService.findByContactIdentifier(c.getIdentifier());
searchContact.setListSurveyUnitNames(listAccreditations.stream().map(a -> a.getQuestioning().getSurveyUnit().getIdSu()).distinct().toList());
Expand Down

0 comments on commit 8e9f22a

Please sign in to comment.