-
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.
Merge pull request #10 from SOPT-all/feat/8
[FEAT] 장소 중복 검사, Entity 구조 변경
- Loading branch information
Showing
27 changed files
with
392 additions
and
33 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
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
4 changes: 4 additions & 0 deletions
4
src/main/java/com/spoony/spoony_server/domain/place/dto/request/PlaceCheckRequestDTO.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,4 @@ | ||
package com.spoony.spoony_server.domain.place.dto.request; | ||
|
||
public record PlaceCheckRequestDTO(long userId, Double latitude, Double longitude) { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/com/spoony/spoony_server/domain/place/dto/request/PlaceCheckResponseDTO.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,4 @@ | ||
package com.spoony.spoony_server.domain.place.dto.request; | ||
|
||
public record PlaceCheckResponseDTO(Boolean duplicate) { | ||
} |
2 changes: 1 addition & 1 deletion
2
...omain/place/dto/PlaceListResponseDTO.java → ...ce/dto/response/PlaceListResponseDTO.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
6 changes: 3 additions & 3 deletions
6
...er/domain/place/dto/PlaceResponseDTO.java → .../place/dto/response/PlaceResponseDTO.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,8 +1,8 @@ | ||
package com.spoony.spoony_server.domain.place.dto; | ||
package com.spoony.spoony_server.domain.place.dto.response; | ||
|
||
public record PlaceResponseDTO(String placeName, | ||
String placeAddress, | ||
String placeRoadAddress, | ||
String latitude, | ||
String longitude) { | ||
Double latitude, | ||
Double longitude) { | ||
} |
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
10 changes: 10 additions & 0 deletions
10
src/main/java/com/spoony/spoony_server/domain/place/repository/PlaceRepository.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.spoony.spoony_server.domain.place.repository; | ||
|
||
import com.spoony.spoony_server.domain.place.entity.PlaceEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface PlaceRepository extends JpaRepository<PlaceEntity, Long> { | ||
boolean existsByPlaceIdInAndLatitudeAndLongitude(List<Integer> placeIds, Double latitude, Double longitude); | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/spoony/spoony_server/domain/place/service/PlaceService.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.spoony.spoony_server.domain.place.service; | ||
|
||
import com.spoony.spoony_server.domain.place.dto.request.PlaceCheckRequestDTO; | ||
import com.spoony.spoony_server.domain.place.repository.PlaceRepository; | ||
import com.spoony.spoony_server.domain.post.entity.PostEntity; | ||
import com.spoony.spoony_server.domain.post.repository.PostRepository; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
public class PlaceService { | ||
|
||
public final PlaceRepository placeRepository; | ||
public final PostRepository postRepository; | ||
|
||
public PlaceService(PlaceRepository placeRepository, PostRepository postRepository) { | ||
this.placeRepository = placeRepository; | ||
this.postRepository = postRepository; | ||
} | ||
|
||
public Boolean isDuplicate(PlaceCheckRequestDTO placeCheckRequestDTO) { | ||
Long userId = placeCheckRequestDTO.userId(); | ||
Double latitude = placeCheckRequestDTO.latitude(); | ||
Double longitude = placeCheckRequestDTO.longitude(); | ||
|
||
List<PostEntity> userPosts = postRepository.findByUser_UserId(userId); | ||
|
||
List<Integer> placeIds = userPosts.stream() | ||
.map(post -> post.getPlace().getPlaceId()) | ||
.toList(); | ||
|
||
boolean exists = placeRepository.existsByPlaceIdInAndLatitudeAndLongitude(placeIds, latitude, longitude); | ||
|
||
return exists; | ||
} | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
src/main/java/com/spoony/spoony_server/domain/post/entity/CategoryEntity.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,12 +1,22 @@ | ||
package com.spoony.spoony_server.domain.post.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Table(name = "category") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class CategoryEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer categoryId; | ||
private String categoryName; | ||
|
||
@Builder | ||
public CategoryEntity(Integer categoryId, String categoryName) { | ||
this.categoryId = categoryId; | ||
this.categoryName = categoryName; | ||
} | ||
} |
22 changes: 20 additions & 2 deletions
22
src/main/java/com/spoony/spoony_server/domain/post/entity/FeedEntity.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,13 +1,31 @@ | ||
package com.spoony.spoony_server.domain.post.entity; | ||
|
||
import com.spoony.spoony_server.domain.user.entity.UserEntity; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Table(name = "feed") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class FeedEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer feedId; | ||
private Integer userId; | ||
private Integer postId; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private UserEntity user; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "post_id") | ||
private PostEntity post; | ||
|
||
@Builder | ||
public FeedEntity(Integer feedId, UserEntity user, PostEntity post) { | ||
this.feedId = feedId; | ||
this.user = user; | ||
this.post = post; | ||
} | ||
} |
17 changes: 16 additions & 1 deletion
17
src/main/java/com/spoony/spoony_server/domain/post/entity/MenuEntity.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,13 +1,28 @@ | ||
package com.spoony.spoony_server.domain.post.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Table(name = "menu") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class MenuEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer menuId; | ||
private Integer postId; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "post_id") | ||
private PostEntity post; | ||
|
||
private String menuName; | ||
|
||
@Builder | ||
public MenuEntity(Integer menuId, PostEntity post, String menuName) { | ||
this.menuId = menuId; | ||
this.post = post; | ||
this.menuName = menuName; | ||
} | ||
} |
17 changes: 16 additions & 1 deletion
17
src/main/java/com/spoony/spoony_server/domain/post/entity/PhotoEntity.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,13 +1,28 @@ | ||
package com.spoony.spoony_server.domain.post.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Table(name = "photo") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class PhotoEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer photoId; | ||
private Integer postId; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "post_id") | ||
private PostEntity post; | ||
|
||
private String photoUrl; | ||
|
||
@Builder | ||
public PhotoEntity(Integer photoId, PostEntity post, String photoUrl) { | ||
this.photoId = photoId; | ||
this.post = post; | ||
this.photoUrl = photoUrl; | ||
} | ||
} |
Oops, something went wrong.