corregir metodo de getTeamLeadName
All checks were successful
PR Builder / Build-PR (pull_request) Successful in 2m47s
All checks were successful
PR Builder / Build-PR (pull_request) Successful in 2m47s
This commit is contained in:
parent
0e142934fa
commit
00810b3f6d
@ -9,8 +9,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public interface EmployeeRepository extends JpaRepository<Employee, UUID> {
|
public interface EmployeeRepository extends JpaRepository<Employee, UUID> {
|
||||||
Optional<Employee> findByUsername(String username);
|
Optional<Employee> findByUsername(String username);
|
||||||
|
|
||||||
Optional<Employee> findByPersonalEmail(String personalEmail);
|
Optional<Employee> findByPersonalEmail(String personalEmail);
|
||||||
Optional<Employee> findByTeamId(UUID teamId);
|
List<Employee> findAllByTeamId(UUID teamId);
|
||||||
List<Employee> findByTeamName(String teamName);
|
List<Employee> findByTeamName(String teamName);
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
package com.primefactorsolutions.service;
|
package com.primefactorsolutions.service;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.primefactorsolutions.model.Employee;
|
import com.primefactorsolutions.model.Employee;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@ -50,7 +51,10 @@ public class EmployeeService {
|
|||||||
|
|
||||||
public String getTeamLeadName(final UUID teamId) {
|
public String getTeamLeadName(final UUID teamId) {
|
||||||
// Encuentra al empleado con el rol de lead_manager en el equipo especificado
|
// Encuentra al empleado con el rol de lead_manager en el equipo especificado
|
||||||
Optional<Employee> leadManager = employeeRepository.findByTeamId(teamId);
|
List<Employee> teamMembers = employeeRepository.findAllByTeamId(teamId);
|
||||||
|
Optional<Employee> leadManager = teamMembers.stream()
|
||||||
|
.filter(e -> Strings.isNullOrEmpty(e.getLeadManager()))
|
||||||
|
.findFirst();
|
||||||
|
|
||||||
return leadManager.map(employee -> employee.getFirstName() + " " + employee.getLastName())
|
return leadManager.map(employee -> employee.getFirstName() + " " + employee.getLastName())
|
||||||
.orElse("No asignado");
|
.orElse("No asignado");
|
||||||
|
Loading…
Reference in New Issue
Block a user