-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from mju-facilty-organization/dev
[refactor/feat] Student의 대학,전공, Facility의 FacilityType 필드를 String에서 Enum으로 변경 / 시설 타입별 시설 전체 조회 api 구현
- Loading branch information
Showing
13 changed files
with
177 additions
and
36 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...main/java/com/example/rentalSystem/domain/affiliation/converter/AffiliationConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.example.rentalSystem.domain.affiliation.converter; | ||
|
||
import com.example.rentalSystem.domain.affiliation.type.AffiliationType; | ||
import jakarta.persistence.AttributeConverter; | ||
|
||
public class AffiliationConverter implements AttributeConverter<AffiliationType, String> { | ||
|
||
@Override | ||
public String convertToDatabaseColumn(AffiliationType affiliationType) { | ||
if (affiliationType == null) { | ||
return null; | ||
} | ||
return affiliationType.getName(); | ||
} | ||
|
||
@Override | ||
public AffiliationType convertToEntityAttribute(String name) { | ||
return AffiliationType.getInstance(name); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
src/main/java/com/example/rentalSystem/domain/affiliation/type/AffiliationType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.example.rentalSystem.domain.affiliation.type; | ||
|
||
import com.example.rentalSystem.global.exception.custom.CustomException; | ||
import com.example.rentalSystem.global.response.ErrorType; | ||
import java.util.Arrays; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum AffiliationType { | ||
// 총학 | ||
STUDENT_COUNCIL(1, "총학", "총학생회", null), | ||
|
||
// 인문대 | ||
HUMANITIES(2, "단과대", "인문대학", null), | ||
KOREAN_LANGUAGE_AND_LITERATURE(3, "학과", "국어국문학과", HUMANITIES), | ||
CREATIVE_WRITING(4, "학과", "문예창작학과", HUMANITIES), | ||
ENGLISH_LANGUAGE_AND_LITERATURE(5, "학과", "영어영문학과", HUMANITIES), | ||
CHINESE_LANGUAGE_AND_LITERATURE(6, "학과", "중어중문학과", HUMANITIES), | ||
JAPANESE_LANGUAGE_AND_LITERATURE(7, "학과", "일어일문학과", HUMANITIES), | ||
LIBRARY_AND_INFORMATION_SCIENCE(8, "학과", "문헌정보학과", HUMANITIES), | ||
ART_HISTORY(9, "학과", "미술사학과", HUMANITIES), | ||
ARABIC_STUDIES(10, "학과", "아랍지역학과", HUMANITIES), | ||
HISTORY(11, "학과", "사학과", HUMANITIES), | ||
PHILOSOPHY(12, "학과", "철학과", HUMANITIES), | ||
|
||
// 사회과학대 | ||
SOCIAL_SCIENCE(13, "단과대", "사회과학대학", null), | ||
PUBLIC_ADMINISTRATION(14, "학과", "행정학과", SOCIAL_SCIENCE), | ||
ECONOMICS(15, "학과", "경제학과", SOCIAL_SCIENCE), | ||
POLITICAL_SCIENCE_AND_DIPLOMACY(16, "학과", "정치외교학과", SOCIAL_SCIENCE), | ||
DIGITAL_MEDIA(17, "학과", "디지털미디어학과", SOCIAL_SCIENCE), | ||
CHILD_STUDIES(18, "학과", "아동학과", SOCIAL_SCIENCE), | ||
YOUTH_GUIDANCE(19, "학과", "청소년지도학과", SOCIAL_SCIENCE), | ||
|
||
// 경영대 | ||
BUSINESS(20, "단과대", "경영대학", null), | ||
BUSINESS_ADMINISTRATION(21, "학과", "경영학과", BUSINESS), | ||
MANAGEMENT_INFORMATION_SYSTEMS(22, "학과", "경영정보학과", BUSINESS), | ||
INTERNATIONAL_TRADE(23, "학과", "국제통상학과", BUSINESS), | ||
|
||
// 법대 | ||
LAW(24, "단과대", "법학대학", null), | ||
DEPARTMENT_OF_LAW(25, "학과", "법학과", LAW), | ||
|
||
// ICT융합대 | ||
ICT(26, "단과대", "ICT융합대학", null), | ||
DIGITAL_CONTENTS_DESIGN(27, "학과", "디지털콘텐츠디자인학과", ICT), | ||
SOFTWARE_APPLICATIONS(28, "학과", "응용소프트웨어전공", ICT), | ||
DATA_TECHNOLOGY(29, "학과", "데이터테크놀로지전공", ICT); | ||
|
||
private final int val; | ||
private final String councilType; | ||
private final String name; | ||
private final AffiliationType parent; // 상위 단과대 | ||
|
||
public static AffiliationType getInstance(String name) { | ||
return Arrays.stream(values()) | ||
.filter(type -> type.name.equals(name)) | ||
.findFirst() | ||
.orElseThrow( | ||
() -> new CustomException(ErrorType.INVALID_AFFILIATION_TYPE)); // 없으면 예외 발생 | ||
} | ||
|
||
public static String getCollegeByMajor(String major) { | ||
return Arrays.stream(values()) | ||
.filter(type -> type.name.equals(major)) | ||
.map(type -> type.parent.name) // 존재하면 value 반환 | ||
.findFirst() | ||
.orElseThrow( | ||
() -> new CustomException(ErrorType.INVALID_AFFILIATION_TYPE)); // 없으면 예외 발생 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/example/rentalSystem/domain/facility/convert/FacilityTypeConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.example.rentalSystem.domain.facility.convert; | ||
|
||
import com.example.rentalSystem.domain.facility.entity.FacilityType; | ||
import jakarta.persistence.AttributeConverter; | ||
|
||
public class FacilityTypeConverter implements AttributeConverter<FacilityType, String> { | ||
|
||
@Override | ||
public String convertToDatabaseColumn(FacilityType facilityType) { | ||
if (facilityType == null) { | ||
return null; | ||
} | ||
return facilityType.getValue(); | ||
} | ||
|
||
@Override | ||
public FacilityType convertToEntityAttribute(String value) { | ||
return FacilityType.getInstanceByValue(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
src/main/java/com/example/rentalSystem/domain/facility/reposiotry/FacilityJpaRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package com.example.rentalSystem.domain.facility.reposiotry; | ||
|
||
import com.example.rentalSystem.domain.facility.entity.Facility; | ||
import com.example.rentalSystem.domain.facility.entity.FacilityType; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface FacilityJpaRepository extends JpaRepository<Facility, Long> { | ||
|
||
// Optional<Facility> findByNameAndLocation(String name, String location); | ||
Page<Facility> findByFacilityType(FacilityType instanceByValue, Pageable pageable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.