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

[SL-12] entity 및 DB 설정 수정 #34

Merged
merged 4 commits into from
Dec 24, 2023
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
Expand Up @@ -24,35 +24,35 @@ public class Answer {
private Application application;

@Column(length = 500)
@ColumnDefault("")
@ColumnDefault("''")
private String commonAnswer1;

@Column(length = 500)
@ColumnDefault("")
@ColumnDefault("''")
private String commonAnswer2;

@Column(length = 500)
@ColumnDefault("")
@ColumnDefault("''")
private String commonAnswer3;

@Column(length = 500)
@ColumnDefault("")
@ColumnDefault("''")
private String commonAnswer4;

@Column(length = 500)
@ColumnDefault("")
@ColumnDefault("''")
private String commonAnswer5;

@Column(length = 500)
@ColumnDefault("")
@ColumnDefault("''")
private String partAnswer1;

@Column(length = 500)
@ColumnDefault("")
@ColumnDefault("''")
private String partAnswer2;

@Column(length = 500)
@ColumnDefault("")
@ColumnDefault("''")
private String partAnswer3;

// 공동 답변 생성자
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,35 @@ public class Application extends BaseTimeEntity {
private CommonQuestion generation; // generation이라고 매핑했지만 실제로는 CommonQuestion의 id를 가리킴

// application page 1 start
@ColumnDefault("")
@ColumnDefault("false")
private Boolean isAgreed;

@Column(length = 30)
@ColumnDefault("")
@ColumnDefault("''")
private String name;

@Column(length = 1)
@ColumnDefault("")
@ColumnDefault("''")
private String gender;

@ColumnDefault("0")
private Integer studentNum;

@Column(length = 30)
@ColumnDefault("")
@ColumnDefault("''")
private String major;

@Column(length = 30)
private String multiMajor;

@ColumnDefault("")
@ColumnDefault("''")
private String semester;

@ColumnDefault("")
@ColumnDefault("''")
private String phone;

@Column(length = 100)
@ColumnDefault("")
@ColumnDefault("''")
private String email;

@OneToMany(cascade = CascadeType.PERSIST, mappedBy = "applicationId") // application 저장 시, pathToKnows도 함께 저장
Expand All @@ -80,10 +80,10 @@ public class Application extends BaseTimeEntity {
// application page 1 end


@ColumnDefault("")
@ColumnDefault("''")
private String portfolio;

@ColumnDefault("")
@ColumnDefault("''")
private String interview;

@ColumnDefault("'N'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ public class Curriculum {

@Column(length = 300)
private String content;

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public class PathToKnow {
private Application applicationId;

@Enumerated(EnumType.STRING)
@Column()
@ColumnDefault("")
@Column
private PathType pathType;

public enum PathType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ public static PartResponse of(Part part, List<PartQuestion> partQuestions, List<
commonQuestion.getCommonQuestion3(),
commonQuestion.getCommonQuestion4(),
commonQuestion.getCommonQuestion5()

),
part.getGeneration() // part의 Generation 정보

);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.Optional;

public interface CurriculumJpaRepository extends JpaRepository<Curriculum, Long> {
List<Curriculum> findByPartId(Part part); // Part를 기반으로 Curriculum을 조회
List<Curriculum> findByPartId(Part part);
}

Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ public PartResponse getPartByName(String name) {
if (partQuestions.isEmpty() && curriculums.isEmpty()) {
throw new NoSuchElementException("PartQuestion과 Curriculum이 모두 비어 있습니다.");
}

Long generation = part.getGeneration();
// 임시로 이렇게 구현했습니다. 후에 파트에 generation을 추가하거나 해야할 듯 합니다.
Long generation = partQuestions.isEmpty() ? curriculums.get(0).getGeneration() : partQuestions.get(0).getGeneration();
CommonQuestion commonQuestion = commonQuestionJpaRepository.findByGeneration(generation)
.orElseThrow(() -> new NoSuchElementException("해당 기수의 CommonQuestion이 없습니다."));
.orElseThrow(() -> new NoSuchElementException("해당 세대의 CommonQuestion이 없습니다."));


return PartResponse.of(part, partQuestions, curriculums, commonQuestion);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spring:

jpa:
hibernate:
ddl-auto: create
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/log4jdbc.log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
log4jdbc.auto.load.popular.drivers=false
log4jdbc.drivers=com.mysql.cj.jdbc.Driver