Skip to content

Commit

Permalink
BUG :: 버그수정
Browse files Browse the repository at this point in the history
  • Loading branch information
HyunSu1768 committed Mar 30, 2024
1 parent 6d9fff6 commit 6cf809e
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 5 deletions.
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
kotlin("plugin.spring") version PluginVersions.SPRING_PLUGIN_VERSION
kotlin("plugin.jpa") version PluginVersions.JPA_PLUGIN_VERSION
kotlin("jvm") version PluginVersions.JVM_VERSION
kotlin("plugin.serialization") version "1.9.22"
}

group = "xquare.app"
Expand Down Expand Up @@ -52,6 +53,8 @@ dependencies {
// redis
implementation(Dependencies.REDIS)
implementation(Dependencies.ANNOTATION_PROCESSOR)

implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
}

dependencyManagement {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
package xquare.app.xquareinfra.domain.auth.service

import kotlinx.serialization.json.Json
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import xquare.app.xquareinfra.domain.auth.adapter.dto.request.SignupRequest
import xquare.app.xquareinfra.domain.auth.application.port.`in`.SignupUseCase
import xquare.app.xquareinfra.domain.user.application.port.out.ExistsUserPort
import xquare.app.xquareinfra.domain.user.application.port.out.SaveUserPort
import xquare.app.xquareinfra.domain.user.domain.Role
import xquare.app.xquareinfra.domain.user.domain.User
import xquare.app.xquareinfra.infrastructure.exception.BusinessLogicException
import xquare.app.xquareinfra.infrastructure.exception.XquareException
import xquare.app.xquareinfra.infrastructure.feign.client.dsm.DsmLoginClient
import xquare.app.xquareinfra.infrastructure.feign.client.dsm.dto.GetDsmUserInfoResponse

@Transactional
@Service
class SignupService(
private val saveUserPort: SaveUserPort,
private val dsmLoginClient: DsmLoginClient
private val dsmLoginClient: DsmLoginClient,
private val existsUserPort: ExistsUserPort
): SignupUseCase {
override fun signup(signupRequest: SignupRequest) {
val userInfo = dsmLoginClient.getUserInfo(
val feignResponse = dsmLoginClient.getUserInfo(
accountId = signupRequest.accountId,
password = signupRequest.password
)

if(feignResponse.status() >= 400) {
throw XquareException.UNAUTHORIZED
}

if(existsUserPort.existsByAccountId(signupRequest.accountId)) {
throw BusinessLogicException.USER_ALREADY_EXISTS
}

val userInfo = Json.decodeFromString<GetDsmUserInfoResponse>(feignResponse.body().toString())

userInfo.run {
saveUserPort.saveUser(
User(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import xquare.app.xquareinfra.domain.deploy.application.port.out.ExistDeployPort
import xquare.app.xquareinfra.domain.deploy.application.port.out.FindDeployPort
import xquare.app.xquareinfra.domain.deploy.application.port.out.persistence.repository.DeployRepository
import xquare.app.xquareinfra.domain.deploy.domain.Deploy
import xquare.app.xquareinfra.domain.team.domain.Team

@Component
class DeployPersistenceAdapter(
Expand All @@ -14,4 +15,5 @@ class DeployPersistenceAdapter(
override fun createDeploy(deploy: Deploy): Deploy = deployRepository.save(deploy)
override fun existByDeployName(deployName: String): Boolean = deployRepository.existsByDeployName(deployName)
override fun findByDeployName(deployName: String): Deploy? = deployRepository.findByDeployName(deployName)
override fun findAllByTeam(team: Team): List<Deploy> = deployRepository.findAllByTeam(team)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package xquare.app.xquareinfra.domain.deploy.application.port.out.persistence.re

import org.springframework.data.jpa.repository.JpaRepository
import xquare.app.xquareinfra.domain.deploy.domain.Deploy
import xquare.app.xquareinfra.domain.team.domain.Team
import java.util.UUID

interface DeployRepository : JpaRepository<Deploy, UUID> {
fun existsByDeployName(deployName: String): Boolean

fun findByDeployName(deployName: String): Deploy?

fun findAllByTeam(team: Team): List<Deploy>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import java.util.UUID

interface ExistsUserPort {
fun existsById(userId: UUID): Boolean
fun existsByAccountId(accountId: String): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UserPersistenceAdapter(
): FindUserPort, ExistsUserPort, SaveUserPort {
override fun findById(userId: UUID): User? = userRepository.findByIdOrNull(userId)
override fun findByAccountId(accountId: String): User? = userRepository.findByAccountId(accountId)

override fun existsById(userId: UUID): Boolean = userRepository.existsById(userId)
override fun existsByAccountId(accountId: String): Boolean = userRepository.existsByAccountId(accountId)
override fun saveUser(user: User): User = userRepository.save(user)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import java.util.UUID

interface UserRepository: JpaRepository<User, UUID> {
fun findByAccountId(accountId: String): User?
fun existsByAccountId(accountId: String): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class User(
var name: String = name
protected set

@Column(name = "account_id", nullable = false)
@Column(name = "account_id", nullable = false, unique = true)
var accountId: String = accountId
protected set

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class BusinessLogicException(
val ALREADY_EXISTS_DEPLOY = BusinessLogicException(ErrorCodePrefixSuffix.ALREADY_EXISTS_XXX, DomainNames.DEPLOY)
val DEPLOY_NOT_FOUND = BusinessLogicException(ErrorCodePrefixSuffix.XXX_NOT_FOUND, DomainNames.DEPLOY)
val CREATE_DEPLOY_BAD_REQUEST = BusinessLogicException(ErrorCodePrefixSuffix.XXX_BAD_REQUEST, DomainNames.DEPLOY)
val USER_ALREADY_EXISTS = BusinessLogicException(ErrorCodePrefixSuffix.ALREADY_EXISTS_XXX, DomainNames.USER)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import xquare.app.xquareinfra.infrastructure.feign.client.dsm.dto.GetDsmUserInfo
@FeignClient(name = "dsm-login", url = "https://prod-server.xquare.app/dsm-login")
interface DsmLoginClient {
@GetMapping("/user/user-data")
fun getUserInfo(@RequestParam("account_id") accountId: String, @RequestParam("password") password: String): GetDsmUserInfoResponse
fun getUserInfo(@RequestParam("account_id") accountId: String, @RequestParam("password") password: String): feign.Response
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package xquare.app.xquareinfra.infrastructure.feign.client.dsm.dto

import kotlinx.serialization.Serializable

@Serializable
data class GetDsmUserInfoResponse(
val id: String,
val accountId: String,
Expand Down

0 comments on commit 6cf809e

Please sign in to comment.