Skip to content

#138 - 쪽지 답장을 사용한적이 있는지 확인하는 API를 구현합니다. #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions app/src/main/kotlin/com/wespot/user/UsedAnswerMessageController.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.wespot.user

import com.wespot.user.port.`in`.UsedAnswerMessageUseCase
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController


@RestController
@RequestMapping("/api/v2/messages/answer/first")
Copy link
Preview

Copilot AI May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The endpoint path '/api/v2/messages/answer/first' does not clearly indicate that it checks for the usage of the answer message feature. Consider renaming the path to something more descriptive, such as '/api/v2/messages/answer/feature-status', to better convey its purpose.

Suggested change
@RequestMapping("/api/v2/messages/answer/first")
@RequestMapping("/api/v2/messages/answer/feature-status")

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No Thanks

class UsedAnswerMessageController(
private val usedAnswerMessageUseCase: UsedAnswerMessageUseCase,
) {

@GetMapping
fun isUsedAnswerMessageFeature(): ResponseEntity<Boolean> {
val response = usedAnswerMessageUseCase.isUsedAnswerMessageFeature()

return ResponseEntity.ok(response)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.wespot.user.port.`in`

interface UsedAnswerMessageUseCase {

fun isUsedAnswerMessageFeature(): Boolean

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ interface UsedAnswerMessagePort {

fun existsByUserId(userId: Long): Boolean

fun findByUserId(userId: Long): UsedAnswerMessage?

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.wespot.user.service

import com.wespot.auth.service.SecurityUtils
import com.wespot.user.port.`in`.UsedAnswerMessageUseCase
import com.wespot.user.port.out.UsedAnswerMessagePort
import com.wespot.user.port.out.UserPort
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
class UsedAnswerMessageService(
private val userPort: UserPort,
private val usedAnswerMessagePort: UsedAnswerMessagePort
) : UsedAnswerMessageUseCase {

@Transactional(readOnly = true)
override fun isUsedAnswerMessageFeature(): Boolean {
val loginUser = SecurityUtils.getLoginUser(userPort = userPort)

return usedAnswerMessagePort.findByUserId(userId = loginUser.id)
?.isUsedAnswerMessageFeature
?: false
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ class UsedAnswerMessagePersistenceAdapter(
return usedAnswerMessageJpaRepository.existsByUserId(userId = userId)
}

override fun findByUserId(userId: Long): UsedAnswerMessage? {
return usedAnswerMessageJpaRepository.findByUserId(userId = userId)
?.let { UsedAnswerMessageMapper.mapToDomainEntity(it) }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ interface UsedAnswerMessageJpaRepository : JpaRepository<UsedAnswerMessageJpaEnt

fun existsByUserId(userId: Long): Boolean

fun findByUserId(userId: Long): UsedAnswerMessageJpaEntity?

}
Loading