Skip to content

Commit

Permalink
Merge pull request #23 from CodingWasabi/refactoring/api
Browse files Browse the repository at this point in the history
🌪️[REF]-#22-변수명 및 API 변경 관련 리팩토링
  • Loading branch information
daehwan2yo authored Dec 28, 2021
2 parents 44de9cf + e3eacfc commit a069173
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.codingwasabi.trti.domain.location.model;
package com.codingwasabi.trti.domain.city.model;

import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<City, Long> {
Optional<City> findByCity(Location city2);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@RestController
@RequiredArgsConstructor
@RequestMapping("/group")
@RequestMapping("/party")
public class PartyController implements PartyAPI {
private final PartyService partyService;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -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] 도시의 정보가 존재하지 않습니다.")));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,7 +10,6 @@

import javax.persistence.*;
import java.time.LocalDate;
import java.util.Optional;

@Entity
@Getter
Expand All @@ -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
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -13,15 +11,15 @@
@AllArgsConstructor
public class RequestCreatePartyDto {
private String title;
private String image;
private String imageUrl;
private String location;
private List<Long> members;
private String[] period;

public Party getEntityFrom() {
return Party.builder()
.title(title)
.imageLink(image)
.imageLink(imageUrl)
.startDate(LocalDate.parse(period[0]))
.endDate(LocalDate.parse(period[1]))
.build();
Expand Down

0 comments on commit a069173

Please sign in to comment.