Skip to content

Commit

Permalink
Merge pull request #168 from Bamdoliro/feat/#167
Browse files Browse the repository at this point in the history
[새기능]전체 입학등록원 및 금연서약서 조회
  • Loading branch information
cabbage16 authored Dec 12, 2024
2 parents cacdc5a + da36649 commit fb3de72
Show file tree
Hide file tree
Showing 16 changed files with 566 additions and 196 deletions.
36 changes: 36 additions & 0 deletions src/docs/asciidoc/form.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,27 @@ include::{snippets}/form-controller-test/원서를_반려한다/http-response.ad
===== 해당하는 원서가 없는 경우
include::{snippets}/form-controller-test/원서를_반려할_때_원서가_없으면_에러가_발생한다/http-response.adoc[]

=== 원서 입학등록
최종합격한 유저는 입학등록원을 제출한 후 원서를 입학등록상태로 변경할 수 있습니다.

==== 요청 형식
===== Request Header
include::{snippets}/form-controller-test/원서의_상태를_입학등록원_제출로_변경한다/request-headers.adoc[]

==== 요청
include::{snippets}/form-controller-test/원서의_상태를_입학등록원_제출로_변경한다/http-request.adoc[]

==== 응답

===== 정상 응답
include::{snippets}/form-controller-test/원서의_상태를_입학등록원_제출로_변경한다/http-response.adoc[]

===== 원서 상태가 적합하지 않은 경우
include::{snippets}/form-controller-test/입학등록원을_제출했거나_최종합격한_지원자가_아닌_지원자가_원서의_상태를_변경하면_에러가_발생한다/http-response.adoc[]

===== 원서가 존재하지 않는 경우
include::{snippets}/form-controller-test/원서를_입학등록_상태로_변경할_때_원서가_없으면_에러가_발생한다/http-response.adoc[]

=== 원서 접수
어드민은 서류 원본을 받은 후 원서를 검토해 최종 접수할 수 있습니다.

Expand Down Expand Up @@ -658,7 +679,22 @@ include::{snippets}/form-controller-test/선택한_원서의_원서url을_조회
===== 정상 응답
include::{snippets}/form-controller-test/선택한_원서의_원서url을_조회한다/http-response.adoc[]

=== 선택한 원서의 입락등록원 및 금연서약서 url 조회
어드민은 선택한 원서의 입학등록원 및 금연서약서 url을 조회할 수 있습니다.

==== 요청 형식
===== Request Header
include::{snippets}/form-controller-test/선택한_원서들의_입학등록원_및_금연서약서url을_조회한다/request-headers.adoc[]

===== Query Parameter
include::{snippets}/form-controller-test/선택한_원서들의_입학등록원_및_금연서약서url을_조회한다/query-parameters.adoc[]

==== 요청
include::{snippets}/form-controller-test/선택한_원서들의_입학등록원_및_금연서약서url을_조회한다/http-request.adoc[]

==== 응답
===== 정상 응답
include::{snippets}/form-controller-test/선택한_원서들의_입학등록원_및_금연서약서url을_조회한다/http-response.adoc[]

=== 2차 합격 자동 처리

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ByteArrayResource execute(User user) {
}

private void validate(Form form) {
if (!form.isPassedNow())
if (!form.isPassedNow() && !form.isEntered())
throw new InvalidFormStatusException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.bamdoliro.maru.application.form;

import com.bamdoliro.maru.domain.form.domain.Form;
import com.bamdoliro.maru.domain.form.exception.InvalidFormStatusException;
import com.bamdoliro.maru.domain.form.service.FormFacade;
import com.bamdoliro.maru.domain.user.domain.User;
import com.bamdoliro.maru.shared.annotation.UseCase;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;

@RequiredArgsConstructor
@UseCase
public class EnterFormUseCase {

private final FormFacade formFacade;

@Transactional
public void execute(User user) {
Form form = formFacade.getForm(user);
validate(form);

form.enter();
}

private void validate(Form form) {
if(!form.isPassedNow() && !form.isEntered())
throw new InvalidFormStatusException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.bamdoliro.maru.application.form;

import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository;
import com.bamdoliro.maru.infrastructure.s3.FileService;
import com.bamdoliro.maru.infrastructure.s3.constants.FolderConstant;
import com.bamdoliro.maru.presentation.form.dto.response.AdmissionAndPledgeUrlResponse;
import com.bamdoliro.maru.presentation.form.dto.response.FormUrlResponse;
import com.bamdoliro.maru.shared.annotation.UseCase;
import lombok.RequiredArgsConstructor;

import java.util.List;

@RequiredArgsConstructor
@UseCase
public class QueryAdmissionAndPledgeUrlUseCase {

private final FormRepository formRepository;
private final FileService fileService;

public List<AdmissionAndPledgeUrlResponse> execute(List<Long> formIdList) {
return formRepository.findFormUrlByFormIdList(formIdList).stream()
.map(vo -> new AdmissionAndPledgeUrlResponse(
vo.getExaminationNumber(),
vo.getName(),
fileService.getPresignedUrl(FolderConstant.ADMISSION_AND_PLEDGE, vo.getUuid()).getDownloadUrl()
)).toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public UrlResponse execute(User user) {
}

private void validate(Form form) {
if(!form.isPassedNow())
if(!form.isPassedNow() && !form.isEntered())
throw new InvalidFormStatusException();
}
}
23 changes: 18 additions & 5 deletions src/main/java/com/bamdoliro/maru/domain/form/domain/Form.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public void noShow() {
this.status = FormStatus.NO_SHOW;
}

public void enter() { this.status = FormStatus.ENTERED; }

public void isApplicant(User user) {
if (!this.user.equals(user)) {
throw new AuthorityMismatchException();
Expand All @@ -147,11 +149,17 @@ public boolean isRejected() {
return status.equals(FormStatus.REJECTED);
}

public boolean isSubmitted() { return status.equals(FormStatus.SUBMITTED); }
public boolean isSubmitted() {
return status.equals(FormStatus.SUBMITTED);
}

public boolean isFinalSubmitted() { return status.equals(FormStatus.FINAL_SUBMITTED); }
public boolean isFinalSubmitted() {
return status.equals(FormStatus.FINAL_SUBMITTED);
}

public boolean isApproved() { return status.equals(FormStatus.APPROVED); }
public boolean isApproved() {
return status.equals(FormStatus.APPROVED);
}

public boolean isReceived() {
return isFirstPassed() != null || status.equals(FormStatus.RECEIVED);
Expand All @@ -165,6 +173,10 @@ public boolean isFirstPassedNow() {
return status.equals(FormStatus.FIRST_PASSED);
}

public boolean isEntered() {
return status.equals(FormStatus.ENTERED);
}

public Boolean isFirstPassed() {
if (isFirstPassedNow() || isPassed() != null || isNoShow()) {
return true;
Expand All @@ -182,13 +194,14 @@ public boolean isPassedNow() {
}

public Boolean isPassed() {
if (isPassedNow()) {
if (isPassedNow() || isEntered()) {
return true;
}

return isFailedNow() || isNoShow() ? false : null;
}


public boolean isFailedNow() {
return status.equals(FormStatus.FAILED);
}
Expand All @@ -210,7 +223,7 @@ public void changeToRegularSecondRound(CalculateFormScoreService calculateFormSc
this.score.updateSubjectScore(subjectGradeScore);

this.score.updateSecondRoundMeisterScoreToRegular();
} else if (type.isSocial()){
} else if (type.isSocial()) {
this.type = FormType.REGULAR;
Double subjectGradeScore = calculateFormScoreService.calculateSubjectGradeScore(this);
this.score.updateSubjectScore(subjectGradeScore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public enum FormStatus implements EnumProperty {
FIRST_FAILED("1차 불합격"),
PASSED("최종 합격"),
FAILED("불합격"),
NO_SHOW("불참");
NO_SHOW("불참"),
ENTERED("입학");

private final String description;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import com.bamdoliro.maru.presentation.form.dto.request.PassOrFailFormListRequest;
import com.bamdoliro.maru.presentation.form.dto.request.SubmitFormRequest;
import com.bamdoliro.maru.presentation.form.dto.request.UpdateFormRequest;
import com.bamdoliro.maru.presentation.form.dto.response.FormResponse;
import com.bamdoliro.maru.presentation.form.dto.response.FormResultResponse;
import com.bamdoliro.maru.presentation.form.dto.response.FormSimpleResponse;
import com.bamdoliro.maru.presentation.form.dto.response.FormUrlResponse;
import com.bamdoliro.maru.presentation.form.dto.response.*;
import com.bamdoliro.maru.shared.auth.AuthenticationPrincipal;
import com.bamdoliro.maru.shared.auth.Authority;
import com.bamdoliro.maru.shared.response.CommonResponse;
Expand Down Expand Up @@ -50,6 +47,7 @@ public class FormController {
private final ApproveFormUseCase approveFormUseCase;
private final RejectFormUseCase rejectFormUseCase;
private final ReceiveFormUseCase receiveFormUseCase;
private final EnterFormUseCase enterFormUseCase;
private final QuerySubmittedFormUseCase querySubmittedFormUseCase;
private final QueryFormUseCase queryFormUseCase;
private final QueryFormStatusUseCase queryFormStatusUseCase;
Expand All @@ -75,6 +73,7 @@ public class FormController {
private final SelectSecondPassUseCase selectSecondPassUseCase;
private final UpdateOriginalTypeUseCase updateOriginalTypeUseCase;
private final GenerateAllAdmissionTicketUseCase generateAllAdmissionTicketUseCase;
private final QueryAdmissionAndPledgeUrlUseCase queryAdmissionAndPledgeUrlUseCase;

@ResponseStatus(HttpStatus.CREATED)
@PostMapping
Expand Down Expand Up @@ -120,6 +119,14 @@ public void receiveForm(
receiveFormUseCase.execute(formId);
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@PatchMapping("/enter")
public void enterForm(
@AuthenticationPrincipal(authority = Authority.USER) User user
) {
enterFormUseCase.execute(user);
}

@GetMapping("/review")
public ListCommonResponse<FormSimpleResponse> getSubmittedFormList(
@AuthenticationPrincipal(authority = Authority.ADMIN) User user
Expand Down Expand Up @@ -159,7 +166,7 @@ public void updateForm(
}

@ResponseStatus(HttpStatus.CREATED)
@PostMapping(value = "/identification-picture")
@PostMapping( "/identification-picture")
public SingleCommonResponse<UrlResponse> uploadIdentificationPicture(
@AuthenticationPrincipal(authority = Authority.USER) User user
) {
Expand All @@ -169,7 +176,7 @@ public SingleCommonResponse<UrlResponse> uploadIdentificationPicture(
}

@ResponseStatus(HttpStatus.CREATED)
@PostMapping(value = "/form-document")
@PostMapping("/form-document")
public SingleCommonResponse<UrlResponse> uploadFormDocument(
@AuthenticationPrincipal(authority = Authority.USER) User user
) {
Expand All @@ -178,7 +185,7 @@ public SingleCommonResponse<UrlResponse> uploadFormDocument(
);
}

@GetMapping(value = "/export")
@GetMapping("/export")
public ResponseEntity<Resource> exportForm(
@AuthenticationPrincipal(authority = Authority.USER) User user,
Model model
Expand All @@ -189,7 +196,7 @@ public ResponseEntity<Resource> exportForm(
.body(exportFormUseCase.execute(user));
}

@GetMapping(value = "/admission-and-pledge")
@GetMapping( "/admission-and-pledge")
public ResponseEntity<Resource> downloadAdmissionAndPledgeFormat(
@AuthenticationPrincipal(authority = Authority.USER) User user
) {
Expand All @@ -198,7 +205,7 @@ public ResponseEntity<Resource> downloadAdmissionAndPledgeFormat(
.body(downloadAdmissionAndPledgeFormatUseCase.execute(user));
}

@PostMapping(value = "/admission-and-pledge")
@PostMapping("/admission-and-pledge")
public SingleCommonResponse<UrlResponse> uploadAdmissionAndPledge(
@AuthenticationPrincipal(authority = Authority.USER) User user
) {
Expand Down Expand Up @@ -337,6 +344,17 @@ public ListCommonResponse<FormUrlResponse> getFormUrl(
);
}


@GetMapping("/admission-and-pledge-url")
public ListCommonResponse<AdmissionAndPledgeUrlResponse> getAdmissionAndPledgeUrl(
@AuthenticationPrincipal(authority = Authority.ADMIN) User user,
@RequestParam(name = "id-list") List<Long> formIdList
) {
return CommonResponse.ok(
queryAdmissionAndPledgeUrlUseCase.execute(formIdList)
);
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@PatchMapping("/second-round/select")
public void selectSecondPass(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.bamdoliro.maru.presentation.form.dto.response;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class AdmissionAndPledgeUrlResponse {

private Long examinationNumber;
private String name;
private String admissionAndPledgeUrl;

}
3 changes: 0 additions & 3 deletions src/main/java/com/bamdoliro/maru/shared/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers)
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins(
"http://localhost:3000",
"http://localhost:3001",
"http://localhost:3002",
"https://maru.bamdoliro.com",
"https://madmin.bamdoliro.com"
)
Expand Down
Loading

0 comments on commit fb3de72

Please sign in to comment.