Skip to content

Commit

Permalink
Merge pull request #21 from Mojacknong/feature_20/버그-수정
Browse files Browse the repository at this point in the history
[fix] 참여 채소 조회 로직 수정
  • Loading branch information
MinchoGreenT authored Nov 23, 2023
2 parents 1b32ce0 + 30c5c8c commit b8ecd2f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class SearchChallengeResponseDto {

private Long challengeId;
private String veggieInfoId;
private String veggieName;
private String challengeName;
private String image;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ private List<SearchChallengeResponseDto> streamChallengeListToSearchResult(List<

return SearchChallengeResponseDto.of(
c.getId(),
c.getVeggieInfoId(),
c.getVeggieName(),
c.getChallengeName(),
c.getImageUrl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public class GetUserLevelAndNicknameResponseDto {

private String level;
private String nickname;
private String motivation;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ public BaseResponseDto<?> getMyVeggieList(
return BaseResponseDto.of(SuccessMessage.SUCCESS, veggieService.getMyVeggieList(userId));
}

@GetMapping("/registration")
@GetMapping("/registration/{veggieInfoId}")
public BaseResponseDto<?> getMyVeggieListForRegistration(
@RequestHeader("user") Long userId
@RequestHeader("user") Long userId,
@PathVariable String veggieInfoId
) {
return BaseResponseDto.of(SuccessMessage.SUCCESS, veggieService.getMyVeggieListForRegistration(userId));
return BaseResponseDto.of(SuccessMessage.SUCCESS, veggieService.getMyVeggieListForRegistration(userId, veggieInfoId));
}

@GetMapping("/mission")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@Getter
public class GetDayRoutinesResponseDto {

private Long veggieId;
private String veggieNickname;
private String color;
private List<GetDayRoutinesDto> routineList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public class GetMyVeggieListDto {

private String userNickname;
private String level;
private String motivation;
private List<GetVeggieInfoResponse> veggieList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Service
Expand Down Expand Up @@ -78,15 +79,15 @@ public GetMyVeggieListDto getMyVeggieList(Long userId) {
Utils.compareLocalDate(LocalDate.now(), v.getBirth())))
.collect(Collectors.toList());

return GetMyVeggieListDto.of(response.getNickname(), response.getLevel(), result);
return GetMyVeggieListDto.of(response.getNickname(), response.getLevel(), response.getMotivation(), result);
}

public List<GetRegistrationVeggieListResponseDto> getMyVeggieListForRegistration(Long userId) {
public List<GetRegistrationVeggieListResponseDto> getMyVeggieListForRegistration(Long userId, String veggieInfoId) {

List<Veggie> veggieList = veggieRepository.findAllByUserId(userId);
List<Veggie> veggieList = veggieRepository.findAllByUserId(userId);

return veggieList.stream()
.filter(v -> v.getRegistration() == null)
.filter(v -> v.getRegistration() == null && v.getVeggieInfoId().equals(veggieInfoId))
.map(v -> GetRegistrationVeggieListResponseDto.of(
v.getId(),
v.getVeggieName(),
Expand Down Expand Up @@ -150,7 +151,7 @@ public CheckRoutineResponseDto checkRoutine(CheckRoutineRequestDto requestDto) {

if (routine.getPeriod() != 0) {
Routine newRoutine = createRoutine(
LocalDate.now().plusDays(routine.getPeriod()).toString(),
routine.getDate().plusDays(routine.getPeriod()).toString(),
routine.getContent(),
routine.getPeriod(),
routine.getVeggie()
Expand Down Expand Up @@ -277,7 +278,7 @@ public GetDayRoutinesResponseDto getRoutineInfo(Veggie veggie, LocalDate date) {
.map(r -> GetDayRoutinesDto.of(r.getId(), r.getContent(), r.getPeriod(), r.getIsDone()))
.collect(Collectors.toList());

return GetDayRoutinesResponseDto.of(veggie.getVeggieNickname(), veggie.getColor(),result);
return GetDayRoutinesResponseDto.of(veggie.getId(), veggie.getVeggieNickname(), veggie.getColor(),result);
}

public String getRandomColorCode() {
Expand Down

0 comments on commit b8ecd2f

Please sign in to comment.