Skip to content

Commit a840e30

Browse files
authored
메인 머지(10/10) Merge pull request #183
메인 머지(10/10) - CORS 설정 포함
2 parents 8f1f2cb + c64f09c commit a840e30

File tree

22 files changed

+89
-83
lines changed

22 files changed

+89
-83
lines changed

back/src/main/java/com/back/domain/mentoring/mentoring/service/MentoringStorage.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,10 @@ public boolean hasReservationsForMentoring(Long mentoringId) {
6363
return reservationRepository.existsByMentoringId(mentoringId);
6464
}
6565

66-
public boolean hasMentorSlotsForMentor(Long mentorId) {
67-
return mentorSlotRepository.existsByMentorId(mentorId);
68-
}
69-
7066
public boolean hasReservationForMentorSlot(Long slotId) {
7167
return reservationRepository.existsByMentorSlotId(slotId);
7268
}
7369

74-
75-
// ===== 데이터 조작 메서드 =====
76-
77-
public void deleteMentorSlotsData(Long mentorId) {
78-
mentorSlotRepository.deleteAllByMentorId(mentorId);
79-
}
80-
8170
public MentoringSession getMentoringSessionBySessionUuid(String mentoringSessionId) {
8271
return mentoringSessionRepository.findBySessionUrl(mentoringSessionId)
8372
.orElseThrow(() -> new ServiceException("404", "세션을 찾을 수 없습니다."));

back/src/main/java/com/back/domain/mentoring/reservation/dto/ReservationDto.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.back.domain.mentoring.reservation.constant.ReservationStatus;
44
import com.back.domain.mentoring.reservation.entity.Reservation;
5-
import com.back.domain.mentoring.session.entity.MentoringSession;
65
import io.swagger.v3.oas.annotations.media.Schema;
76

87
import java.time.LocalDateTime;
@@ -23,20 +22,17 @@ public record ReservationDto(
2322
@Schema(description = "시작 일시")
2423
LocalDateTime startDateTime,
2524
@Schema(description = "종료 일시")
26-
LocalDateTime endDateTime,
27-
@Schema(description = "멘토링 세션 ID")
28-
Long mentoringSessionId
25+
LocalDateTime endDateTime
2926
) {
30-
public static ReservationDto from(Reservation reservation, MentoringSession mentoringSession) {
27+
public static ReservationDto from(Reservation reservation) {
3128
return new ReservationDto(
3229
reservation.getId(),
3330
reservation.getStatus(),
3431
reservation.getMentoring().getId(),
3532
reservation.getMentoring().getTitle(),
3633
reservation.getMentorSlot().getId(),
3734
reservation.getMentorSlot().getStartDateTime(),
38-
reservation.getMentorSlot().getEndDateTime(),
39-
mentoringSession != null ? mentoringSession.getId() : null
35+
reservation.getMentorSlot().getEndDateTime()
4036
);
4137
}
4238
}

back/src/main/java/com/back/domain/mentoring/reservation/entity/Reservation.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.back.domain.mentoring.reservation.constant.ReservationStatus;
88
import com.back.domain.mentoring.reservation.error.ReservationErrorCode;
99
import com.back.domain.mentoring.slot.entity.MentorSlot;
10+
import com.back.global.app.AppConfig;
1011
import com.back.global.exception.ServiceException;
1112
import com.back.global.jpa.BaseEntity;
1213
import jakarta.persistence.*;
@@ -132,6 +133,10 @@ private void ensureCanComplete() {
132133
if(!this.status.canComplete()) {
133134
throw new ServiceException(ReservationErrorCode.CANNOT_COMPLETE);
134135
}
136+
// 개발·테스트 환경에서는 검증 스킵 (Swagger 테스트 허용)
137+
if (AppConfig.isDev() || AppConfig.isTest()) {
138+
return;
139+
}
135140
// 시작 이후 완료 가능 (조기 종료 허용)
136141
if (!mentorSlot.isPast()) {
137142
throw new ServiceException(ReservationErrorCode.MENTORING_NOT_STARTED);

back/src/main/java/com/back/domain/mentoring/reservation/service/ReservationService.java

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ public Page<ReservationDto> getReservations(Member member, int page, int size) {
4848
} else {
4949
reservations = reservationRepository.findAllByMenteeMember(member, pageable);
5050
}
51-
return reservations.map(r -> {
52-
MentoringSession mentoringSession = mentoringSessionService.getMentoringSessionByReservation(r);
53-
return ReservationDto.from(r, mentoringSession);
54-
});
51+
return reservations.map(ReservationDto::from);
5552
}
5653

5754
@Transactional(readOnly = true)
@@ -66,28 +63,24 @@ public ReservationResponse getReservation(Member member, Long reservationId) {
6663

6764
@Transactional
6865
public ReservationResponse createReservation(Mentee mentee, ReservationRequest reqDto) {
69-
try {
70-
Mentoring mentoring = mentoringStorage.findMentoring(reqDto.mentoringId());
71-
MentorSlot mentorSlot = mentoringStorage.findMentorSlot(reqDto.mentorSlotId());
66+
Mentoring mentoring = mentoringStorage.findMentoring(reqDto.mentoringId());
67+
MentorSlot mentorSlot = mentoringStorage.findMentorSlot(reqDto.mentorSlotId());
7268

73-
DateTimeValidator.validateStartTimeNotInPast(mentorSlot.getStartDateTime());
74-
validateMentorSlotStatus(mentorSlot, mentee);
75-
validateOverlappingTimeForMentee(mentee, mentorSlot);
69+
DateTimeValidator.validateStartTimeNotInPast(mentorSlot.getStartDateTime());
70+
validateMentorSlotStatus(mentorSlot, mentee);
71+
validateOverlappingTimeForMentee(mentee, mentorSlot);
7672

77-
Reservation reservation = Reservation.builder()
78-
.mentoring(mentoring)
79-
.mentee(mentee)
80-
.mentorSlot(mentorSlot)
81-
.preQuestion(reqDto.preQuestion())
82-
.build();
83-
reservationRepository.save(reservation);
73+
Reservation reservation = Reservation.builder()
74+
.mentoring(mentoring)
75+
.mentee(mentee)
76+
.mentorSlot(mentorSlot)
77+
.preQuestion(reqDto.preQuestion())
78+
.build();
79+
reservationRepository.save(reservation);
8480

85-
mentorSlot.updateStatus(MentorSlotStatus.PENDING);
81+
mentorSlot.updateStatus(MentorSlotStatus.PENDING);
8682

87-
return ReservationResponse.from(reservation);
88-
} catch (OptimisticLockException e) {
89-
throw new ServiceException(ReservationErrorCode.CONCURRENT_RESERVATION_CONFLICT);
90-
}
83+
return ReservationResponse.from(reservation);
9184
}
9285

9386
@Transactional
@@ -98,10 +91,9 @@ public ReservationResponse approveReservation(Mentor mentor, Long reservationId)
9891
reservation.approve(mentor);
9992
reservation.getMentorSlot().updateStatus(MentorSlotStatus.APPROVED);
10093

101-
// 예약이 승인되면 세션을 생성한다.
10294
MentoringSession mentoringSession = mentoringSessionService.create(reservation);
10395

104-
return ReservationResponse.from(reservation);
96+
return ReservationResponse.from(reservation, mentoringSession);
10597
} catch (OptimisticLockException e) {
10698
throw new ServiceException(ReservationErrorCode.CONCURRENT_APPROVAL_CONFLICT);
10799
}

back/src/main/java/com/back/domain/mentoring/session/controller/MentoringSessionController.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,47 @@
55
import com.back.domain.mentoring.session.service.MentoringSessionManager;
66
import com.back.global.rq.Rq;
77
import com.back.global.rsData.RsData;
8+
import io.swagger.v3.oas.annotations.Operation;
9+
import io.swagger.v3.oas.annotations.tags.Tag;
810
import lombok.RequiredArgsConstructor;
911
import org.springframework.security.access.prepost.PreAuthorize;
10-
import org.springframework.security.core.annotation.AuthenticationPrincipal;
1112
import org.springframework.web.bind.annotation.*;
1213

1314
@RestController
1415
@RequiredArgsConstructor
1516
@RequestMapping("/sessions")
17+
@Tag(name = "MentoringSessionController", description = "멘토링 세션 API - 화상 채팅으로 멘토링 진행")
1618
public class MentoringSessionController {
1719
private final MentoringSessionManager mentoringSessionManager;
1820
private final Rq rq;
1921

20-
//세션참여 URL발급
2122
@GetMapping("/{sessionId}/url")
23+
@Operation(summary = "세션참여 URL 발급", description = "세션 참여를 위한 URL을 발급합니다.")
2224
public RsData<GetSessionUrlResponse> getSessionUrl(@PathVariable Long sessionId) {
2325
GetSessionUrlResponse response = mentoringSessionManager.getSessionUrl(sessionId);
2426
return new RsData<>("200", "요청완료", response);
2527
}
2628

27-
//세션 상세 정보(참여 현황?, 제목 등등?)
2829
@GetMapping("/{sessionId}")
30+
@Operation(summary = "세션 상세 정보", description = "세션 제목, 멘토, 멘티, 메시지 목록 등 세션의 상세 정보를 조회합니다.")
2931
public RsData<GetSessionInfoResponse> getSessionDetail(@PathVariable Long sessionId) {
3032
GetSessionInfoResponse response = mentoringSessionManager.getSessionDetail(sessionId);
3133
return new RsData<>("200", "요청완료", response);
3234
}
3335

34-
//세션 열기
3536
@PutMapping("/{sessionId}")
3637
@PreAuthorize("hasRole('MENTOR')")
38+
@Operation(summary = "세션 열기", description = "세션을 열어 멘토링을 진행합니다.")
3739
public RsData<OpenSessionResponse> openSession(@PathVariable Long sessionId) {
3840
Member member = rq.getActor();
3941
OpenSessionRequest openSessionRequest = new OpenSessionRequest(sessionId);
4042
OpenSessionResponse response = mentoringSessionManager.openSession(member, openSessionRequest);
4143
return new RsData<>("200", "세션 오픈 완료", response);
4244
}
4345

44-
//세션종료
4546
@DeleteMapping("/{sessionId}")
4647
@PreAuthorize("hasRole('MENTOR')")
48+
@Operation(summary = "세션 종료", description = "세션을 닫아 멘토링을 종료합니다.")
4749
public RsData<CloseSessionResponse> closeSession(@PathVariable Long sessionId) {
4850
Member member = rq.getActor();
4951
DeleteSessionRequest deleteSessionRequest = new DeleteSessionRequest(sessionId);
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.back.domain.mentoring.session.dto;
22

33
import com.back.domain.mentoring.session.entity.MessageType;
4-
import com.back.domain.mentoring.session.entity.SenderRole;
4+
import io.swagger.v3.oas.annotations.media.Schema;
55

66
public record ChatMessageRequest(
7+
@Schema(description = "메시지 타입", example = "TEXT")
78
MessageType type,
9+
@Schema(description = "메시지 내용", example = "msg")
810
String content
911
) {
1012
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package com.back.domain.mentoring.session.dto;
22

3+
import io.swagger.v3.oas.annotations.media.Schema;
4+
35
import java.time.LocalDateTime;
46

57
public record ChatMessageResponse(
8+
@Schema(description = "작성자명")
69
String senderName,
10+
@Schema(description = "메시지 내용")
711
String content,
12+
@Schema(description = "작성일시")
813
LocalDateTime createdAt
914
) {
1015
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package com.back.domain.mentoring.session.dto;
22

3+
import io.swagger.v3.oas.annotations.media.Schema;
4+
35
public record CloseSessionResponse(
6+
@Schema(description = "세션 URL")
47
String sessionUrl,
8+
@Schema(description = "멘토링 제목")
59
String mentoringTitle,
10+
@Schema(description = "세션 상태")
611
String status
712
) {
813
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.back.domain.mentoring.session.dto;
22

3+
import io.swagger.v3.oas.annotations.media.Schema;
4+
35
public record DeleteSessionRequest(
6+
@Schema(description = "세션 ID")
47
Long sessionId
58
) {
69
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package com.back.domain.mentoring.session.dto;
22

3+
import io.swagger.v3.oas.annotations.media.Schema;
4+
35
public record GetSessionInfoResponse(
6+
@Schema(description = "멘토링 제목")
47
String mentoringTitle,
8+
@Schema(description = "멘토 이름")
59
String mentorName,
10+
@Schema(description = "멘티 이름")
611
String menteeName,
12+
@Schema(description = "세션 상태")
713
String sessionStatus
814
) {
915
}

0 commit comments

Comments
 (0)