-
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.
Browse files
Browse the repository at this point in the history
공연장 entity 구현
- Loading branch information
Showing
13 changed files
with
424 additions
and
0 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
22 changes: 22 additions & 0 deletions
22
src/main/java/com/ajou/hertz/common/entity/Coordinate.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,22 @@ | ||
package com.ajou.hertz.common.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
@Embeddable | ||
public class Coordinate { | ||
|
||
@Column(nullable = false) | ||
private String lat; | ||
|
||
@Column(nullable = false) | ||
private String lng; | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Embeddable | ||
public class FullAddress { | ||
|
||
@Column(nullable = false) | ||
private String sido; | ||
|
||
@Column(nullable = false) | ||
private String sgg; | ||
|
||
private String lotNumberAddress; | ||
|
||
private String roadAddress; | ||
|
||
@Column(nullable = false) | ||
private String detailAddress; | ||
|
||
public static FullAddress of(String fullAddress, String detailAddress) { | ||
|
||
String[] parsedAddress = fullAddress.split(" "); | ||
|
||
if (parsedAddress.length < 2) { | ||
throw new InvalidAddressFormatException(fullAddress); | ||
|
||
} | ||
|
||
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(" "); | ||
} | ||
|
||
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)); | ||
} | ||
} | ||
|
||
return new FullAddress(sido, sgg, lotNumberAddress, roadAddress, detailAddress); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/ajou/hertz/common/exception/InvalidAddressFormatException.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,9 @@ | ||
package com.ajou.hertz.common.exception; | ||
|
||
import com.ajou.hertz.common.exception.constant.CustomExceptionType; | ||
|
||
public class InvalidAddressFormatException extends BadRequestException { | ||
public InvalidAddressFormatException(String address) { | ||
super(CustomExceptionType.INVALID_ADDRESS_FORMAT, "address=" + address); | ||
} | ||
} |
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
src/main/java/com/ajou/hertz/domain/concert_hall/constant/ConcertHallProgressStatus.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 com.ajou.hertz.domain.concert_hall.constant; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
public enum ConcertHallProgressStatus { | ||
|
||
SELLING("판매중"), | ||
RESERVED("예약중"), | ||
SOLD_OUT("판매 완료"); | ||
|
||
private final String description; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/ajou/hertz/domain/concert_hall/dto/ConcertHallImageDto.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,25 @@ | ||
package com.ajou.hertz.domain.concert_hall.dto; | ||
|
||
import com.ajou.hertz.domain.concert_hall.entity.ConcertHallImage; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
public class ConcertHallImageDto { | ||
private Long id; | ||
private String name; | ||
private String url; | ||
|
||
public static ConcertHallImageDto from(ConcertHallImage concertHallImage) { | ||
return new ConcertHallImageDto( | ||
concertHallImage.getId(), | ||
concertHallImage.getOriginalName(), | ||
concertHallImage.getUrl() | ||
); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
src/main/java/com/ajou/hertz/domain/concert_hall/entity/ConcertHall.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,87 @@ | ||
package com.ajou.hertz.domain.concert_hall.entity; | ||
|
||
import com.ajou.hertz.common.entity.Coordinate; | ||
import com.ajou.hertz.common.entity.FullAddress; | ||
import com.ajou.hertz.common.entity.TimeTrackedBaseEntity; | ||
import com.ajou.hertz.domain.concert_hall.constant.ConcertHallProgressStatus; | ||
import com.ajou.hertz.domain.user.entity.User; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embedded; | ||
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 lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Entity | ||
public class ConcertHall extends TimeTrackedBaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "concert_hall_id", nullable = false) | ||
private Long id; | ||
|
||
@JoinColumn(name = "seller_id", nullable = false) | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private User seller; | ||
|
||
@Column(nullable = false) | ||
private String title; | ||
|
||
@Column(nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
private ConcertHallProgressStatus progressStatus; | ||
|
||
@Column(nullable = false) | ||
@Embedded | ||
private FullAddress fullAddress; | ||
|
||
@Column(nullable = false) | ||
private Boolean hasSoundEquipment; | ||
|
||
@Column(nullable = false) | ||
private Boolean hasStaff; | ||
|
||
@Column(nullable = false) | ||
private Boolean hasAdditionalSpace; | ||
|
||
@Column(nullable = false) | ||
private Integer pricePerDay; | ||
|
||
@Column(nullable = false) | ||
private Integer pricePerHour; | ||
|
||
@Column(nullable = false) | ||
private Short capacity; | ||
|
||
@Column(nullable = false) | ||
private String size; | ||
|
||
@Column(nullable = false) | ||
private Boolean hasParkingLot; | ||
|
||
@Column(length = 1000, nullable = false) | ||
private String description; | ||
|
||
@Embedded | ||
private Coordinate coordinate; | ||
|
||
@Embedded | ||
private ConcertHallImages images = new ConcertHallImages(); | ||
|
||
@Embedded | ||
private ConcertHallHashtags hashtags = new ConcertHallHashtags(); | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/ajou/hertz/domain/concert_hall/entity/ConcertHallHashtag.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,39 @@ | ||
package com.ajou.hertz.domain.concert_hall.entity; | ||
|
||
import com.ajou.hertz.common.entity.BaseEntity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
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 lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Entity | ||
public class ConcertHallHashtag extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "concert_hall_hashtag_id", nullable = false) | ||
private Long id; | ||
|
||
@JoinColumn(name = "concert_hall_id", nullable = false) | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private ConcertHall concertHall; | ||
|
||
@Column(length = 10, nullable = false) | ||
private String content; | ||
|
||
public static ConcertHallHashtag create(ConcertHall concertHall, String content) { | ||
return new ConcertHallHashtag(null, concertHall, content); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/ajou/hertz/domain/concert_hall/entity/ConcertHallHashtags.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.ajou.hertz.domain.concert_hall.entity; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import jakarta.persistence.Embeddable; | ||
import jakarta.persistence.OneToMany; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Embeddable | ||
public class ConcertHallHashtags { | ||
|
||
@OneToMany(mappedBy = "concertHall") | ||
private List<ConcertHallHashtag> content = new LinkedList<>(); | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/ajou/hertz/domain/concert_hall/entity/ConcertHallImage.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,46 @@ | ||
package com.ajou.hertz.domain.concert_hall.entity; | ||
|
||
import com.ajou.hertz.common.entity.FileEntity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
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 lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Entity | ||
public class ConcertHallImage extends FileEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "concert_hall_image_id", nullable = false) | ||
private Long id; | ||
|
||
@JoinColumn(name = "concert_hall", nullable = false) | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private ConcertHall concertHall; | ||
|
||
private ConcertHallImage(Long id, ConcertHall concertHall, String originalName, String storedName, String url) { | ||
super(originalName, storedName, url); | ||
this.id = id; | ||
this.concertHall = concertHall; | ||
} | ||
|
||
public static ConcertHallImage create(ConcertHall concertHall, String originalName, String storedName, String url) { | ||
return new ConcertHallImage( | ||
null, | ||
concertHall, | ||
originalName, | ||
storedName, | ||
url | ||
); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/ajou/hertz/domain/concert_hall/entity/ConcertHallImages.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,19 @@ | ||
package com.ajou.hertz.domain.concert_hall.entity; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import jakarta.persistence.Embeddable; | ||
import jakarta.persistence.OneToMany; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Embeddable | ||
public class ConcertHallImages { | ||
@OneToMany(mappedBy = "concertHall") | ||
private List<ConcertHallImage> content = new LinkedList<>(); | ||
|
||
} |
Oops, something went wrong.