Skip to content

Commit

Permalink
release: 0.8.7 (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb authored Oct 28, 2024
2 parents 56df78e + d88c93a commit 704bd65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.gitanimals.render.controller
import org.gitanimals.render.app.UserFacade
import org.gitanimals.render.controller.request.ChangeFieldRequest
import org.gitanimals.render.controller.response.BackgroundResponse
import org.gitanimals.render.controller.response.ErrorResponse
import org.gitanimals.render.domain.FieldType
import org.gitanimals.render.domain.UserService
import org.gitanimals.render.domain.UserService.Companion.loadField
Expand Down Expand Up @@ -43,4 +44,9 @@ class BackgroundController(
@RequestHeader(HttpHeaders.AUTHORIZATION) token: String,
@RequestParam(name = "name") name: String,
) = userFacade.deleteField(token, FieldType.valueOf(name.uppercase()))

@ExceptionHandler(IllegalArgumentException::class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
fun handleIllegalArgumentException(illegalArgumentException: IllegalArgumentException): ErrorResponse =
ErrorResponse.from(illegalArgumentException)
}
4 changes: 4 additions & 0 deletions src/main/kotlin/org/gitanimals/render/domain/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ class User(
}

fun addField(fieldType: FieldType) {
require(fields.any { it.fieldType == fieldType }.not()) {
"Duplicated add field request."
}

getOrCreateDefaultFieldIfAbsent()

this.fields.add(Field.from(this, fieldType))
Expand Down

0 comments on commit 704bd65

Please sign in to comment.