-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sprint crud #9
Sprint crud #9
Conversation
|
||
@Override | ||
@PostMapping(value = ADD_SPRINT) | ||
public SprintResponse addNewSprint(@RequestParam String name, @RequestParam LocalDate startDate, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zmień to na @RequestBody bo duży tych parametrów jest lepiej to w jakimś SprintRequest przerzucić
private final SprintRepository sprintRepository; | ||
private final SprintMapper sprintMapper; | ||
|
||
public final SprintResponse addNewSprint(String name, LocalDate startDate, LocalDate endDate, String description) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Daj te @Override
przy metodach z interfejsu
.orElseThrow(() -> new SprintDoesNotExistException(sprintId)); | ||
log.info("Found sprint to update: {}", sprintToUpdate); | ||
|
||
if (sprintToUpdate.getSprintEndDate().isBefore(startDate)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dodaj w sprincie metodę isEndBefore(LocalDate date)
. Ogólnie to jest uważane za code smell bo nie powinno się robić gettera i potem wywoływać na nim warunku tylko powinno się to shermetyzować
@@ -0,0 +1,18 @@ | |||
package dev.corn.cornbackend.api.sprint.constants; | |||
|
|||
public class SprintMappings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final
klasa i prywatny konstruktor
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface SprintRepository extends JpaRepository<Sprint, Long> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Repository
|
||
public interface SprintRepository extends JpaRepository<Sprint, Long> { | ||
|
||
Page<Sprint> findAllByOwnerOrderByName(User owner, Pageable pageable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ta metoda nie działa w spring data jpa bo w Sprint nie ma pola Owner spróbuj takiej sygnatury metody:
Page<Sprint> findAllByProjectOwnerOrderBySprintName(User owner, Pageable pageable);
No description provided.