Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -226,7 +226,7 @@ ResponseEntity<ApiResponse<PersonalRetrospectiveFormResponse>> getPersonalRetros
summary = "개인 회고 수정 폼 조회 (developer: 경서영)",
description = """
기존에 작성한 개인 회고를 수정하기 위한 데이터를 조회합니다.
- 권한: 약속 멤버
- 권한: 약속 멤버 (본인이 작성한 회고만 조회 가능)

**응답 구조**
- changedThoughts: 기존 생각의 변화 목록 (confirmOrder 순)
Expand All @@ -236,8 +236,7 @@ ResponseEntity<ApiResponse<PersonalRetrospectiveFormResponse>> getPersonalRetros
- meetingMembers: 본인 제외 약속 멤버 목록
""",
parameters = {
@Parameter(name = "meetingId", description = "약속 식별자", in = ParameterIn.PATH, required = true),
@Parameter(name = "retrospectiveId", description = "개인 회고 식별자", in = ParameterIn.PATH, required = true)
@Parameter(name = "meetingId", description = "약속 식별자", in = ParameterIn.PATH, required = true)
}
)
@ApiResponses({
Expand Down Expand Up @@ -311,26 +310,24 @@ ResponseEntity<ApiResponse<PersonalRetrospectiveFormResponse>> getPersonalRetros
)
)
})
@GetMapping(value = "/{retrospectiveId}/form", produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(value = "/form/edit", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<ApiResponse<PersonalRetrospectiveEditResponse>> getPersonalRetrospectiveEditForm(
@PathVariable Long meetingId,
@PathVariable Long retrospectiveId
@PathVariable Long meetingId
);

@Operation(
summary = "개인 회고 상세 조회 (developer: 경서영)",
description = """
특정 개인 회고의 상세 정보를 조회합니다.
- 권한: 약속 멤버
본인이 작성한 개인 회고의 상세 정보를 조회합니다.
- 권한: 약속 멤버 (본인 회고만 조회 가능)

**응답 구조**
- changedThoughts: 생각의 변화 목록 (confirmOrder 순, 주제별 사전/사후 의견)
- othersPerspectives: 인상 깊은 의견 목록 (confirmOrder 순 -> 같은 주제가 있을 경우 작성된 순서, 멤버 프로필 이미지 포함)
- freeTexts: 자유 기록 목록
""",
parameters = {
@Parameter(name = "meetingId", description = "약속 식별자", in = ParameterIn.PATH, required = true),
@Parameter(name = "retrospectiveId", description = "개인 회고 식별자", in = ParameterIn.PATH, required = true)
@Parameter(name = "meetingId", description = "약속 식별자", in = ParameterIn.PATH, required = true)
}
)
@ApiResponses({
Expand Down Expand Up @@ -404,10 +401,9 @@ ResponseEntity<ApiResponse<PersonalRetrospectiveEditResponse>> getPersonalRetros
)
)
})
@GetMapping(value = "/{retrospectiveId}", produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<ApiResponse<PersonalRetrospectiveDetailResponse>> getPersonalRetrospective(
@PathVariable Long meetingId,
@PathVariable Long retrospectiveId
@PathVariable Long meetingId
);

@Operation(
Expand All @@ -419,8 +415,7 @@ ResponseEntity<ApiResponse<PersonalRetrospectiveDetailResponse>> getPersonalRetr
- 동작: 기존 데이터 삭제 후 새로운 데이터로 전체 교체
""",
parameters = {
@Parameter(name = "meetingId", description = "약속 식별자", in = ParameterIn.PATH, required = true),
@Parameter(name = "retrospectiveId", description = "개인 회고 식별자", in = ParameterIn.PATH, required = true)
@Parameter(name = "meetingId", description = "약속 식별자", in = ParameterIn.PATH, required = true)
}
)
@ApiResponses({
Expand Down Expand Up @@ -506,10 +501,9 @@ ResponseEntity<ApiResponse<PersonalRetrospectiveDetailResponse>> getPersonalRetr
)
)
})
@PutMapping(value = "/{retrospectiveId}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PutMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<ApiResponse<PersonalRetrospectiveResponse>> editPersonalRetrospective(
@PathVariable Long meetingId,
@PathVariable Long retrospectiveId,
@Valid @RequestBody PersonalRetrospectiveRequest request
);

Expand All @@ -522,8 +516,7 @@ ResponseEntity<ApiResponse<PersonalRetrospectiveResponse>> editPersonalRetrospec
- 제약: 이미 삭제된 회고는 다시 삭제 불가
""",
parameters = {
@Parameter(name = "meetingId", description = "약속 식별자", in = ParameterIn.PATH, required = true),
@Parameter(name = "retrospectiveId", description = "개인 회고 식별자", in = ParameterIn.PATH, required = true)
@Parameter(name = "meetingId", description = "약속 식별자", in = ParameterIn.PATH, required = true)
}
)
@ApiResponses({
Expand Down Expand Up @@ -604,9 +597,8 @@ ResponseEntity<ApiResponse<PersonalRetrospectiveResponse>> editPersonalRetrospec
)
)
})
@DeleteMapping(value = "/{retrospectiveId}", produces = MediaType.APPLICATION_JSON_VALUE)
@DeleteMapping(produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<ApiResponse<Void>> deletePersonalRetrospective(
@PathVariable Long meetingId,
@PathVariable Long retrospectiveId
@PathVariable Long meetingId
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,50 +45,45 @@ public ResponseEntity<ApiResponse<PersonalRetrospectiveFormResponse>> getPersona


@Override
@GetMapping("/{retrospectiveId}/form")
@GetMapping("/form/edit")
public ResponseEntity<ApiResponse<PersonalRetrospectiveEditResponse>> getPersonalRetrospectiveEditForm(
@PathVariable Long meetingId,
@PathVariable Long retrospectiveId
@PathVariable Long meetingId
) {
PersonalRetrospectiveEditResponse response
= personalRetrospectiveService.getPersonalRetrospectiveEditForm(meetingId, retrospectiveId);
= personalRetrospectiveService.getPersonalRetrospectiveEditForm(meetingId);

return ApiResponse.success(response, "개인 회고 수정 폼 조회를 성공했습니다.");
}

@Override
@PutMapping("/{retrospectiveId}")
@PutMapping
public ResponseEntity<ApiResponse<PersonalRetrospectiveResponse>> editPersonalRetrospective(
@PathVariable Long meetingId,
@PathVariable Long retrospectiveId,
@Valid @RequestBody PersonalRetrospectiveRequest request
) {
PersonalRetrospectiveResponse response =
personalRetrospectiveService.editPersonalRetrospective(meetingId, retrospectiveId, request);
personalRetrospectiveService.editPersonalRetrospective(meetingId, request);

return ApiResponse.success(response, "개인 회고 수정을 성공했습니다.");
}

@Override
@DeleteMapping("/{retrospectiveId}")
@DeleteMapping
public ResponseEntity<ApiResponse<Void>> deletePersonalRetrospective(
@PathVariable Long meetingId,
@PathVariable Long retrospectiveId
@PathVariable Long meetingId
) {

personalRetrospectiveService.deletePersonalRetrospective(meetingId, retrospectiveId);
personalRetrospectiveService.deletePersonalRetrospective(meetingId);

return ApiResponse.deleted("개인 회고 삭제를 성공했습니다.");
}

@Override
@GetMapping("/{retrospectiveId}")
@GetMapping
public ResponseEntity<ApiResponse<PersonalRetrospectiveDetailResponse>> getPersonalRetrospective(
@PathVariable Long meetingId,
@PathVariable Long retrospectiveId
@PathVariable Long meetingId
) {
PersonalRetrospectiveDetailResponse response
= personalRetrospectiveService.getPersonalRetrospective(meetingId, retrospectiveId);
= personalRetrospectiveService.getPersonalRetrospective(meetingId);

return ApiResponse.success(response, "개인 회고 조회를 성공했습니다.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ int countRetrospectivesByBookAndUser(

boolean existsByIdAndUserId(Long retrospectiveId, Long userId);

Optional<PersonalMeetingRetrospective> findByMeeting_IdAndUser_Id(Long meetingId, Long userId);

@Query("""
SELECT pmr
FROM PersonalMeetingRetrospective pmr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ public PersonalRetrospectiveFormResponse getPersonalRetrospectiveForm(Long meeti
}

@Transactional(readOnly = true)
public PersonalRetrospectiveEditResponse getPersonalRetrospectiveEditForm(
Long meetingId,
Long retrospectiveId
) {
public PersonalRetrospectiveEditResponse getPersonalRetrospectiveEditForm(Long meetingId) {

Long userId = SecurityUtil.getCurrentUserId();

meetingValidator.validateMeeting(meetingId);
meetingValidator.validateMeetingMember(meetingId, userId);
retrospectiveValidator.validateRetrospective(retrospectiveId);

PersonalMeetingRetrospective retrospective
= retrospectiveValidator.getRetrospectiveByMeetingAndUser(meetingId, userId);
Long retrospectiveId = retrospective.getId();

List<RetrospectiveChangedThought> changedThoughts
= changedThoughtRepository.findByPersonalMeetingRetrospective(retrospectiveId);
Expand Down Expand Up @@ -138,16 +138,14 @@ public PersonalRetrospectiveEditResponse getPersonalRetrospectiveEditForm(
@Transactional
public PersonalRetrospectiveResponse editPersonalRetrospective(
Long meetingId,
Long retrospectiveId,
PersonalRetrospectiveRequest request
) {
Long userId = SecurityUtil.getCurrentUserId();

meetingValidator.validateMeeting(meetingId);
meetingValidator.validateMeetingMember(meetingId, userId);
retrospectiveValidator.validateRetrospective(retrospectiveId);
PersonalMeetingRetrospective retrospective
= retrospectiveValidator.getRetrospective(retrospectiveId, userId);
= retrospectiveValidator.getRetrospectiveByMeetingAndUser(meetingId, userId);

retrospective.clearChangedThoughts();
retrospective.clearOthersPerspectives();
Expand Down Expand Up @@ -230,29 +228,28 @@ public CursorResponse<RetrospectiveRecordResponse, RetrospectiveRecordsCursor> g
}

@Transactional
public void deletePersonalRetrospective(Long meetingId, Long retrospectiveId) {
public void deletePersonalRetrospective(Long meetingId) {
Long userId = SecurityUtil.getCurrentUserId();

meetingValidator.validateMeeting(meetingId);
meetingValidator.validateMeetingMember(meetingId, userId);

PersonalMeetingRetrospective retrospective
= retrospectiveValidator.getRetrospective(retrospectiveId, userId);
= retrospectiveValidator.getRetrospectiveByMeetingAndUser(meetingId, userId);

retrospective.softDelete();
}

@Transactional(readOnly = true)
public PersonalRetrospectiveDetailResponse getPersonalRetrospective(
Long meetingId,
Long retrospectiveId
) {
public PersonalRetrospectiveDetailResponse getPersonalRetrospective(Long meetingId) {
Long userId = SecurityUtil.getCurrentUserId();

meetingValidator.validateMeeting(meetingId);
meetingValidator.validateMeetingMember(meetingId, userId);
retrospectiveValidator.validateRetrospective(retrospectiveId);
retrospectiveValidator.validateRetrospectiveByUser(retrospectiveId, userId);

PersonalMeetingRetrospective retrospective
= retrospectiveValidator.getRetrospectiveByMeetingAndUser(meetingId, userId);
Long retrospectiveId = retrospective.getId();

List<RetrospectiveChangedThought> changedThoughts
= changedThoughtRepository.findByPersonalMeetingRetrospective(retrospectiveId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public PersonalMeetingRetrospective getRetrospective(Long retrospectiveId, Long

}

public PersonalMeetingRetrospective getRetrospectiveByMeetingAndUser(Long meetingId, Long userId) {
return personalRetrospectiveRepository.findByMeeting_IdAndUser_Id(meetingId, userId)
.orElseThrow(() -> new RetrospectiveException(RetrospectiveErrorCode.RETROSPECTIVE_NOT_FOUND));
}

public void validateMeetingRetrospectiveDeletePermission(MeetingRetrospective retrospective, Long userId) {
// 삭제하는 사람이 작성자 본인인지 확인
if (retrospective.getCreatedBy().getId().equals(userId)) {
Expand Down
Loading