-
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.
Merge pull request #34 from TeamMiso/feat/email-random-key-confirm
🔀 :: 이메일 인증 API 구현
- Loading branch information
Showing
15 changed files
with
95 additions
and
18 deletions.
There are no files selected for viewing
13 changes: 0 additions & 13 deletions
13
src/main/kotlin/andreas311/miso/common/entitiy/BaseIdxEntity.kt
This file was deleted.
Oops, something went wrong.
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
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/andreas311/miso/domain/email/adapter/input/EmailAdapter.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,22 @@ | ||
package andreas311.miso.domain.email.adapter.input | ||
|
||
import andreas311.miso.common.annotation.RequestController | ||
import andreas311.miso.domain.email.adapter.input.data.request.RandomKeyRequest | ||
import andreas311.miso.domain.email.adapter.input.mapper.EmailDataMapper | ||
import andreas311.miso.domain.email.application.port.input.RandomKeyConfirmUseCase | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import javax.validation.Valid | ||
|
||
@RequestController("/email") | ||
class EmailAdapter( | ||
private val emailDataMapper: EmailDataMapper, | ||
private val randomKeyConfirmUseCase: RandomKeyConfirmUseCase | ||
) { | ||
@PostMapping | ||
fun emailCheck(@RequestBody @Valid randomKeyRequest: RandomKeyRequest): ResponseEntity<Void> = | ||
randomKeyConfirmUseCase.execute(emailDataMapper toDto randomKeyRequest) | ||
.let { ResponseEntity.status(HttpStatus.OK).build() } | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/andreas311/miso/domain/email/adapter/input/data/request/RandomKeyRequest.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,8 @@ | ||
package andreas311.miso.domain.email.adapter.input.data.request | ||
|
||
import javax.validation.constraints.NotNull | ||
|
||
data class RandomKeyRequest( | ||
@field:NotNull | ||
val randomKey: String | ||
) |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/andreas311/miso/domain/email/adapter/input/mapper/EmailDataMapper.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 andreas311.miso.domain.email.adapter.input.mapper | ||
|
||
import andreas311.miso.domain.email.adapter.input.data.request.RandomKeyRequest | ||
import andreas311.miso.domain.email.application.port.input.dto.RandomKeyDto | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class EmailDataMapper { | ||
infix fun toDto(randomKeyRequest: RandomKeyRequest): RandomKeyDto = | ||
RandomKeyDto( | ||
randomKey = randomKeyRequest.randomKey | ||
) | ||
} |
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
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
6 changes: 6 additions & 0 deletions
6
...ain/kotlin/andreas311/miso/domain/email/application/exception/EmailKeyInvalidException.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,6 @@ | ||
package andreas311.miso.domain.email.application.exception | ||
|
||
import andreas311.miso.global.error.ErrorCode | ||
import andreas311.miso.global.error.exception.MisoException | ||
|
||
class EmailKeyInvalidException : MisoException(ErrorCode.EMAIL_KEY_IS_INVALID) |
7 changes: 7 additions & 0 deletions
7
...ain/kotlin/andreas311/miso/domain/email/application/port/input/RandomKeyConfirmUseCase.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 andreas311.miso.domain.email.application.port.input | ||
|
||
import andreas311.miso.domain.email.application.port.input.dto.RandomKeyDto | ||
|
||
interface RandomKeyConfirmUseCase { | ||
fun execute(randomKeyDto: RandomKeyDto) | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/andreas311/miso/domain/email/application/port/input/dto/RandomKeyDto.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 andreas311.miso.domain.email.application.port.input.dto | ||
|
||
data class RandomKeyDto( | ||
val randomKey: String | ||
) |
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
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/andreas311/miso/domain/email/application/service/RandomKeyConfirmService.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,21 @@ | ||
package andreas311.miso.domain.email.application.service | ||
|
||
import andreas311.miso.common.annotation.RollbackService | ||
import andreas311.miso.domain.email.application.exception.EmailKeyInvalidException | ||
import andreas311.miso.domain.email.application.port.input.RandomKeyConfirmUseCase | ||
import andreas311.miso.domain.email.application.port.input.dto.RandomKeyDto | ||
import andreas311.miso.domain.email.application.port.output.CommandEmailPort | ||
import andreas311.miso.domain.email.application.port.output.QueryEmailPort | ||
|
||
@RollbackService | ||
class RandomKeyConfirmService( | ||
private val commandEmailPort: CommandEmailPort, | ||
private val queryEmailPort: QueryEmailPort | ||
): RandomKeyConfirmUseCase { | ||
override fun execute(randomKeyDto: RandomKeyDto) { | ||
val email = queryEmailPort.findByRandomKeyOrNull(randomKeyDto.randomKey) | ||
?: throw EmailKeyInvalidException() | ||
|
||
commandEmailPort.saveEmail(email.updateAuthentication(true)) | ||
} | ||
} |
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