-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efeb765
commit 933fc43
Showing
17 changed files
with
510 additions
and
7 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
backend/src/main/java/kr/touroot/travelogue/domain/TravelogueCountry.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,47 @@ | ||
package kr.touroot.travelogue.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import kr.touroot.travelogue.domain.search.CountryCode; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@EqualsAndHashCode(of = "id", callSuper = false) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Entity | ||
public class TravelogueCountry { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@JoinColumn(nullable = false) | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Travelogue travelogue; | ||
|
||
@Column(nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
private CountryCode countryCode; | ||
|
||
@Column(nullable = false) | ||
private Long count; | ||
|
||
public TravelogueCountry(Travelogue travelogue, CountryCode countryCode, Long count) { | ||
this.travelogue = travelogue; | ||
this.countryCode = countryCode; | ||
this.count = count; | ||
} | ||
} |
261 changes: 261 additions & 0 deletions
261
backend/src/main/java/kr/touroot/travelogue/domain/search/CountryCode.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,261 @@ | ||
package kr.touroot.travelogue.domain.search; | ||
|
||
import java.util.Arrays; | ||
import java.util.Set; | ||
import kr.touroot.global.exception.BadRequestException; | ||
|
||
public enum CountryCode { | ||
|
||
AF(Set.of("아프가니스탄")), | ||
AL(Set.of("알바니아")), | ||
DZ(Set.of("알제리")), | ||
AS(Set.of("아메리칸 사모아")), | ||
AD(Set.of("안도라")), | ||
AO(Set.of("앙골라")), | ||
AI(Set.of("앵귈라")), | ||
AQ(Set.of("남극")), | ||
AG(Set.of("앤티가 바부다")), | ||
AR(Set.of("아르헨티나")), | ||
AM(Set.of("아르메니아")), | ||
AW(Set.of("아루바")), | ||
AU(Set.of("호주")), | ||
AT(Set.of("오스트리아")), | ||
AZ(Set.of("아제르바이잔")), | ||
BS(Set.of("바하마")), | ||
BH(Set.of("바레인")), | ||
BD(Set.of("방글라데시")), | ||
BB(Set.of("바베이도스")), | ||
BY(Set.of("벨라루스")), | ||
BE(Set.of("벨기에")), | ||
BZ(Set.of("벨리즈")), | ||
BJ(Set.of("베냉")), | ||
BM(Set.of("버뮤다")), | ||
BT(Set.of("부탄")), | ||
BO(Set.of("볼리비아")), | ||
BA(Set.of("보스니아 헤르체고비나")), | ||
BW(Set.of("보츠와나")), | ||
BV(Set.of("부베섬")), | ||
BR(Set.of("브라질")), | ||
IO(Set.of("영국령 인도양 지역")), | ||
VG(Set.of("영국령 버진 아일랜드")), | ||
BN(Set.of("브루나이")), | ||
BG(Set.of("불가리아")), | ||
BF(Set.of("부르키나파소")), | ||
BI(Set.of("부룬디")), | ||
KH(Set.of("캄보디아")), | ||
CM(Set.of("카메룬")), | ||
CA(Set.of("캐나다")), | ||
CV(Set.of("카보베르데")), | ||
KY(Set.of("케이맨 제도")), | ||
CF(Set.of("중앙아프리카 공화국")), | ||
TD(Set.of("차드")), | ||
CL(Set.of("칠레")), | ||
CN(Set.of("중국")), | ||
CX(Set.of("크리스마스 섬")), | ||
CC(Set.of("코코스 제도")), | ||
CO(Set.of("콜롬비아")), | ||
KM(Set.of("코모로")), | ||
CD(Set.of("콩고 민주공화국")), | ||
CG(Set.of("콩고 공화국")), | ||
CK(Set.of("쿡 제도")), | ||
CR(Set.of("코스타리카")), | ||
CI(Set.of("코트디부아르")), | ||
CU(Set.of("쿠바")), | ||
CY(Set.of("키프로스")), | ||
CZ(Set.of("체코")), | ||
DK(Set.of("덴마크")), | ||
DJ(Set.of("지부티")), | ||
DM(Set.of("도미니카")), | ||
DO(Set.of("도미니카 공화국")), | ||
EC(Set.of("에콰도르")), | ||
EG(Set.of("이집트")), | ||
SV(Set.of("엘살바도르")), | ||
GQ(Set.of("적도기니")), | ||
ER(Set.of("에리트레아")), | ||
EE(Set.of("에스토니아")), | ||
ET(Set.of("에티오피아")), | ||
FO(Set.of("페로 제도")), | ||
FK(Set.of("포클랜드 제도")), | ||
FJ(Set.of("피지")), | ||
FI(Set.of("핀란드")), | ||
FR(Set.of("프랑스")), | ||
GF(Set.of("프랑스령 기아나")), | ||
PF(Set.of("프랑스령 폴리네시아")), | ||
TF(Set.of("프랑스령 남부 지역")), | ||
GA(Set.of("가봉")), | ||
GM(Set.of("감비아")), | ||
GE(Set.of("조지아")), | ||
DE(Set.of("독일")), | ||
GH(Set.of("가나")), | ||
GI(Set.of("지브롤터")), | ||
GR(Set.of("그리스")), | ||
GL(Set.of("그린란드")), | ||
GD(Set.of("그레나다")), | ||
GP(Set.of("과들루프")), | ||
GU(Set.of("괌")), | ||
GT(Set.of("과테말라")), | ||
GN(Set.of("기니")), | ||
GW(Set.of("기니비사우")), | ||
GY(Set.of("가이아나")), | ||
HT(Set.of("아이티")), | ||
HM(Set.of("허드 맥도널드 제도")), | ||
VA(Set.of("바티칸")), | ||
HN(Set.of("온두라스")), | ||
HK(Set.of("홍콩")), | ||
HR(Set.of("크로아티아")), | ||
HU(Set.of("헝가리")), | ||
IS(Set.of("아이슬란드")), | ||
IN(Set.of("인도")), | ||
ID(Set.of("인도네시아")), | ||
IR(Set.of("이란")), | ||
IQ(Set.of("이라크")), | ||
IE(Set.of("아일랜드")), | ||
IL(Set.of("이스라엘")), | ||
IT(Set.of("이탈리아")), | ||
JM(Set.of("자메이카")), | ||
JP(Set.of("일본")), | ||
JO(Set.of("요르단")), | ||
KZ(Set.of("카자흐스탄")), | ||
KE(Set.of("케냐")), | ||
KI(Set.of("키리바시")), | ||
KP(Set.of("북한", "조선민주주의인민공화국")), | ||
KR(Set.of("대한민국", "한국")), | ||
KW(Set.of("쿠웨이트")), | ||
KG(Set.of("키르기스스탄")), | ||
LA(Set.of("라오스")), | ||
LV(Set.of("라트비아")), | ||
LB(Set.of("레바논")), | ||
LS(Set.of("레소토")), | ||
LR(Set.of("라이베리아")), | ||
LY(Set.of("리비아")), | ||
LI(Set.of("리히텐슈타인")), | ||
LT(Set.of("리투아니아")), | ||
LU(Set.of("룩셈부르크")), | ||
MO(Set.of("마카오")), | ||
MK(Set.of("북마케도니아")), | ||
MG(Set.of("마다가스카르")), | ||
MW(Set.of("말라위")), | ||
MY(Set.of("말레이시아")), | ||
MV(Set.of("몰디브")), | ||
ML(Set.of("말리")), | ||
MT(Set.of("몰타")), | ||
MH(Set.of("마셜제도")), | ||
MQ(Set.of("마르티니크")), | ||
MR(Set.of("모리타니")), | ||
MU(Set.of("모리셔스")), | ||
YT(Set.of("마요트")), | ||
MX(Set.of("멕시코")), | ||
FM(Set.of("미크로네시아")), | ||
MD(Set.of("몰도바")), | ||
MC(Set.of("모나코")), | ||
MN(Set.of("몽골")), | ||
MS(Set.of("몬트세랫")), | ||
MA(Set.of("모로코")), | ||
MZ(Set.of("모잠비크")), | ||
MM(Set.of("미얀마")), | ||
NA(Set.of("나미비아")), | ||
NR(Set.of("나우루")), | ||
NP(Set.of("네팔")), | ||
AN(Set.of("네덜란드 안틸레스")), | ||
NL(Set.of("네덜란드")), | ||
NC(Set.of("뉴칼레도니아")), | ||
NZ(Set.of("뉴질랜드")), | ||
NI(Set.of("니카라과")), | ||
NE(Set.of("니제르")), | ||
NG(Set.of("나이지리아")), | ||
NU(Set.of("니우에")), | ||
NF(Set.of("노퍽 섬")), | ||
MP(Set.of("북마리아나 제도")), | ||
NO(Set.of("노르웨이")), | ||
OM(Set.of("오만")), | ||
PK(Set.of("파키스탄")), | ||
PW(Set.of("팔라우")), | ||
PS(Set.of("팔레스타인")), | ||
PA(Set.of("파나마")), | ||
PG(Set.of("파푸아 뉴기니")), | ||
PY(Set.of("파라과이")), | ||
PE(Set.of("페루")), | ||
PH(Set.of("필리핀")), | ||
PN(Set.of("핏케언 제도")), | ||
PL(Set.of("폴란드")), | ||
PT(Set.of("포르투갈")), | ||
PR(Set.of("푸에르토리코")), | ||
QA(Set.of("카타르")), | ||
RE(Set.of("레위니옹")), | ||
RO(Set.of("루마니아")), | ||
RU(Set.of("러시아")), | ||
RW(Set.of("르완다")), | ||
SH(Set.of("세인트헬레나")), | ||
KN(Set.of("세인트키츠 네비스")), | ||
LC(Set.of("세인트루시아")), | ||
PM(Set.of("세인트피에르 미클롱")), | ||
VC(Set.of("세인트빈센트 그레나딘")), | ||
WS(Set.of("사모아")), | ||
SM(Set.of("산마리노")), | ||
ST(Set.of("상투메 프린시페")), | ||
SA(Set.of("사우디아라비아")), | ||
SN(Set.of("세네갈")), | ||
CS(Set.of("세르비아 몬테네그로")), | ||
SC(Set.of("세이셸")), | ||
SL(Set.of("시에라리온")), | ||
SG(Set.of("싱가포르")), | ||
SK(Set.of("슬로바키아")), | ||
SI(Set.of("슬로베니아")), | ||
SB(Set.of("솔로몬 제도")), | ||
SO(Set.of("소말리아")), | ||
ZA(Set.of("남아프리카 공화국", "남아공")), | ||
GS(Set.of("사우스조지아 사우스샌드위치 제도")), | ||
ES(Set.of("스페인", "에스파냐")), | ||
LK(Set.of("스리랑카")), | ||
SD(Set.of("수단")), | ||
SR(Set.of("수리남")), | ||
SJ(Set.of("스발바르 얀마웬")), | ||
SZ(Set.of("스와질란드", "에스와티니")), | ||
SE(Set.of("스웨덴")), | ||
CH(Set.of("스위스")), | ||
SY(Set.of("시리아")), | ||
TW(Set.of("대만", "타이완")), | ||
TJ(Set.of("타지키스탄")), | ||
TZ(Set.of("탄자니아")), | ||
TH(Set.of("태국")), | ||
TL(Set.of("동티모르")), | ||
TG(Set.of("토고")), | ||
TK(Set.of("토켈라우")), | ||
TO(Set.of("통가")), | ||
TT(Set.of("트리니다드 토바고")), | ||
TN(Set.of("튀니지")), | ||
TR(Set.of("터키", "튀르키예")), | ||
TM(Set.of("투르크메니스탄")), | ||
TC(Set.of("터크스 케이커스 제도")), | ||
TV(Set.of("투발루")), | ||
VI(Set.of("미국령 버진 아일랜드")), | ||
UG(Set.of("우간다")), | ||
UA(Set.of("우크라이나")), | ||
AE(Set.of("아랍에미리트")), | ||
GB(Set.of("영국")), | ||
UM(Set.of("미국령 외곽 소섬")), | ||
US(Set.of("미국")), | ||
UY(Set.of("우루과이")), | ||
UZ(Set.of("우즈베키스탄")), | ||
VU(Set.of("바누아투")), | ||
VE(Set.of("베네수엘라")), | ||
VN(Set.of("베트남")), | ||
WF(Set.of("왈리스 푸투나")), | ||
EH(Set.of("서사하라")), | ||
YE(Set.of("예멘")), | ||
ZM(Set.of("잠비아")), | ||
ZW(Set.of("짐바브웨")); | ||
|
||
private final Set<String> names; | ||
|
||
CountryCode(Set<String> names) { | ||
this.names = names; | ||
} | ||
|
||
public static CountryCode findByName(String name) { | ||
return Arrays.stream(values()) | ||
.filter(code -> code.names.contains(name)) | ||
.findFirst() | ||
.orElseThrow(() -> new BadRequestException("국가 이름을 찾을 수 없습니다.")); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
backend/src/main/java/kr/touroot/travelogue/repository/TravelogueCountryRepository.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,15 @@ | ||
package kr.touroot.travelogue.repository; | ||
|
||
import java.util.List; | ||
import kr.touroot.travelogue.domain.Travelogue; | ||
import kr.touroot.travelogue.domain.TravelogueCountry; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface TravelogueCountryRepository extends JpaRepository<TravelogueCountry, Long> { | ||
|
||
List<TravelogueCountry> findAllByTravelogue(Travelogue travelogue); | ||
|
||
void deleteAllByTravelogue(Travelogue travelogue); | ||
} |
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.