-
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.
Merge pull request #16 from TeamUStory/feat/recommend
feat: recommend, rename: like에서 great
- Loading branch information
Showing
31 changed files
with
668 additions
and
157 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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/elice/ustory/domain/address/AddressQueryDslRepository.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,13 @@ | ||
package com.elice.ustory.domain.address; | ||
|
||
import com.elice.ustory.domain.recommand.dto.RecommendCountDTO; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
public interface AddressQueryDslRepository { | ||
|
||
List<RecommendCountDTO> countEqualAddress(); | ||
List<RecommendCountDTO> countEqualAddress(Pageable pageable, LocalDateTime requestTime); | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/com/elice/ustory/domain/address/AddressQueryDslRepositoryImpl.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,58 @@ | ||
package com.elice.ustory.domain.address; | ||
|
||
import com.elice.ustory.domain.recommand.dto.RecommendCountDTO; | ||
import com.querydsl.core.types.Projections; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import static com.elice.ustory.domain.address.QAddress.address; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class AddressQueryDslRepositoryImpl implements AddressQueryDslRepository { | ||
|
||
private final JPAQueryFactory jpaQueryFactory; | ||
|
||
@Override | ||
public List<RecommendCountDTO> countEqualAddress() { | ||
|
||
return jpaQueryFactory | ||
.select(Projections.constructor(RecommendCountDTO.class, | ||
address.store, | ||
address.city, | ||
address.coordinateX, | ||
address.coordinateY, | ||
address.id.count() | ||
)) | ||
.from(address) | ||
.groupBy(address.store, address.city, address.coordinateX, address.coordinateY) | ||
.orderBy(address.id.count().desc()) | ||
.fetch(); | ||
} | ||
|
||
@Override | ||
public List<RecommendCountDTO> countEqualAddress(Pageable pageable, LocalDateTime requestTime) { | ||
|
||
return jpaQueryFactory | ||
.select(Projections.constructor(RecommendCountDTO.class, | ||
address.store, | ||
address.city, | ||
address.coordinateX, | ||
address.coordinateY, | ||
address.id.count() | ||
)) | ||
.from(address) | ||
.where(address.createdAt.loe(requestTime)) | ||
.groupBy(address.store, address.city, address.coordinateX, address.coordinateY) | ||
.orderBy(address.id.count().desc()) | ||
.offset(pageable.getOffset()) | ||
.limit(pageable.getPageSize()) | ||
.fetch(); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/elice/ustory/domain/address/AddressRecommendDTO.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,24 @@ | ||
package com.elice.ustory.domain.address; | ||
|
||
import com.elice.ustory.domain.recommand.dto.RecommendCountDTO; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AddressRecommendDTO { | ||
|
||
private String store; | ||
private String city; | ||
private Double coordinateX; | ||
private Double coordinateY; | ||
|
||
public AddressRecommendDTO(RecommendCountDTO recommendCountDTO) { | ||
this.store = recommendCountDTO.getStore(); | ||
this.city = recommendCountDTO.getCity(); | ||
this.coordinateX = recommendCountDTO.getCoordinateX(); | ||
this.coordinateY = recommendCountDTO.getCoordinateY(); | ||
} | ||
} |
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
Oops, something went wrong.