Skip to content

Commit

Permalink
[Feat] #38 (#39)
Browse files Browse the repository at this point in the history
* feat: 지원서를 id로 조회할 수 있다.

* feat: 서류 합불, 면접시간 설정 api 추가

* docs: api 문서 개발
  • Loading branch information
birdieHyun authored Oct 27, 2023
1 parent e9e8389 commit abb4047
Show file tree
Hide file tree
Showing 12 changed files with 466 additions and 29 deletions.
25 changes: 24 additions & 1 deletion src/docs/asciidoc/api/application/application.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,27 @@ include::{snippets}/admin-application-doc/http-request.adoc[]

==== HTTP Response
include::{snippets}/admin-application-doc/http-response.adoc[]
include::{snippets}/admin-application-doc/response-fields-data.adoc[]
include::{snippets}/admin-application-doc/response-fields-data.adoc[]

=== 지원서 단일 조회
==== HTTP Request
include::{snippets}/admin-application-find-doc/http-request.adoc[]

==== HTTP Response
include::{snippets}/admin-application-find-doc/http-response.adoc[]
include::{snippets}/admin-application-find-doc/response-fields-data.adoc[]

=== 서류 합격 불합격 처리
==== HTTP Request
include::{snippets}/admin-application-updateDocumentPass-doc/http-request.adoc[]
include::{snippets}/admin-application-updateDocumentPass-doc/request-fields.adoc[]

=== 최종 합격 불합격 처리
==== HTTP Request
include::{snippets}/admin-application-updateDocumentPass-doc/http-request.adoc[]
include::{snippets}/admin-application-updateDocumentPass-doc/request-fields.adoc[]

=== 면접 시간 변경
==== HTTP Request
include::{snippets}/admin-application-updateInterviewTime-doc/http-request.adoc[]
include::{snippets}/admin-application-updateInterviewTime-doc/request-fields.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import yonseigolf.server.apply.dto.request.ApplicationRequest;
import yonseigolf.server.apply.dto.request.EmailAlertRequest;
import yonseigolf.server.apply.dto.request.*;
import yonseigolf.server.apply.dto.response.ApplicationResponse;
import yonseigolf.server.apply.dto.response.SingleApplicationResult;
import yonseigolf.server.apply.service.ApplyPeriodService;
import yonseigolf.server.apply.service.ApplyService;
import yonseigolf.server.util.CustomResponse;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Controller
public class ApplicationController {
Expand Down Expand Up @@ -87,6 +88,9 @@ public ResponseEntity<CustomResponse<Page<SingleApplicationResult>>> getApplicat
@RequestParam(required = false) Boolean finalPass,
Pageable pageable) {

System.out.println("documentPass = " + documentPass);
System.out.println("finalPass = " + finalPass);

return ResponseEntity
.ok()
.body(new CustomResponse(
Expand All @@ -96,4 +100,59 @@ public ResponseEntity<CustomResponse<Page<SingleApplicationResult>>> getApplicat
applicationService.getApplicationResults(documentPass, finalPass, pageable)
));
}

@GetMapping("/admin/forms/{id}")
public ResponseEntity<CustomResponse<ApplicationResponse>> getApplication(@PathVariable Long id) {

return ResponseEntity
.ok()
.body(new CustomResponse(
"success",
200,
"연세골프 지원서 조회 성공",
applicationService.getApplication(id)
));
}

@PatchMapping("/admin/forms/{id}/documentPass")
public ResponseEntity<CustomResponse> updateDocumentPass(@PathVariable Long id, @RequestBody DocumentPassRequest documentPass) {

applicationService.updateDocumentPass(id, documentPass.isDocumentPass());

return ResponseEntity
.ok()
.body(new CustomResponse(
"success",
200,
"연세골프 지원서 서류 합격 수정 성공"
));
}

@PatchMapping("/admin/forms/{id}/finalPass")
public ResponseEntity<CustomResponse> updateFinalPass(@PathVariable Long id, @RequestBody FinalPassRequest finalPass) {

applicationService.updateFinalPass(id, finalPass.isFinalPass());

return ResponseEntity
.ok()
.body(new CustomResponse(
"success",
200,
"연세골프 지원서 최종 합격 수정 성공"
));
}

@PatchMapping("/admin/forms/{id}/interviewTime")
public ResponseEntity<CustomResponse> updateInterviewTime(@PathVariable Long id, @RequestBody UpdateInterviewTimeRequest time) {

applicationService.updateInterviewTime(id, time.getTime());

return ResponseEntity
.ok()
.body(new CustomResponse(
"success",
200,
"연세골프 지원서 면접 시간 수정 성공"
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class ApplicationRequest {
private long age;
private long studentId;
private String major;
private String email;
private String phoneNumber;
private long golfDuration;
private long roundCount;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package yonseigolf.server.apply.dto.request;

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

@Getter
@NoArgsConstructor
@AllArgsConstructor
public class DocumentPassRequest {

private boolean documentPass;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package yonseigolf.server.apply.dto.request;

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

@Getter
@NoArgsConstructor
@AllArgsConstructor
public class FinalPassRequest {

private boolean finalPass;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package yonseigolf.server.apply.dto.request;

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

import java.time.LocalDateTime;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public class UpdateInterviewTimeRequest {

private LocalDateTime time;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package yonseigolf.server.apply.dto.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import yonseigolf.server.apply.entity.Application;

import java.time.LocalDateTime;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ApplicationResponse {

private Long id;
private String name;
private String photo;
private long age;
private long studentId;
private String email;
private String major;
private String phoneNumber;
private long golfDuration;
private long roundCount;
private boolean lessonStatus;
private boolean clubStatus;
private String selfIntroduction;
private String applyReason;
private String skillEvaluation;
private String golfMemory;
private String otherClub;
private String swingVideo;
@JsonFormat(pattern = "MM월dd일 HH:mm")
private LocalDateTime submitTime;
private Boolean documentPass;
private Boolean finalPass;
@JsonFormat(pattern = "MM월dd일 HH:mm")
private LocalDateTime interviewTime;

public static ApplicationResponse fromApplication(Application application) {

return ApplicationResponse.builder()
.id(application.getId())
.name(application.getName())
.photo(application.getPhoto())
.age(application.getAge())
.studentId(application.getStudentId())
.email(application.getEmail())
.major(application.getMajor())
.phoneNumber(application.getPhoneNumber())
.golfDuration(application.getGolfDuration())
.roundCount(application.getRoundCount())
.lessonStatus(application.isLessonStatus())
.clubStatus(application.isClubStatus())
.selfIntroduction(application.getSelfIntroduction())
.applyReason(application.getApplyReason())
.skillEvaluation(application.getSkillEvaluation())
.golfMemory(application.getGolfMemory())
.otherClub(application.getOtherClub())
.swingVideo(application.getSwingVideo())
.submitTime(application.getSubmitTime())
.documentPass(application.getDocumentPass())
.finalPass(application.getFinalPass())
.interviewTime(application.getInterviewTime())
.build();
}
}
18 changes: 17 additions & 1 deletion src/main/java/yonseigolf/server/apply/entity/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Application {
private String photo;
private long age;
private long studentId;
private String email;
private String major;
private String phoneNumber;
private long golfDuration;
Expand All @@ -43,7 +44,6 @@ public class Application {
private Boolean documentPass;
private Boolean finalPass;
private LocalDateTime interviewTime;
private String etc;

public static Application of(ApplicationRequest request) {

Expand All @@ -52,6 +52,7 @@ public static Application of(ApplicationRequest request) {
.photo(request.getPhoto())
.age(request.getAge())
.studentId(request.getStudentId())
.email(request.getEmail())
.major(request.getMajor())
.phoneNumber(request.getPhoneNumber())
.golfDuration(request.getGolfDuration())
Expand All @@ -68,4 +69,19 @@ public static Application of(ApplicationRequest request) {
.build();

}

public void updateDocumentPass(boolean documentPass) {

this.documentPass = documentPass;
}

public void updateFinalPass(boolean finalPass) {

this.finalPass = finalPass;
}

public void updateInterviewTime(LocalDateTime time) {

this.interviewTime = time;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

public interface ApplicationRepositoryCustom {

public Page<SingleApplicationResult> getApplicationResults(Boolean documentPass, Boolean finalPass, Pageable pageable);
Page<SingleApplicationResult> getApplicationResults(Boolean documentPass, Boolean finalPass, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Page<SingleApplicationResult> getApplicationResults(Boolean documentPass,
documentPassEq(documentPass),
finalPassEq(finalPass)
)
.orderBy(application.id.desc())
.orderBy(application.interviewTime.asc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetchResults();
Expand All @@ -50,7 +50,7 @@ public Page<SingleApplicationResult> getApplicationResults(Boolean documentPass,
private BooleanExpression documentPassEq(Boolean documentPass) {

if (documentPass == null) {
return null;
return application.documentPass.isNull();
}

return application.documentPass.eq(documentPass);
Expand All @@ -59,7 +59,7 @@ private BooleanExpression documentPassEq(Boolean documentPass) {
private BooleanExpression finalPassEq(Boolean finalPass) {

if (finalPass == null) {
return null;
return application.finalPass.isNull();
}

return application.finalPass.eq(finalPass);
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/yonseigolf/server/apply/service/ApplyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import yonseigolf.server.apply.dto.request.ApplicationRequest;
import yonseigolf.server.apply.dto.request.EmailAlertRequest;
import yonseigolf.server.apply.dto.response.ApplicationResponse;
import yonseigolf.server.apply.dto.response.SingleApplicationResult;
import yonseigolf.server.apply.entity.Application;
import yonseigolf.server.apply.entity.EmailAlarm;
import yonseigolf.server.apply.repository.ApplicationRepository;
import yonseigolf.server.apply.repository.EmailRepository;

import java.time.LocalDateTime;


@Service
public class ApplyService {
Expand Down Expand Up @@ -40,4 +44,33 @@ public Page<SingleApplicationResult> getApplicationResults(Boolean documentPass,

return applicationRepository.getApplicationResults(documentPass, finalPass, pageable);
}

public ApplicationResponse getApplication(Long id) {

return ApplicationResponse.fromApplication(findById(id));
}

@Transactional
public void updateDocumentPass(Long id, Boolean updatePass) {

findById(id).updateDocumentPass(updatePass);
}

@Transactional
public void updateFinalPass(Long id, boolean finalPass) {

findById(id).updateFinalPass(finalPass);
}

@Transactional
public void updateInterviewTime(Long id, LocalDateTime time) {

findById(id).updateInterviewTime(time);
}

private Application findById(Long id) {

return applicationRepository.findById(id)
.orElseThrow(() -> new IllegalArgumentException("해당 지원서가 존재하지 않습니다. id"));
}
}
Loading

0 comments on commit abb4047

Please sign in to comment.