Skip to content

Commit

Permalink
πŸ› μ‚­μ œλœ κ²Œμ‹œκΈ€ λ³΄μ΄λŠ” ν˜„μƒ μˆ˜μ • (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
hwgyun authored Jan 2, 2025
1 parent 4dfcbc4 commit 8403262
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import backend.team.ahachul_backend.api.lost.domain.entity.CategoryEntity
import backend.team.ahachul_backend.api.lost.domain.entity.LostPostEntity
import backend.team.ahachul_backend.api.lost.domain.entity.LostPostFileEntity
import backend.team.ahachul_backend.api.lost.domain.model.LostOrigin
import backend.team.ahachul_backend.api.lost.domain.model.LostPostType
import backend.team.ahachul_backend.api.member.application.port.out.MemberReader
import backend.team.ahachul_backend.common.domain.entity.SubwayLineEntity
import backend.team.ahachul_backend.common.dto.ImageDto
Expand Down Expand Up @@ -44,6 +45,11 @@ class LostPostService(

override fun getLostPost(id: Long): GetLostPostDto.Response {
val entity = lostPostReader.getLostPost(id)

if (entity.type == LostPostType.DELETED) {
throw CommonException(ResponseCode.POST_NOT_FOUND)
}

val recommendPosts = getRecommendPosts(entity.subwayLine, entity.category)
val recommendPostsDto = mapRecommendPostsDto(recommendPosts)
val commentCnt = commentReader.countLost(id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class CustomLostPostRepository(
command.lostType,
command.date,
command.lostPostId
)
),
typeNotEq(LostPostType.DELETED)
)
.orderBy(*orderSpecifier.toTypedArray())
.limit((command.pageSize + 1).toLong())
Expand Down Expand Up @@ -126,6 +127,10 @@ class CustomLostPostRepository(
.or(lostPostEntity.content.contains(keyword))
}

private fun typeNotEq(type: LostPostType?) =
type?.let { lostPostEntity.type.ne(type) }


private fun createdAtBeforeOrEqual(lostType: LostType, localDateTime: LocalDateTime?, id: Long?) =
if (lostType == LostType.ACQUIRE) {
localDateTime?.let { date ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum class ResponseCode(

// POST
IMPOSSIBLE_RECOMMEND_LOST_POST("600", "μΆ”μ²œν•  수 μ—†λŠ” μŠ΅λ“λ¬Ό κ²Œμ‹œλ¬Όμž…λ‹ˆλ‹€.", HttpStatus.BAD_REQUEST),
POST_NOT_FOUND("404", "κ²Œμ‹œκΈ€μ΄ μ‘΄μž¬ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.", HttpStatus.NOT_FOUND),

// TRAIN
INVALID_PREFIX_TRAIN_NO("700", "μœ νš¨ν•˜μ§€ μ•Šμ€ μ—΄μ°¨ λ²ˆν˜Έμž…λ‹ˆλ‹€.", HttpStatus.BAD_REQUEST),
Expand Down

0 comments on commit 8403262

Please sign in to comment.