Skip to content

Commit

Permalink
feat: 멘토 스터디 커리큘럼 조회 (#606)
Browse files Browse the repository at this point in the history
* feat: 멘토 스터디 커리큘럼 조회

* feat: format변환해서 응답 반환해주기

* feat: 네이밍 단수-> 복수로 변경

* feat: 노션 링크 삭제
  • Loading branch information
AlmondBreez3 authored Aug 13, 2024
1 parent 78a85bb commit b76dcc0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gdschongik.gdsc.domain.study.application.MentorStudyDetailService;
import com.gdschongik.gdsc.domain.study.dto.request.AssignmentCreateUpdateRequest;
import com.gdschongik.gdsc.domain.study.dto.response.AssignmentResponse;
import com.gdschongik.gdsc.domain.study.dto.response.StudySessionResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
Expand Down Expand Up @@ -62,4 +63,12 @@ public ResponseEntity<Void> cancelStudyAssignment(@PathVariable Long studyDetail
mentorStudyDetailService.cancelStudyAssignment(studyDetailId);
return ResponseEntity.noContent().build();
}

// TODO 스터디 세션 워딩을 커리큘럼으로 변경해야함
@Operation(summary = "스터디 주차별 커리큘럼 목록 조회", description = "멘토가 자신의 스터디 커리큘럼 목록을 조회합니다")
@GetMapping("/sessions")
public ResponseEntity<List<StudySessionResponse>> getStudySessions(@RequestParam(name = "study") Long studyId) {
List<StudySessionResponse> response = mentorStudyDetailService.getSessions(studyId);
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.gdschongik.gdsc.domain.study.domain.StudyDetailValidator;
import com.gdschongik.gdsc.domain.study.dto.request.AssignmentCreateUpdateRequest;
import com.gdschongik.gdsc.domain.study.dto.response.AssignmentResponse;
import com.gdschongik.gdsc.domain.study.dto.response.StudySessionResponse;
import com.gdschongik.gdsc.global.exception.CustomException;
import com.gdschongik.gdsc.global.util.MemberUtil;
import java.util.List;
Expand Down Expand Up @@ -83,4 +84,10 @@ public void updateStudyAssignment(Long studyDetailId, AssignmentCreateUpdateRequ

log.info("[MentorStudyDetailService] 과제 수정 완료: studyDetailId={}", studyDetailId);
}

@Transactional(readOnly = true)
public List<StudySessionResponse> getSessions(Long studyId) {
List<StudyDetail> studyDetails = studyDetailRepository.findAllByStudyId(studyId);
return studyDetails.stream().map(StudySessionResponse::from).toList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.gdschongik.gdsc.domain.study.dto.response;

import com.gdschongik.gdsc.domain.recruitment.domain.vo.Period;
import com.gdschongik.gdsc.domain.study.domain.Difficulty;
import com.gdschongik.gdsc.domain.study.domain.StudyDetail;
import com.gdschongik.gdsc.domain.study.domain.vo.Session;

public record StudySessionResponse(Long studyDetailId, Period period, Long week, String title, Difficulty difficulty) {

public static StudySessionResponse from(StudyDetail studyDetail) {
Session session = studyDetail.getSession();
return new StudySessionResponse(
studyDetail.getId(),
studyDetail.getPeriod(),
studyDetail.getWeek(),
session.getTitle(),
session.getDifficulty());
}
}

0 comments on commit b76dcc0

Please sign in to comment.