Skip to content

Commit 0f46554

Browse files
CLAP-356 카테고리 수정시 고유코드 및 제목 중복 가능한 문제 수정
* CLAP-343 fix: 카테고리 고유코드 및 제목 중복 가능한 문제 수정 <footer> - #443 * CLAP-343 fix: 카테고리 고유코드 및 제목 중복 가능한 문제 수정 <footer> - #443 * CLAP-356 fix: 카테고리 수정시 고유코드 및 제목 중복 가능한 문제 수정 <footer> - #449
1 parent 1bb2590 commit 0f46554

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/main/java/clap/server/adapter/outbound/persistense/CategoryPersistenceAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public List<Category> findSubCategory() {
5151

5252
@Override
5353
public boolean existsByNameOrCode(String name, String code) {
54-
return categoryRepository.existsByNameOrCode(name, code);
54+
return categoryRepository.existsByNameOrCodeAndIsDeletedFalse(name, code);
5555
}
5656

5757
@Override

src/main/java/clap/server/adapter/outbound/persistense/repository/task/CategoryRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ public interface CategoryRepository extends JpaRepository<CategoryEntity, Long>
1212
List<CategoryEntity> findByIsDeletedFalseAndMainCategoryIsNull();
1313
List<CategoryEntity> findByIsDeletedFalseAndMainCategoryIsNotNull();
1414

15-
boolean existsByNameOrCode(String name, String code);
15+
boolean existsByNameOrCodeAndIsDeletedFalse(String name, String code);
1616
}

src/main/java/clap/server/application/service/admin/UpdateCategoryService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.springframework.transaction.annotation.Transactional;
1313

1414
import static clap.server.exception.code.MemberErrorCode.ACTIVE_MEMBER_NOT_FOUND;
15+
import static clap.server.exception.code.TaskErrorCode.CATEGORY_DUPLICATE;
1516
import static clap.server.exception.code.TaskErrorCode.CATEGORY_NOT_FOUND;
1617

1718
@ApplicationService
@@ -25,6 +26,7 @@ public class UpdateCategoryService implements UpdateCategoryUsecase {
2526
@Transactional
2627
public void updateCategory(Long adminId, Long categoryId, String name, String code, String descriptionExample) {
2728
Member admin = loadMemberPort.findActiveMemberById(adminId).orElseThrow(() -> new ApplicationException(ACTIVE_MEMBER_NOT_FOUND));
29+
if (loadCategoryPort.existsByNameOrCode(name, code)) throw new ApplicationException(CATEGORY_DUPLICATE);
2830
Category category = loadCategoryPort.findById(categoryId)
2931
.orElseThrow(() -> new ApplicationException(CATEGORY_NOT_FOUND));
3032
category.updateCategory(admin, name, code, descriptionExample);

0 commit comments

Comments
 (0)