arreglar-funcionalidad #84

Merged
alex merged 14 commits from arreglar-funcionalidad into main 2024-11-28 02:52:23 +00:00
2 changed files with 7 additions and 2 deletions
Showing only changes of commit 3fa90b925b - Show all commits

View File

@ -11,6 +11,6 @@ public interface EmployeeRepository extends JpaRepository<Employee, UUID> {
Optional<Employee> findByUsername(String username);
Optional<Employee> findByPersonalEmail(String personalEmail);
List<Employee> findAllByTeamId(UUID teamId);
Optional<Employee> findByTeamIdAndLeadManagerTrue(UUID teamId);
//Optional<Employee> findByTeamIdAndLeadManagerTrue(UUID teamId);
List<Employee> findByTeamName(String teamName);
}

View File

@ -1,4 +1,5 @@
package com.primefactorsolutions.service;
import com.google.common.base.Strings;
import com.primefactorsolutions.model.Employee;
import jakarta.persistence.EntityManager;
import lombok.AllArgsConstructor;
@ -49,7 +50,11 @@ public class EmployeeService {
}
public String getTeamLeadName(final UUID teamId) {
Optional<Employee> leadManager = employeeRepository.findByTeamIdAndLeadManagerTrue(teamId);
// Encuentra al empleado con el rol de lead_manager en el equipo especificado
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())
.orElse("No asignado");
}