Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

카테고리 목록 조회 로직 변경 #337

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import codezap.category.dto.request.CreateCategoryRequest;
Expand Down Expand Up @@ -42,8 +43,11 @@ public ResponseEntity<Void> createCategory(
}

@GetMapping
public ResponseEntity<FindAllCategoriesResponse> getCategories(@BasicAuthentication MemberDto memberDto) {
return ResponseEntity.ok(categoryService.findAllByMember(memberDto));
public ResponseEntity<FindAllCategoriesResponse> getCategories(
@BasicAuthentication MemberDto memberDto,
@RequestParam Long memberId
) {
return ResponseEntity.ok(categoryService.findAllByMember(memberId));
}

@PutMapping("/{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public interface SpringDocCategoryController {
@Operation(summary = "카테고리 목록 조회", description = "생성된 모든 카테고리를 조회합니다.")
@ApiResponse(responseCode = "200", description = "조회 성공",
content = {@Content(schema = @Schema(implementation = FindAllCategoriesResponse.class))})
ResponseEntity<FindAllCategoriesResponse> getCategories(MemberDto memberDto);
ResponseEntity<FindAllCategoriesResponse> getCategories(MemberDto memberDto, Long memberId);

@Operation(summary = "카테고리 수정", description = "해당하는 식별자의 카테고리를 수정합니다.")
@ApiResponse(responseCode = "200", description = "카테고리 수정 성공")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public Long create(CreateCategoryRequest createCategoryRequest, MemberDto member
return categoryRepository.save(category).getId();
}

public FindAllCategoriesResponse findAllByMember(MemberDto memberDto) {
Member member = memberJpaRepository.fetchById(memberDto.id());
public FindAllCategoriesResponse findAllByMember(Long memberId) {
Member member = memberJpaRepository.fetchById(memberId);
return FindAllCategoriesResponse.from(categoryRepository.findAllByMember(member));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void findAllCategoriesSuccess() {
RestAssured.given().log().all()
.cookie("Authorization", cookie)
.contentType(ContentType.JSON)
.when().get("/categories")
.when().get("/categories?memberId=1")
.then().log().all()
.statusCode(200)
.body("categories.size()", is(2));
Expand Down