-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
20 changed files
with
627 additions
and
620 deletions.
There are no files selected for viewing
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
26 changes: 15 additions & 11 deletions
26
src/main/java/com/ajou/hertz/common/dto/request/CoordinateRequest.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,26 +1,30 @@ | ||
package com.ajou.hertz.common.dto.request; | ||
|
||
import com.ajou.hertz.common.entity.Coordinate; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.*; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Setter | ||
@Getter | ||
public class CoordinateRequest { | ||
|
||
@Schema(description = "위도", example = "37.123456") | ||
@NotBlank | ||
private String lat; | ||
|
||
@Schema(description = "경도", example = "127.123456") | ||
@NotBlank | ||
private String lng; | ||
@Schema(description = "위도", example = "37.123456") | ||
@NotBlank | ||
private String lat; | ||
|
||
@Schema(description = "경도", example = "127.123456") | ||
@NotBlank | ||
private String lng; | ||
|
||
public Coordinate toEntity() { | ||
return new Coordinate(lat, lng); | ||
} | ||
public Coordinate toEntity() { | ||
return new Coordinate(lat, lng); | ||
} | ||
} |
25 changes: 15 additions & 10 deletions
25
src/main/java/com/ajou/hertz/common/dto/request/FullAddressRequest.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,25 +1,30 @@ | ||
package com.ajou.hertz.common.dto.request; | ||
|
||
import com.ajou.hertz.common.entity.FullAddress; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.*; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Setter | ||
@Getter | ||
public class FullAddressRequest { | ||
|
||
@Schema(description = "전체 주소", example = "서울특별시 강남구 역삼동 123-45") | ||
@NotBlank | ||
private String fullAddress; | ||
@Schema(description = "전체 주소", example = "서울특별시 강남구 역삼동 123-45") | ||
@NotBlank | ||
private String fullAddress; | ||
|
||
@Schema(description = "상세주소", example = "아주 빌딩 2층") | ||
@NotBlank | ||
private String detailAddress; | ||
@Schema(description = "상세주소", example = "아주 빌딩 2층") | ||
@NotBlank | ||
private String detailAddress; | ||
|
||
public FullAddress toEntity() { | ||
return FullAddress.of(fullAddress, detailAddress); | ||
} | ||
public FullAddress toEntity() { | ||
return FullAddress.of(fullAddress, detailAddress); | ||
} | ||
} |
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
73 changes: 37 additions & 36 deletions
73
src/main/java/com/ajou/hertz/common/entity/FullAddress.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,66 +1,67 @@ | ||
package com.ajou.hertz.common.entity; | ||
|
||
import java.util.Arrays; | ||
|
||
import com.ajou.hertz.common.exception.InvalidAddressFormatException; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.Arrays; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Embeddable | ||
public class FullAddress { | ||
|
||
@Column(nullable = false) | ||
private String sido; | ||
@Column(nullable = false) | ||
private String sido; | ||
|
||
@Column(nullable = false) | ||
private String sgg; | ||
@Column(nullable = false) | ||
private String sgg; | ||
|
||
private String lotNumberAddress; | ||
private String lotNumberAddress; | ||
|
||
private String roadAddress; | ||
private String roadAddress; | ||
|
||
@Column(nullable = false) | ||
private String detailAddress; | ||
@Column(nullable = false) | ||
private String detailAddress; | ||
|
||
public static FullAddress of(String fullAddress, String detailAddress) { | ||
public static FullAddress of(String fullAddress, String detailAddress) { | ||
|
||
String[] parsedAddress = fullAddress.split(" "); | ||
String[] parsedAddress = fullAddress.split(" "); | ||
|
||
if (parsedAddress.length < 2) { | ||
throw new InvalidAddressFormatException(fullAddress); | ||
if (parsedAddress.length < 2) { | ||
throw new InvalidAddressFormatException(fullAddress); | ||
|
||
} | ||
} | ||
|
||
String sido = parsedAddress[0]; | ||
StringBuilder sggBuilder = new StringBuilder(); | ||
String lotNumberAddress = null; | ||
String roadAddress = null; | ||
String sido = parsedAddress[0]; | ||
StringBuilder sggBuilder = new StringBuilder(); | ||
String lotNumberAddress = null; | ||
String roadAddress = null; | ||
|
||
int num; | ||
for (num = 1; num < parsedAddress.length; num++) { | ||
if (parsedAddress[num].matches(".*[동면읍소로길]$")) { | ||
break; | ||
} | ||
sggBuilder.append(parsedAddress[num]).append(" "); | ||
} | ||
int num; | ||
for (num = 1; num < parsedAddress.length; num++) { | ||
if (parsedAddress[num].matches(".*[동면읍소로길]$")) { | ||
break; | ||
} | ||
sggBuilder.append(parsedAddress[num]).append(" "); | ||
} | ||
|
||
String sgg = sggBuilder.toString().trim(); | ||
String sgg = sggBuilder.toString().trim(); | ||
|
||
if (parsedAddress.length > num) { | ||
if (fullAddress.matches(".+[로길].+")) { | ||
roadAddress = String.join(" ", Arrays.copyOfRange(parsedAddress, num, parsedAddress.length)); | ||
} else { | ||
lotNumberAddress = String.join(" ", Arrays.copyOfRange(parsedAddress, num, parsedAddress.length)); | ||
} | ||
} | ||
if (parsedAddress.length > num) { | ||
if (fullAddress.matches(".+[로길].+")) { | ||
roadAddress = String.join(" ", Arrays.copyOfRange(parsedAddress, num, parsedAddress.length)); | ||
} else { | ||
lotNumberAddress = String.join(" ", Arrays.copyOfRange(parsedAddress, num, parsedAddress.length)); | ||
} | ||
} | ||
|
||
return new FullAddress(sido, sgg, lotNumberAddress, roadAddress, detailAddress); | ||
} | ||
return new FullAddress(sido, sgg, lotNumberAddress, roadAddress, detailAddress); | ||
} | ||
} |
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.