Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] #559 application detail get api #737

Merged
merged 6 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
package gg.data.recruit.application;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import gg.data.BaseTimeEntity;
import gg.data.recruit.recruitment.Question;
import gg.data.recruit.recruitment.enums.InputType;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ApplicationAnswer extends BaseTimeEntity {

@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "answer_type")
public abstract class ApplicationAnswer extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "question_id", nullable = false)
private Question questionId;
private Question question;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "application_id", nullable = false)
private Application applicationId;
@Getter
private Application application;

public InputType getInputType() {
return question.getInputType();
}

public Long getQuestionId() {
return question.getId();
}

public abstract ApplicationAnswerEntityDto toForm();

}
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
package gg.data.recruit.application;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import gg.data.BaseTimeEntity;
import gg.data.recruit.recruitment.CheckList;
import lombok.NoArgsConstructor;

@Entity
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED)
public class ApplicationAnswerCheckList extends BaseTimeEntity {
@DiscriminatorValue("CHECK_LIST")
public class ApplicationAnswerCheckList extends ApplicationAnswer {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "application_answer_id", nullable = false)
private ApplicationAnswer applicationAnswerId;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "check_list_id", nullable = false)
private CheckList checkListId;
private CheckList checkList;

@Override
public ApplicationAnswerEntityDto toForm() {
return new ApplicationAnswerEntityDto(this.getQuestionId(), this.getInputType(),
new CheckListEntityDto(checkList.getId(), checkList.getContent()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package gg.data.recruit.application;
import gg.data.recruit.recruitment.enums.InputType;
import lombok.Getter;

@Getter
public class ApplicationAnswerEntityDto {
private Long questionId;
private InputType inputType;

private CheckListEntityDto checkedList;
private String answer;

public ApplicationAnswerEntityDto(Long questionId, InputType inputType, CheckListEntityDto checkedList) {
this.questionId = questionId;
this.inputType = inputType;
this.checkedList = checkedList;
}

public ApplicationAnswerEntityDto(Long questionId, InputType inputType, String answer) {
this.questionId = questionId;
this.inputType = inputType;
this.answer = answer;
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
package gg.data.recruit.application;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import gg.data.BaseTimeEntity;
import lombok.NoArgsConstructor;

@Entity
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED)
public class ApplicationAnswerText extends BaseTimeEntity {
@DiscriminatorValue("TEXT")
public class ApplicationAnswerText extends ApplicationAnswer {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "application_answer_id", nullable = false)
private ApplicationAnswer applicationAnswerId;

@Column(length = 1000)
private String answer;

@Override
public ApplicationAnswerEntityDto toForm() {
return new ApplicationAnswerEntityDto(this.getQuestionId(), this.getInputType(), answer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package gg.data.recruit.application;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public class CheckListEntityDto {
private Long checkListId;
private String content;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

import gg.data.BaseTimeEntity;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class CheckList extends BaseTimeEntity {

@Id
Expand All @@ -23,7 +25,7 @@ public class CheckList extends BaseTimeEntity {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "question_id", nullable = false)
private Question questionId;
private Question question;

@Column(length = 100)
private String content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import gg.data.BaseTimeEntity;
import gg.data.recruit.recruitment.enums.InputType;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Question extends BaseTimeEntity {
@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ public GroupedOpenApi group1() {
.build();
}

@Bean
public GroupedOpenApi recruitGroup() {
return GroupedOpenApi.builder()
.group("recruit")
.pathsToMatch("/recruitments/**")
.packagesToScan("gg.recruit.api.user")
.build();
}

@Bean
public GroupedOpenApi recruitAdminGroup() {
return GroupedOpenApi.builder()
.group("recruit admin")
.pathsToMatch("admin/recruitments/**")
.packagesToScan("gg.recruit.api.admin")
.build();
}

@Bean
public GroupedOpenApi admin_group() {
return GroupedOpenApi.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ protected ResponseEntity<ErrorResponse> httpRequestMethodNotSupportedExceptionHa
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleException(Exception ex) {
log.error("!!!!!! SERVER ERROR !!!!!!", ex.getMessage());
ex.printStackTrace();
ErrorResponse response = new ErrorResponse(ErrorCode.INTERNAL_SERVER_ERR);
return new ResponseEntity<>(response, HttpStatus.valueOf(response.getStatus()));
}
Expand Down
21 changes: 7 additions & 14 deletions gg-pingpong-api/src/main/resources/db/migration/V2__recruit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ CREATE TABLE `application_answer` (
`modified_at` datetime(6) DEFAULT NULL,
`application_id` bigint NOT NULL ,
`question_id` bigint NOT NULL ,
`answer_type` varchar(20) NOT NULL,
PRIMARY KEY (`id`),
KEY `FKn2ayp7tptdv0yycdqkp2hcm63` (`application_id`),
KEY `FK59sj9jdfki14kkp34kc2jdhyj` (`question_id`),
Expand All @@ -65,27 +66,19 @@ CREATE TABLE `check_list` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE `application_answer_check_list` (
`id` bigint NOT NULL AUTO_INCREMENT,
`created_at` datetime(6) NOT NULL,
`modified_at` datetime(6) DEFAULT NULL,
`application_answer_id` bigint NOT NULL,
`id` bigint NOT NULL,
`check_list_id` bigint NOT NULL,
PRIMARY KEY (`id`),
KEY `FKqdnt92yg8t27q74he0ersyiax` (`application_answer_id`),
KEY `FKqdnt92yg8t27q74he0ersyiax` (`id`),
KEY `FK3mf6hfr08f2ex01aqejikxk9w` (`check_list_id`),
CONSTRAINT `FK3mf6hfr08f2ex01aqejikxk9w` FOREIGN KEY (`check_list_id`) REFERENCES `check_list` (`id`),
CONSTRAINT `FKqdnt92yg8t27q74he0ersyiax` FOREIGN KEY (`application_answer_id`) REFERENCES `application_answer` (`id`)
CONSTRAINT `FKqdnt92yg8t27q74he0ersyiax` FOREIGN KEY (`id`) REFERENCES `application_answer` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE `application_answer_text` (
`id` bigint NOT NULL AUTO_INCREMENT,
`created_at` datetime(6) NOT NULL,
`modified_at` datetime(6) DEFAULT NULL,
`id` bigint NOT NULL ,
`answer` varchar(1000) DEFAULT NULL,
`application_answer_id` bigint NOT NULL ,
PRIMARY KEY (`id`),
KEY `FKlhk4m3hi4r3v8xqk8lx4bx5g7` (`application_answer_id`),
CONSTRAINT `FKlhk4m3hi4r3v8xqk8lx4bx5g7` FOREIGN KEY (`application_answer_id`) REFERENCES `application_answer` (`id`)
KEY `FKlhk4m3hi4r3v8xqk8lx4bx5g7` (`id`),
CONSTRAINT `FKlhk4m3hi4r3v8xqk8lx4bx5g7` FOREIGN KEY (`id`) REFERENCES `application_answer` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

import gg.auth.UserDto;
import gg.auth.argumentresolver.Login;
import gg.recruit.api.user.controller.response.MyApplicationDetailResDto;
import gg.recruit.api.user.controller.response.MyApplicationsResDto;
import gg.recruit.api.user.service.ApplicationService;
import gg.recruit.api.user.service.response.ApplicationListDto;
import gg.recruit.api.user.service.param.FindApplicationDetailParam;
import gg.recruit.api.user.service.response.ApplicationListSvcDto;
import gg.recruit.api.user.service.response.ApplicationWithAnswerSvcDto;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;

@RestController
Expand All @@ -20,7 +24,16 @@ public class ApplicationController {

@GetMapping("/applications")
public MyApplicationsResDto getMyApplications(@Login UserDto userDto) {
ApplicationListDto res = applicationService.findMyApplications(userDto.getId());
ApplicationListSvcDto res = applicationService.findMyApplications(userDto.getId());
return new MyApplicationsResDto(res);
}

@GetMapping("{recruitmentId}/applications/{applicationId}")
public MyApplicationDetailResDto getMyApplication(@Login @Parameter(hidden = true) UserDto userDto,
Long recruitmentId, Long applicationId) {
ApplicationWithAnswerSvcDto res = applicationService
.findMyApplicationDetail(new FindApplicationDetailParam(userDto.getId(), recruitmentId, applicationId));
return new MyApplicationDetailResDto(res);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.time.LocalDateTime;

import gg.recruit.api.user.service.response.ApplicationDto;
import gg.recruit.api.user.service.response.ApplicationSvcDto;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand All @@ -17,7 +17,7 @@ public class ApplicationResDto {
private String generation;
private String status;

public ApplicationResDto(ApplicationDto applicationDto) {
public ApplicationResDto(ApplicationSvcDto applicationDto) {
this.recruitId = applicationDto.getRecruitId();
this.applicationId = applicationDto.getApplicationId();
this.startDate = applicationDto.getStartDate();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package gg.recruit.api.user.controller.response;

import gg.recruit.api.user.service.response.CheckListSvcDto;
import lombok.Getter;

@Getter
public class CheckListResDto {
private Long checkListId;
private String content;

public CheckListResDto(CheckListSvcDto checkListSvcDto) {
this.checkListId = checkListSvcDto.getCheckListId();
this.content = checkListSvcDto.getContent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package gg.recruit.api.user.controller.response;

import static java.util.stream.Collectors.*;

import java.util.List;

import gg.recruit.api.user.service.response.FormSvcDto;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public class FormResDto {
private Long questionId;
private String inputType;
private List<CheckListResDto> checkeList;
private String answer;

public FormResDto(FormSvcDto formSvcDto) {
this.questionId = formSvcDto.getQuestionId();
this.inputType = formSvcDto.getInputType();
this.checkeList = formSvcDto.getCheckedList().stream()
.map(CheckListResDto::new).collect(toList());
this.answer = formSvcDto.getAnswer();
}
}
Loading
Loading