Removed -Dto suffix from DTOs

This commit is contained in:
dankito 2023-04-10 20:10:23 +02:00
parent f8d526f923
commit 7a6d6055f1
3 changed files with 14 additions and 17 deletions

View File

@ -2,8 +2,8 @@ package net.codinux.banking.epcqrcode.rest
import net.codinux.banking.epcqrcode.EpcQrCodeConfig import net.codinux.banking.epcqrcode.EpcQrCodeConfig
import net.codinux.banking.epcqrcode.EpcQrCodeGenerator import net.codinux.banking.epcqrcode.EpcQrCodeGenerator
import net.codinux.banking.epcqrcode.rest.dto.GenerateEpcQrCodeRequestDto import net.codinux.banking.epcqrcode.rest.dto.GenerateEpcQrCodeRequest
import net.codinux.banking.epcqrcode.rest.dto.GenerateEpcQrCodeResponseDto import net.codinux.banking.epcqrcode.rest.dto.GenerateEpcQrCodeResponse
import org.eclipse.microprofile.openapi.annotations.Operation import org.eclipse.microprofile.openapi.annotations.Operation
import org.eclipse.microprofile.openapi.annotations.media.Content import org.eclipse.microprofile.openapi.annotations.media.Content
import org.eclipse.microprofile.openapi.annotations.media.Schema import org.eclipse.microprofile.openapi.annotations.media.Schema
@ -21,42 +21,39 @@ import javax.ws.rs.core.Response
@Tag(name = "EPC QR Code") @Tag(name = "EPC QR Code")
class EpcQrCodeResource { class EpcQrCodeResource {
companion object {
private val log = LoggerFactory.getLogger(EpcQrCodeResource::class.java)
}
protected val epcQrCodeGenerator = EpcQrCodeGenerator() protected val epcQrCodeGenerator = EpcQrCodeGenerator()
private val log = LoggerFactory.getLogger(EpcQrCodeResource::class.java)
@Operation(summary = "Creates a EPC QR code (also marketed as GiroCode, scan2Code, ...)") @Operation(summary = "Creates a EPC QR code (also marketed as GiroCode, scan2Code, ...)")
@APIResponse(responseCode = "200", description = "The generated EPC QR Code", @APIResponse(responseCode = "200", description = "The generated EPC QR Code",
content = [ Content(mediaType = "application/json", schema = Schema(implementation = GenerateEpcQrCodeResponseDto::class)) ]) content = [ Content(mediaType = "application/json", schema = Schema(implementation = GenerateEpcQrCodeResponse::class)) ])
@APIResponse(responseCode = "500", description = "An internal error occurred") @APIResponse(responseCode = "500", description = "An internal error occurred")
@GET @GET
fun createEpcQrCodeGet(@BeanParam request: GenerateEpcQrCodeRequestDto): Response { fun createEpcQrCodeGet(@BeanParam request: GenerateEpcQrCodeRequest): Response {
return handleJsonRequest(request) return handleJsonRequest(request)
} }
@Operation(summary = "Creates a EPC QR code (also marketed as GiroCode, scan2Code, ...)") @Operation(summary = "Creates a EPC QR code (also marketed as GiroCode, scan2Code, ...)")
@APIResponse(responseCode = "200", description = "The generated EPC QR Code", @APIResponse(responseCode = "200", description = "The generated EPC QR Code",
content = [ Content(mediaType = "application/json", schema = Schema(implementation = GenerateEpcQrCodeResponseDto::class)) ]) content = [ Content(mediaType = "application/json", schema = Schema(implementation = GenerateEpcQrCodeResponse::class)) ])
@APIResponse(responseCode = "500", description = "An internal error occurred") @APIResponse(responseCode = "500", description = "An internal error occurred")
@POST @POST
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
fun createEpcQrCodePost( fun createEpcQrCodePost(
@RequestBody(content = [ Content(schema = Schema(implementation = GenerateEpcQrCodeRequestDto::class)) ]) @RequestBody(content = [ Content(schema = Schema(implementation = GenerateEpcQrCodeRequest::class)) ])
request: GenerateEpcQrCodeRequestDto request: GenerateEpcQrCodeRequest
): Response { ): Response {
return handleJsonRequest(request) return handleJsonRequest(request)
} }
private fun handleJsonRequest(request: GenerateEpcQrCodeRequestDto): Response { private fun handleJsonRequest(request: GenerateEpcQrCodeRequest): Response {
try { try {
val epcQrCode = epcQrCodeGenerator.generateEpcQrCode(mapToEpcQrCodeConfig(request), request.imageHeightAndWidth) val epcQrCode = epcQrCodeGenerator.generateEpcQrCode(mapToEpcQrCodeConfig(request), request.imageHeightAndWidth)
val qrCodeBytes = epcQrCode.bytes // TODO: convert to Base64 val qrCodeBytes = epcQrCode.bytes // TODO: convert to Base64
return Response.ok(GenerateEpcQrCodeResponseDto(qrCodeBytes)) return Response.ok(GenerateEpcQrCodeResponse(qrCodeBytes))
.header("Access-Control-Allow-Origin", "*") .header("Access-Control-Allow-Origin", "*")
.build() .build()
} catch (e: Exception) { } catch (e: Exception) {
@ -68,7 +65,7 @@ class EpcQrCodeResource {
} }
} }
private fun mapToEpcQrCodeConfig(dto: GenerateEpcQrCodeRequestDto): EpcQrCodeConfig { private fun mapToEpcQrCodeConfig(dto: GenerateEpcQrCodeRequest): EpcQrCodeConfig {
return EpcQrCodeConfig( return EpcQrCodeConfig(
dto.receiverName, dto.receiverName,
dto.iban, dto.iban,

View File

@ -9,7 +9,7 @@ import javax.ws.rs.DefaultValue
import javax.ws.rs.QueryParam import javax.ws.rs.QueryParam
class GenerateEpcQrCodeRequestDto { class GenerateEpcQrCodeRequest {
@QueryParam("receiverName") @QueryParam("receiverName")
@Parameter(description = "The name of the receiver of this money transfer (that is in most cases your name or your company's name)", required = true) @Parameter(description = "The name of the receiver of this money transfer (that is in most cases your name or your company's name)", required = true)

View File

@ -3,7 +3,7 @@ package net.codinux.banking.epcqrcode.rest.dto
import org.eclipse.microprofile.openapi.annotations.media.Schema import org.eclipse.microprofile.openapi.annotations.media.Schema
class GenerateEpcQrCodeResponseDto( class GenerateEpcQrCodeResponse(
// JAX-RS automatically encodes ByteArray to Base64 // JAX-RS automatically encodes ByteArray to Base64
@Schema(description = "The Base64 encoded generated EPC QR Code") @Schema(description = "The Base64 encoded generated EPC QR Code")
val qrCodeBase64Encoded: ByteArray val qrCodeBase64Encoded: ByteArray