feat(agent-read): 관리자 에이전트 닉네임 검색 컨트롤러를 추가한다
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package kr.co.vividnext.sodalive.admin.partner.agent.read
|
||||
|
||||
import kr.co.vividnext.sodalive.admin.member.AdminSimpleMemberResponse
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
@@ -28,6 +29,14 @@ class AdminAgentReadController(
|
||||
service.searchAssignableCreators(searchWord = searchWord, offset = pageable.offset, limit = pageable.pageSize.toLong())
|
||||
)
|
||||
|
||||
@GetMapping("/search-by-nickname")
|
||||
fun searchAgentByNickname(
|
||||
@RequestParam(value = "search_word") searchWord: String,
|
||||
@RequestParam(value = "size", required = false) size: Int?
|
||||
): ApiResponse<List<AdminSimpleMemberResponse>> = ApiResponse.ok(
|
||||
service.searchAgentByNickname(searchWord = searchWord, size = size ?: 20)
|
||||
)
|
||||
|
||||
@GetMapping("/{agentId}/creator/list")
|
||||
fun getAssignedCreators(
|
||||
@PathVariable agentId: Long,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package kr.co.vividnext.sodalive.admin.partner.agent.read
|
||||
|
||||
import kr.co.vividnext.sodalive.admin.member.AdminSimpleMemberResponse
|
||||
import kr.co.vividnext.sodalive.common.CountryContext
|
||||
import kr.co.vividnext.sodalive.i18n.LangContext
|
||||
import kr.co.vividnext.sodalive.i18n.SodaMessageSource
|
||||
@@ -95,6 +96,32 @@ class AdminAgentReadControllerSecurityTest @Autowired constructor(
|
||||
println(result.response.contentAsString)
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("관리자 권한이면 에이전트 닉네임 검색에 성공한다")
|
||||
fun shouldAllowAdminRoleForAgentNicknameSearch() {
|
||||
Mockito.`when`(service.searchAgentByNickname(searchWord = "agent", size = 10)).thenReturn(
|
||||
listOf(
|
||||
AdminSimpleMemberResponse(
|
||||
id = 11L,
|
||||
nickname = "agent-a"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val result = mockMvc.perform(
|
||||
get("/admin/partner/agent/search-by-nickname")
|
||||
.param("search_word", "agent")
|
||||
.param("size", "10")
|
||||
.with(user("admin").roles("ADMIN"))
|
||||
)
|
||||
.andExpect(status().isOk)
|
||||
.andExpect(jsonPath("$.success").value(true))
|
||||
.andExpect(jsonPath("$.data[0].id").value(11L))
|
||||
.andReturn()
|
||||
|
||||
println(result.response.contentAsString)
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("익명 사용자는 관리자 조회 API에 접근할 수 없다")
|
||||
fun shouldRejectAnonymousUser() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package kr.co.vividnext.sodalive.admin.partner.agent.read
|
||||
|
||||
import kr.co.vividnext.sodalive.admin.member.AdminSimpleMemberResponse
|
||||
import kr.co.vividnext.sodalive.partner.agent.calculate.GetAgentChannelDonationSettlementByCreatorItem
|
||||
import kr.co.vividnext.sodalive.partner.agent.calculate.GetAgentChannelDonationSettlementByCreatorResponse
|
||||
import kr.co.vividnext.sodalive.partner.agent.calculate.GetAgentChannelDonationSettlementTotal
|
||||
@@ -76,6 +77,24 @@ class AdminAgentReadControllerTest {
|
||||
Mockito.verify(service).searchAssignableCreators(searchWord = "creator", offset = 0L, limit = 10L)
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("관리자 컨트롤러는 에이전트 닉네임 검색 파라미터를 서비스로 전달한다")
|
||||
fun shouldForwardAgentNicknameSearchRequest() {
|
||||
val body = listOf(
|
||||
AdminSimpleMemberResponse(
|
||||
id = 11L,
|
||||
nickname = "agent-a"
|
||||
)
|
||||
)
|
||||
Mockito.`when`(service.searchAgentByNickname(searchWord = "agent", size = 10)).thenReturn(body)
|
||||
|
||||
val response = controller.searchAgentByNickname(searchWord = "agent", size = 10)
|
||||
|
||||
assertEquals(true, response.success)
|
||||
assertEquals(11L, response.data!!.first().id)
|
||||
Mockito.verify(service).searchAgentByNickname(searchWord = "agent", size = 10)
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("관리자 컨트롤러는 소속 크리에이터 목록 조회 파라미터를 서비스로 전달한다")
|
||||
fun shouldForwardAssignedCreatorListRequest() {
|
||||
|
||||
Reference in New Issue
Block a user