Skip to content

Commit

Permalink
[FIX] API 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
unanchoi committed Jan 13, 2024
1 parent 925f8eb commit b9931e4
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter
public class Application extends BaseTimeEntity {

private static final boolean DEFAULT_AGREEMENT = true;
private static final int DEFAULT_ANSWER_LIMIT = 700;
private static final int PLAN_PART_ANSWER_LIMIT = 1000;

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

private boolean isPersonalInformationAgreed = DEFAULT_AGREEMENT;
private boolean isPersonalInformationAgreed;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
Expand Down Expand Up @@ -119,6 +120,16 @@ public class Application extends BaseTimeEntity {
@Column(columnDefinition = "TEXT")
private String partAnswer4;

private int commonAnswer1Limit = DEFAULT_ANSWER_LIMIT;
private int commonAnswer2Limit = DEFAULT_ANSWER_LIMIT;
private int commonAnswer3Limit = DEFAULT_ANSWER_LIMIT;
private int commonAnswer4Limit = DEFAULT_ANSWER_LIMIT;
private int commonAnswer5Limit = DEFAULT_ANSWER_LIMIT;
private int partAnswer1Limit = DEFAULT_ANSWER_LIMIT;
private int partAnswer2Limit = DEFAULT_ANSWER_LIMIT;
private int partAnswer3Limit = DEFAULT_ANSWER_LIMIT;
private int partAnswer4Limit = DEFAULT_ANSWER_LIMIT;

@Builder
private Application(boolean isPersonalInformationAgreed,
User user,
Expand Down Expand Up @@ -182,6 +193,13 @@ public void updateApplicationPage1(ApplicationPage1Request request) {
this.semester = Semester.valueOf(request.semester());
this.studentNumber = request.studentNumber();
this.isPersonalInformationAgreed = request.isAgreed();

if (ApplyPart.valueOf(request.part()) == ApplyPart.PLAN) {
this.partAnswer1Limit = PLAN_PART_ANSWER_LIMIT;
this.partAnswer2Limit = PLAN_PART_ANSWER_LIMIT;
this.partAnswer3Limit = PLAN_PART_ANSWER_LIMIT;
this.partAnswer4Limit = PLAN_PART_ANSWER_LIMIT;
}
}

public void updateApplicationPage2(ApplicationPage2Request request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Part {
@Column(nullable = false)
private Long partId;

// BE FE DESIGN PLAN
@Column(nullable = false)
private String name;

Expand All @@ -32,4 +33,5 @@ public class Part {

@Column(nullable = false)
private Long generation;

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.startlion.startlionserver.domain.entity;

import com.startlion.startlionserver.domain.enums.ApplyPart;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Builder;
Expand All @@ -15,7 +14,7 @@ public class PartQuestion {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long questionId;
@Enumerated(EnumType.STRING)
private ApplyPart part;
private String part;
@Column(nullable = false)
private int generation;
@Column(columnDefinition = "TEXT")
Expand All @@ -28,7 +27,7 @@ public class PartQuestion {
private String partQuestion4;

@Builder
private PartQuestion(ApplyPart part, int generation, String partQuestion1, String partQuestion2, String partQuestion3, String partQuestion4) {
private PartQuestion(String part, int generation, String partQuestion1, String partQuestion2, String partQuestion3, String partQuestion4) {
this.part = part;
this.generation = generation;
this.partQuestion1 = partQuestion1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@Getter
@RequiredArgsConstructor
public enum ApplyPart {
DEFAULT(""),
BE("백엔드"),
FE("프론트엔드"),
DESIGN("디자인"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@Getter
@RequiredArgsConstructor
public enum Semester {
DEFAULT(""),
FIRST("1-1"),
SECOND("1-2"),
THIRD("2-1"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public record ApplicationPage4Request(
@Schema(description = "최종 제출 여부", example = "true")
boolean isSubmit,
@Schema(description = "면접 시간", example = "0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1")
@Schema(description = "면접 시간", example = "0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1")
String availableInterviewTime
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public record PartResponse(

@Schema(description = "파트 이름", example = "기획")
String part,
String partName,
@Schema(description = "파트 내용", example = "기획 파트는 기획을 합니다.")
String partContent,
@Schema(description = "파트 타입", example = "기획")
Expand All @@ -26,7 +26,11 @@ public record PartResponse(
String curriculumContents,
@Schema(description = "파트 기수", example = "12")
Long curriculumGeneration,

@Schema(description = "공통 질문", example = "공통 질문")
List<String> commonQuestions,

@Schema(description = "파트별 질문", example = "파트별 질문")
List<String> partQuestions
) {

Expand All @@ -35,24 +39,16 @@ public static PartResponse of(Part part,
Curriculum curriculum,
CommonQuestion commonQuestion
) {
return new PartResponse(
part.getName(),
part.getPartContent(),
part.getTypeOfTalent(),
part.getImageUrl(),
curriculum.getContent(),
part.getGeneration(),
List.of(
commonQuestion.getCommonQuestion1(),
commonQuestion.getCommonQuestion2(),
commonQuestion.getCommonQuestion3(),
commonQuestion.getCommonQuestion4(),
commonQuestion.getCommonQuestion5()),
List.of(
partQuestion.getPartQuestion1(),
partQuestion.getPartQuestion2(),
partQuestion.getPartQuestion3(),
partQuestion.getPartQuestion4())
);
return PartResponse.builder()
.partName(part.getName())
.partContent(part.getPartContent())
.typeOfTalent(part.getTypeOfTalent())
.imageUrl(part.getImageUrl())
.curriculumContents(curriculum.getContent())
.curriculumGeneration(curriculum.getGeneration())
.commonQuestions(List.of(commonQuestion.getCommonQuestion1(), commonQuestion.getCommonQuestion2(), commonQuestion.getCommonQuestion3(), commonQuestion.getCommonQuestion4(), commonQuestion.getCommonQuestion5()))
.partQuestions(List.of(partQuestion.getPartQuestion1(), partQuestion.getPartQuestion2(), partQuestion.getPartQuestion3()))
.build()
;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.startlion.startlionserver.repository;

import com.startlion.startlionserver.domain.entity.PartQuestion;
import com.startlion.startlionserver.domain.enums.ApplyPart;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Optional;

public interface PartQuestionJpaRepository extends JpaRepository<PartQuestion, Long> {

Optional<PartQuestion> findByPartAndGeneration(ApplyPart part, int generation);
default PartQuestion findByPartAndGenerationOrThrow(ApplyPart part, int generation) {
Optional<PartQuestion> findByPartAndGeneration(String part, int generation);
default PartQuestion findByPartAndGenerationOrThrow(String part, int generation) {
return findByPartAndGeneration(part, generation).orElseThrow(() -> new IllegalArgumentException("해당하는 PartQuestion이 없습니다."));

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.startlion.startlionserver.service;


import com.startlion.startlionserver.domain.enums.ApplyPart;
import com.startlion.startlionserver.dto.response.part.PartResponse;
import com.startlion.startlionserver.repository.CommonQuestionJpaRepository;
import com.startlion.startlionserver.repository.CurriculumJpaRepository;
Expand All @@ -27,9 +26,10 @@ public class PartService {
@Value("${current-generation}")
private int currentGeneration;

public PartResponse getPartByName(String name) {
val part = partJpaRepository.findByName(name).orElseThrow(() -> new EntityNotFoundException("해당하는 파트가 없습니다."));
val partQuestion = partQuestionJpaRepository.findByPartAndGenerationOrThrow(ApplyPart.valueOf(name), currentGeneration);
// partName : BE, FE, DESIGN, PLAN
public PartResponse getPartByName(String partName) {
val part = partJpaRepository.findByName(partName).orElseThrow(() -> new EntityNotFoundException("해당하는 파트가 없습니다."));
val partQuestion = partQuestionJpaRepository.findByPartAndGenerationOrThrow(partName, currentGeneration);
val commonQuestion = commonQuestionJpaRepository.findByGeneration(currentGeneration).orElseThrow(() -> new EntityNotFoundException("해당하는 공통 질문이 없습니다."));
val curriculum = curriculumJpaRepository.findByPartOrThrow(part);
return PartResponse.of(part, partQuestion, curriculum, commonQuestion);
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/application-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ springdoc:
groups:
enabled: true

global:
generation: 12
current-generation: 12

0 comments on commit b9931e4

Please sign in to comment.