Skip to content

Commit

Permalink
[DDING-000] 지원자 전체 조회 API 누락된 정보 추가 (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seooooo24 authored Feb 8, 2025
1 parent 198b7b7 commit d3565af
Show file tree
Hide file tree
Showing 46 changed files with 1,191 additions and 1,102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,56 +29,56 @@
@RequestMapping("/server/central")
public interface CentralFormApi {

@Operation(summary = "동아리 지원 폼지 생성 API")
@ApiResponse(responseCode = "201", description = "동아리 지원 폼지 생성 성공")
@ResponseStatus(HttpStatus.CREATED)
@SecurityRequirement(name = "AccessToken")
@PostMapping("/my/forms")
void createForm(
@Valid @RequestBody CreateFormRequest createFormRequest,
@AuthenticationPrincipal PrincipalDetails principalDetails
);
@Operation(summary = "동아리 지원 폼지 생성 API")
@ApiResponse(responseCode = "201", description = "동아리 지원 폼지 생성 성공")
@ResponseStatus(HttpStatus.CREATED)
@SecurityRequirement(name = "AccessToken")
@PostMapping("/my/forms")
void createForm(
@Valid @RequestBody CreateFormRequest createFormRequest,
@AuthenticationPrincipal PrincipalDetails principalDetails
);

@Operation(summary = "동아리 지원 폼지 수정 API")
@ApiResponse(responseCode = "204", description = "동아리 지원 폼지 수정 성공")
@ResponseStatus(HttpStatus.NO_CONTENT)
@SecurityRequirement(name = "AccessToken")
@PutMapping("/my/forms/{formId}")
void updateForm(
@Valid @RequestBody UpdateFormRequest updateFormRequest,
@PathVariable("formId") Long formId,
@AuthenticationPrincipal PrincipalDetails principalDetails
);
@Operation(summary = "동아리 지원 폼지 수정 API")
@ApiResponse(responseCode = "204", description = "동아리 지원 폼지 수정 성공")
@ResponseStatus(HttpStatus.NO_CONTENT)
@SecurityRequirement(name = "AccessToken")
@PutMapping("/my/forms/{formId}")
void updateForm(
@Valid @RequestBody UpdateFormRequest updateFormRequest,
@PathVariable("formId") Long formId,
@AuthenticationPrincipal PrincipalDetails principalDetails
);

@Operation(summary = "동아리 지원 폼지 삭제 API")
@ApiResponse(responseCode = "204", description = "동아리 지원 폼지 삭제 성공")
@ResponseStatus(HttpStatus.NO_CONTENT)
@SecurityRequirement(name = "AccessToken")
@DeleteMapping("/my/forms/{formId}")
void deleteForm(
@PathVariable("formId") Long formId,
@AuthenticationPrincipal PrincipalDetails principalDetails
);
@Operation(summary = "동아리 지원 폼지 삭제 API")
@ApiResponse(responseCode = "204", description = "동아리 지원 폼지 삭제 성공")
@ResponseStatus(HttpStatus.NO_CONTENT)
@SecurityRequirement(name = "AccessToken")
@DeleteMapping("/my/forms/{formId}")
void deleteForm(
@PathVariable("formId") Long formId,
@AuthenticationPrincipal PrincipalDetails principalDetails
);

@Operation(summary = "동아리 지원 폼지 전체조회 API")
@ApiResponse(responseCode = "200", description = "동아리 지원 폼지 전체조회 성공",
content = @Content(
array = @ArraySchema(schema = @Schema(implementation = FormListResponse.class))
))
@ResponseStatus(HttpStatus.OK)
@SecurityRequirement(name = "AccessToken")
@GetMapping("/my/forms")
List<FormListResponse> getAllMyForm(
@AuthenticationPrincipal PrincipalDetails principalDetails
);
@Operation(summary = "동아리 지원 폼지 전체조회 API")
@ApiResponse(responseCode = "200", description = "동아리 지원 폼지 전체조회 성공",
content = @Content(
array = @ArraySchema(schema = @Schema(implementation = FormListResponse.class))
))
@ResponseStatus(HttpStatus.OK)
@SecurityRequirement(name = "AccessToken")
@GetMapping("/my/forms")
List<FormListResponse> getAllMyForm(
@AuthenticationPrincipal PrincipalDetails principalDetails
);

@Operation(summary = "동아리 지원 폼지 상세조회 API")
@ApiResponse(responseCode = "200", description = "동아리 지원 폼지 상세조회 성공",
content = @Content(schema = @Schema(implementation = FormResponse.class)))
@ResponseStatus(HttpStatus.OK)
@SecurityRequirement(name = "AccessToken")
@GetMapping("/my/forms/{formId}")
FormResponse getForm(
@PathVariable("formId") Long formId
);
@Operation(summary = "동아리 지원 폼지 상세조회 API")
@ApiResponse(responseCode = "200", description = "동아리 지원 폼지 상세조회 성공",
content = @Content(schema = @Schema(implementation = FormResponse.class)))
@ResponseStatus(HttpStatus.OK)
@SecurityRequirement(name = "AccessToken")
@GetMapping("/my/forms/{formId}")
FormResponse getForm(
@PathVariable("formId") Long formId
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,44 @@
@RequiredArgsConstructor
public class CentralFormController implements CentralFormApi {

private final FacadeCentralFormService facadeCentralFormService;

@Override
public void createForm(
CreateFormRequest createFormRequest,
PrincipalDetails principalDetails
) {
User user = principalDetails.getUser();
facadeCentralFormService.createForm(createFormRequest.toCommand(user));
}

@Override
public void updateForm(
UpdateFormRequest updateFormRequest,
Long formId,
PrincipalDetails principalDetails
) {
facadeCentralFormService.updateForm(updateFormRequest.toCommand(formId));
}

@Override
public void deleteForm(Long formId, PrincipalDetails principalDetails) {
User user = principalDetails.getUser();
facadeCentralFormService.deleteForm(formId, user);
}

@Override
public List<FormListResponse> getAllMyForm(PrincipalDetails principalDetails) {
User user = principalDetails.getUser();
List<FormListQuery> queries = facadeCentralFormService.getAllMyForm(user);
return queries.stream()
.map(FormListResponse::from)
.toList();
}

@Override
public FormResponse getForm(Long formId) {
FormQuery query = facadeCentralFormService.getForm(formId);
return FormResponse.from(query);
}
private final FacadeCentralFormService facadeCentralFormService;

@Override
public void createForm(
CreateFormRequest createFormRequest,
PrincipalDetails principalDetails
) {
User user = principalDetails.getUser();
facadeCentralFormService.createForm(createFormRequest.toCommand(user));
}

@Override
public void updateForm(
UpdateFormRequest updateFormRequest,
Long formId,
PrincipalDetails principalDetails
) {
facadeCentralFormService.updateForm(updateFormRequest.toCommand(formId));
}

@Override
public void deleteForm(Long formId, PrincipalDetails principalDetails) {
User user = principalDetails.getUser();
facadeCentralFormService.deleteForm(formId, user);
}

@Override
public List<FormListResponse> getAllMyForm(PrincipalDetails principalDetails) {
User user = principalDetails.getUser();
List<FormListQuery> queries = facadeCentralFormService.getAllMyForm(user);
return queries.stream()
.map(FormListResponse::from)
.toList();
}

@Override
public FormResponse getForm(Long formId) {
FormQuery query = facadeCentralFormService.getForm(formId);
return FormResponse.from(query);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,79 +12,79 @@


public record CreateFormRequest(
@Schema(description = "폼지 제목", example = "폼지제목입니다")
@NotNull(message = "폼지 제목은 null이 될 수 없습니다.")
String title,
@Schema(description = "폼지 제목", example = "폼지제목입니다")
@NotNull(message = "폼지 제목은 null이 될 수 없습니다.")
String title,

@Schema(description = "폼지 설명", example = "우리 동아리는 띵동입니다.")
String description,
@Schema(description = "폼지 설명", example = "우리 동아리는 띵동입니다.")
String description,

@Schema(description = "폼지 시작일자", example = "2001-01-01")
@NotNull(message = "폼지 시작일자는 null이 될 수 없습니다.")
LocalDate startDate,
@Schema(description = "폼지 시작일자", example = "2001-01-01")
@NotNull(message = "폼지 시작일자는 null이 될 수 없습니다.")
LocalDate startDate,

@Schema(description = "폼지 종료일자", example = "2001-01-02")
@NotNull(message = "폼지 종료일자는 null이 될 수 없습니다.")
LocalDate endDate,
@Schema(description = "폼지 종료일자", example = "2001-01-02")
@NotNull(message = "폼지 종료일자는 null이 될 수 없습니다.")
LocalDate endDate,

@Schema(description = "면접여부", example = "true")
@NotNull(message = "면접여부는 null이 될 수 없습니다.")
boolean hasInterview,
@Schema(description = "면접여부", example = "true")
@NotNull(message = "면접여부는 null이 될 수 없습니다.")
boolean hasInterview,

@ArraySchema(schema = @Schema(implementation = CreateFormFieldRequest.class))
List<CreateFormFieldRequest> formFields
@ArraySchema(schema = @Schema(implementation = CreateFormFieldRequest.class))
List<CreateFormFieldRequest> formFields
) {

record CreateFormFieldRequest(
@Schema(description = "폼지 질문", example = "우리 동아리 들어올겁니까?")
@NotNull(message = "질문는 null이 될 수 없습니다.")
String question,

@Schema(description = "질문 종류", example = "CHECK_BOX")
@NotNull(message = "질문 종류는 null이 될 수 없습니다.")
FieldType type,

@Schema(description = "질문의 선택리스트", example = "[지문1이다., 지문2이다., 지문3이다.]")
List<String> options,

@Schema(description = "필수여부", example = "true")
@NotNull(message = "필수여부는 null이 될 수 없습니다.")
boolean required,

@Schema(description = "질문 순서", example = "1")
@NotNull(message = "질문 순서는 null이 될 수 없습니다.")
int order,

@Schema(description = "질문 섹션 종류", example = "공통")
@NotNull(message = "질문 섹션종류는 null이 될 수 없습니다.")
String section
) {

public CreateFormFieldCommand toCommand() {
return CreateFormFieldCommand.builder()
.question(question)
.type(type)
.options(options)
.required(required)
.order(order)
.section(section)
.build();
}
}

public CreateFormCommand toCommand(User user) {
List<CreateFormFieldCommand> createFormFieldCommands = formFields.stream()
.map(CreateFormFieldRequest::toCommand)
.toList();
return CreateFormCommand.builder()
.user(user)
.title(title)
.description(description)
.startDate(startDate)
.endDate(endDate)
.hasInterview(hasInterview)
.formFieldCommands(createFormFieldCommands)
.build();
record CreateFormFieldRequest(
@Schema(description = "폼지 질문", example = "우리 동아리 들어올겁니까?")
@NotNull(message = "질문는 null이 될 수 없습니다.")
String question,

@Schema(description = "질문 종류", example = "CHECK_BOX")
@NotNull(message = "질문 종류는 null이 될 수 없습니다.")
FieldType type,

@Schema(description = "질문의 선택리스트", example = "[지문1이다., 지문2이다., 지문3이다.]")
List<String> options,

@Schema(description = "필수여부", example = "true")
@NotNull(message = "필수여부는 null이 될 수 없습니다.")
boolean required,

@Schema(description = "질문 순서", example = "1")
@NotNull(message = "질문 순서는 null이 될 수 없습니다.")
int order,

@Schema(description = "질문 섹션 종류", example = "공통")
@NotNull(message = "질문 섹션종류는 null이 될 수 없습니다.")
String section
) {

public CreateFormFieldCommand toCommand() {
return CreateFormFieldCommand.builder()
.question(question)
.type(type)
.options(options)
.required(required)
.order(order)
.section(section)
.build();
}
}

public CreateFormCommand toCommand(User user) {
List<CreateFormFieldCommand> createFormFieldCommands = formFields.stream()
.map(CreateFormFieldRequest::toCommand)
.toList();
return CreateFormCommand.builder()
.user(user)
.title(title)
.description(description)
.startDate(startDate)
.endDate(endDate)
.hasInterview(hasInterview)
.formFieldCommands(createFormFieldCommands)
.build();
}

}
Loading

0 comments on commit d3565af

Please sign in to comment.