Skip to content

Commit

Permalink
resolve: merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangwook02 committed Aug 2, 2024
2 parents bac85e6 + 285e23f commit ff7411c
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ private List<Long> getIdsByQueryOption(
.from(order)
.innerJoin(recruitmentRound)
.on(order.recruitmentRoundId.eq(recruitmentRound.id))
.innerJoin(member)
.on(order.memberId.eq(member.id))
.where(matchesOrderQueryOption(queryOption), predicate)
.orderBy(orderSpecifiers)
.fetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import com.gdschongik.gdsc.domain.study.application.StudyMentorService;
import com.gdschongik.gdsc.domain.study.domain.request.AssignmentCreateRequest;
import com.gdschongik.gdsc.domain.study.dto.response.AssignmentResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand All @@ -24,6 +26,20 @@ public ResponseEntity<Void> createStudyAssignment(
return null;
}

@Operation(summary = "스터디 주차별 과제 목록 조회", description = "주차별 스터디 과제 목록을 조회합니다.")
@GetMapping("/assignments/{studyId}")
public ResponseEntity<List<AssignmentResponse>> getWeeklyAssignments(@PathVariable Long studyId) {
List<AssignmentResponse> response = studyMentorService.getWeeklyAssignments(studyId);
return ResponseEntity.ok(response);
}

@Operation(summary = "스터디 과제 상세 조회", description = "멘토가 자신의 스터디 과제를 조회합니다.")
@GetMapping("/assignments/{studyDetailId}")
public ResponseEntity<AssignmentResponse> getStudyAssignment(@PathVariable Long studyDetailId) {
AssignmentResponse response = studyMentorService.getAssignment(studyDetailId);
return ResponseEntity.ok(response);
}

@Operation(summary = "스터디 과제 휴강 처리", description = "해당 주차 과제를 휴강 처리합니다.")
@PatchMapping("/assignments/{studyDetailId}/cancel")
public ResponseEntity<Void> cancelStudyAssignment(@PathVariable Long studyDetailId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import com.gdschongik.gdsc.domain.study.dao.StudyDetailRepository;
import com.gdschongik.gdsc.domain.study.domain.StudyDetail;
import com.gdschongik.gdsc.domain.study.domain.StudyDetailValidator;
import com.gdschongik.gdsc.domain.study.dto.response.AssignmentResponse;
import com.gdschongik.gdsc.global.exception.CustomException;
import com.gdschongik.gdsc.global.util.MemberUtil;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand All @@ -23,6 +25,20 @@ public class StudyMentorService {
private final StudyDetailRepository studyDetailRepository;
private final StudyDetailValidator studyDetailValidator;

@Transactional(readOnly = true)
public List<AssignmentResponse> getWeeklyAssignments(Long studyId) {
List<StudyDetail> studyDetails = studyDetailRepository.findAllByStudyId(studyId);
return studyDetails.stream().map(AssignmentResponse::from).toList();
}

@Transactional(readOnly = true)
public AssignmentResponse getAssignment(Long studyDetailId) {
StudyDetail studyDetail = studyDetailRepository
.findById(studyDetailId)
.orElseThrow(() -> new CustomException(STUDY_DETAIL_NOT_FOUND));
return AssignmentResponse.from(studyDetail);
}

@Transactional
public void cancelStudyAssignment(Long studyDetailId) {
Member currentMember = memberUtil.getCurrentMember();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.gdschongik.gdsc.domain.study.dao;

import com.gdschongik.gdsc.domain.study.domain.StudyDetail;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;

public interface StudyDetailRepository extends JpaRepository<StudyDetail, Long> {}
public interface StudyDetailRepository extends JpaRepository<StudyDetail, Long> {

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

import com.gdschongik.gdsc.domain.study.domain.StudyDetail;
import com.gdschongik.gdsc.domain.study.domain.StudyStatus;
import com.gdschongik.gdsc.domain.study.domain.vo.Assignment;
import io.swagger.v3.oas.annotations.media.Schema;

public record AssignmentResponse(
Long studyDetailId,
@Schema(description = "과제 제목") String title,
@Schema(description = "마감 기한") String deadline,
@Schema(description = "과제 명세 링크") String descriptionLink,
@Schema(description = "과제 상태") StudyStatus assignmentStatus) {
public static AssignmentResponse from(StudyDetail studyDetail) {
Assignment assignment = studyDetail.getAssignment();
return new AssignmentResponse(
studyDetail.getId(),
assignment.getTitle(),
assignment.getDeadline().toString(),
assignment.getDescriptionLink(),
assignment.getStatus());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public enum ErrorCode {
STUDY_NOT_CANCELABLE_APPLICATION_PERIOD(HttpStatus.CONFLICT, "스터디 신청기간이 아니라면 취소할 수 없습니다."),

// StudyDetail
STUDY_DETAIL_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 스터디 상세정보입니다."),
STUDY_DETAIL_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 스터디 상세 정보입니다."),
STUDY_DETAIL_NOT_MODIFIABLE_INVALID_ROLE(HttpStatus.FORBIDDEN, "수정할 수 있는 권한이 없습니다."),

// StudyHistory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class 재학생_메일_인증시 {
@Test
void 레디스에_이메일인증정보가_존재하지_않으면_실패한다() {
// given
Member member = Member.createGuestMember(OAUTH_ID);
Member member = createGuestMember();
memberRepository.save(member);
String verificationToken =
emailVerificationTokenUtil.generateEmailVerificationToken(member.getId(), UNIV_EMAIL);
Expand All @@ -53,8 +53,7 @@ class 재학생_메일_인증시 {
@Test
void 인증토큰과_레디스에_존재하는_인증정보의_토큰이_다르면_실패한다() {
// given
// TODO: 아래 두줄 createGuestMember로 대체하기
Member member = memberRepository.save(Member.createGuestMember(OAUTH_ID));
Member member = createGuestMember();
logoutAndReloginAs(member.getId(), member.getRole());

// when
Expand Down

0 comments on commit ff7411c

Please sign in to comment.