Skip to content

Commit

Permalink
Feat: 질문지 종료 메서드 구현
Browse files Browse the repository at this point in the history
finishDateTime과 값 비교 이후 종료하도록 구현
finishDateTime 이전에 요청이 올 때 반환 될 예외 추가

[#49]
  • Loading branch information
MuseopKim committed Jun 28, 2021
1 parent 8f55e61 commit e75836f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.careerzip.domain.questionpaper.entity;

import com.careerzip.domain.questionpaperform.entity.QuestionPaperForm;
import com.careerzip.global.error.exception.business.QuestionPaperNotFinishedException;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand Down Expand Up @@ -49,4 +50,11 @@ private QuestionPaper(Long id, String title, LocalDateTime startDateTime, LocalD
this.opened = opened;
this.questionPaperForm = questionPaperForm;
}

public void finishPaper() {
if (finishDateTime.isAfter(LocalDateTime.now())) {
throw new QuestionPaperNotFinishedException();
}
this.opened = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.careerzip.global.error.exception.business;

import com.careerzip.global.error.exception.BusinessException;
import com.careerzip.global.error.response.ErrorCode;
import lombok.Getter;

@Getter
public class QuestionPaperNotFinishedException extends BusinessException {

public QuestionPaperNotFinishedException() {
super(ErrorCode.QUESTION_PAPER_NOT_FINISHED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public enum ErrorCode {
RECORD_NOT_FOUND(404, "해당 아카이빙 기록을 찾을 수 없습니다."),

// QuestionPaper
QUESTION_PAPER_NOT_FINISHED(400, "질문지가 마감되지 않아 종료할 수 없습니다."),
QUESTION_PAPER_NOT_FOUND(404, "해당 질문지를 찾을 수 없습니다."),

// Project
Expand Down

0 comments on commit e75836f

Please sign in to comment.