PMT-4: Mitarbeiter zu einem projekt hinzufügen #14

Merged
SZUT-Dominik merged 7 commits from story/PMT-4-mitarbeiter-zu-einem-projekt into trunk 2024-10-21 14:11:15 +00:00
3 changed files with 8 additions and 7 deletions
Showing only changes of commit 9009c7c79e - Show all commits

View file

@ -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);

View file

@ -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

View file

@ -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);
}