PMT-4: Mitarbeiter zu einem projekt hinzufügen #14
3 changed files with 8 additions and 7 deletions
|
@ -124,12 +124,12 @@ public class ApiController implements DefaultApi {
|
|||
|
||||
long start = project.getStart().toEpochSecond(ZoneOffset.UTC);
|
||||
long plannedEnd = project.getPlannedEnd().toEpochSecond(ZoneOffset.UTC);
|
||||
List<Allocation> allocations = allocationRepository.findAllocationsByEmployeeId(body.getEmployeeId());
|
||||
List<Allocation> allocations = allocationRepository.findAllByEmployeeId(body.getEmployeeId());
|
||||
if (allocations.stream()
|
||||
.map(Allocation::getProject)
|
||||
.anyMatch(allocatedProject -> {
|
||||
long allocatedStart = allocatedProject.getStart().toEpochSecond(null);
|
||||
long allocatedPlannedEnd = allocatedProject.getPlannedEnd().toEpochSecond(null);
|
||||
long allocatedStart = allocatedProject.getStart().toEpochSecond(ZoneOffset.UTC);
|
||||
long allocatedPlannedEnd = allocatedProject.getPlannedEnd().toEpochSecond(ZoneOffset.UTC);
|
||||
return Math.max(start, allocatedStart) <= Math.min(plannedEnd, allocatedPlannedEnd);
|
||||
})) {
|
||||
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||
|
|
|
@ -14,11 +14,12 @@ import lombok.*;
|
|||
public class Allocation {
|
||||
|
||||
@Id
|
||||
@Column(name = "project_id")
|
||||
@Setter(AccessLevel.NONE)
|
||||
private Long projectId;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "allocation_project", referencedColumnName = "id", insertable = false, updatable = false)
|
||||
@JoinColumn(name = "project_id", referencedColumnName = "id", insertable = false, updatable = false)
|
||||
private Project project;
|
||||
|
||||
@Id
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.hmmh.pmt.db;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AllocationRepository extends CrudRepository<Allocation, AllocationId> {
|
||||
public interface AllocationRepository extends JpaRepository<Allocation, AllocationId> {
|
||||
|
||||
List<Allocation> findAllocationsByEmployeeId(Long employeeId);
|
||||
List<Allocation> findAllByEmployeeId(Long employeeId);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue