Skip to content
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

Merged
merged 11 commits into from
Dec 17, 2023
Merged

Sprint crud #9

merged 11 commits into from
Dec 17, 2023

Conversation

igorkedzierawski
Copy link
Collaborator

No description provided.


@Override
@PostMapping(value = ADD_SPRINT)
public SprintResponse addNewSprint(@RequestParam String name, @RequestParam LocalDate startDate,
Copy link
Owner

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) {
Copy link
Owner

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)) {
Copy link
Owner

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 {
Copy link
Owner

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> {
Copy link
Owner

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);
Copy link
Owner

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

@szymonpoltorak szymonpoltorak merged commit ab627a5 into main Dec 17, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants