Skip to content

Commit

Permalink
feat :: Exception 처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
HyunSu1768 committed Feb 14, 2024
1 parent b190714 commit 5c24cb0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.mergebackend.domain.deploy.exception

import com.example.mergebackend.global.config.error.data.ErrorCode
import com.example.mergebackend.global.config.error.exception.BusinessException

object AlreadyExistsDeployException : BusinessException(ErrorCode.ALREADY_EXISTS_DEPLOY)
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.example.mergebackend.domain.deploy.repository

import com.example.mergebackend.domain.deploy.entity.Deploy
import com.example.mergebackend.domain.deploy.entity.type.ServiceType
import com.example.mergebackend.domain.project.entity.Project
import org.springframework.data.jpa.repository.JpaRepository
import java.util.UUID

interface DeployRepository : JpaRepository<Deploy, UUID>
interface DeployRepository : JpaRepository<Deploy, UUID> {
fun existsByProjectAndServiceType(project: Project, serviceType: ServiceType): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.example.mergebackend.domain.deploy.service

import com.example.mergebackend.domain.deploy.entity.Deploy
import com.example.mergebackend.domain.deploy.entity.vo.DeployStatus
import com.example.mergebackend.domain.deploy.exception.AlreadyExistsDeployException
import com.example.mergebackend.domain.deploy.presentation.dto.request.CreateDeployRequest
import com.example.mergebackend.domain.deploy.presentation.dto.request.WebhookRequest
import com.example.mergebackend.domain.deploy.presentation.dto.response.CreateDeployResponse
Expand All @@ -19,6 +20,9 @@ private class DeployServiceImpl(
): DeployService {
override fun createDeploy(createDeployRequest: CreateDeployRequest): CreateDeployResponse {
val project = projectRepository.findByIdOrNull(createDeployRequest.projectId) ?: throw ProjectNotFoundException
if(deployRepository.existsByProjectAndServiceType(project, createDeployRequest.serviceType)) {
throw AlreadyExistsDeployException
}

val organization = extractOrganization(createDeployRequest.githubUrl)
val deploy = deployRepository.save(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum class ErrorCode(
ALREADY_SIGN_UP(HttpStatus.CONFLICT, "이미 가입한 계정입니다."),
ALREADY_EXISTS_ENVIRONMENT_VARIABLE(HttpStatus.CONFLICT, "이미 환경변수가 존재합니다,"),
ALREADY_EXIST(HttpStatus.BAD_REQUEST, "이미 존재하는 프로젝트 이름입니다."),
ALREADY_EXISTS_DEPLOY(HttpStatus.CONFLICT, "이미 해당 배포정보에 대한 배포내역이 존재합니다."),

// 500
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "서버 내부 에러"),
Expand Down

0 comments on commit 5c24cb0

Please sign in to comment.