Skip to content

Commit

Permalink
Template 리팩토링 (Fastcampus-Final-Team3#189)
Browse files Browse the repository at this point in the history
* Template 리팩토링
  • Loading branch information
hybiis authored Oct 24, 2023
1 parent 0c4d6a0 commit eb9ccf4
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApiUtils.ApiResponse<MemberAuthResponse>> findTemplateAuthList(@RequestParam final SpaceType spaceType, @RequestParam final Long memberId, @RequestParam final Long templateBlockId) {
public ResponseEntity<ApiResponse.Response<MemberAuthResponse>> 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<ApiUtils.ApiResponse<TemplateResponse>> findTemplateRecommend(@RequestParam final SpaceWallCategoryType category){
public ResponseEntity<ApiResponse.Response<TemplateResponse>> 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<ApiUtils.ApiResponse<TemplateResponse>> findTemplateCategoryList(@RequestParam final SpaceWallCategoryType category){
public ResponseEntity<ApiResponse.Response<TemplateResponse>> 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<ApiUtils.ApiResponse<TemplateResponse>> findSearchTemplatesByTitle(@RequestParam final String search){
public ResponseEntity<ApiResponse.Response<TemplateResponse>> 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);
}
}

0 comments on commit eb9ccf4

Please sign in to comment.