diff --git a/src/main/java/com/codingwasabi/trti/domain/location/model/Location.java b/src/main/java/com/codingwasabi/trti/domain/city/model/City.java similarity index 63% rename from src/main/java/com/codingwasabi/trti/domain/location/model/Location.java rename to src/main/java/com/codingwasabi/trti/domain/city/model/City.java index 8cbbe1c..34603e3 100644 --- a/src/main/java/com/codingwasabi/trti/domain/location/model/Location.java +++ b/src/main/java/com/codingwasabi/trti/domain/city/model/City.java @@ -1,4 +1,4 @@ -package com.codingwasabi.trti.domain.location.model; +package com.codingwasabi.trti.domain.city.model; import lombok.Getter; import lombok.NoArgsConstructor; @@ -8,17 +8,13 @@ @Entity @Getter @NoArgsConstructor -public class Location { +public class City { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Enumerated(EnumType.STRING) - private City city; - - private String latitude; - - private String longitude; + private Location location; private String information; } diff --git a/src/main/java/com/codingwasabi/trti/domain/city/model/Location.java b/src/main/java/com/codingwasabi/trti/domain/city/model/Location.java new file mode 100644 index 0000000..2e98309 --- /dev/null +++ b/src/main/java/com/codingwasabi/trti/domain/city/model/Location.java @@ -0,0 +1,35 @@ +package com.codingwasabi.trti.domain.city.model; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum Location { + SEOUL("서울특별시", "37.75768", "128.87375"), + BUSAN("부산광역시", "33.34889", "126.28097"), + JEJU("제주시", "33.43144", "126.87424"), + GWANGJU("광주광역시", "36.34831", "127.39059"), + DAEGU("대구광역시", "35.00525", "127.64877"), + ULSAN("울산광역시", "35.59360", "129.35200"), + DAEJEON("대전광역시", "35.19401", "128.10196"), + INCHEON("인천광역시", "37.43779", "126.97586"); + + private String name; + private String latitude; + private String longitude; + + public static Location parseName(String korName) { + for (Location location : Location.values()) { + if (location.toString().equals(korName)) { + return location; + } + } + + throw new IllegalArgumentException("[ERROR] 잘못된 도시 이름이 입력되었습니다."); + } + + public String toString() { + return name; + } +} diff --git a/src/main/java/com/codingwasabi/trti/domain/city/repository/CityRepository.java b/src/main/java/com/codingwasabi/trti/domain/city/repository/CityRepository.java new file mode 100644 index 0000000..8804865 --- /dev/null +++ b/src/main/java/com/codingwasabi/trti/domain/city/repository/CityRepository.java @@ -0,0 +1,11 @@ +package com.codingwasabi.trti.domain.city.repository; + +import com.codingwasabi.trti.domain.city.model.Location; +import com.codingwasabi.trti.domain.city.model.City; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface CityRepository extends JpaRepository { + Optional findByCity(Location city2); +} diff --git a/src/main/java/com/codingwasabi/trti/domain/image/response/ResponseImageDto.java b/src/main/java/com/codingwasabi/trti/domain/image/response/ResponseImageDto.java index 8ed7c1f..d7ac7cc 100644 --- a/src/main/java/com/codingwasabi/trti/domain/image/response/ResponseImageDto.java +++ b/src/main/java/com/codingwasabi/trti/domain/image/response/ResponseImageDto.java @@ -7,7 +7,7 @@ @Getter @AllArgsConstructor public class ResponseImageDto { - private String path; + private String imageUrl; public static ResponseImageDto from(PartyImage uploadedImage) { return new ResponseImageDto(uploadedImage.getPath()); diff --git a/src/main/java/com/codingwasabi/trti/domain/location/model/City.java b/src/main/java/com/codingwasabi/trti/domain/location/model/City.java deleted file mode 100644 index 1db58f3..0000000 --- a/src/main/java/com/codingwasabi/trti/domain/location/model/City.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.codingwasabi.trti.domain.location.model; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum City { - SEOUL("서울특별시"), - BUSAN("부산광역시"), - JEJU("제주특별자치구"), - GWANGJU("광주광역시"), - DAEGU("대구광역시"), - ULSAN("울산광역시"), - DAEJEON("대전광역시"), - INCHEON("인천광역시"); - - private String name; - - public static City parseName(String korName) { - for (City city : City.values()) { - if (city.toString().equals(korName)) { - return city; - } - } - - throw new IllegalArgumentException("[ERROR] 잘못된 도시 이름이 입력되었습니다."); - } - public String toString() { - return name; - } -} diff --git a/src/main/java/com/codingwasabi/trti/domain/location/repository/LocationRepository.java b/src/main/java/com/codingwasabi/trti/domain/location/repository/LocationRepository.java deleted file mode 100644 index 95dad12..0000000 --- a/src/main/java/com/codingwasabi/trti/domain/location/repository/LocationRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.codingwasabi.trti.domain.location.repository; - -import com.codingwasabi.trti.domain.location.model.City; -import com.codingwasabi.trti.domain.location.model.Location; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.Optional; - -public interface LocationRepository extends JpaRepository { - Optional findByCity(City city); -} diff --git a/src/main/java/com/codingwasabi/trti/domain/member/model/response/ResponseMyInfoDto.java b/src/main/java/com/codingwasabi/trti/domain/member/model/response/ResponseMyInfoDto.java index 6d9134c..870b582 100644 --- a/src/main/java/com/codingwasabi/trti/domain/member/model/response/ResponseMyInfoDto.java +++ b/src/main/java/com/codingwasabi/trti/domain/member/model/response/ResponseMyInfoDto.java @@ -13,7 +13,7 @@ public class ResponseMyInfoDto { private Long id; private String nickname; private String email; - private String image; + private String imageUrl; private String ageRange; private Gender gender; @@ -22,7 +22,7 @@ public static ResponseMyInfoDto getEntity(Member member) { .id(member.getId()) .nickname(member.getNickname()) .email(member.getEmail()) - .image(member.getImagePath()) + .imageUrl(member.getImagePath()) .ageRange(member.getAgeRange()) .gender(member.getGender()) .build(); diff --git a/src/main/java/com/codingwasabi/trti/domain/party/implementation/PartyController.java b/src/main/java/com/codingwasabi/trti/domain/party/implementation/PartyController.java index e6d63a2..44edd25 100644 --- a/src/main/java/com/codingwasabi/trti/domain/party/implementation/PartyController.java +++ b/src/main/java/com/codingwasabi/trti/domain/party/implementation/PartyController.java @@ -14,7 +14,7 @@ @RestController @RequiredArgsConstructor -@RequestMapping("/group") +@RequestMapping("/party") public class PartyController implements PartyAPI { private final PartyService partyService; diff --git a/src/main/java/com/codingwasabi/trti/domain/party/implementation/PartyServiceImpl.java b/src/main/java/com/codingwasabi/trti/domain/party/implementation/PartyServiceImpl.java index 3f95dda..2315796 100644 --- a/src/main/java/com/codingwasabi/trti/domain/party/implementation/PartyServiceImpl.java +++ b/src/main/java/com/codingwasabi/trti/domain/party/implementation/PartyServiceImpl.java @@ -1,7 +1,7 @@ package com.codingwasabi.trti.domain.party.implementation; -import com.codingwasabi.trti.domain.location.model.City; -import com.codingwasabi.trti.domain.location.repository.LocationRepository; +import com.codingwasabi.trti.domain.city.model.Location; +import com.codingwasabi.trti.domain.city.repository.CityRepository; import com.codingwasabi.trti.domain.member.model.entity.Member; import com.codingwasabi.trti.domain.member.repository.MemberRepository; import com.codingwasabi.trti.domain.memberInParty.model.MemberInParty; @@ -23,7 +23,7 @@ public class PartyServiceImpl implements PartyService { private final PartyRepository partyRepository; private final MemberInPartyRepository memberInPartyRepository; private final MemberRepository memberRepository; - private final LocationRepository locationRepository; + private final CityRepository locationRepository; @Override @Transactional @@ -44,9 +44,9 @@ private void setPartyCaptain(Member member, Party party) { } private void setPartyCity(RequestCreatePartyDto requestDto, Party party) { - City.parseName(requestDto.getLocation()); + Location.parseName(requestDto.getLocation()); party.setLocation(locationRepository - .findByCity(City.parseName(requestDto.getLocation())) + .findByCity(Location.parseName(requestDto.getLocation())) .orElseThrow(() -> new IllegalArgumentException("[ERROR] 도시의 정보가 존재하지 않습니다."))); } diff --git a/src/main/java/com/codingwasabi/trti/domain/party/model/Party.java b/src/main/java/com/codingwasabi/trti/domain/party/model/Party.java index ffc06b8..0f2c9bd 100644 --- a/src/main/java/com/codingwasabi/trti/domain/party/model/Party.java +++ b/src/main/java/com/codingwasabi/trti/domain/party/model/Party.java @@ -1,7 +1,7 @@ package com.codingwasabi.trti.domain.party.model; import com.codingwasabi.trti.domain.common.Period; -import com.codingwasabi.trti.domain.location.model.Location; +import com.codingwasabi.trti.domain.city.model.City; import com.codingwasabi.trti.domain.member.model.entity.Member; import lombok.AllArgsConstructor; import lombok.Builder; @@ -10,7 +10,6 @@ import javax.persistence.*; import java.time.LocalDate; -import java.util.Optional; @Entity @Getter @@ -36,7 +35,7 @@ public class Party extends Period { private Member captain; @ManyToOne(fetch = FetchType.LAZY) - private Location location; + private City location; public void setCaptain(Member member) { // Error code @@ -47,7 +46,7 @@ public void setCaptain(Member member) { this.captain = member; } - public void setLocation(Location city) { + public void setLocation(City city) { this.location = city; } } diff --git a/src/main/java/com/codingwasabi/trti/domain/party/model/request/RequestCreatePartyDto.java b/src/main/java/com/codingwasabi/trti/domain/party/model/request/RequestCreatePartyDto.java index 05985f5..5671a0e 100644 --- a/src/main/java/com/codingwasabi/trti/domain/party/model/request/RequestCreatePartyDto.java +++ b/src/main/java/com/codingwasabi/trti/domain/party/model/request/RequestCreatePartyDto.java @@ -1,8 +1,6 @@ package com.codingwasabi.trti.domain.party.model.request; -import com.codingwasabi.trti.domain.location.model.Location; import com.codingwasabi.trti.domain.party.model.Party; -import jdk.javadoc.doclet.Taglet; import lombok.AllArgsConstructor; import lombok.Getter; @@ -13,7 +11,7 @@ @AllArgsConstructor public class RequestCreatePartyDto { private String title; - private String image; + private String imageUrl; private String location; private List members; private String[] period; @@ -21,7 +19,7 @@ public class RequestCreatePartyDto { public Party getEntityFrom() { return Party.builder() .title(title) - .imageLink(image) + .imageLink(imageUrl) .startDate(LocalDate.parse(period[0])) .endDate(LocalDate.parse(period[1])) .build();