diff --git a/src/main/client/src/app/layout/navbar/navbar.component.css b/src/main/client/src/app/navbar/navbar.component.css
similarity index 100%
rename from src/main/client/src/app/layout/navbar/navbar.component.css
rename to src/main/client/src/app/navbar/navbar.component.css
diff --git a/src/main/client/src/app/layout/navbar/navbar.component.html b/src/main/client/src/app/navbar/navbar.component.html
similarity index 96%
rename from src/main/client/src/app/layout/navbar/navbar.component.html
rename to src/main/client/src/app/navbar/navbar.component.html
index 4c7f66d..4114ad8 100644
--- a/src/main/client/src/app/layout/navbar/navbar.component.html
+++ b/src/main/client/src/app/navbar/navbar.component.html
@@ -8,6 +8,8 @@
class="fa fa-home w3-margin-right">Worklife
+
diff --git a/src/main/client/src/app/layout/navbar/navbar.component.ts b/src/main/client/src/app/navbar/navbar.component.ts
similarity index 69%
rename from src/main/client/src/app/layout/navbar/navbar.component.ts
rename to src/main/client/src/app/navbar/navbar.component.ts
index 6dd7e9f..9ac342f 100644
--- a/src/main/client/src/app/layout/navbar/navbar.component.ts
+++ b/src/main/client/src/app/navbar/navbar.component.ts
@@ -1,11 +1,19 @@
import {Component, OnDestroy, OnInit} from '@angular/core';
import {Router} from "@angular/router";
-import {User} from "../../shared/user/user.model";
-import {AuthService} from "../../shared/auth/auth.service";
-import {FileUploadService} from "../../shared/fiile-upload/file-upload.service";
-import {Notification, Notifications} from "../../shared/notifications/notification.model";
-import {NotificationService} from "../../shared/notifications/notification.service";
+import {User} from "../shared/user/user.model";
+import {AuthService} from "../shared/auth/auth.service";
+import {Notification, Notifications} from "../shared/notifications/notification.model";
+import {NotificationService} from "../shared/notifications/notification.service";
import {interval} from "rxjs";
+import {FileUploadService} from "../shared/fiile-upload/file-upload.service";
+import {LikeComponent} from "../newsfeed/post-list/like/like.component";
+import {BsModalService, ModalOptions} from "ngx-bootstrap";
+import {SearchUserComponent} from "./search-user/search-user.component";
+
+const options: ModalOptions = {
+ class: 'modal-m',
+ backdrop: 'static',
+};
@Component({
selector: 'app-navbar',
@@ -22,6 +30,7 @@ export class NavbarComponent implements OnInit, OnDestroy {
constructor(private router: Router,
private _uploadService: FileUploadService,
+ private _modal: BsModalService,
private _notificationService: NotificationService,
private authService: AuthService) {
}
@@ -69,4 +78,11 @@ export class NavbarComponent implements OnInit, OnDestroy {
return obj.notificationId !== notification.notificationId;
});
}
+
+ search() {
+ const initialState = {
+ };
+
+ this._modal.show(SearchUserComponent, {...options, initialState});
+ }
}
diff --git a/src/main/client/src/app/navbar/search-user/search-user.component.css b/src/main/client/src/app/navbar/search-user/search-user.component.css
new file mode 100644
index 0000000..e69de29
diff --git a/src/main/client/src/app/navbar/search-user/search-user.component.html b/src/main/client/src/app/navbar/search-user/search-user.component.html
new file mode 100644
index 0000000..9313a2a
--- /dev/null
+++ b/src/main/client/src/app/navbar/search-user/search-user.component.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/client/src/app/navbar/search-user/search-user.component.ts b/src/main/client/src/app/navbar/search-user/search-user.component.ts
new file mode 100644
index 0000000..d6edbe8
--- /dev/null
+++ b/src/main/client/src/app/navbar/search-user/search-user.component.ts
@@ -0,0 +1,40 @@
+import {Component, OnInit} from '@angular/core';
+import {BsModalRef} from "ngx-bootstrap";
+import {Users} from "../../shared/user/user.model";
+import {UserService} from "../../shared/user/user.service";
+
+@Component({
+ selector: 'app-search-user',
+ templateUrl: './search-user.component.html',
+ styleUrls: ['./search-user.component.css']
+})
+export class SearchUserComponent implements OnInit {
+ users: Users;
+
+ constructor(public _modal: BsModalRef,
+ private _userService: UserService) {
+ }
+
+ ngOnInit() {
+ this.users = [];
+ }
+
+ searchUser(event) {
+ let term = event.target.value;
+ if (term == '') {
+ this.users = [];
+ return;
+ }
+ this._userService.search(term)
+ .then((users: Users) => {
+ this.users = users;
+ });
+ }
+
+ close() {
+ if (this._modal) {
+ this._modal.hide();
+ this._modal = null;
+ }
+ }
+}
diff --git a/src/main/client/src/app/shared/user/user.service.ts b/src/main/client/src/app/shared/user/user.service.ts
index 72af7cb..ebbcbfa 100644
--- a/src/main/client/src/app/shared/user/user.service.ts
+++ b/src/main/client/src/app/shared/user/user.service.ts
@@ -26,6 +26,14 @@ export class UserService {
.toPromise() as Promise
;
}
+ search(term: string) {
+ return this.repoService.get('network/connections/users/search/?username='+term)
+ .pipe(map((Users: any[]) => {
+ return Users.map(user => this.deserializeUser(user))
+ }))
+ .toPromise() as Promise;
+ }
+
loginUser(username: string, password: string) {
let invalid = false;
this.authService.loginUser(username, password)
diff --git a/src/main/java/com/linkedin/entities/database/repo/UserRepository.java b/src/main/java/com/linkedin/entities/database/repo/UserRepository.java
index 20c2acb..3a66c8d 100644
--- a/src/main/java/com/linkedin/entities/database/repo/UserRepository.java
+++ b/src/main/java/com/linkedin/entities/database/repo/UserRepository.java
@@ -2,6 +2,8 @@
import com.linkedin.entities.database.User;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@@ -9,6 +11,11 @@
@Repository
public interface UserRepository extends JpaRepository {
User findByUsernameIgnoreCase(String username);
- List findAllByUsernameIgnoreCase(String username);
+
+ @Query("SELECT u FROM User u WHERE lower(u.username) LIKE CONCAT('%',lower(:term),'%') "
+ + "OR lower(u.name) LIKE CONCAT('%',lower(:term),'%') "
+ + "OR lower(u.surname) LIKE CONCAT('%',lower(:term),'%')")
+ List searchUser(@Param("term") String term);
+
boolean existsByEmailIgnoreCase(String email);
}
diff --git a/src/main/java/com/linkedin/service/ConnectionService.java b/src/main/java/com/linkedin/service/ConnectionService.java
index 6da7eb5..e927fbb 100644
--- a/src/main/java/com/linkedin/service/ConnectionService.java
+++ b/src/main/java/com/linkedin/service/ConnectionService.java
@@ -4,9 +4,11 @@
import com.linkedin.converter.UserConverter;
import com.linkedin.entities.database.Connection;
import com.linkedin.entities.database.ConnectionRequest;
+import com.linkedin.entities.database.Login;
import com.linkedin.entities.database.User;
import com.linkedin.entities.database.repo.ConnectionRepository;
import com.linkedin.entities.database.repo.ConnectionRequestRepository;
+import com.linkedin.entities.database.repo.LoginRepository;
import com.linkedin.entities.database.repo.UserRepository;
import com.linkedin.entities.model.UserDto;
import com.linkedin.entities.model.UserSimpleDto;
@@ -26,201 +28,209 @@
@Service
public class ConnectionService {
- private final ConnectionRepository connectionRepository;
- private final ConnectionRequestRepository connectionRequestRepository;
- private final ConnectionConverter connectionConverter;
- private final UserRepository userRepository;
- private final UserConverter userConverter;
- private final NotificationService notificationService;
-
- @Autowired
- public ConnectionService(ConnectionRepository connectionRepository, ConnectionRequestRepository connectionRequestRepository, ConnectionConverter connectionConverter, UserRepository userRepository, UserConverter userConverter, NotificationService notificationService) {
- this.connectionRepository = connectionRepository;
- this.connectionRequestRepository = connectionRequestRepository;
- this.connectionConverter = connectionConverter;
- this.userRepository = userRepository;
-
- //this.connectionRequestDto = connectionRequestDto;
- this.userConverter = userConverter;
- this.notificationService = notificationService;
- }
-
- public void deleteConnection(Long connectionId) throws Exception {
- Long userId = AuthenticationFacade.getUserId();
- Connection connection = connectionRepository.findById(connectionId).orElseThrow(() -> new ObjectNotFoundException(Connection.class, connectionId));
- if (!isUsersConnection(userId, connection)) {
- throw new IllegalAccessException("not yours connection");
+ private final ConnectionRepository connectionRepository;
+ private final ConnectionRequestRepository connectionRequestRepository;
+ private final ConnectionConverter connectionConverter;
+ private final UserRepository userRepository;
+ private final UserConverter userConverter;
+ private final NotificationService notificationService;
+ private final LoginRepository loginRepository;
+
+ @Autowired
+ public ConnectionService(ConnectionRepository connectionRepository, ConnectionRequestRepository connectionRequestRepository, ConnectionConverter connectionConverter, UserRepository userRepository, UserConverter userConverter, NotificationService notificationService, LoginRepository loginRepository) {
+ this.connectionRepository = connectionRepository;
+ this.connectionRequestRepository = connectionRequestRepository;
+ this.connectionConverter = connectionConverter;
+ this.userRepository = userRepository;
+
+ //this.connectionRequestDto = connectionRequestDto;
+ this.userConverter = userConverter;
+ this.notificationService = notificationService;
+ this.loginRepository = loginRepository;
}
- connectionRepository.delete(connection);
- }
- private boolean isUsersConnection(Long userId, Connection connection) {
- return connection.getUserAcceptedId().equals(userId) || connection.getUserRequestedId().equals(userId);
- }
+ public void deleteConnection(Long connectionId) throws Exception {
+ Long userId = AuthenticationFacade.getUserId();
+ Connection connection = connectionRepository.findById(connectionId).orElseThrow(() -> new ObjectNotFoundException(Connection.class, connectionId));
+ if (!isUsersConnection(userId, connection)) {
+ throw new IllegalAccessException("not yours connection");
+ }
+ connectionRepository.delete(connection);
+ }
+
+ private boolean isUsersConnection(Long userId, Connection connection) {
+ return connection.getUserAcceptedId().equals(userId) || connection.getUserRequestedId().equals(userId);
+ }
- //Gyrna ta Connection tou User pou einai loged in twra
- public List getMyConnections() {
- Long userId = AuthenticationFacade.authenticatedUser().getUserId();
+ //Gyrna ta Connection tou User pou einai loged in twra
+ public List getMyConnections() {
+ Long userId = AuthenticationFacade.authenticatedUser().getUserId();
- return connectionRepository.findAllByUserRequestedIdOrUserAcceptedId(userId, userId)
- .stream()
- //.map(x -> x.getUserAccepted().equals(userId) ? x.getUserRequested() : x.getUserAccepted())
- .map(connectionConverter::toConnectionDto)
- .collect(Collectors.toList());
- }
- //Gyrna ta Connection tou tou User me id userid
+ return connectionRepository.findAllByUserRequestedIdOrUserAcceptedId(userId, userId)
+ .stream()
+ //.map(x -> x.getUserAccepted().equals(userId) ? x.getUserRequested() : x.getUserAccepted())
+ .map(connectionConverter::toConnectionDto)
+ .collect(Collectors.toList());
+ }
+ //Gyrna ta Connection tou tou User me id userid
+
+ public List getUserConnections(Long userId) throws Exception {
+ if (!userRepository.existsById(userId)) {
+ throw new ObjectNotFoundException(User.class, userId);
+ }
+ return connectionRepository.findAllByUserRequestedIdOrUserAcceptedId(userId, userId)
+ .stream()
+ //.map(x -> x.getUserAccepted().equals(userId) ? x.getUserRequested() : x.getUserAccepted())
+ .map(connectionConverter::toConnectionDto)
+ .collect(Collectors.toList());
- public List getUserConnections(Long userId) throws Exception {
- if (!userRepository.existsById(userId)) {
- throw new ObjectNotFoundException(User.class, userId);
}
- return connectionRepository.findAllByUserRequestedIdOrUserAcceptedId(userId, userId)
- .stream()
- //.map(x -> x.getUserAccepted().equals(userId) ? x.getUserRequested() : x.getUserAccepted())
- .map(connectionConverter::toConnectionDto)
- .collect(Collectors.toList());
-
- }
-
- //returns All the connection requests that other Users did to the user
- public List getMyConnectionRequests() {
- Long userId = AuthenticationFacade.authenticatedUser().getUserId();
- return connectionRequestRepository.findAllByUserTargetId(userId)
- .stream()
- .map(connectionConverter::toConnectionRequestDto)
- .filter(x -> x.getStatus() == 0)
- .collect(Collectors.toList());
- }
-
- //returns the connectionRequests that user with userid did to the loged user
- public List getConnectionRequestsFromUser(Long userId) {
- return connectionRequestRepository.findAllByUserTargetIdAndUserRequestedId(userId, userId)
- .stream()
- .map(connectionConverter::toConnectionRequestDto)
- .filter(x -> x.getStatus() == 0)
- .collect(Collectors.toList());
- }
-
-
- //logged User makes a Request to another user with Id userId
- public ConnectionRequestDto createNewConnectionRequest(Long userId) throws Exception {
- if (!userRepository.existsById(userId)) {
- throw new ObjectNotFoundException(User.class, userId);
+
+ //returns All the connection requests that other Users did to the user
+ public List getMyConnectionRequests() {
+ Long userId = AuthenticationFacade.authenticatedUser().getUserId();
+ return connectionRequestRepository.findAllByUserTargetId(userId)
+ .stream()
+ .map(connectionConverter::toConnectionRequestDto)
+ .filter(x -> x.getStatus() == 0)
+ .collect(Collectors.toList());
}
- ConnectionRequest connectionRequest = new ConnectionRequest();
- Long loggedUserId = AuthenticationFacade.authenticatedUser().getUserId();
- //an o loggedUser exei kanei hdh connection Request na mhn ton ksanaafhsei dhladh na mhn kanei tpt
- if (connectionRequestRepository.findAllByUserTargetIdAndUserRequestedId(userId, loggedUserId).size() > 0) {
- return null;
+
+ //returns the connectionRequests that user with userid did to the loged user
+ public List getConnectionRequestsFromUser(Long userId) {
+ return connectionRequestRepository.findAllByUserTargetIdAndUserRequestedId(userId, userId)
+ .stream()
+ .map(connectionConverter::toConnectionRequestDto)
+ .filter(x -> x.getStatus() == 0)
+ .collect(Collectors.toList());
}
- connectionRequest.setDateOfRequest(new Date());
- connectionRequest.setStatus(0); //pending to start with
- connectionRequest.setUserRequestedId(loggedUserId);
- connectionRequest.setUserTargetId(userId);
- connectionRequestRepository.save(connectionRequest);
- notificationService.createNotification(userId, 2, connectionRequest.getConnectionRequestId());
+ //logged User makes a Request to another user with Id userId
+ public ConnectionRequestDto createNewConnectionRequest(Long userId) throws Exception {
+ if (!userRepository.existsById(userId)) {
+ throw new ObjectNotFoundException(User.class, userId);
+ }
+ ConnectionRequest connectionRequest = new ConnectionRequest();
+ Long loggedUserId = AuthenticationFacade.authenticatedUser().getUserId();
+ //an o loggedUser exei kanei hdh connection Request na mhn ton ksanaafhsei dhladh na mhn kanei tpt
+ if (connectionRequestRepository.findAllByUserTargetIdAndUserRequestedId(userId, loggedUserId).size() > 0) {
+ return null;
+ }
- return connectionConverter.toConnectionRequestDto(connectionRequest);
+ connectionRequest.setDateOfRequest(new Date());
+ connectionRequest.setStatus(0); //pending to start with
+ connectionRequest.setUserRequestedId(loggedUserId);
+ connectionRequest.setUserTargetId(userId);
- }
+ connectionRequestRepository.save(connectionRequest);
+ notificationService.createNotification(userId, 2, connectionRequest.getConnectionRequestId());
+
+ return connectionConverter.toConnectionRequestDto(connectionRequest);
- public ConnectionDto acceptToConnectionRequest(Long connectionRequestId) throws Exception {
- if (!connectionRequestRepository.existsById(connectionRequestId)) {
- throw new ObjectNotFoundException(ConnectionRequest.class, connectionRequestId);
}
- ConnectionRequest connectionRequest = connectionRequestRepository.findById(connectionRequestId).orElse(null);
- connectionRequest.setStatus(1); //accept
- connectionRequestRepository.save(connectionRequest);
- //apothikebw sto connections
+ public ConnectionDto acceptToConnectionRequest(Long connectionRequestId) throws Exception {
+ if (!connectionRequestRepository.existsById(connectionRequestId)) {
+ throw new ObjectNotFoundException(ConnectionRequest.class, connectionRequestId);
+ }
+ ConnectionRequest connectionRequest = connectionRequestRepository.findById(connectionRequestId).orElse(null);
+ connectionRequest.setStatus(1); //accept
+ connectionRequestRepository.save(connectionRequest);
- Connection connection = new Connection();
- connection.setConnectionRequestId(connectionRequestId);
- connection.setCreateDate(connectionRequest.getDateOfRequest());
- connection.setUserAcceptedId(connectionRequest.getUserTargetId());
- connection.setUserRequestedId(connectionRequest.getUserRequestedId());
- connectionRepository.save(connection);
- return connectionConverter.toConnectionDto(connection);
+ //apothikebw sto connections
- }
+ Connection connection = new Connection();
+ connection.setConnectionRequestId(connectionRequestId);
+ connection.setCreateDate(connectionRequest.getDateOfRequest());
+ connection.setUserAcceptedId(connectionRequest.getUserTargetId());
+ connection.setUserRequestedId(connectionRequest.getUserRequestedId());
+ connectionRepository.save(connection);
+ return connectionConverter.toConnectionDto(connection);
- public void rejectConnectionRequest(Long connectionRequestId) throws Exception {
- if (!connectionRequestRepository.existsById(connectionRequestId)) {
- throw new ObjectNotFoundException(ConnectionRequest.class, connectionRequestId);
}
- ConnectionRequest connectionRequest = connectionRequestRepository.findById(connectionRequestId).orElse(null);
- connectionRequest.setStatus(2); //reject
- connectionRequestRepository.save(connectionRequest);
- }
-
- //epistrefei lista apo Users pou einai connected me ton User mas
- private List getFriends(Long userId) {
- List connections = connectionRepository.findAllByUserRequestedIdOrUserAcceptedId(userId, userId);
- List userList = new ArrayList<>();
-
- for (Connection connection : connections) {
- if (!connection.getUserRequestedId().equals(userId) && connection.getUserAcceptedId().equals(userId)) {
- userList.add(userRepository.findById(connection.getUserRequestedId()).orElse(null));
- } else if (connection.getUserRequestedId().equals(userId) && !connection.getUserAcceptedId().equals(userId)) {
- userList.add(userRepository.findById(connection.getUserAcceptedId()).orElse(null));
- }
- }
- return userList;
- }
+ public void rejectConnectionRequest(Long connectionRequestId) throws Exception {
+ if (!connectionRequestRepository.existsById(connectionRequestId)) {
+ throw new ObjectNotFoundException(ConnectionRequest.class, connectionRequestId);
+ }
- public List getFriendsToUserSimpleDto(Long userId) {
- List userDtoList = new ArrayList<>();
- List userList = getFriends(userId);
- for (User anUserList : userList) {
- if (anUserList != null) {
- userDtoList.add(userConverter.toUserSimpleDto(anUserList));
- }
+ ConnectionRequest connectionRequest = connectionRequestRepository.findById(connectionRequestId).orElse(null);
+ connectionRequest.setStatus(2); //reject
+ connectionRequestRepository.save(connectionRequest);
+ }
+ //epistrefei lista apo Users pou einai connected me ton User mas
+ private List getFriends(Long userId) {
+ List connections = connectionRepository.findAllByUserRequestedIdOrUserAcceptedId(userId, userId);
+ List userList = new ArrayList<>();
+
+ for (Connection connection : connections) {
+ if (!connection.getUserRequestedId().equals(userId) && connection.getUserAcceptedId().equals(userId)) {
+ userList.add(userRepository.findById(connection.getUserRequestedId()).orElse(null));
+ } else if (connection.getUserRequestedId().equals(userId) && !connection.getUserAcceptedId().equals(userId)) {
+ userList.add(userRepository.findById(connection.getUserAcceptedId()).orElse(null));
+ }
+ }
+ return userList;
}
- return userDtoList;
- }
- public List getConnectionRequestsToOtherUsers() {
- Long loggedUserId = AuthenticationFacade.authenticatedUser().getUserId();
- return connectionRequestRepository.findAllByUserRequestedId(loggedUserId).stream().map(connectionConverter::toConnectionRequestDto).collect(Collectors.toList());
- }
+ public List getFriendsToUserSimpleDto(Long userId) {
+ List userDtoList = new ArrayList<>();
+ List userList = getFriends(userId);
+ for (User anUserList : userList) {
+ if (anUserList != null) {
+ userDtoList.add(userConverter.toUserSimpleDto(anUserList));
+ }
- public ConnectionStatusDto getConnectionStatus(Long userId) throws Exception {
- if (!userRepository.existsById(userId)) {
- throw new ObjectNotFoundException(User.class, userId);
+ }
+ return userDtoList;
}
- Long loggedUserId = AuthenticationFacade.authenticatedUser().getUserId();
- ConnectionStatusDto connectionStatusDto = new ConnectionStatusDto();
- //myprofile
- if (loggedUserId == userId) {
- connectionStatusDto.setConnectionStatus(4);
- return connectionStatusDto;
- }
- //an einai connected
- if (connectionRepository.existsByUserAcceptedIdAndUserRequestedId(userId, loggedUserId) || connectionRepository.existsByUserAcceptedIdAndUserRequestedId(loggedUserId, userId)) {
- connectionStatusDto.setConnectionStatus(0);
- }
- //an exei steilei o allos se emena pou eimai logedin
- else if (connectionRequestRepository.findAllByUserTargetIdAndUserRequestedId(loggedUserId, userId).size() > 0) {
- connectionStatusDto.setConnectionStatus(2);
+ public List getConnectionRequestsToOtherUsers() {
+ Long loggedUserId = AuthenticationFacade.authenticatedUser().getUserId();
+ return connectionRequestRepository.findAllByUserRequestedId(loggedUserId).stream().map(connectionConverter::toConnectionRequestDto).collect(Collectors.toList());
}
- //an tou exw steilei egw connectionRequest
- else if (connectionRequestRepository.findAllByUserTargetIdAndUserRequestedId(userId, loggedUserId).size() > 0) {
- connectionStatusDto.setConnectionStatus(3);
- } else {//an den einai filoi
- connectionStatusDto.setConnectionStatus(1);
+ public ConnectionStatusDto getConnectionStatus(Long userId) throws Exception {
+ if (!userRepository.existsById(userId)) {
+ throw new ObjectNotFoundException(User.class, userId);
+ }
+ Long loggedUserId = AuthenticationFacade.authenticatedUser().getUserId();
+ ConnectionStatusDto connectionStatusDto = new ConnectionStatusDto();
+ //myprofile
+ if (loggedUserId == userId) {
+ connectionStatusDto.setConnectionStatus(4);
+ return connectionStatusDto;
+ }
+ //an einai connected
+ if (connectionRepository.existsByUserAcceptedIdAndUserRequestedId(userId, loggedUserId) || connectionRepository.existsByUserAcceptedIdAndUserRequestedId(loggedUserId, userId)) {
+ connectionStatusDto.setConnectionStatus(0);
+ }
+ //an exei steilei o allos se emena pou eimai logedin
+ else if (connectionRequestRepository.findAllByUserTargetIdAndUserRequestedId(loggedUserId, userId).size() > 0) {
+ connectionStatusDto.setConnectionStatus(2);
+
+ }
+ //an tou exw steilei egw connectionRequest
+ else if (connectionRequestRepository.findAllByUserTargetIdAndUserRequestedId(userId, loggedUserId).size() > 0) {
+ connectionStatusDto.setConnectionStatus(3);
+
+ } else {//an den einai filoi
+ connectionStatusDto.setConnectionStatus(1);
+ }
+ return connectionStatusDto;
}
- return connectionStatusDto;
- }
- public List getUserSearchResults(String username) {
- return userRepository.findAllByUsernameIgnoreCase(username).stream().map(userConverter::toUserDto).collect(Collectors.toList());
- }
+ public List getUserSearchResults(String username) {
+ List users = userRepository.searchUser(username);
+ return users.stream()
+ .map(x -> {
+ Login login = loginRepository.findByUserId(x.getId()).orElse(null);
+ Integer role = login != null ? login.getRole().ordinal() : 0;
+ return userConverter.toUserDto(x, role);
+ }).collect(Collectors.toList());
+ }
}