init
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package space.luminic.finance.api
|
||||
|
||||
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType
|
||||
import io.swagger.v3.oas.annotations.security.SecurityScheme
|
||||
import org.springframework.web.bind.annotation.DeleteMapping
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.PutMapping
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import space.luminic.finance.dtos.CurrencyDTO
|
||||
import space.luminic.finance.mappers.CurrencyMapper.toDto
|
||||
import space.luminic.finance.services.CurrencyService
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/references")
|
||||
@SecurityScheme(
|
||||
name = "bearerAuth",
|
||||
type = SecuritySchemeType.HTTP,
|
||||
bearerFormat = "JWT",
|
||||
scheme = "bearer"
|
||||
)
|
||||
class ReferenceController(
|
||||
private val currencyService: CurrencyService
|
||||
) {
|
||||
|
||||
@GetMapping("/currencies")
|
||||
suspend fun getCurrencies(): List<CurrencyDTO> {
|
||||
return currencyService.getCurrencies().map { it.toDto() }
|
||||
}
|
||||
|
||||
@GetMapping("/currencies/{currencyCode}")
|
||||
suspend fun getCurrency(@PathVariable currencyCode: String): CurrencyDTO {
|
||||
return currencyService.getCurrency(currencyCode).toDto()
|
||||
}
|
||||
|
||||
@PostMapping("/currencies")
|
||||
suspend fun createCurrency(@RequestBody currencyDTO: CurrencyDTO): CurrencyDTO {
|
||||
return currencyService.createCurrency(currencyDTO).toDto()
|
||||
}
|
||||
|
||||
@PutMapping("/currencies/{currencyCode}")
|
||||
suspend fun updateCurrency(@PathVariable currencyCode: String, @RequestBody currencyDTO: CurrencyDTO): CurrencyDTO {
|
||||
return currencyService.updateCurrency(currencyDTO).toDto()
|
||||
}
|
||||
|
||||
@DeleteMapping("/currencies/{currencyCode}")
|
||||
suspend fun deleteCurrency(@PathVariable currencyCode: String) {
|
||||
currencyService.deleteCurrency(currencyCode)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user