-
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.
Browse files
Browse the repository at this point in the history
#156 schedule search
- Loading branch information
Showing
13 changed files
with
338 additions
and
38 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
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/com/tistory/shanepark/dutypark/schedule/domain/dto/ScheduleSearchResult.kt
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.tistory.shanepark.dutypark.schedule.domain.dto | ||
|
||
import com.tistory.shanepark.dutypark.schedule.domain.entity.Schedule | ||
import java.time.LocalDateTime | ||
|
||
data class ScheduleSearchResult( | ||
val content: String, | ||
val startDateTime: LocalDateTime, | ||
val endDateTime: LocalDateTime, | ||
val visibility: String, | ||
val isTagged: Boolean, | ||
) { | ||
companion object { | ||
fun of(schedule: Schedule): ScheduleSearchResult { | ||
return ScheduleSearchResult( | ||
content = schedule.content, | ||
startDateTime = schedule.startDateTime, | ||
endDateTime = schedule.endDateTime, | ||
visibility = schedule.visibility.name, | ||
isTagged = schedule.tags.isNotEmpty() | ||
) | ||
} | ||
} | ||
} |
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/kotlin/com/tistory/shanepark/dutypark/schedule/service/ScheduleSearchService.kt
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.tistory.shanepark.dutypark.schedule.service | ||
|
||
import com.tistory.shanepark.dutypark.schedule.domain.dto.ScheduleSearchResult | ||
import com.tistory.shanepark.dutypark.security.domain.dto.LoginMember | ||
import org.springframework.data.domain.Page | ||
import org.springframework.data.domain.Pageable | ||
|
||
interface ScheduleSearchService { | ||
|
||
fun search(loginMember: LoginMember, targetMemberId: Long, page: Pageable, query: String): Page<ScheduleSearchResult> | ||
} |
39 changes: 39 additions & 0 deletions
39
...ain/kotlin/com/tistory/shanepark/dutypark/schedule/service/ScheduleSearchServiceDBImpl.kt
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.tistory.shanepark.dutypark.schedule.service | ||
|
||
import com.tistory.shanepark.dutypark.member.repository.MemberRepository | ||
import com.tistory.shanepark.dutypark.member.service.FriendService | ||
import com.tistory.shanepark.dutypark.schedule.domain.dto.ScheduleSearchResult | ||
import com.tistory.shanepark.dutypark.schedule.repository.ScheduleRepository | ||
import com.tistory.shanepark.dutypark.security.domain.dto.LoginMember | ||
import org.springframework.data.domain.Page | ||
import org.springframework.data.domain.Pageable | ||
import org.springframework.stereotype.Service | ||
|
||
/** | ||
* When search engine is implemented, this service will be replaced with ScheduleSearchServiceESImpl | ||
*/ | ||
@Service | ||
class ScheduleSearchServiceDBImpl( | ||
private val scheduleRepository: ScheduleRepository, | ||
private val memberRepository: MemberRepository, | ||
private val friendService: FriendService, | ||
) : ScheduleSearchService { | ||
|
||
override fun search( | ||
loginMember: LoginMember, | ||
targetMemberId: Long, | ||
page: Pageable, | ||
query: String | ||
): Page<ScheduleSearchResult> { | ||
val target = memberRepository.findById(targetMemberId).orElseThrow() | ||
val availableVisibilities = friendService.availableVisibilities(loginMember, target) | ||
|
||
return scheduleRepository.findByMemberAndContentContainingAndVisibilityIn( | ||
member = target, | ||
content = query, | ||
visibility = availableVisibilities, | ||
pageable = page | ||
).map { ScheduleSearchResult.of(it) } | ||
} | ||
|
||
} |
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
Oops, something went wrong.