feat(home): 추천 크리에이터 동시 팔로우 API를 추가한다

This commit is contained in:
2026-06-01 10:19:49 +09:00
parent 8300b1875c
commit cdff31422c
3 changed files with 259 additions and 0 deletions

View File

@@ -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
}
}

View File

@@ -0,0 +1,5 @@
package kr.co.vividnext.sodalive.v2.api.home.dto
data class FollowRecommendedCreatorsRequest(
val creatorIds: List<Long>?
)