Skip to content

Commit

Permalink
fix(tag): 템플릿 태그 조회 API 변경 및 인증 확인 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kyum-q committed Aug 8, 2024
1 parent ee36b23 commit ff273a1
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package codezap.tag.controller;

import org.springframework.http.ResponseEntity;

import codezap.member.dto.MemberDto;
import codezap.template.dto.response.FindAllTagsResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "태그 API", description = "템플릿 조회 API")
public interface SpringDocTagController {
@Operation(summary = "태그 목록 조회", description = """
유저가 가지고 있는 태그 목록을 조회합니다.
""")
@ApiResponse(responseCode = "200", description = "태그 목록 조회 성공",
content = {@Content(schema = @Schema(implementation = FindAllTagsResponse.class))})
ResponseEntity<FindAllTagsResponse> getTags(MemberDto memberDto, Long memberId);

}
32 changes: 32 additions & 0 deletions backend/src/main/java/codezap/tag/controller/TagController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package codezap.tag.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import codezap.member.configuration.BasicAuthentication;
import codezap.member.dto.MemberDto;
import codezap.template.dto.response.FindAllTagsResponse;
import codezap.template.service.TemplateService;

@RestController
@RequestMapping("/tags")
public class TagController implements SpringDocTagController {

private final TemplateService templateService;

public TagController(TemplateService templateService) {
this.templateService = templateService;
}

@GetMapping
public ResponseEntity<FindAllTagsResponse> getTags(
@BasicAuthentication MemberDto memberDto,
@RequestParam Long memberId
) {
FindAllTagsResponse response = templateService.findAllTagsByMemberId(memberId);
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import codezap.global.swagger.error.ApiErrorResponse;
import codezap.global.swagger.error.ErrorCase;
import codezap.member.dto.MemberDto;
import codezap.template.dto.request.CreateTemplateRequest;
import codezap.template.dto.request.UpdateTemplateRequest;
import codezap.template.dto.response.ExploreTemplatesResponse;
import codezap.template.dto.response.FindAllTagsResponse;
import codezap.template.dto.response.FindAllTemplatesResponse;
import codezap.template.dto.response.FindTemplateResponse;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -70,13 +67,6 @@ ResponseEntity<FindAllTemplatesResponse> getTemplates(
Pageable pageable
);

@Operation(summary = "태그 목록 조회", description = """
유저가 가지고 있는 태그 목록을 조회합니다.
""")
@ApiResponse(responseCode = "200", description = "태그 목록 조회 성공",
content = {@Content(schema = @Schema(implementation = FindAllTagsResponse.class))})
ResponseEntity<FindAllTagsResponse> getTags(Long memberId);

@Operation(summary = "템플릿 단건 조회", description = "해당하는 식별자의 템플릿을 조회합니다.")
@ApiResponse(responseCode = "200", description = "템플릿 단건 조회 성공",
content = {@Content(schema = @Schema(implementation = ExploreTemplatesResponse.class))})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import codezap.template.dto.request.CreateTemplateRequest;
import codezap.template.dto.request.UpdateTemplateRequest;
import codezap.template.dto.response.ExploreTemplatesResponse;
import codezap.template.dto.response.FindAllTagsResponse;
import codezap.template.dto.response.FindAllTemplatesResponse;
import codezap.template.dto.response.FindTemplateResponse;
import codezap.template.service.TemplateService;
Expand Down Expand Up @@ -61,12 +60,6 @@ public ResponseEntity<FindAllTemplatesResponse> getTemplates(
return ResponseEntity.ok(response);
}

@GetMapping("/tags")
public ResponseEntity<FindAllTagsResponse> getTags(@RequestParam Long memberId) {
FindAllTagsResponse response = templateService.findAllTagsByMemberId(memberId);
return ResponseEntity.ok(response);
}

@GetMapping("/explore")
public ResponseEntity<ExploreTemplatesResponse> explore() {
return ResponseEntity.ok(templateService.findAll());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package codezap.template.service;
package codezap.tag.service;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
Expand Down Expand Up @@ -33,6 +33,7 @@
import codezap.template.repository.TemplateRepository;
import codezap.template.repository.TemplateTagRepository;
import codezap.template.repository.ThumbnailSnippetRepository;
import codezap.template.service.TemplateService;
import io.restassured.RestAssured;

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
Expand Down

0 comments on commit ff273a1

Please sign in to comment.