Skip to content

Commit

Permalink
feat: 없는 역량 키워드 삭제 시도 예외 처리(#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
whereami2048 committed May 17, 2024
1 parent 9baf5ef commit 9ec3f78
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 19 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ sealed class StrongPointException(
class DuplicatedStrongPointName(message: String = "역량 키워드 이름이 중복됩니다.") :
StrongPointException(errorCode = 1, httpStatusCode = HttpStatus.BAD_REQUEST, message = message)

class NotFoundStrongPoint(message: String = "존재하지 않는 역량 키워드 입니다.") :
StrongPointException(errorCode = 2, httpStatusCode = HttpStatus.NOT_FOUND, message = message)

companion object {
const val CODE_PREFIX = "STRONG_POINT"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package com.bamyanggang.domainmodule.domain.strongpoint.repository

import com.bamyanggang.domainmodule.domain.strongpoint.aggregate.StrongPoint
import java.util.*

interface StrongPointRepository {
}
fun save(newStrongPoint: StrongPoint): UUID
fun findAllByUserId(userId: UUID): List<StrongPoint>
fun deleteByStrongPointId(strongPointId: UUID)
fun isExistByStrongPointId(strongPointId: UUID): Boolean
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.bamyanggang.domainmodule.domain.strongpoint.service

import com.bamyanggang.domainmodule.domain.experience.repository.StrongPointRepository
import com.bamyanggang.domainmodule.domain.strongpoint.repository.StrongPointRepository
import com.bamyanggang.domainmodule.domain.strongpoint.aggregate.StrongPoint
import org.springframework.stereotype.Service
import java.util.*
Expand All @@ -14,4 +14,4 @@ class StrongPointAppender(
strongPointRepository.save(it)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.bamyanggang.domainmodule.domain.strongpoint.service

import com.bamyanggang.domainmodule.domain.experience.repository.StrongPointRepository
import com.bamyanggang.domainmodule.domain.strongpoint.repository.StrongPointRepository
import com.bamyanggang.domainmodule.domain.strongpoint.aggregate.StrongPoint
import org.springframework.stereotype.Service
import java.util.*
Expand All @@ -12,4 +12,4 @@ class StrongPointReader(
fun findAllByUserId(userId: UUID): List<StrongPoint> {
return strongPointRepository.findAllByUserId(userId)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package com.bamyanggang.domainmodule.domain.strongpoint.service

import com.bamyanggang.domainmodule.domain.experience.repository.StrongPointRepository
import com.bamyanggang.domainmodule.domain.strongpoint.exception.StrongPointException
import com.bamyanggang.domainmodule.domain.strongpoint.repository.StrongPointRepository
import org.springframework.stereotype.Service
import java.util.*

@Service
class StrongPointRemover(
private val strongPointRepository: StrongPointRepository
) {
fun removeStrongPoint(strongPointId: UUID) = strongPointRepository.deleteByStrongPointId(strongPointId)
fun removeStrongPoint(strongPointId: UUID) {
if (!strongPointRepository.isExistByStrongPointId(strongPointId)) {
throw StrongPointException.NotFoundStrongPoint()
}

strongPointRepository.deleteByStrongPointId(strongPointId)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.bamyanggang.persistence.strongpoint;

import com.bamyanggang.domainmodule.domain.experience.repository.StrongPointRepository;
import com.bamyanggang.domainmodule.domain.strongpoint.aggregate.StrongPoint;
import com.bamyanggang.domainmodule.domain.strongpoint.repository.StrongPointRepository;
import com.bamyanggang.persistence.strongpoint.jpa.entity.StrongPointJpaEntity;
import com.bamyanggang.persistence.strongpoint.jpa.repository.StrongPointJpaRepository;
import com.bamyanggang.persistence.strongpoint.mapper.StrongPointMapper;
Expand Down Expand Up @@ -34,4 +34,9 @@ public List<StrongPoint> findAllByUserId(UUID userId) {
public void deleteByStrongPointId(UUID strongPointId) {
strongPointJpaRepository.deleteById(strongPointId);
}

@Override
public boolean isExistByStrongPointId(UUID strongPointId) {
return strongPointJpaRepository.existsById(strongPointId);
}
}

0 comments on commit 9ec3f78

Please sign in to comment.