-
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.
- Loading branch information
Showing
13 changed files
with
534 additions
and
18 deletions.
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
59 changes: 54 additions & 5 deletions
59
api/src/main/kotlin/com/john/lotto/scrap/adatper/in/web/ScrapHandler.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,18 +1,67 @@ | ||
package com.john.lotto.scrap.adatper.`in`.web | ||
|
||
import com.john.lotto.common.dto.BaseResponse | ||
import com.john.lotto.common.exception.BadRequestException | ||
import com.john.lotto.common.filter.userId | ||
import com.john.lotto.scrap.adatper.`in`.web.dto.ScrapInput | ||
import com.john.lotto.scrap.application.port.`in`.DeleteStoreScrapUseCase | ||
import com.john.lotto.scrap.application.port.`in`.FindStoreScrapUseCase | ||
import com.john.lotto.scrap.application.port.`in`.RegisterScrapUseCase | ||
import org.springframework.stereotype.Component | ||
import org.springframework.web.reactive.function.server.ServerRequest | ||
import org.springframework.web.reactive.function.server.ServerResponse | ||
import reactor.core.publisher.Mono | ||
|
||
/** | ||
* @author yoonho | ||
* @since 2023.07.19 | ||
*/ | ||
@Component | ||
class ScrapHandler( | ||
|
||
private val registerScrapUseCase: RegisterScrapUseCase, | ||
private val findStoreScrapUseCase: FindStoreScrapUseCase, | ||
private val deleteStoreScrapUseCase: DeleteStoreScrapUseCase | ||
) { | ||
|
||
// TODO: | ||
// - 스크랩 조회 | ||
// - 스크랩 등록 | ||
// - 스크랩 삭제 | ||
/** | ||
* 판매점스크랩 등록 | ||
* | ||
* @param request [ServerRequest] | ||
* @return [Mono]<[ServerResponse]> | ||
* @author yoonho | ||
* @since 2023.07.23 | ||
*/ | ||
fun register(request: ServerRequest): Mono<ServerResponse> = | ||
request.bodyToMono(ScrapInput::class.java) | ||
.flatMap { return@flatMap Mono.just(it.validate()) } | ||
.flatMap { registerScrapUseCase.register(userId = request.userId(), rtlrid = it.rtlrid!!) } | ||
.flatMap { BaseResponse().success(it) } | ||
|
||
/** | ||
* 판매점스크랩 조회 | ||
* | ||
* @param request [ServerRequest] | ||
* @return [Mono]<[ServerResponse]> | ||
* @author yoonho | ||
* @since 2023.07.23 | ||
*/ | ||
fun search(request: ServerRequest): Mono<ServerResponse> = | ||
findStoreScrapUseCase.search(userId = request.userId()) | ||
.collectList() | ||
.flatMap { BaseResponse().success(it) } | ||
|
||
/** | ||
* 판매점스크랩 탈퇴 | ||
* | ||
* @param request [ServerRequest] | ||
* @return [Mono]<[ServerResponse]> | ||
* @author yoonho | ||
* @since 2023.07.23 | ||
*/ | ||
fun delete(request: ServerRequest): Mono<ServerResponse> = | ||
deleteStoreScrapUseCase.delete( | ||
userId = request.userId(), | ||
rtlrid = request.queryParam("rtlrid").orElseThrow { BadRequestException("필수 입력값 누락") }.toString() | ||
) | ||
.flatMap { BaseResponse().success(it) } | ||
} |
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
24 changes: 24 additions & 0 deletions
24
api/src/main/kotlin/com/john/lotto/scrap/adatper/in/web/dto/ScrapInput.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,24 @@ | ||
package com.john.lotto.scrap.adatper.`in`.web.dto | ||
|
||
import com.john.lotto.common.exception.BadRequestException | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import java.io.Serializable | ||
|
||
|
||
/** | ||
* @author yoonho | ||
* @since 2023.07.23 | ||
*/ | ||
data class ScrapInput( | ||
@Schema(description = "rtlrid", example = "1111") | ||
val rtlrid: String? = "" | ||
): Serializable { | ||
|
||
fun validate(): ScrapInput { | ||
if(this.rtlrid.isNullOrEmpty()) { | ||
throw BadRequestException("판매점정보가 정보가 누락되었습니다.") | ||
} | ||
|
||
return this | ||
} | ||
} |
Oops, something went wrong.