-
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.
* MemberAttraction 과 attraction 둘다 가지고있던 명소명을 Attraction에만 가지게끔 설계변경. * 불필요하게 Wrapper 타입으로 설정되어있던 memberId 파라미터를 원시타입으로 변경
- Loading branch information
Showing
9 changed files
with
87 additions
and
66 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
7 changes: 6 additions & 1 deletion
7
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 |
---|---|---|
@@ -1,9 +1,14 @@ | ||
package com.dnd.dndtravel.map.repository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.dnd.dndtravel.map.domain.Photo; | ||
import com.dnd.dndtravel.map.repository.custom.PhotoRepositoryCustom; | ||
|
||
public interface PhotoRepository extends JpaRepository<Photo, Long> { | ||
public interface PhotoRepository extends JpaRepository<Photo, Long>, PhotoRepositoryCustom { | ||
|
||
List<Photo> findByMemberAttractionId(Long id); | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/dnd/dndtravel/map/repository/custom/PhotoRepositoryCustom.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,11 @@ | ||
package com.dnd.dndtravel.map.repository.custom; | ||
|
||
import java.util.List; | ||
|
||
import com.dnd.dndtravel.map.repository.dto.projection.AttractionPhotoProjection; | ||
import com.dnd.dndtravel.map.repository.dto.projection.RecordProjection; | ||
|
||
public interface PhotoRepositoryCustom { | ||
|
||
List<AttractionPhotoProjection> findByRecordDtos(List<RecordProjection> dtos); | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/dnd/dndtravel/map/repository/custom/PhotoRepositoryImpl.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,35 @@ | ||
package com.dnd.dndtravel.map.repository.custom; | ||
|
||
import static com.dnd.dndtravel.map.domain.QMemberAttraction.memberAttraction; | ||
import static com.dnd.dndtravel.map.domain.QPhoto.photo; | ||
|
||
import java.util.List; | ||
|
||
import com.dnd.dndtravel.map.repository.dto.projection.AttractionPhotoProjection; | ||
import com.dnd.dndtravel.map.repository.dto.projection.RecordProjection; | ||
import com.querydsl.core.types.Projections; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class PhotoRepositoryImpl implements PhotoRepositoryCustom { | ||
|
||
private final JPAQueryFactory jpaQueryFactory; | ||
|
||
@Override | ||
public List<AttractionPhotoProjection> findByRecordDtos(List<RecordProjection> recordDtos) { | ||
List<Long> memberAttractionIds = recordDtos.stream() | ||
.map(RecordProjection::getMemberAttractionId) | ||
.toList(); | ||
|
||
return jpaQueryFactory.select( | ||
Projections.constructor(AttractionPhotoProjection.class, | ||
memberAttraction.id, | ||
photo.url)) | ||
.from(photo) | ||
.join(photo.memberAttraction, memberAttraction) | ||
.where(photo.memberAttraction.id.in(memberAttractionIds)) | ||
.fetch(); | ||
} | ||
} |
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