Skip to content

Commit

Permalink
Merge pull request #115 from Sinchone/LAS-67/feat/recruitment-detail-…
Browse files Browse the repository at this point in the history
…check-application

[Feat]: 모집글 상세에서 신청 상태 체크 파악을 위한 API 기능 구현
  • Loading branch information
Jeongho0805 authored Jul 2, 2023
2 parents 2ea75a5 + 7f0f873 commit 0f187ec
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ public ResponseEntity<CommonResponse> getRecruitmentListInMain() {
return ResponseEntity.ok().body(CommonResponse.success(SuccessCode.RECRUITMENT_LIST_FOR_MAIN, recruitmentList));
}

@PreAuthorize("isAuthenticated()")
@GetMapping("/{recruitmentId}/application")
public ResponseEntity<CommonResponse> checkApplyStatusForMember(@PathVariable Long recruitmentId,
@AuthenticationPrincipal UserDetailsImpl userDetails) {
RecruitmentApplyStatusForMember applyStatus = recruitmentService.isAlreadyApplyRecruitment(recruitmentId, userDetails.getId());
return ResponseEntity.ok().body(CommonResponse.success(SuccessCode.RECRUITMENT_APPLY_STATUS_FOR_MEMBER, applyStatus));
}

@PreAuthorize("isAuthenticated()")
@PostMapping
public ResponseEntity<CommonResponse> createRecruitment(@AuthenticationPrincipal UserDetailsImpl userDetails,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.lastone.apiserver.service.recruitment;

import com.lastone.core.dto.recruitment.RecruitmentRequestDto;
import com.lastone.core.dto.recruitment.RecruitmentDetailDto;
import com.lastone.core.dto.recruitment.RecruitmentListDto;
import com.lastone.core.dto.recruitment.RecruitmentSearchCondition;
import com.lastone.core.dto.recruitment.*;
import org.springframework.data.domain.Slice;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
Expand All @@ -22,4 +19,6 @@ public interface RecruitmentService {
void updateRecruitment(Long recruitmentId, Long memberId, RecruitmentRequestDto recruitment, List<MultipartFile> imgFiles) throws IOException;

void deleteRecruitment(Long recruitmentId, Long id);

RecruitmentApplyStatusForMember isAlreadyApplyRecruitment(Long recruitmentId, Long memberId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
import com.lastone.core.domain.recruitment.Recruitment;
import com.lastone.core.domain.recruitment_img.RecruitmentImg;
import com.lastone.core.dto.gym.GymDto;
import com.lastone.core.dto.recruitment.RecruitmentDetailDto;
import com.lastone.core.dto.recruitment.RecruitmentListDto;
import com.lastone.core.dto.recruitment.RecruitmentRequestDto;
import com.lastone.core.dto.recruitment.RecruitmentSearchCondition;
import com.lastone.core.dto.recruitment.*;
import com.lastone.core.util.mapper.GymMapper;
import com.lastone.core.repository.gym.GymRepository;
import com.lastone.core.repository.member.MemberRepository;
Expand Down Expand Up @@ -113,6 +110,14 @@ public void deleteRecruitment(Long recruitmentId, Long memberId) {
recruitment.delete();
}

@Override
public RecruitmentApplyStatusForMember isAlreadyApplyRecruitment(Long recruitmentId, Long memberId) {
Recruitment recruitment = recruitmentRepository.findById(recruitmentId).orElseThrow(RecruitmentNotFoundException::new);
boolean result = recruitment.getApplications().stream()
.anyMatch(application -> application.getApplicant().getId().equals(memberId));
return new RecruitmentApplyStatusForMember(result);
}

private void updateImgFiles(Recruitment recruitment, List<MultipartFile> imgFiles) throws IOException {
if (imgFileIsExist(imgFiles)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum SuccessCode {
RECRUITMENT_CREATE("모집글 작성이 완료되었습니다."),
RECRUITMENT_UPDATE("모집글 수정이 완료되었습니다."),
RECRUITMENT_DELETE("모집글 삭제가 완료되었습니다."),
RECRUITMENT_APPLY_STATUS_FOR_MEMBER("모집글 신청 여부 조회가 완료되었습니다."),

/* 신청 */
APPLICATION_CREATE("신청 처리가 완료되었습니다."),
Expand All @@ -42,7 +43,7 @@ public enum SuccessCode {
NOTIFICATION_LIST("알림 목록 조회가 완료되었습니다."),
NOTIFICATION_READ("알림 읽기 처리가 완료되었습니다."),
NOTIFICATION_DELETE("알림 삭제 처리가 완료되었습니다."),
;
;

private String message;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.lastone.core.dto.recruitment;

import lombok.Getter;

@Getter
public class RecruitmentApplyStatusForMember {

Boolean isApply;

public RecruitmentApplyStatusForMember(boolean isApply) {
this.isApply = isApply;
}
}

0 comments on commit 0f187ec

Please sign in to comment.