Skip to content

Commit

Permalink
Exception code 문서화 (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
Juhongseok authored Nov 24, 2023
1 parent 26708aa commit e3e5da5
Show file tree
Hide file tree
Showing 23 changed files with 289 additions and 22 deletions.
3 changes: 3 additions & 0 deletions src/docs/asciidoc/all.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ include::{snippets}/resume/component/find/activities/response-fields.adoc[]

== [첨삭 피드백]
=== 이력서 첨삭 피드백 조회

include::{snippets}/comment/getAll/exception-response.adoc[]

*Request*
include::{snippets}/comment/getAll/http-request.adoc[]
include::{snippets}/comment/getAll/path-parameters.adoc[]
Expand Down
25 changes: 25 additions & 0 deletions src/docs/asciidoc/mentee.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ include::{snippets}/user/mentee/update/response-fields.adoc[]

== [이력서]
=== 이력서 작성

include::{snippets}/resume/create/exception-response.adoc[]

*Request*
include::{snippets}/resume/create/http-request.adoc[]
include::{snippets}/resume/create/request-fields.adoc[]
Expand Down Expand Up @@ -176,6 +179,9 @@ include::{snippets}/resume/updateTitle/http-response.adoc[]
include::{snippets}/resume/updateTitle/response-fields.adoc[]

=== 이력서 제목 수정 V2

include::{snippets}/resume/v2/updateTitle/exception-response.adoc[]

*Request*
include::{snippets}/resume/v2/updateTitle/http-request.adoc[]
include::{snippets}/resume/v2/updateTitle/path-parameters.adoc[]
Expand All @@ -194,6 +200,9 @@ include::{snippets}/resume/update/http-response.adoc[]
include::{snippets}/resume/update/response-fields.adoc[]

=== 이력서 기본정보 수정 V2

include::{snippets}/resume/v2/updateBasicInfo/exception-response.adoc[]

*Request*
include::{snippets}/resume/v2/updateBasicInfo/http-request.adoc[]
include::{snippets}/resume/v2/updateBasicInfo/path-parameters.adoc[]
Expand All @@ -212,6 +221,9 @@ include::{snippets}/resume/updateMemo/http-response.adoc[]
include::{snippets}/resume/updateMemo/response-fields.adoc[]

=== 이력서 메모 수정 V2

include::{snippets}/resume/v2/updateMemo/exception-response.adoc[]

*Request*
include::{snippets}/resume/v2/updateMemo/http-request.adoc[]
include::{snippets}/resume/v2/updateMemo/path-parameters.adoc[]
Expand All @@ -238,6 +250,8 @@ include::{snippets}/resume/findEvents/http-response.adoc[]
include::{snippets}/resume/findEvents/response-fields.adoc[]

=== 이력서 삭제
include::{snippets}/resume/delete/exception-response.adoc[]

*Request*
include::{snippets}/resume/delete/http-request.adoc[]
include::{snippets}/resume/delete/path-parameters.adoc[]
Expand All @@ -246,6 +260,7 @@ include::{snippets}/resume/delete/path-parameters.adoc[]
include::{snippets}/resume/delete/http-response.adoc[]

=== 이력서 피드백 반영 완료

*Request*
include::{snippets}/resume/complete/http-request.adoc[]
include::{snippets}/resume/complete/path-parameters.adoc[]
Expand All @@ -254,6 +269,9 @@ include::{snippets}/resume/complete/path-parameters.adoc[]
include::{snippets}/resume/complete/response-fields.adoc[]

=== 이력서 스냅샷 조회
include::{snippets}/resume/snapshot/exception-response.adoc[]


*Request*
include::{snippets}/resume/snapshot/http-request.adoc[]
include::{snippets}/resume/snapshot/query-parameters.adoc[]
Expand All @@ -264,6 +282,8 @@ include::{snippets}/resume/snapshot/response-body.adoc[]

== [첨삭]
=== 첨삭 이벤트 참여 신청
include::{snippets}/event/apply/exception-response.adoc[]

*Request*
include::{snippets}/event/apply/http-request.adoc[]
include::{snippets}/event/apply/request-fields.adoc[]
Expand All @@ -273,6 +293,8 @@ include::{snippets}/event/apply/http-response.adoc[]
include::{snippets}/event/apply/response-fields.adoc[]

=== 첨삭 이벤트 참여 리스트 조회
include::{snippets}/user/mentee/events/exception-response.adoc[]

*Request*
include::{snippets}/user/mentee/events/http-request.adoc[]
include::{snippets}/user/mentee/events/path-parameters.adoc[]
Expand All @@ -290,6 +312,8 @@ include::{snippets}/event/requestReview/http-request.adoc[]
include::{snippets}/event/requestReview/http-response.adoc[]

=== 첨삭 내용 전체 조회
include::{snippets}/comment/getAll/exception-response.adoc[]

*Request*
include::{snippets}/comment/getAll/http-request.adoc[]
include::{snippets}/comment/getAll/path-parameters.adoc[]
Expand All @@ -301,6 +325,7 @@ include::{snippets}/comment/getAll/response-fields.adoc[]

== [합격 이력서]
=== 합격이력서 공유 소개글 작성
include::{snippets}/resume/create/exception-response.adoc[]

*Request*
include::{snippets}/result/create/http-request.adoc[]
Expand Down
23 changes: 23 additions & 0 deletions src/docs/asciidoc/mentor.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ include::{snippets}/user/mentor/update/response-fields.adoc[]
== [첨삭 이벤트]
=== 첨삭 이벤트 생성

include::{snippets}/event/create/exception-response.adoc[]

*Request*
include::{snippets}/event/create/http-request.adoc[]
include::{snippets}/event/create/request-fields.adoc[]
Expand All @@ -33,8 +35,23 @@ include::{snippets}/event/create/request-fields.adoc[]
include::{snippets}/event/create/http-response.adoc[]
include::{snippets}/event/create/response-fields.adoc[]

=== 첨삭 이벤트 수정

include::{snippets}/event/update/exception-response.adoc[]

*Request*
include::{snippets}/event/update/http-request.adoc[]
include::{snippets}/event/update/request-fields.adoc[]
include::{snippets}/event/update/path-parameters.adoc[]

*Response*
include::{snippets}/event/update/http-response.adoc[]
include::{snippets}/event/update/response-fields.adoc[]

=== 첨삭 이벤트 조회

include::{snippets}/user/mentor/events/exception-response.adoc[]

*Request*
include::{snippets}/user/mentor/events/http-request.adoc[]
include::{snippets}/user/mentor/events/path-parameters.adoc[]
Expand All @@ -45,6 +62,8 @@ include::{snippets}/user/mentor/events/response-fields.adoc[]

=== 첨삭 피드백 작성

include::{snippets}/comment/create/exception-response.adoc[]

*Request*
include::{snippets}/comment/create/http-request.adoc[]
include::{snippets}/comment/create/request-fields.adoc[]
Expand All @@ -55,6 +74,8 @@ include::{snippets}/comment/create/response-fields.adoc[]

=== 첨삭 피드백 수정

include::{snippets}/comment/update/exception-response.adoc[]

*Request*
include::{snippets}/comment/update/http-request.adoc[]
include::{snippets}/comment/update/path-parameters.adoc[]
Expand All @@ -65,6 +86,8 @@ include::{snippets}/comment/update/http-response.adoc[]

=== 첨삭 피드백 삭제

include::{snippets}/comment/delete/exception-response.adoc[]

*Request*
include::{snippets}/comment/delete/http-request.adoc[]
include::{snippets}/comment/delete/path-parameters.adoc[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import static org.devcourse.resumeme.global.exception.ExceptionCode.COMMENT_NOT_FOUND;
import static org.devcourse.resumeme.global.exception.ExceptionCode.NOT_FOUND_DATA;

@Service
@Transactional
Expand All @@ -40,7 +42,7 @@ public Comment create(Comment comment, Long resumeId) {

snapshotRepository.save(new Snapshot(json, resumeId));
} catch (URISyntaxException | JsonProcessingException e) {
throw new CustomException("NOT_FOUND_DATA", "정보를 찾을 수 없습니다");
throw new CustomException(NOT_FOUND_DATA);
}
}
return commentRepository.save(comment);
Expand All @@ -49,7 +51,7 @@ public Comment create(Comment comment, Long resumeId) {
@Transactional(readOnly = true)
public Comment getOne(Long commentId) {
return commentRepository.findById(commentId)
.orElseThrow();
.orElseThrow(() -> new CustomException(COMMENT_NOT_FOUND));
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import org.devcourse.resumeme.business.event.controller.dto.EventPageResponse;
import org.devcourse.resumeme.business.event.controller.dto.EventRejectRequest;
import org.devcourse.resumeme.business.event.controller.dto.EventResponse;
import org.devcourse.resumeme.business.event.controller.dto.EventUpdateRequest;
import org.devcourse.resumeme.business.event.domain.Event;
import org.devcourse.resumeme.business.event.domain.EventPosition;
import org.devcourse.resumeme.business.event.service.EventPositionService;
import org.devcourse.resumeme.business.event.service.EventService;
import org.devcourse.resumeme.business.event.service.vo.AllEventFilter;
import org.devcourse.resumeme.business.event.service.vo.EventReject;
import org.devcourse.resumeme.business.event.service.vo.EventUpdateVo;
import org.devcourse.resumeme.business.user.domain.mentor.Mentor;
import org.devcourse.resumeme.business.user.service.mentor.MentorService;
import org.devcourse.resumeme.common.response.IdResponse;
Expand Down Expand Up @@ -52,6 +54,14 @@ public IdResponse createEvent(@RequestBody EventCreateRequest request, @Authenti
return new IdResponse(eventService.create(event));
}

@PatchMapping("/{eventId}")
public IdResponse updateEvent(@RequestBody EventUpdateRequest request, @PathVariable Long eventId) {
EventUpdateVo updateVo = request.toVo(eventId);
eventService.update(updateVo);

return new IdResponse(eventId);
}

@PatchMapping("/{eventId}/mentee/{menteeId}")
public void rejectApply(@PathVariable Long eventId, @PathVariable Long menteeId, @RequestBody EventRejectRequest request) {
eventService.reject(new EventReject(eventId, menteeId, request.rejectMessage()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.devcourse.resumeme.business.event.controller.dto;

import org.devcourse.resumeme.business.event.service.vo.EventUpdateVo;
import org.devcourse.resumeme.common.domain.Position;

import java.time.LocalDateTime;
import java.util.List;

import static org.devcourse.resumeme.common.util.Validator.notNull;

public record EventUpdateRequest(EventInfoRequest info, EventTimeRequest time, List<String> positions) {

public EventUpdateVo toVo(Long eventId) {
notNull(positions);
List<Position> positionEntities = positions.stream()
.map(position -> Position.valueOf(position.toUpperCase()))
.toList();

return new EventUpdateVo(eventId, info.title, info.content, info().maximumAttendee, positionEntities,
time.openDateTime, time.closeDateTime, time.endDate);
}

public record EventInfoRequest(String title, String content, int maximumAttendee) {

}

public record EventTimeRequest(LocalDateTime openDateTime, LocalDateTime closeDateTime, LocalDateTime endDate) {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import static lombok.AccessLevel.PROTECTED;
import static org.devcourse.resumeme.business.event.domain.EventStatus.FINISH;
import static org.devcourse.resumeme.common.util.Validator.notNull;
import static org.devcourse.resumeme.global.exception.ExceptionCode.APPLICATION_NOT_FOUND;
import static org.devcourse.resumeme.global.exception.ExceptionCode.DUPLICATED_EVENT_OPEN;
import static org.devcourse.resumeme.global.exception.ExceptionCode.DUPLICATE_APPLICATION_EVENT;
import static org.devcourse.resumeme.global.exception.ExceptionCode.MENTEE_NOT_FOUND;
Expand Down Expand Up @@ -134,16 +133,6 @@ public void openReservationEvent(LocalDateTime nowDateTime) {
eventInfo.open();
}

public Long getApplicantId(Long menteeId) {
for (MenteeToEvent applicant : applicants) {
if (applicant.isSameMentee(menteeId)) {
return applicant.getId();
}
}

throw new EventException(APPLICATION_NOT_FOUND);
}

public Mentor getMentor() {
return mentor;
}
Expand Down Expand Up @@ -199,4 +188,27 @@ public int compareTo(Event other) {
return eventTimeInfo.getOpenDateTime().compareTo(other.eventTimeInfo.getOpenDateTime());
}

public void updateInfo(String title, String content, int maximumAttendee) {
this.eventInfo.update(title, content, maximumAttendee);
}

public void updatePosition(List<Position> positions) {
for (int i = 0; i < this.positions.size(); i++) {
this.positions.remove(i--);
}

List<EventPosition> newPositions = getNewPosition(positions);
this.positions.addAll(newPositions);
}

private List<EventPosition> getNewPosition(List<Position> positions) {
return new ArrayList<>(positions.stream()
.map(position -> new EventPosition(position, this))
.toList());
}

public void updateTimeInfo(LocalDateTime openDateTime, LocalDateTime closeDateTime, LocalDateTime endDateTime) {
this.eventTimeInfo.update(openDateTime, closeDateTime, endDateTime);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,12 @@ public boolean isOpen() {
return this.status.isOpen();
}

public void update(String title, String content, int maximumAttendee) {
validateInput(maximumAttendee, title, content);

this.title = title;
this.content = content;
this.maximumAttendee = maximumAttendee;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,12 @@ public boolean isAfterOpenTime(LocalDateTime nowDateTime) {
return nowDateTime.isAfter(this.openDateTime);
}

public void update(LocalDateTime openDateTime, LocalDateTime closeDateTime, LocalDateTime endDateTime) {
validateInput(openDateTime, closeDateTime, endDateTime);

this.openDateTime = openDateTime;
this.closeDateTime = closeDateTime;
this.endDate = endDateTime;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.devcourse.resumeme.business.event.service.vo.AcceptMenteeToEvent;
import org.devcourse.resumeme.business.event.service.vo.AllEventFilter;
import org.devcourse.resumeme.business.event.service.vo.EventReject;
import org.devcourse.resumeme.business.event.service.vo.EventUpdateVo;
import org.devcourse.resumeme.global.exception.CustomException;
import org.devcourse.resumeme.global.exception.ExceptionCode;
import org.springframework.data.domain.Page;
Expand Down Expand Up @@ -121,4 +122,9 @@ public String getOverallReview(Event event, Long resumeId) {
.getOverallReview();
}

public void update(EventUpdateVo updateVo) {
Event event = getOne(updateVo.getEventId());
updateVo.update(event);
}

}
Loading

0 comments on commit e3e5da5

Please sign in to comment.