-
Notifications
You must be signed in to change notification settings - Fork 0
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
13 changed files
with
384 additions
and
3 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
38 changes: 38 additions & 0 deletions
38
src/main/java/com/dnd/dndtravel/map/controller/request/RecordRequest.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,38 @@ | ||
package com.dnd.dndtravel.map.controller.request; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import com.dnd.dndtravel.map.dto.RecordDto; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Pattern; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public record RecordRequest( | ||
String region, | ||
|
||
@NotBlank(message = "명소 이름은 필수 입력 사항입니다.") | ||
@Pattern(regexp = "^[가-힣]+$", message = "명소 이름은 한글만 입력 가능합니다.") | ||
@Size(max = 50, message = "명소 이름은 50자 이내여야 합니다.") | ||
String attractionName, | ||
|
||
@Size(max = 25, message = "메모는 25자 이내여야 합니다.") | ||
String memo, | ||
|
||
@NotNull(message = "날짜는 필수 입력 사항입니다.") | ||
LocalDate localDate | ||
) { | ||
public RecordDto toDto(List<MultipartFile> photos) { | ||
return RecordDto.builder() | ||
.region(this.region) | ||
.attractionName(this.attractionName) | ||
.photos(photos) | ||
.memo(this.memo) | ||
.dateTime(this.localDate) | ||
.build(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/dnd/dndtravel/map/domain/Attraction.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.dnd.dndtravel.map.domain; | ||
|
||
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.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
public class Attraction { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "region_id") | ||
private Region region; | ||
|
||
private String name; // 명소 이름 | ||
|
||
@Builder | ||
private Attraction(Region region, String name) { | ||
this.region = region; | ||
this.name = name; | ||
} | ||
|
||
public static Attraction of(Region region, String attraction) { | ||
return new Attraction(region, attraction); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/com/dnd/dndtravel/map/domain/MemberAttraction.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,69 @@ | ||
package com.dnd.dndtravel.map.domain; | ||
|
||
import java.time.LocalDate; | ||
|
||
import com.dnd.dndtravel.member.domain.Member; | ||
|
||
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.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
public class MemberAttraction { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "attraction_id") | ||
private Attraction attraction; | ||
|
||
private String memo; // 방문기록 메모 | ||
private LocalDate localDate; // 방문 날짜 | ||
private String region; // 지역 | ||
private int photosCount; // 사진 개수, 필요한가? | ||
|
||
@Builder | ||
private MemberAttraction(Member member, Attraction attraction, String memo, LocalDate localDate, String region, | ||
int photosCount) { | ||
this.member = member; | ||
this.attraction = attraction; | ||
this.memo = memo; | ||
this.localDate = localDate; | ||
this.region = region; | ||
this.photosCount = photosCount; | ||
} | ||
|
||
public static MemberAttraction of(Member member, Attraction attraction, String memo, LocalDate localDate, | ||
String region) { | ||
return MemberAttraction.builder() | ||
.member(member) | ||
.attraction(attraction) | ||
.memo(memo) | ||
.localDate(localDate) | ||
.region(region) | ||
.build(); | ||
} | ||
|
||
public void update(String region, String attraction, String memo, LocalDate localDate) { | ||
this.region = region; | ||
// this.attraction = attraction; | ||
this.memo = memo; | ||
this.localDate = localDate; | ||
} | ||
} |
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,37 @@ | ||
package com.dnd.dndtravel.map.domain; | ||
|
||
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; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
public class Photo { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "memberAttraction_id") | ||
private MemberAttraction memberAttraction; | ||
|
||
private String url; | ||
|
||
private Photo(MemberAttraction memberAttraction, String url) { | ||
this.memberAttraction = memberAttraction; | ||
this.url = url; | ||
} | ||
|
||
public static Photo of(MemberAttraction memberAttraction, String imageUrl) { | ||
return new Photo(memberAttraction, imageUrl); | ||
} | ||
} |
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.dnd.dndtravel.map.dto; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import lombok.Builder; | ||
/** | ||
* | ||
*/ | ||
@Builder | ||
public record RecordDto( | ||
String region, | ||
String attractionName, | ||
List<MultipartFile> photos, | ||
String memo, | ||
LocalDate dateTime | ||
) { | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/dnd/dndtravel/map/repository/AttractionRepository.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,10 @@ | ||
package com.dnd.dndtravel.map.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.dnd.dndtravel.map.domain.Attraction; | ||
|
||
public interface AttractionRepository extends JpaRepository<Attraction, Long> { | ||
|
||
Attraction findByName(String name); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/dnd/dndtravel/map/repository/MemberAttractionRepository.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,8 @@ | ||
package com.dnd.dndtravel.map.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.dnd.dndtravel.map.domain.MemberAttraction; | ||
|
||
public interface MemberAttractionRepository extends JpaRepository<MemberAttraction, Long> { | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/dnd/dndtravel/map/repository/PhotoRepository.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.dnd.dndtravel.map.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.dnd.dndtravel.map.domain.Photo; | ||
|
||
public interface PhotoRepository extends JpaRepository<Photo, Long> { | ||
|
||
} |
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.