-
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.
* feat: browseMemberSubscribeWorkbooks 구현 * feat: WorkbookOrderDelegator 선언 * feat: BasicWorkbookOrderDelegator 구현 * feat: MainViewWorkbookOrderDelegator 구현 * feat: BrowseWorkbooksUseCaseIn에 viewCategory, memberId 추가 * refactor: orderStrategy에 따라 정렬된 워크북 반환하도록 수정 * refactor: view 파람 추가 * refactor: mainView에서 로그인/비로그인 분리하도록 수정 * refactor: WorkbookOrderDelegatorExecutor 구현 및 반영 * test: 변경 사항 테스트 반영 * chore: workbooks 인자의 주석 추가
- Loading branch information
1 parent
476bf95
commit 44332ef
Showing
12 changed files
with
403 additions
and
6 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
api/src/main/kotlin/com/few/api/domain/workbook/service/WorkbookSubscribeService.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,25 @@ | ||
package com.few.api.domain.workbook.service | ||
|
||
import com.few.api.domain.workbook.service.dto.BrowseMemberSubscribeWorkbooksInDto | ||
import com.few.api.domain.workbook.service.dto.BrowseMemberSubscribeWorkbooksOutDto | ||
import com.few.api.repo.dao.subscription.SubscriptionDao | ||
import com.few.api.repo.dao.subscription.query.SelectAllMemberWorkbookSubscriptionStatusNotConsiderDeletedAtQuery | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class WorkbookSubscribeService( | ||
private val subscriptionDao: SubscriptionDao, | ||
) { | ||
|
||
fun browseMemberSubscribeWorkbooks(dto: BrowseMemberSubscribeWorkbooksInDto): List<BrowseMemberSubscribeWorkbooksOutDto> { | ||
return SelectAllMemberWorkbookSubscriptionStatusNotConsiderDeletedAtQuery(dto.memberId).let { it -> | ||
subscriptionDao.selectAllWorkbookSubscriptionStatus(it).map { | ||
BrowseMemberSubscribeWorkbooksOutDto( | ||
workbookId = it.workbookId, | ||
isActiveSub = it.isActiveSub, | ||
currentDay = it.currentDay | ||
) | ||
} | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...ain/kotlin/com/few/api/domain/workbook/service/dto/BrowseMemberSubscribeWorkbooksInDto.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,5 @@ | ||
package com.few.api.domain.workbook.service.dto | ||
|
||
data class BrowseMemberSubscribeWorkbooksInDto( | ||
val memberId: Long, | ||
) |
7 changes: 7 additions & 0 deletions
7
...in/kotlin/com/few/api/domain/workbook/service/dto/BrowseMemberSubscribeWorkbooksOutDto.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.few.api.domain.workbook.service.dto | ||
|
||
data class BrowseMemberSubscribeWorkbooksOutDto( | ||
val workbookId: Long, | ||
val isActiveSub: Boolean, | ||
val currentDay: 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
3 changes: 3 additions & 0 deletions
3
api/src/main/kotlin/com/few/api/domain/workbook/usecase/dto/BrowseWorkbooksUseCaseIn.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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package com.few.api.domain.workbook.usecase.dto | ||
|
||
import com.few.api.web.support.ViewCategory | ||
import com.few.api.web.support.WorkBookCategory | ||
|
||
data class BrowseWorkbooksUseCaseIn( | ||
val category: WorkBookCategory, | ||
val viewCategory: ViewCategory?, | ||
val memberId: Long?, | ||
) |
66 changes: 66 additions & 0 deletions
66
...in/kotlin/com/few/api/domain/workbook/usecase/model/AuthMainViewWorkbookOrderDelegator.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,66 @@ | ||
package com.few.api.domain.workbook.usecase.model | ||
|
||
import com.few.api.domain.workbook.service.dto.BrowseMemberSubscribeWorkbooksOutDto | ||
import com.few.api.domain.workbook.usecase.dto.BrowseWorkBookDetail | ||
|
||
class AuthMainViewWorkbookOrderDelegator( | ||
/** | ||
* @see com.few.api.repo.dao.workbook.WorkbookDao.browseWorkBookWithSubscriptionCount | ||
*/ | ||
private val workbooks: List<BrowseWorkBookDetail>, | ||
private val memberSubscribeWorkbooks: List<BrowseMemberSubscribeWorkbooksOutDto>, | ||
) : WorkbookOrderDelegator { | ||
|
||
/** | ||
* 메인 화면에 보여질 워크북을 정렬합니다. | ||
* 1. 활성화된 구독 워크북을 먼저 보여줍니다. | ||
* 2. 구독 기록이 없는 워크북을 보여줍니다. | ||
* 3. 비활성화된 구독 워크북을 보여줍니다. | ||
*/ | ||
override fun order(): List<BrowseWorkBookDetail> { | ||
val allWorkbookIds = workbooks.associate { it.id to false }.toMutableMap() | ||
val activeSubWorkbookIds = memberSubscribeWorkbooks.filter { it.isActiveSub }.sortedByDescending { | ||
it.currentDay | ||
}.map { it.workbookId } | ||
val inActiveSubWorkbookIds = memberSubscribeWorkbooks.filter { !it.isActiveSub }.map { it.workbookId } | ||
|
||
val orderedWorkbooks = mutableListOf<BrowseWorkBookDetail>() | ||
|
||
/** | ||
* 활성화된 구독 워크북을 먼저 보여줍니다. | ||
*/ | ||
activeSubWorkbookIds.forEach { activeSubWorkbookId -> | ||
workbooks.find { it.id == activeSubWorkbookId }?.let { | ||
orderedWorkbooks.add(it) | ||
allWorkbookIds[activeSubWorkbookId] = true | ||
} | ||
} | ||
|
||
/** | ||
* 비활성화된 구독 워크북을 모아둡니다. | ||
*/ | ||
val lastAddWorkbooks = mutableListOf<BrowseWorkBookDetail>() | ||
inActiveSubWorkbookIds.forEach { inActiveSubWorkbookId -> | ||
workbooks.find { it.id == inActiveSubWorkbookId }?.let { | ||
lastAddWorkbooks.add(it) | ||
allWorkbookIds[inActiveSubWorkbookId] = true | ||
} | ||
} | ||
|
||
/** | ||
* 구독 기록이 없는 워크북을 보여줍니다. | ||
*/ | ||
allWorkbookIds.filter { !it.value }.forEach { (id, _) -> | ||
workbooks.find { it.id == id }?.let { | ||
orderedWorkbooks.add(it) | ||
} | ||
} | ||
|
||
/** | ||
* 비활성화된 구독 워크북을 보여줍니다. | ||
*/ | ||
orderedWorkbooks.addAll(lastAddWorkbooks) | ||
|
||
return orderedWorkbooks | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
api/src/main/kotlin/com/few/api/domain/workbook/usecase/model/BasicWorkbookOrderDelegator.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.few.api.domain.workbook.usecase.model | ||
|
||
import com.few.api.domain.workbook.usecase.dto.BrowseWorkBookDetail | ||
|
||
class BasicWorkbookOrderDelegator( | ||
private val workbooks: List<BrowseWorkBookDetail>, | ||
) : WorkbookOrderDelegator { | ||
override fun order(): List<BrowseWorkBookDetail> { | ||
return workbooks | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
api/src/main/kotlin/com/few/api/domain/workbook/usecase/model/WorkbookOrderDelegator.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.few.api.domain.workbook.usecase.model | ||
|
||
import com.few.api.domain.workbook.usecase.dto.BrowseWorkBookDetail | ||
|
||
interface WorkbookOrderDelegator { | ||
|
||
/** | ||
* 워크북을 정렬합니다. | ||
* */ | ||
fun order(): List<BrowseWorkBookDetail> | ||
} |
13 changes: 13 additions & 0 deletions
13
...main/kotlin/com/few/api/domain/workbook/usecase/service/WorkbookOrderDelegatorExecutor.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,13 @@ | ||
package com.few.api.domain.workbook.usecase.service | ||
|
||
import com.few.api.domain.workbook.usecase.dto.BrowseWorkBookDetail | ||
import com.few.api.domain.workbook.usecase.model.WorkbookOrderDelegator | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class WorkbookOrderDelegatorExecutor { | ||
|
||
fun execute(delegator: WorkbookOrderDelegator): List<BrowseWorkBookDetail> { | ||
return delegator.order() | ||
} | ||
} |
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.