diff --git a/backend/src/main/java/com/worlabel/domain/category/controller/LabelCategoryController.java b/backend/src/main/java/com/worlabel/domain/category/controller/LabelCategoryController.java index 503580c..eed7222 100644 --- a/backend/src/main/java/com/worlabel/domain/category/controller/LabelCategoryController.java +++ b/backend/src/main/java/com/worlabel/domain/category/controller/LabelCategoryController.java @@ -3,8 +3,6 @@ package com.worlabel.domain.category.controller; import com.worlabel.domain.category.entity.dto.CategoryRequest; import com.worlabel.domain.category.entity.dto.CategoryResponse; import com.worlabel.domain.category.service.CategoryService; -import com.worlabel.domain.folder.entity.dto.FolderRequest; -import com.worlabel.domain.folder.entity.dto.FolderResponse; import com.worlabel.global.annotation.CurrentUser; import com.worlabel.global.config.swagger.SwaggerApiError; import com.worlabel.global.config.swagger.SwaggerApiSuccess; @@ -35,21 +33,22 @@ public class LabelCategoryController { return categoryService.createCategory(memberId, projectId, categoryRequest); } -// @Operation(summary = "레이블 카테고리 단일 조회", description = "레이블 카테고리를 조회합니다..") -// @SwaggerApiSuccess(description = "카테고리 성공적으로 조회합니다.") -// @SwaggerApiError({ErrorCode.EMPTY_REQUEST_PARAMETER, ErrorCode.SERVER_ERROR}) -// @GetMapping("/{category_id}") -// public CategoryResponse getCategory( -// @CurrentUser final Integer memberId, -// @PathVariable("project_id") final Integer projectId, -// @RequestBody final CategoryRequest categoryRequest) { -// return categoryService.get(memberId, projectId, categoryRequest); -// } + @Operation(summary = "레이블 카테고리 단일 조회", description = "레이블 카테고리를 조회합니다..") + @SwaggerApiSuccess(description = "카테고리 성공적으로 조회합니다.") + @SwaggerApiError({ErrorCode.EMPTY_REQUEST_PARAMETER, ErrorCode.SERVER_ERROR}) + @GetMapping("/{category_id}") + public CategoryResponse getCategory( + @CurrentUser final Integer memberId, + @PathVariable("project_id") final Integer projectId, + @PathVariable("category_id") final Integer categoryId + ) { + return categoryService.getCategoryById(memberId, projectId, categoryId); + } @Operation(summary = "카테고리 삭제", description = "카테고리를 삭제합니다.") - @SwaggerApiSuccess(description = "카테고리를 성공적으로 삭제합니다.") @SwaggerApiError({ErrorCode.EMPTY_REQUEST_PARAMETER, ErrorCode.SERVER_ERROR}) + @SwaggerApiSuccess(description = "카테고리를 성공적으로 삭제합니다.") @DeleteMapping("/{category_id}") public BaseResponse deleteFolder( @CurrentUser final Integer memberId, diff --git a/backend/src/main/java/com/worlabel/domain/category/service/CategoryService.java b/backend/src/main/java/com/worlabel/domain/category/service/CategoryService.java index 480c2fd..f0a8f60 100644 --- a/backend/src/main/java/com/worlabel/domain/category/service/CategoryService.java +++ b/backend/src/main/java/com/worlabel/domain/category/service/CategoryService.java @@ -40,13 +40,18 @@ public class CategoryService { return CategoryResponse.from(labelCategory); } - public void deleteCategory(Integer memberId, Integer projectId, Integer categoryId) { + public void deleteCategory(final int memberId, final int projectId, final int categoryId) { participantService.checkEditorUnauthorized(memberId, projectId); LabelCategory category = getCategory(categoryId); categoryRepository.delete(category); } - private LabelCategory getCategory(Integer categoryId) { + public CategoryResponse getCategoryById(final int memberId, final int projectId, final int categoryId){ + participantService.checkViewerUnauthorized(memberId,projectId); + return CategoryResponse.from(getCategory(categoryId)); + } + + private LabelCategory getCategory(final Integer categoryId) { return categoryRepository.findById(categoryId).orElseThrow(() ->new CustomException(ErrorCode.PROJECT_CATEGORY_NOT_FOUND)); }