Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into feat/emailCode
  • Loading branch information
BlueRedOrange committed Dec 21, 2024
2 parents 43a38a4 + b40d295 commit 7ab70cf
Show file tree
Hide file tree
Showing 18 changed files with 210 additions and 59 deletions.
2 changes: 1 addition & 1 deletion script/stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ TIME_NOW=$(date +%c)
CURRENT_PID=$(pgrep -f $JAR_FILE)

# 프로세스가 켜져 있으면 종료
if [ -z $CURRENT_PID ]; then
if [ -z "$CURRENT_PID" ]; then
echo "$TIME_NOW > 현재 실행중인 애플리케이션이 없습니다" >> $DEPLOY_LOG
else
echo "$TIME_NOW > 실행중인 $CURRENT_PID 애플리케이션 종료 " >> $DEPLOY_LOG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public enum ErrorCode {
JSON_CONVERT_ERROR(false, HttpStatus.INTERNAL_SERVER_ERROR.value(), "JSON 변환중 오류가 발생하였습니다."),
CLUB_NOT_FOUND(false, 404, "동아리를 찾을 수 없습니다."),
FORM_NOT_FOUND(false, 404, "지원폼을 찾을 수 없습니다."),
ALREADY_APPLIED(false, HttpStatus.BAD_REQUEST.value(), "이미 지원했습니다.");


ALREADY_APPLIED(false, HttpStatus.BAD_REQUEST.value(), "이미 지원했습니다."),
MEETING_TIME_NOT_FOUND(false, HttpStatus.NOT_FOUND.value(), "면접 시간을 찾을 수 없습니다."),
ALLOWED_NUM_EXCEEDED(false, HttpStatus.BAD_REQUEST.value(), "면접 허용 인원을 초과했습니다.");

private final Boolean isSuccess;
private final int code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import com.likelion.innerjoin.common.response.CommonResponse;
import com.likelion.innerjoin.post.model.dto.request.*;
import com.likelion.innerjoin.post.model.dto.response.ApplicationDto;
import com.likelion.innerjoin.post.model.dto.response.MeetingTimeResponseDTO;
import com.likelion.innerjoin.post.model.entity.Application;
import com.likelion.innerjoin.post.service.ApplicationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.servlet.http.HttpSession;
import jakarta.validation.constraints.Email;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
Expand All @@ -21,10 +21,11 @@
@RestController
@RequiredArgsConstructor
@Slf4j
@RequestMapping("/application")
public class ApplicationController {
private final ApplicationService applicationService;

@PostMapping("/application")
@PostMapping
@Operation(summary = "지원하기 api")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공적인 응답"),
Expand All @@ -37,7 +38,7 @@ public CommonResponse<Long> postApplication(@RequestBody ApplicationRequestDto a
return new CommonResponse<>(ErrorCode.CREATED, application.getId());
}

@GetMapping("/application/{application_id}")
@GetMapping("/{application_id}")
@Operation(summary = "지원 상세조회 api (통합)")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공적인 응답"),
Expand All @@ -52,7 +53,7 @@ public CommonResponse<ApplicationDto> getApplicationDetail(
return new CommonResponse<>(applicationService.getApplicationDetail(applicationId, session));
}

@GetMapping("/application/list")
@GetMapping("/list")
@Operation(summary = "로그인된 지원자의 지원서 목록 조회 (지원자용)")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공적인 응답"),
Expand All @@ -62,7 +63,7 @@ public CommonResponse<List<ApplicationDto>> getApplicationList(HttpSession sessi
return new CommonResponse<>(applicationService.getApplicationList(session));
}

@PutMapping("/application/{application_id}")
@PutMapping("/{application_id}")
@Operation(summary = "지원서 정보 수정용 api (동아리용)")
public CommonResponse<ApplicationDto> updateApplication(
@RequestBody ApplicationPutRequestDto applicationPutRequestDto,
Expand All @@ -72,26 +73,42 @@ public CommonResponse<ApplicationDto> updateApplication(
applicationService.updateApplication(applicationPutRequestDto, applicationId, session));
}

@PostMapping("/application/formscore")
@PostMapping("/formscore")
@Operation(summary = "지원서 점수 수정용 api (동아리용)")
public CommonResponse<ApplicationDto> updateFormScore(
@RequestBody FormScoreDto formScoreDto,
HttpSession session) {
return new CommonResponse<>(applicationService.updateFormScore(formScoreDto, session));
}

@PostMapping("/application/meetingscore")
@PostMapping("/meetingscore")
@Operation(summary = "면접 점수 수정용 api (동아리용)")
public CommonResponse<ApplicationDto> updateMeetingScore(
@RequestBody MeetingScoreDto meetingScoreDto,
HttpSession session) {
return new CommonResponse<>(applicationService.updateMeetingScore(meetingScoreDto, session));
}

@PostMapping("/application/email")
@PostMapping("/email")
@Operation(summary = "이메일 전송 api (동아리용)")
public CommonResponse<ApplicationDto> sendEmail(@RequestBody EmailDto emailDto, HttpSession session) {
return new CommonResponse<>(applicationService.sendEmail(emailDto, session));
}

@PostMapping("/interview-time")
@Operation(summary = "면접 시간 선택 api(지원자용)")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공적인 응답"),
@ApiResponse(responseCode = "401", description = "세션값이 잘못되었습니다."),
@ApiResponse(responseCode = "401", description = "권한이 없습니다."),
@ApiResponse(responseCode = "404", description = "면접 시간을 찾을 수 없습니다.."),
@ApiResponse(responseCode = "404", description = "지원 내역이 존재하지 않습니다."),
@ApiResponse(responseCode = "400", description = "면접 허용 인원을 초과했습니다."),
})
public CommonResponse<MeetingTimeResponseDTO> selectMeetingTime(
@RequestBody MeetingTimeSelectionDto meetingTimeDto,
HttpSession session) {
return new CommonResponse<>(applicationService.selectMeetingTime(meetingTimeDto, session));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ public CommonResponse<String> createInterviewTimes(@RequestBody MeetingTimeReque
@ApiResponse(responseCode = "500", description = "서버 내부 오류")
})
public CommonResponse<MeetingTimeListResponseDTO> getMeetingTimes(@PathVariable Long recruiting_id) {
MeetingTimeListResponseDTO response = meetingTimeService.getMeetingTimesByRecruitingId(recruiting_id);
return new CommonResponse<>(response);
return meetingTimeService.getMeetingTimesByRecruitingId(recruiting_id);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.likelion.innerjoin.post.exception;

public class AllowedNumExceededException extends RuntimeException {
public AllowedNumExceededException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,18 @@ public CommonResponse<?> alreadyApplied(AlreadyAppliedException e, HttpServletRe
log.warn("APPLICATION-005> 요청 URI: " + request.getRequestURI() + ", 에러 메세지: " + e.getMessage());
return new CommonResponse<>(ErrorCode.ALREADY_APPLIED);
}

@ExceptionHandler(MeetingTimeNotFound.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public CommonResponse<?> meetingNotFound(MeetingTimeNotFound e, HttpServletRequest request) {
log.warn("APPLICATION-006> 요청 URI: " + request.getRequestURI() + ", 에러 메세지: " + e.getMessage());
return new CommonResponse<>(ErrorCode.MEETING_TIME_NOT_FOUND);
}

@ExceptionHandler(AllowedNumExceededException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public CommonResponse<?> allowedNumExceeded(AllowedNumExceededException e, HttpServletRequest request) {
log.warn("APPLICATION-006> 요청 URI: " + request.getRequestURI() + ", 에러 메세지: " + e.getMessage());
return new CommonResponse<>(ErrorCode.ALLOWED_NUM_EXCEEDED);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.likelion.innerjoin.post.exception;

public class MeetingTimeNotFound extends RuntimeException {
public MeetingTimeNotFound(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.likelion.innerjoin.post.model.dto.request;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class MeetingTimeSelectionDto {
private Long applicationId;
private Long meetingTimeId;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
@AllArgsConstructor
public class MeetingTimeListResponseDTO {
private Long recruitingId;
private List<MeetingTimeDTO> meetingTimes;
private List<MeetingTimeResponseDTO> meetingTimes;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.likelion.innerjoin.post.model.dto.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;

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

@Data
@AllArgsConstructor
public class MeetingTimeResponseDTO {
private Long meetingTimeId;
private int allowedNum;
private int reservedNum; // 예약된 사람 수
private List<ApplicantDTO> applicantList; // 예약한 사람 리스트

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
private LocalDateTime meetingStartTime;

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
private LocalDateTime meetingEndTime;

@Data
@AllArgsConstructor
public static class ApplicantDTO {
private Long applicantId;
private String name;
private String studentNumber;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.likelion.innerjoin.post.exception.*;
import com.likelion.innerjoin.post.model.dto.request.*;
import com.likelion.innerjoin.post.model.dto.response.ApplicationDto;
import com.likelion.innerjoin.post.model.dto.response.MeetingTimeResponseDTO;
import com.likelion.innerjoin.post.model.entity.*;
import com.likelion.innerjoin.post.model.mapper.ApplicationMapper;
import com.likelion.innerjoin.post.repository.*;
Expand Down Expand Up @@ -55,9 +56,17 @@ public Application postApplication (ApplicationRequestDto applicationRequestDto,
application.setApplicant(applicant);
application.setRecruiting(recruiting);

// TODO: recruiting type에 따라서 결과를 미리 넣어놓기 (response도 있는지 없는지에 따라 처리해줘야함)
application.setFormResult(ResultType.PENDING);
application.setMeetingResult(ResultType.PENDING);
Post post = recruiting.getPost();
if(post.getRecruitmentType() == RecruitmentType.FORM_AND_MEETING){
application.setFormResult(ResultType.PENDING);
application.setMeetingResult(ResultType.PENDING);
}else if(post.getRecruitmentType() == RecruitmentType.FORM_ONLY){
application.setFormResult(ResultType.PENDING);
application.setMeetingResult(ResultType.PASS);
}else if(post.getRecruitmentType() == RecruitmentType.MEETING_ONLY){
application.setFormResult(ResultType.PASS);
application.setMeetingResult(ResultType.PENDING);
}

application.setResponseList(new ArrayList<>());
for(AnswerRequestDto answer : applicationRequestDto.getAnswers()) {
Expand Down Expand Up @@ -219,6 +228,43 @@ public ErrorCode sendEmail(EmailDto emailDto, HttpSession session) {
return ErrorCode.SUCCESS;
}

/**
* 면접 시간 설정
* @param dto 설정할 면접시간정보
* @param session 세션값
* @return MeetingTimeDTO
*/
@Transactional
public MeetingTimeResponseDTO selectMeetingTime (MeetingTimeSelectionDto dto, HttpSession session){
Applicant applicant = checkApplicant(session);
Application application = applicationRepository.findById(dto.getApplicationId())
.orElseThrow(()-> new ApplicationNotFoundException("지원 이력이 없습니다."));
if(!application.getApplicant().equals(applicant)){
throw new UnauthorizedException("권한이 없습니다.");
}

MeetingTime meetingTime = meetingTimeRepository.findById(dto.getMeetingTimeId())
.orElseThrow(() -> new MeetingTimeNotFound("면접시간이 존재하지 않습니다."));
if(!meetingTime.getRecruiting().equals(application.getRecruiting())){
throw new UnauthorizedException("권한이 없습니다.");
}
if(meetingTime.getAllowedNum()<= meetingTime.getApplicationList().size()){
throw new AllowedNumExceededException("면접 허용 인원을 초과했습니다.");
}

application.setMeetingTime(meetingTime);
applicationRepository.save(application);

return new MeetingTimeResponseDTO(
meetingTime.getId(),
meetingTime.getAllowedNum(),
meetingTime.getApplicationList().size() + 1,
null,
meetingTime.getMeetingStartTime(),
meetingTime.getMeetingEndTime()
);
}

Applicant checkApplicant (HttpSession session) {
User user = sessionVerifier.verifySession(session);
if(!(user instanceof Applicant applicant)) {
Expand Down
Loading

0 comments on commit 7ab70cf

Please sign in to comment.