Skip to content

Commit

Permalink
fix: pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwwinter committed Dec 10, 2024
1 parent c1525b9 commit 0868540
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -53,30 +57,15 @@ class SkillController(
pageSize: Int = 10,
): ResponseEntity<Any> {
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(
Expand Down Expand Up @@ -153,4 +142,13 @@ class SkillController(
)
}
}

private fun getBadRequestResponse(message: String): ResponseEntity<Any> {
return ResponseEntity.badRequest().body(
HttpErrorDto(
errorCode = "BAD_REQUEST",
errorMessage = message
)
)
}
}
Original file line number Diff line number Diff line change
@@ -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,
}

/**
Expand Down

0 comments on commit 0868540

Please sign in to comment.