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 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);
|
||||||
SZUT-Rajbir marked this conversation as resolved
Outdated
|
|||||||
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);
|
||||||
SZUT-Rajbir marked this conversation as resolved
Outdated
SZUT-Dominik
commented
Einmalige methode zum enscheiden von etwas hat hier nix zu suchen, gehört inline Einmalige methode zum enscheiden von etwas hat hier nix zu suchen, gehört inline
|
|||||||
})) {
|
})) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
SZUT-Rajbir marked this conversation as resolved
Outdated
SZUT-Dominik
commented
Raw SQL, bitte die features von Spring Repositories direkt nutzen, siehe andere Repository Klassen würde ungefähr so ausehen:
Raw SQL, bitte die features von Spring Repositories direkt nutzen, siehe andere Repository Klassen
würde ungefähr so ausehen:
`List<Allocation> findAllocationsByEmployeeId(Long employeeId);`
SZUT-Rajbir
commented
ist es eine Vorgab von Heidemann das wir kein raw sql nutzen dürfen ? ist es eine Vorgab von Heidemann das wir kein raw sql nutzen dürfen ?
|
|||||||
|
|
Loading…
Reference in a new issue
Direkt in das If tun