feat(home): 추천 크리에이터 동시 팔로우 API를 추가한다
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package kr.co.vividnext.sodalive.v2.api.home.adapter.`in`.web
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.v2.api.home.dto.FollowRecommendedCreatorsRequest
|
||||
import kr.co.vividnext.sodalive.v2.recommend.application.RecommendedCreatorFollowService
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v2/home/recommendations")
|
||||
class HomeRecommendationController(
|
||||
private val recommendedCreatorFollowService: RecommendedCreatorFollowService
|
||||
) {
|
||||
@PostMapping("/creators/follow")
|
||||
fun followRecommendedCreators(
|
||||
@RequestBody request: FollowRecommendedCreatorsRequest,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException(messageKey = "common.error.bad_credentials")
|
||||
val creatorIds = request.creatorIds
|
||||
if (creatorIds.isNullOrEmpty() || creatorIds.size > MAX_CREATOR_IDS) {
|
||||
throw SodaException(messageKey = "common.error.invalid_request")
|
||||
}
|
||||
|
||||
recommendedCreatorFollowService.followCreators(
|
||||
member = member,
|
||||
creatorIds = creatorIds
|
||||
)
|
||||
ApiResponse.ok<Unit>()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MAX_CREATOR_IDS = 50
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package kr.co.vividnext.sodalive.v2.api.home.dto
|
||||
|
||||
data class FollowRecommendedCreatorsRequest(
|
||||
val creatorIds: List<Long>?
|
||||
)
|
||||
Reference in New Issue
Block a user