From fa7acc5cd5c8f837218617e8fcb9b357a53c9fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=A9=EC=88=98?= Date: Fri, 13 Sep 2024 17:17:23 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EB=A0=88=EC=9D=B4=EB=B8=94=20=EC=B9=B4?= =?UTF-8?q?=ED=85=8C=EA=B3=A0=EB=A6=AC=20=EB=8B=A8=EC=9D=BC=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LabelCategoryController.java | 25 +++++++++---------- .../category/service/CategoryService.java | 9 +++++-- 2 files changed, 19 insertions(+), 15 deletions(-) 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)); }