PMT-4: Fix Repository
This commit is contained in:
parent
1b036ca6f0
commit
9009c7c79e
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 start = project.getStart().toEpochSecond(ZoneOffset.UTC);
|
||||||
long plannedEnd = project.getPlannedEnd().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()
|
if (allocations.stream()
|
||||||
.map(Allocation::getProject)
|
.map(Allocation::getProject)
|
||||||
.anyMatch(allocatedProject -> {
|
.anyMatch(allocatedProject -> {
|
||||||
long allocatedStart = allocatedProject.getStart().toEpochSecond(null);
|
long allocatedStart = allocatedProject.getStart().toEpochSecond(ZoneOffset.UTC);
|
||||||
long allocatedPlannedEnd = allocatedProject.getPlannedEnd().toEpochSecond(null);
|
long allocatedPlannedEnd = allocatedProject.getPlannedEnd().toEpochSecond(ZoneOffset.UTC);
|
||||||
return Math.max(start, allocatedStart) <= Math.min(plannedEnd, allocatedPlannedEnd);
|
return Math.max(start, allocatedStart) <= Math.min(plannedEnd, allocatedPlannedEnd);
|
||||||
})) {
|
})) {
|
||||||
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
|
|
|
@ -14,11 +14,12 @@ import lombok.*;
|
||||||
public class Allocation {
|
public class Allocation {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@Column(name = "project_id")
|
||||||
@Setter(AccessLevel.NONE)
|
@Setter(AccessLevel.NONE)
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "allocation_project", referencedColumnName = "id", insertable = false, updatable = false)
|
@JoinColumn(name = "project_id", referencedColumnName = "id", insertable = false, updatable = false)
|
||||||
private Project project;
|
private Project project;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package de.hmmh.pmt.db;
|
package de.hmmh.pmt.db;
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
import java.util.List;
|
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