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

feat: 스터디 수강생 명단 조회 #623

Merged
merged 24 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9de4594
feat: 스터디원 조회 api 스펙
AlmondBreez3 Aug 14, 2024
46bce0c
Merge branch 'develop' of https://github.com/GDSC-Hongik/gdsc-server …
AlmondBreez3 Aug 14, 2024
59eeb9a
feat: 멘토 특정 스터디 수강생 명단 조회 구현
AlmondBreez3 Aug 14, 2024
456ee61
feat: 해당 스터디의 멘토인지 검증하는 로직 추가
AlmondBreez3 Aug 14, 2024
a9465b6
feat: 자잘한 컨벤션 지키기
AlmondBreez3 Aug 14, 2024
73c601d
feat: endpoint수정하기
AlmondBreez3 Aug 14, 2024
019ca34
feat: 외부 도메인 서비스에 의해 참조 엔티티에 대한 검증 책임 구현
AlmondBreez3 Aug 14, 2024
90846e6
feat: 디스코드 관련 명칭 수정
AlmondBreez3 Aug 14, 2024
55f4ce6
feat: 어드민, 멘토, 즉 게스트인 회원에 대한 접근을 검증하는 로직 추가
AlmondBreez3 Aug 14, 2024
90f22ff
feat: 어드민도 스터디의 수강생 명단 볼 수 있게 구성
AlmondBreez3 Aug 16, 2024
a5c3d2e
feat: 오타 수정
AlmondBreez3 Aug 16, 2024
05f9f6e
feat: 테스트 추가
AlmondBreez3 Aug 16, 2024
dc87777
feat: 테스트 추가 및 로직 수정
AlmondBreez3 Aug 16, 2024
2f28e48
feat: 스터디 validator확장성 고려해서 수정
AlmondBreez3 Aug 16, 2024
3a3bc02
feat: 변경된 validator 매개변수 테스트코드에 반영
AlmondBreez3 Aug 16, 2024
6aeede4
feat: 변경된 매개변수 코드에 적용하기
AlmondBreez3 Aug 16, 2024
ee35677
feat: 복잡한 예외 케이스 분리하기
AlmondBreez3 Aug 16, 2024
9790339
feat: 스터디 validator 테스트 오류 수정
AlmondBreez3 Aug 16, 2024
7fc485d
feat: description 수정, 불필요한 로직 수정
AlmondBreez3 Aug 16, 2024
aa9a407
feat: 코드 컨벤션 지키기
AlmondBreez3 Aug 17, 2024
203449b
feat: 오타 수정
AlmondBreez3 Aug 17, 2024
7e5c230
fix: 머지 컨플릭트 수정하기
AlmondBreez3 Aug 17, 2024
758a038
Merge branch 'develop' of https://github.com/GDSC-Hongik/gdsc-server …
AlmondBreez3 Aug 17, 2024
b870af0
feat: develop과 merge
AlmondBreez3 Aug 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import com.gdschongik.gdsc.domain.study.application.MentorStudyService;
import com.gdschongik.gdsc.domain.study.dto.response.MentorStudyResponse;
import com.gdschongik.gdsc.domain.study.dto.response.StudyStudentResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
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.RestController;

Expand All @@ -25,4 +27,11 @@ public ResponseEntity<List<MentorStudyResponse>> getStudiesInCharge() {
List<MentorStudyResponse> response = mentorStudyService.getStudiesInCharge();
return ResponseEntity.ok(response);
}

@Operation(summary = "내 스터디 수강생 명단 조회", description = "내가 멘토로 있는 스터디 수강생 명단을 조회합니다")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Operation(summary = "스터디 수강생 명단 조회", description = "내가 멘토로 있는 스터디 수강생 명단을 조회합니다")
@Operation(summary = "스터디 수강생 명단 조회", description = "해당 스터디의 수강생 명단을 조회합니다")

@GetMapping("/me/{studyId}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/me/{studyId}는 스터디의 정보를 조회하는 엔드포인트 아닌가요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 다른 controller랑 겹치지 않아서 단순히 이렇게 해놨는데
/me/students/{studyId}
로 바꾸겠습니다

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그럼 내 학생들의 스터디를 조회한다는 의미가 되는데, 더 적절해지지 않아질 것 같습니다

public ResponseEntity<List<StudyStudentResponse>> getStudyStudents(@PathVariable Long studyId) {
List<StudyStudentResponse> response = mentorStudyService.getStudyStudents(studyId);
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.gdschongik.gdsc.domain.study.application;

import com.gdschongik.gdsc.domain.member.domain.Member;
import com.gdschongik.gdsc.domain.study.dao.StudyHistoryRepository;
import com.gdschongik.gdsc.domain.study.dao.StudyRepository;
import com.gdschongik.gdsc.domain.study.domain.Study;
import com.gdschongik.gdsc.domain.study.domain.StudyHistory;
import com.gdschongik.gdsc.domain.study.dto.response.MentorStudyResponse;
import com.gdschongik.gdsc.domain.study.dto.response.StudyStudentResponse;
import com.gdschongik.gdsc.global.util.MemberUtil;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand All @@ -16,11 +19,19 @@ public class MentorStudyService {

private final MemberUtil memberUtil;
private final StudyRepository studyRepository;
private final StudyHistoryRepository studyHistoryRepository;

@Transactional(readOnly = true)
public List<MentorStudyResponse> getStudiesInCharge() {
Member currentMember = memberUtil.getCurrentMember();
List<Study> myStudies = studyRepository.findAllByMentor(currentMember);
return myStudies.stream().map(MentorStudyResponse::from).toList();
}

@Transactional(readOnly = true)
public List<StudyStudentResponse> getStudyStudents(Long studyId) {
List<StudyHistory> studyHistories = studyHistoryRepository.findByStudyId(studyId);

return studyHistories.stream().map(StudyStudentResponse::from).toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ public interface StudyHistoryRepository extends JpaRepository<StudyHistory, Long
List<StudyHistory> findAllByMentee(Member member);

Optional<StudyHistory> findByMenteeAndStudy(Member member, Study study);

List<StudyHistory> findByStudyId(Long studyId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.gdschongik.gdsc.domain.study.dto.response;

import com.gdschongik.gdsc.domain.study.domain.StudyHistory;
import io.swagger.v3.oas.annotations.media.Schema;

public record StudyStudentResponse(
@Schema(description = "멤버 아이디") Long memberId,
@Schema(description = "학생 이름") String name,
@Schema(description = "학번") String studentId,
@Schema(description = "디스코드 사용자명") String discordName,
@Schema(description = "디스코드 닉네임") String discordUsername,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Schema(description = "디스코드 사용자명") String discordName,
@Schema(description = "디스코드 닉네임") String discordUsername,
@Schema(description = "디스코드 사용자명") String discordUsername,
@Schema(description = "디스코드 닉네임") String nickname,

@Schema(description = "깃허브 링크") String githubLink) {
public static StudyStudentResponse from(StudyHistory studyHistory) {
return new StudyStudentResponse(
studyHistory.getMentee().getId(),
studyHistory.getMentee().getName(),
studyHistory.getMentee().getStudentId(),
studyHistory.getMentee().getDiscordId(),
studyHistory.getMentee().getDiscordUsername(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
studyHistory.getMentee().getDiscordId(),
studyHistory.getMentee().getDiscordUsername(),
studyHistory.getMentee().getDiscordUsername(),
studyHistory.getMentee().getNickname(),

studyHistory.getRepositoryLink());
}
}