From eb9ccf41cfa718cbe2f28daef9e1c8ba69bc4e86 Mon Sep 17 00:00:00 2001 From: hj_00 <76191250+hybiis@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:33:28 +0900 Subject: [PATCH] =?UTF-8?q?Template=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= =?UTF-8?q?=20(#189)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Template 리팩토링 --- .../controller/TemplateController.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/javajober/template/controller/TemplateController.java b/src/main/java/com/javajober/template/controller/TemplateController.java index 98ae9c4..8c2db84 100644 --- a/src/main/java/com/javajober/template/controller/TemplateController.java +++ b/src/main/java/com/javajober/template/controller/TemplateController.java @@ -7,52 +7,55 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.javajober.core.exception.ApiStatus; import com.javajober.core.message.SuccessMessage; import com.javajober.core.util.ApiUtils; +import com.javajober.core.util.response.ApiResponse; import com.javajober.spaceWall.spaceWallCategory.domain.SpaceWallCategoryType; import com.javajober.template.dto.response.MemberAuthResponse; import com.javajober.space.domain.SpaceType; import com.javajober.template.dto.response.TemplateResponse; import com.javajober.template.service.TemplateService; -import lombok.RequiredArgsConstructor; - @RestController -@RequiredArgsConstructor @RequestMapping("/api/wall/templates") public class TemplateController { private final TemplateService templateService; + public TemplateController(TemplateService templateService) { + this.templateService = templateService; + } + @GetMapping("/auth") - public ResponseEntity> findTemplateAuthList(@RequestParam final SpaceType spaceType, @RequestParam final Long memberId, @RequestParam final Long templateBlockId) { + public ResponseEntity> findTemplateAuthList(@RequestParam final SpaceType spaceType, @RequestParam final Long memberId, @RequestParam final Long templateBlockId) { MemberAuthResponse data = templateService.findTemplateAuthList(spaceType, memberId, templateBlockId); - return ResponseEntity.ok(ApiUtils.success(HttpStatus.OK, SuccessMessage.TEMPLATE_AUTH_SUCCESS, data)); + return ApiResponse.response(ApiStatus.OK, "권한설정을 위한 유저정보 조회를 성공했습니다.", data); } @GetMapping - public ResponseEntity> findTemplateRecommend(@RequestParam final SpaceWallCategoryType category){ + public ResponseEntity> findTemplateRecommend(@RequestParam final SpaceWallCategoryType category){ TemplateResponse data = templateService.findTemplateRecommend(category); - return ResponseEntity.ok(ApiUtils.success(HttpStatus.OK, SuccessMessage.TEMPLATE_RECOMMEND_SUCCESS, data)); + return ApiResponse.response(ApiStatus.OK, "추천템플릿 조회를 성공했습니다", data); } @GetMapping("/lists") - public ResponseEntity> findTemplateCategoryList(@RequestParam final SpaceWallCategoryType category){ + public ResponseEntity> findTemplateCategoryList(@RequestParam final SpaceWallCategoryType category){ TemplateResponse data = templateService.findTemplateRecommend(category); - return ResponseEntity.ok(ApiUtils.success(HttpStatus.OK, SuccessMessage.TEMPLATE_CATEGORY_SUCCESS, data)); + return ApiResponse.response(ApiStatus.OK, "카테고리별 템플릿 리스트 조회를 성공했습니다.", data); } @GetMapping(params = "search") - public ResponseEntity> findSearchTemplatesByTitle(@RequestParam final String search){ + public ResponseEntity> findSearchTemplatesByTitle(@RequestParam final String search){ TemplateResponse data = templateService.findSearchTemplatesByTitle(search); - return ResponseEntity.ok(ApiUtils.success(HttpStatus.OK, SuccessMessage.TEMPLATE_SEARCH_SUCCESS, data)); + return ApiResponse.response(ApiStatus.OK, "템플릿 검색을 성공했습니다.", data); } } \ No newline at end of file