-
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
* feat : 안읽음, 즐겨찾기 개수 조회 dto * feat : 안읽음, 즐겨찾기 개수 조회 api * feat : 안읽음, 즐겨찾기 개수 조회 유스케이스 구현 * feat : 안읽음, 즐겨찾기 개수 조회 포트 구현
- Loading branch information
1 parent
fce2b67
commit 0b8b42b
Showing
7 changed files
with
83 additions
and
1 deletion.
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
32 changes: 32 additions & 0 deletions
32
...persistence/src/main/kotlin/com/pokit/out/persistence/content/impl/ContentCountAdapter.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,32 @@ | ||
package com.pokit.out.persistence.content.impl | ||
|
||
import com.pokit.content.port.out.ContentCountPort | ||
import com.pokit.log.model.LogType | ||
import com.pokit.out.persistence.bookmark.persist.BookMarkRepository | ||
import com.pokit.out.persistence.category.persist.QCategoryEntity.categoryEntity | ||
import com.pokit.out.persistence.content.persist.QContentEntity.contentEntity | ||
import com.pokit.out.persistence.log.persist.QUserLogEntity.userLogEntity | ||
import com.querydsl.jpa.impl.JPAQueryFactory | ||
import org.springframework.stereotype.Repository | ||
|
||
@Repository | ||
class ContentCountAdapter( | ||
private val queryFactory: JPAQueryFactory, | ||
private val bookMarkRepository: BookMarkRepository | ||
) : ContentCountPort { | ||
override fun getUnreadCount(userId: Long): Int { | ||
return queryFactory.select(contentEntity.count()) | ||
.from(contentEntity) | ||
.leftJoin(userLogEntity).on(userLogEntity.contentId.eq(contentEntity.id)) | ||
.join(categoryEntity).on(categoryEntity.id.eq(contentEntity.categoryId)) | ||
.where( | ||
categoryEntity.userId.eq(userId), | ||
contentEntity.deleted.isFalse, | ||
userLogEntity.id.isNull.or(userLogEntity.type.ne(LogType.READ)) | ||
) | ||
.fetchFirst()!!.toInt() | ||
} | ||
|
||
override fun getBookmarkContent(userId: Long) = | ||
bookMarkRepository.countByUserIdAndDeleted(userId, false) | ||
} |
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: 7 additions & 0 deletions
7
application/src/main/kotlin/com/pokit/content/port/out/ContentCountPort.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,7 @@ | ||
package com.pokit.content.port.out | ||
|
||
interface ContentCountPort { | ||
fun getUnreadCount(userId: Long): Int | ||
|
||
fun getBookmarkContent(userId: Long): Int | ||
} |
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