Skip to content

Commit

Permalink
feat: 목표-퀘스트 조회
Browse files Browse the repository at this point in the history
  • Loading branch information
koosco committed Nov 23, 2024
1 parent d4e010a commit 2678a42
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum ErrorCode {
NOT_FOUND_S3(40406, HttpStatus.NOT_FOUND, "해당 파일을 찾을 수 없습니다."),
NOT_FOUND_QUEST(40407, HttpStatus.NOT_FOUND, "해당 퀘스트가 존재하지 않습니다."),
NOT_FOUND_GOAL_CATEGORY(40408, HttpStatus.NOT_FOUND, "해당 목표 카테고리가 존재하지 않습니다."),
NOT_FOUND_MEMBER_GOAL(40409, HttpStatus.NOT_FOUND, "해당 사용자 목표가 존재하지 않습니다."),

// Invalid Argument Error
MISSING_REQUEST_PARAMETER(40000, HttpStatus.BAD_REQUEST, "필수 요청 파라미터가 누락되었습니다."),
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/groom/orbit/goal/app/MemberGoalService.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.groom.orbit.goal.dao.MemberGoalRepository;
import com.groom.orbit.goal.dao.entity.Goal;
import com.groom.orbit.goal.dao.entity.MemberGoal;
import com.groom.orbit.goal.dao.entity.Quest;
import com.groom.orbit.member.app.MemberQueryService;
import com.groom.orbit.member.dao.jpa.entity.Member;

Expand Down Expand Up @@ -136,4 +137,18 @@ private List<String> getGoalTitle(List<Long> startIds) {
public List<MemberGoal> findMemberGoalsByGoalId(Long goalId) {
return memberGoalRepository.findAllByGoalId(goalId);
}

public GetMemberGoalResponseDto findGoal(Long memberGoalId) {
MemberGoal memberGoal = findMemberGoal(memberGoalId);
List<Quest> quests = memberGoal.getQuests();
List<GetQuestResponseDto> questDtos =
quests.stream()
.map(
quest ->
new GetQuestResponseDto(
quest.getQuestId(), quest.getTitle(), quest.getIsComplete()))
.toList();
return new GetMemberGoalResponseDto(
memberGoal.getMemberGoalId(), memberGoal.getTitle(), questDtos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -27,6 +28,12 @@ public ResponseDto<List<GetMemberGoalResponseDto>> getGoals(
return ResponseDto.ok(memberGoalService.findGoals(memberId, isComplete));
}

@GetMapping("/{member_goal_id}")
public ResponseDto<GetMemberGoalResponseDto> getGoal(
@PathVariable("member_goal_id") Long memberGoalId) {
return ResponseDto.ok(memberGoalService.findGoal(memberGoalId));
}

@GetMapping("/recommend")
public ResponseDto<?> getRecommendedGoals(@AuthMember Long memberId) {
return ResponseDto.ok(memberGoalService.findMemberGoalNotCompleted(memberId));
Expand Down

0 comments on commit 2678a42

Please sign in to comment.