Skip to content

Commit

Permalink
update :: null 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Aug 8, 2024
1 parent 12cd59f commit f3ba37d
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.example.whopper.domain.document.exception.DocumentIllegalStatusException;
import com.example.whopper.domain.document.exception.DocumentNotFoundException;
import com.example.whopper.domain.feedback.dao.FeedbackMongoRepository;
import com.example.whopper.domain.student.domain.StudentEntity;
import com.example.whopper.global.utils.current.CurrentStudent;
import com.example.whopper.global.utils.DataResponseInfo;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -40,9 +41,9 @@ public DocumentResponse getIntroduceRecentlySharedDocuments() {
public FullDocumentResponse getCurrentStudentDocument() {
var currentStudentDocument = currentStudent.getDocument();
var student = currentStudentDocument.getStudent();
var major = student.getMajor();
var majorName = getMajorName(student);

return FullDocumentResponse.of(currentStudentDocument, major.name());
return FullDocumentResponse.of(currentStudentDocument, majorName);
}

@Override
Expand All @@ -51,9 +52,9 @@ public FullDocumentResponse getSubmittedDocument(String documentId) {
.orElseThrow(() -> DocumentNotFoundException.EXCEPTION);

var student = document.getStudent();
var major = student.getMajor();
var majorName = getMajorName(student);

return FullDocumentResponse.of(document, major.name());
return FullDocumentResponse.of(document, majorName);
}

@Override
Expand Down Expand Up @@ -92,7 +93,13 @@ public FullDocumentResponse findReleasedDocument(String documentId) {
if (!document.getStatus().equals(DocumentStatus.RELEASED)) {
throw DocumentIllegalStatusException.EXCEPTION;
}
var student = document.getStudent();
var majorName = getMajorName(student);

return FullDocumentResponse.of(document, majorName);
}

return FullDocumentResponse.of(document, document.getStudent().getMajor().name());
private String getMajorName(StudentEntity student) {
return student.getMajor() == null ? "전공 미정" : student.getMajor().name();
}
}

0 comments on commit f3ba37d

Please sign in to comment.