Skip to content

Commit 1569c88

Browse files
authored
Dev > Main 브랜치 병합
1. 내 프로젝트에 본인이 지원 시 오류가 나는 코드를 작성하였습니다. 통합 테스트 거친 뒤 Main 브랜치로 병합합니다.
2 parents e11bfef + 3620759 commit 1569c88

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/main/java/hs/kr/backend/devpals/domain/project/service/ProjectApplyService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public ResponseEntity<ApiResponse<String>> projectApply(Long projectId, ProjectA
4444
ProjectEntity project = projectRepository.findById(projectId)
4545
.orElseThrow(() -> new CustomException(ErrorException.PROJECT_NOT_FOUND));
4646

47+
if (project.getUserId().equals(user.getId())) {
48+
throw new CustomException(ErrorException.CANNOT_APPLY_TO_OWN_PROJECT);
49+
}
50+
4751
Optional<ApplicantEntity> existingApplicant = applicantRepository.findByUserAndProject(user, project);
4852
if (existingApplicant.isPresent()) {
4953
throw new CustomException(ErrorException.ALREADY_APPLIED);

src/main/java/hs/kr/backend/devpals/global/exception/ErrorException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public enum ErrorException {
2222
INVALID_DATE_RANGE(400, "조회 기간(startDate, endDate)은 필수입니다."),
2323
ALREADY_IMPOSED(400, "이미 제재된 신고입니다."),
2424
INVALID_REPORT_TYPE(400, "해당 신고는 유저를 대상으로 하지 않습니다."),
25+
CANNOT_APPLY_TO_OWN_PROJECT(400, "자신이 생성한 프로젝트에는 지원할 수 없습니다."),
2526

2627
UNAUTHORIZED(401, "인증 권한이 없습니다."),
2728
TOKEN_EXPIRED(401, "토큰이 만료되었습니다."),

0 commit comments

Comments
 (0)