-
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.
Showing
17 changed files
with
334 additions
and
210 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
19 changes: 19 additions & 0 deletions
19
...mongo/src/main/java/com/heachi/mongo/define/notify/repository/NotifyRepositoryCustom.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.heachi.mongo.define.notify.repository; | ||
|
||
import com.heachi.mongo.define.notify.Notify; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
|
||
public interface NotifyRepositoryCustom { | ||
|
||
/** | ||
* userId가 받는 알림을 페이징한다. (ReceiveUserIds In userId) | ||
*/ | ||
public Flux<Notify> findNotifyByReceiveUserIdsPaging(String userId, int page); | ||
|
||
/** | ||
* notifyId로 notify를 검색하는데, userId가 recevierUserIds에 존재하는지 | ||
*/ | ||
public Mono<Notify> findNotifyByIdWhereReceiveUserIdsIn(String userId, String notifyId); | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
...n-mongo/src/main/java/com/heachi/mongo/define/notify/repository/NotifyRepositoryImpl.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,41 @@ | ||
package com.heachi.mongo.define.notify.repository; | ||
|
||
import com.heachi.mongo.define.notify.Notify; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.data.mongodb.core.ReactiveMongoTemplate; | ||
import org.springframework.data.mongodb.core.query.Criteria; | ||
import org.springframework.data.mongodb.core.query.Query; | ||
import org.springframework.stereotype.Component; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class NotifyRepositoryImpl implements NotifyRepositoryCustom { | ||
|
||
private final ReactiveMongoTemplate mongoTemplate; | ||
|
||
@Override | ||
public Flux<Notify> findNotifyByReceiveUserIdsPaging(String userId, int page) { | ||
return Mono.just(PageRequest.of(page, 10, Sort.by("createdTime").descending())) | ||
.map(pageable -> { | ||
Query query = new Query() | ||
.with(pageable); | ||
query.addCriteria(Criteria.where("receiveUserIds").in(userId)); | ||
|
||
return query; | ||
} | ||
).flatMapMany(query -> mongoTemplate.find(query, Notify.class, "notify")); | ||
} | ||
|
||
@Override | ||
public Mono<Notify> findNotifyByIdWhereReceiveUserIdsIn(String userId, String notifyId) { | ||
return Mono.just(new Query().addCriteria(Criteria.where("id").is(notifyId) | ||
.and("receiveUserIds").in(userId))) | ||
.flatMap(query -> mongoTemplate.findOne(query, Notify.class, "notify")); | ||
} | ||
|
||
|
||
} |
40 changes: 0 additions & 40 deletions
40
heachi-domain-mongo/src/test/java/com/heachi/mongo/TestConnection.java
This file was deleted.
Oops, something went wrong.
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
1 change: 0 additions & 1 deletion
1
heachi-notify/src/main/java/com/heachi/notify/HeachiNotifyApplication.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
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.