Skip to content

Commit

Permalink
Merge pull request #101 from Bamdoliro/fix/#100
Browse files Browse the repository at this point in the history
[버그] 고입 검정 학생의 학교, 선생님 정보에 대한 null 값 처리
  • Loading branch information
cabbage16 authored Jul 12, 2024
2 parents d95685e + 06fdfda commit b76fbbc
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class PhoneNumber {

@Override
public String toString() {
if (value == null) {
return "";
}
if (value.length() == 10) {
return value.substring(0, 3) + "-" + value.substring(3, 6) + "-" + value.substring(6);
} else if (value.length() == 11) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
@Embeddable
public class School {

@Column(name = "school_name", nullable = false, length = 20)
@Column(name = "school_name", nullable = true, length = 20)
private String name;

@Column(name = "school_location", nullable = false, length = 20)
@Column(name = "school_location", nullable = true, length = 20)
private String location;

@Column(name = "school_address", nullable = false, length = 40)
@Column(name = "school_address", nullable = true, length = 40)
private String address;

@Column(name = "school_code", nullable = false, length = 10)
@Column(name = "school_code", nullable = true, length = 10)
private String code;

public boolean isBusan() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ public class EducationRequest {
@Size(min = 4, max = 4, message = "4자여야 합니다.")
private String graduationYear;

@NotBlank(message = "필수값입니다.")
@Nullable
@Size(max = 20, message = "20자 이하여야 합니다.")
private String schoolName;

@NotBlank(message = "필수값입니다.")
@Nullable
@Size(max = 20, message = "20자 이하여야 합니다.")
private String schoolLocation;

@NotBlank(message = "필수값입니다.")
@Nullable
@Size(max = 40, message = "40자 이하여야 합니다.")
private String schoolAddress;

@NotBlank(message = "필수값입니다.")
@Nullable
@Size(min = 7, max = 7, message = "7자여야 합니다.")
private String schoolCode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public EducationResponse(Education education) {
this.schoolLocation = education.getSchool().getLocation();
this.schoolAddress = education.getSchool().getAddress();
this.schoolCode = education.getSchool().getCode();
this.schoolPhoneNumber = education.getTeacher().getPhoneNumber().toString();
this.schoolPhoneNumber = education.getTeacher().getPhoneNumber().toString().isEmpty() ? null : education.getTeacher().getPhoneNumber().toString();
this.teacherName = education.getTeacher().getName();
this.teacherMobilePhoneNumber = education.getTeacher().getMobilePhoneNumber().toString();
this.teacherMobilePhoneNumber = education.getTeacher().getMobilePhoneNumber().toString().isEmpty() ? null : education.getTeacher().getMobilePhoneNumber().toString();
}
}
2 changes: 2 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ spring:
properties:
hibernate:
format_sql: true
create_empty_composites:
enabled: true

generate-ddl: true
hibernate:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,19 @@ class FormControllerTest extends RestDocsTestSupport {
.description("<<graduation-type,졸업 유형>>"),
fieldWithPath("education.graduationYear")
.type(JsonFieldType.STRING)
.description("졸업 연도"),
.description("졸업 연도, 합격 연도"),
fieldWithPath("education.schoolName")
.type(JsonFieldType.STRING)
.description("출신 학교 이름"),
.description("출신 학교 이름 (없는 경우 null)"),
fieldWithPath("education.schoolLocation")
.type(JsonFieldType.STRING)
.description("출신 학교 지역"),
.description("출신 학교 지역 (없는 경우 null)"),
fieldWithPath("education.schoolAddress")
.type(JsonFieldType.STRING)
.description("출신 학교 주소지"),
.description("출신 학교 주소지 (없는 경우 null)"),
fieldWithPath("education.schoolCode")
.type(JsonFieldType.STRING)
.description("출신 학교 코드"),
.description("출신 학교 코드 (없는 경우 null)"),
fieldWithPath("education.teacherName")
.type(JsonFieldType.STRING)
.description("작성 교사 (없는 경우 null)"),
Expand Down
17 changes: 6 additions & 11 deletions src/test/java/com/bamdoliro/maru/shared/fixture/FormFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public static Form createRandomQualificationExaminationForm(User user) {
new Education(
GraduationType.QUALIFICATION_EXAMINATION,
"2021",
new School("비전중학교", "경기도", "경기도 비전시 비전구 비전로 1", "7631003"),
null,
null
),
new Grade(
Expand Down Expand Up @@ -286,12 +286,7 @@ public static Form createQualificationExaminationForm(FormType type) {
new Education(
GraduationType.QUALIFICATION_EXAMINATION,
"2021",
new School(
"비전중학교",
"경기도",
"경기도 비전시 비전구 비전로 1",
"7631003"
),
null,
null
),
new Grade(
Expand Down Expand Up @@ -369,10 +364,10 @@ public static SubmitFormRequest createQualificationExaminationFormRequest(FormTy
new EducationRequest(
GraduationType.QUALIFICATION_EXAMINATION,
"2021",
"비전중학교",
"경기도",
"경기도 비전시 비전구 비전로 1",
"7631003",
null,
null,
null,
null,
null,
null,
null
Expand Down

0 comments on commit b76fbbc

Please sign in to comment.