Feat: 레이블 카테고리 단일 조회
This commit is contained in:
parent
bb5a303d77
commit
fa7acc5cd5
@ -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.CategoryRequest;
|
||||||
import com.worlabel.domain.category.entity.dto.CategoryResponse;
|
import com.worlabel.domain.category.entity.dto.CategoryResponse;
|
||||||
import com.worlabel.domain.category.service.CategoryService;
|
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.annotation.CurrentUser;
|
||||||
import com.worlabel.global.config.swagger.SwaggerApiError;
|
import com.worlabel.global.config.swagger.SwaggerApiError;
|
||||||
import com.worlabel.global.config.swagger.SwaggerApiSuccess;
|
import com.worlabel.global.config.swagger.SwaggerApiSuccess;
|
||||||
@ -35,21 +33,22 @@ public class LabelCategoryController {
|
|||||||
return categoryService.createCategory(memberId, projectId, categoryRequest);
|
return categoryService.createCategory(memberId, projectId, categoryRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Operation(summary = "레이블 카테고리 단일 조회", description = "레이블 카테고리를 조회합니다..")
|
@Operation(summary = "레이블 카테고리 단일 조회", description = "레이블 카테고리를 조회합니다..")
|
||||||
// @SwaggerApiSuccess(description = "카테고리 성공적으로 조회합니다.")
|
@SwaggerApiSuccess(description = "카테고리 성공적으로 조회합니다.")
|
||||||
// @SwaggerApiError({ErrorCode.EMPTY_REQUEST_PARAMETER, ErrorCode.SERVER_ERROR})
|
@SwaggerApiError({ErrorCode.EMPTY_REQUEST_PARAMETER, ErrorCode.SERVER_ERROR})
|
||||||
// @GetMapping("/{category_id}")
|
@GetMapping("/{category_id}")
|
||||||
// public CategoryResponse getCategory(
|
public CategoryResponse getCategory(
|
||||||
// @CurrentUser final Integer memberId,
|
@CurrentUser final Integer memberId,
|
||||||
// @PathVariable("project_id") final Integer projectId,
|
@PathVariable("project_id") final Integer projectId,
|
||||||
// @RequestBody final CategoryRequest categoryRequest) {
|
@PathVariable("category_id") final Integer categoryId
|
||||||
// return categoryService.get(memberId, projectId, categoryRequest);
|
) {
|
||||||
// }
|
return categoryService.getCategoryById(memberId, projectId, categoryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "카테고리 삭제", description = "카테고리를 삭제합니다.")
|
@Operation(summary = "카테고리 삭제", description = "카테고리를 삭제합니다.")
|
||||||
@SwaggerApiSuccess(description = "카테고리를 성공적으로 삭제합니다.")
|
|
||||||
@SwaggerApiError({ErrorCode.EMPTY_REQUEST_PARAMETER, ErrorCode.SERVER_ERROR})
|
@SwaggerApiError({ErrorCode.EMPTY_REQUEST_PARAMETER, ErrorCode.SERVER_ERROR})
|
||||||
|
@SwaggerApiSuccess(description = "카테고리를 성공적으로 삭제합니다.")
|
||||||
@DeleteMapping("/{category_id}")
|
@DeleteMapping("/{category_id}")
|
||||||
public BaseResponse<Void> deleteFolder(
|
public BaseResponse<Void> deleteFolder(
|
||||||
@CurrentUser final Integer memberId,
|
@CurrentUser final Integer memberId,
|
||||||
|
@ -40,13 +40,18 @@ public class CategoryService {
|
|||||||
return CategoryResponse.from(labelCategory);
|
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);
|
participantService.checkEditorUnauthorized(memberId, projectId);
|
||||||
LabelCategory category = getCategory(categoryId);
|
LabelCategory category = getCategory(categoryId);
|
||||||
categoryRepository.delete(category);
|
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));
|
return categoryRepository.findById(categoryId).orElseThrow(() ->new CustomException(ErrorCode.PROJECT_CATEGORY_NOT_FOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user