feat: update Employee entity
This commit is contained in:
parent
5a7d2b1f9c
commit
10f6c7753d
@ -14,6 +14,7 @@ import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -86,7 +87,7 @@ public class Employee implements UserDetails {
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@OneToMany(mappedBy = "employee")
|
||||
private List<Visit> visits;
|
||||
private List<Visit> visits = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.example.nto.dto.mappers.employee;
|
||||
|
||||
import com.example.nto.domain.entity.Employee;
|
||||
import com.example.nto.domain.entity.Employee;
|
||||
import com.example.nto.domain.entity.Office;
|
||||
import com.example.nto.domain.entity.Position;
|
||||
import com.example.nto.domain.entity.Role;
|
||||
@ -8,6 +8,8 @@ import com.example.nto.dto.entity.employee.EmployeeCreateDTO;
|
||||
import com.example.nto.utils.Utils;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@UtilityClass
|
||||
public class EmployeeCreateMapper {
|
||||
public static Employee convertFromDTO(
|
||||
@ -27,7 +29,7 @@ public class EmployeeCreateMapper {
|
||||
employee.setRole(role);
|
||||
employee.setProfileImageUrl(Utils.getRandomUrlProfileImage());
|
||||
employee.setBlocked(false);
|
||||
|
||||
employee.setCreatedAt(LocalDateTime.now());
|
||||
return employee;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class EmployeeItemMapper {
|
||||
// todo: Протестировать работу!
|
||||
|
||||
List<Visit> visitsLast30Days = Utils.filterDateLast30Days(employee.getVisits());
|
||||
employeeItemDTO.setVisitStatus(visitsLast30Days.stream().anyMatch(visit -> !visit.isFinished()));
|
||||
employeeItemDTO.setVisitStatus(employee.getVisits().stream().anyMatch(visit -> !visit.isFinished()));
|
||||
|
||||
return employeeItemDTO;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user