From 0868540400306cb0fe968b28dedf2b07af81fcbb Mon Sep 17 00:00:00 2001 From: Tom Winter Date: Tue, 10 Dec 2024 11:24:45 +0100 Subject: [PATCH] fix: pr feedback --- .../skill/controller/SkillController.kt | 36 +++++++++---------- .../skill/domain/EscoSkill.kt | 5 +++ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/controller/SkillController.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/controller/SkillController.kt index 8d139b2..6d68d8f 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/controller/SkillController.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/controller/SkillController.kt @@ -43,6 +43,10 @@ class SkillController( private val userProfileRepository: SkillLabUserProfileRepository, ) { + companion object { + private const val MAX_PAGE_SIZE = 100 + } + @GetMapping("/user-profile") @PreAuthorize("hasAnyAuthority('ROLE_aam_skill_reader')") fun fetchUserProfiles( @@ -53,30 +57,15 @@ class SkillController( pageSize: Int = 10, ): ResponseEntity { if (page < 1) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body( - HttpErrorDto( - errorCode = "BAD_REQUEST", - errorMessage = "Page must be greater than 0", - ) - ) + return getBadRequestResponse(message = "Page must be greater than 0") } if (pageSize < 1) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body( - HttpErrorDto( - errorCode = "BAD_REQUEST", - errorMessage = "Page size must not be less than one", - ) - ) + return getBadRequestResponse(message = "Page size must not be less than one") } - if (pageSize > 100) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body( - HttpErrorDto( - errorCode = "BAD_REQUEST", - errorMessage = "Max pageSize limit is 100", - ) - ) + if (pageSize > MAX_PAGE_SIZE) { + return getBadRequestResponse(message = "Max pageSize limit is $MAX_PAGE_SIZE") } val result = searchUserProfileUseCase.run( @@ -153,4 +142,13 @@ class SkillController( ) } } + + private fun getBadRequestResponse(message: String): ResponseEntity { + return ResponseEntity.badRequest().body( + HttpErrorDto( + errorCode = "BAD_REQUEST", + errorMessage = message + ) + ) + } } diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/domain/EscoSkill.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/domain/EscoSkill.kt index 7ea97d9..9dd87a5 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/domain/EscoSkill.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/domain/EscoSkill.kt @@ -1,11 +1,16 @@ package com.aamdigital.aambackendservice.skill.domain +import com.fasterxml.jackson.annotation.JsonProperty + enum class SkillUsage { ALMOST_NEVER, SOMETIMES, OFTEN, ALMOST_ALWAYS, ALWAYS, + + @JsonProperty("BI-WEEKLY") + BI_WEEKLY, } /**