generated from aura-ascend/template-service
add AccountController
This commit is contained in:
28
src/main/kotlin/ltd/lulz/controller/AccountController.kt
Normal file
28
src/main/kotlin/ltd/lulz/controller/AccountController.kt
Normal file
@@ -0,0 +1,28 @@
|
||||
package ltd.lulz.controller
|
||||
|
||||
import jakarta.validation.Valid
|
||||
import ltd.lulz.model.Account
|
||||
import ltd.lulz.service.AccountService
|
||||
import ltd.lulz.util.toEntity
|
||||
import ltd.lulz.util.toResponse
|
||||
import org.springframework.http.HttpStatus.CREATED
|
||||
import org.springframework.validation.annotation.Validated
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.ResponseStatus
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
class AccountController(
|
||||
private val accountService: AccountService,
|
||||
) {
|
||||
|
||||
@PostMapping("/account")
|
||||
@ResponseStatus(CREATED)
|
||||
fun create(
|
||||
@Valid @RequestBody request: Account.Request,
|
||||
): Mono<Account.Response> = accountService.create(request.toEntity())
|
||||
.map { it.toResponse() }
|
||||
}
|
||||
Reference in New Issue
Block a user