Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
return 204 when no data. closes #274
Browse files Browse the repository at this point in the history
  • Loading branch information
cnevinc committed May 4, 2020
1 parent 824bcba commit acdedea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class ContentController @Inject constructor(private val contentService: ContentS
when (val result = cacheContent.get(ContentServiceQueryParam(category, locale, tag))) {
is ContentServiceQueryResult.InvalidParam -> ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result.message)
is ContentServiceQueryResult.Success -> ResponseEntity.status(HttpStatus.OK).body(ContentResponse(result.version, result.tag, result.data.subcategories))
is ContentServiceQueryResult.Empty -> ResponseEntity.status(HttpStatus.NO_CONTENT).body(result.message)
is ContentServiceQueryResult.Fail -> ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result.message)
}
} catch (e: ExecutionException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ class AddContentRequest(

sealed class ContentRepoResult {
class Success(val version: Long, val tag: String, val data: Category) : ContentRepoResult()
open class Fail(val message: String) : ContentRepoResult()
class Empty(message: String) : Fail(message)
class Fail(val message: String) : ContentRepoResult()
class Empty(val message: String) : ContentRepoResult()
}

data class ContentRepoQuery(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ class ContentService @Inject constructor(private val contentRepository: ContentR
log.warn("[Content]====getContent===${result.message}")
ContentServiceQueryResult.Fail(result.message)
}
is ContentRepoResult.Empty -> {
log.warn("[Content]====getContent===${result.message}")
ContentServiceQueryResult.Empty(result.message)
}
is ContentRepoResult.Success -> {
log.info("[Content]====getContent===${result.version}")
ContentServiceQueryResult.Success(result.version, result.tag, result.data)
Expand Down Expand Up @@ -182,6 +186,7 @@ class ContentService @Inject constructor(private val contentRepository: ContentR
sealed class ContentServiceQueryResult {
class Success(val version: Long, val tag: String, val data: Category) : ContentServiceQueryResult()
class InvalidParam(val message: String) : ContentServiceQueryResult()
class Empty(val message: String) : ContentServiceQueryResult()
class Fail(val message: String) : ContentServiceQueryResult()
}

Expand Down

0 comments on commit acdedea

Please sign in to comment.