From 7e27aeb2f66f5e75adf693bc8c748ead401452d7 Mon Sep 17 00:00:00 2001 From: yujinKim Date: Fri, 10 May 2024 07:25:05 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EB=AA=A9=EB=A1=9D=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/model/dto/PublisherDto.java | 17 +++++++++ .../controller/CategoryController.java | 25 ++++++++++++ .../client/ParticipantApiClient.java | 26 +++++++++++++ .../controller/ParticipantController.java | 38 +++++++++++++++++++ .../participant/dto/ParticipantDto.java | 21 ++++++++++ .../participant/dto/ParticipantRoleDto.java | 21 ++++++++++ .../publishers/client/PublisherApiClient.java | 18 +++++++++ .../controller/PublisherController.java | 29 ++++++++++++++ .../frontserver/tag/client/TagApiClient.java | 20 ++++++++++ .../tag/controller/TagController.java | 28 ++++++++++++++ 10 files changed, 243 insertions(+) create mode 100644 src/main/java/com/t3t/frontserver/book/model/dto/PublisherDto.java create mode 100644 src/main/java/com/t3t/frontserver/category/controller/CategoryController.java create mode 100644 src/main/java/com/t3t/frontserver/participant/client/ParticipantApiClient.java create mode 100644 src/main/java/com/t3t/frontserver/participant/controller/ParticipantController.java create mode 100644 src/main/java/com/t3t/frontserver/participant/dto/ParticipantDto.java create mode 100644 src/main/java/com/t3t/frontserver/participant/dto/ParticipantRoleDto.java create mode 100644 src/main/java/com/t3t/frontserver/publishers/client/PublisherApiClient.java create mode 100644 src/main/java/com/t3t/frontserver/publishers/controller/PublisherController.java create mode 100644 src/main/java/com/t3t/frontserver/tag/client/TagApiClient.java create mode 100644 src/main/java/com/t3t/frontserver/tag/controller/TagController.java diff --git a/src/main/java/com/t3t/frontserver/book/model/dto/PublisherDto.java b/src/main/java/com/t3t/frontserver/book/model/dto/PublisherDto.java new file mode 100644 index 0000000..98f4f44 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/book/model/dto/PublisherDto.java @@ -0,0 +1,17 @@ +package com.t3t.frontserver.book.model.dto; + +import lombok.Builder; +import lombok.Data; +import lombok.Getter; + +import javax.validation.constraints.NotNull; + +@Data +@Getter +@Builder +public class PublisherDto { + @NotNull + private Long publisherId; + private String publisherName; + private String publisherEmail; +} diff --git a/src/main/java/com/t3t/frontserver/category/controller/CategoryController.java b/src/main/java/com/t3t/frontserver/category/controller/CategoryController.java new file mode 100644 index 0000000..57a8c7c --- /dev/null +++ b/src/main/java/com/t3t/frontserver/category/controller/CategoryController.java @@ -0,0 +1,25 @@ +package com.t3t.frontserver.category.controller; + +import com.t3t.frontserver.category.client.CategoryApiClient; +import com.t3t.frontserver.category.response.CategoryTreeResponse; +import com.t3t.frontserver.model.response.BaseResponse; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +@Slf4j +@RequiredArgsConstructor +@Controller +public class CategoryController { + private final CategoryApiClient categoryApiClient; + + @GetMapping("/categories") + ResponseEntity>> getCategoryTreeByDepth(@RequestParam Integer startDepth, @RequestParam Integer maxDepth) { + return categoryApiClient.getCategoryTreeByDepth(startDepth, maxDepth); + } +} diff --git a/src/main/java/com/t3t/frontserver/participant/client/ParticipantApiClient.java b/src/main/java/com/t3t/frontserver/participant/client/ParticipantApiClient.java new file mode 100644 index 0000000..a2e3a91 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/participant/client/ParticipantApiClient.java @@ -0,0 +1,26 @@ +package com.t3t.frontserver.participant.client; + +import com.t3t.frontserver.model.response.BaseResponse; +import com.t3t.frontserver.model.response.PageResponse; +import com.t3t.frontserver.participant.dto.ParticipantDto; +import com.t3t.frontserver.participant.dto.ParticipantRoleDto; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@FeignClient(name = "categoryApiClient", url = "${t3t.feignClient.url}") +public interface ParticipantApiClient { + + @GetMapping("/t3t/bookstore/participants") + ResponseEntity>> getParticipantList( + @RequestParam(value = "pageNo", defaultValue = "0", required = false) int pageNo, + @RequestParam(value = "pageSize", defaultValue = "10", required = false) int pageSize, + @RequestParam(value = "sortBy", defaultValue = "participantId", required = false) String sortBy); + + @GetMapping("/t3t/bookstore/participantRoles") + ResponseEntity>> getParticipantRoleList( + @RequestParam(value = "pageNo", defaultValue = "0", required = false) int pageNo, + @RequestParam(value = "pageSize", defaultValue = "10", required = false) int pageSize, + @RequestParam(value = "sortBy", defaultValue = "participantRoleId", required = false) String sortBy); +} diff --git a/src/main/java/com/t3t/frontserver/participant/controller/ParticipantController.java b/src/main/java/com/t3t/frontserver/participant/controller/ParticipantController.java new file mode 100644 index 0000000..0932849 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/participant/controller/ParticipantController.java @@ -0,0 +1,38 @@ +package com.t3t.frontserver.participant.controller; + +import com.t3t.frontserver.model.response.BaseResponse; +import com.t3t.frontserver.model.response.PageResponse; +import com.t3t.frontserver.participant.client.ParticipantApiClient; +import com.t3t.frontserver.participant.dto.ParticipantDto; +import com.t3t.frontserver.participant.dto.ParticipantRoleDto; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@Slf4j +@RequiredArgsConstructor +@Controller +public class ParticipantController { + private final ParticipantApiClient participantApiClient; + + @GetMapping("/participants") + ResponseEntity>> getParticipantList( + @RequestParam(value = "pageNo", defaultValue = "0", required = false) int pageNo, + @RequestParam(value = "pageSize", defaultValue = "10", required = false) int pageSize, + @RequestParam(value = "sortBy", defaultValue = "participantId", required = false) String sortBy) { + + return participantApiClient.getParticipantList(pageNo, pageSize, sortBy); + } + + @GetMapping("/participantRoles") + ResponseEntity>> getParticipantRoleList( + @RequestParam(value = "pageNo", defaultValue = "0", required = false) int pageNo, + @RequestParam(value = "pageSize", defaultValue = "10", required = false) int pageSize, + @RequestParam(value = "sortBy", defaultValue = "participantRoleId", required = false) String sortBy) { + + return participantApiClient.getParticipantRoleList(pageNo, pageSize, sortBy); + } +} diff --git a/src/main/java/com/t3t/frontserver/participant/dto/ParticipantDto.java b/src/main/java/com/t3t/frontserver/participant/dto/ParticipantDto.java new file mode 100644 index 0000000..cb30e38 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/participant/dto/ParticipantDto.java @@ -0,0 +1,21 @@ +package com.t3t.frontserver.participant.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * 도서 참여자에 대한 데이터 전송 객체(DTO)
+ * 각 객체는 도서 참여자의 식별자(ID)와 이름, 이메일을 가지고 있음 + * @author Yujin-nKim(김유진) + */ +@Getter +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ParticipantDto { + private Long id; + private String name; + private String email; +} diff --git a/src/main/java/com/t3t/frontserver/participant/dto/ParticipantRoleDto.java b/src/main/java/com/t3t/frontserver/participant/dto/ParticipantRoleDto.java new file mode 100644 index 0000000..28ccf2b --- /dev/null +++ b/src/main/java/com/t3t/frontserver/participant/dto/ParticipantRoleDto.java @@ -0,0 +1,21 @@ +package com.t3t.frontserver.participant.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * 도서 참여자 역할에 대한 데이터 전송 객체(DTO)
+ * 각 객체는 도서 참여자 역할의 식별자(ID)와 영어 이름, 한국어 이름을 가지고 있음 + * @author Yujin-nKim(김유진) + */ +@Getter +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ParticipantRoleDto { + private Integer id; + private String roleNameEn; + private String roleNameKr; +} diff --git a/src/main/java/com/t3t/frontserver/publishers/client/PublisherApiClient.java b/src/main/java/com/t3t/frontserver/publishers/client/PublisherApiClient.java new file mode 100644 index 0000000..97548ac --- /dev/null +++ b/src/main/java/com/t3t/frontserver/publishers/client/PublisherApiClient.java @@ -0,0 +1,18 @@ +package com.t3t.frontserver.publishers.client; + +import com.t3t.frontserver.book.model.dto.PublisherDto; +import com.t3t.frontserver.model.response.BaseResponse; +import com.t3t.frontserver.model.response.PageResponse; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@FeignClient(name = "publisherApiClient", url = "${t3t.feignClient.url}") +public interface PublisherApiClient { + @GetMapping("t3t/bookstore/publishers") + ResponseEntity>> getPublisherList( + @RequestParam(value = "pageNo", defaultValue = "0", required = false) int pageNo, + @RequestParam(value = "pageSize", defaultValue = "10", required = false) int pageSize, + @RequestParam(value = "sortBy", defaultValue = "publisherId", required = false) String sortBy); +} diff --git a/src/main/java/com/t3t/frontserver/publishers/controller/PublisherController.java b/src/main/java/com/t3t/frontserver/publishers/controller/PublisherController.java new file mode 100644 index 0000000..9b40ca2 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/publishers/controller/PublisherController.java @@ -0,0 +1,29 @@ +package com.t3t.frontserver.publishers.controller; + +import com.t3t.frontserver.book.model.dto.PublisherDto; +import com.t3t.frontserver.model.response.BaseResponse; +import com.t3t.frontserver.model.response.PageResponse; +import com.t3t.frontserver.publishers.client.PublisherApiClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@Slf4j +@RequiredArgsConstructor +@Controller +public class PublisherController { + + private final PublisherApiClient publisherApiClient; + + @GetMapping("/publishers") + public ResponseEntity>> getPublisherList( + @RequestParam(value = "pageNo", defaultValue = "0", required = false) int pageNo, + @RequestParam(value = "pageSize", defaultValue = "10", required = false) int pageSize, + @RequestParam(value = "sortBy", defaultValue = "publisherId", required = false) String sortBy) { + + return publisherApiClient.getPublisherList(pageNo, pageSize, sortBy); + } +} diff --git a/src/main/java/com/t3t/frontserver/tag/client/TagApiClient.java b/src/main/java/com/t3t/frontserver/tag/client/TagApiClient.java new file mode 100644 index 0000000..a8dfdc4 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/tag/client/TagApiClient.java @@ -0,0 +1,20 @@ +package com.t3t.frontserver.tag.client; + +import com.t3t.frontserver.book.model.dto.TagDto; +import com.t3t.frontserver.model.response.BaseResponse; +import com.t3t.frontserver.model.response.PageResponse; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@FeignClient(name = "tagApiClient", url = "${t3t.feignClient.url}") +public interface TagApiClient { + + @GetMapping(value = "/t3t/bookstore/tags") + ResponseEntity>> getTagList( + @RequestParam(value = "pageNo", defaultValue = "0", required = false) int pageNo, + @RequestParam(value = "pageSize", defaultValue = "10", required = false) int pageSize, + @RequestParam(value = "sortBy", defaultValue = "tagId", required = false) String sortBy); + +} diff --git a/src/main/java/com/t3t/frontserver/tag/controller/TagController.java b/src/main/java/com/t3t/frontserver/tag/controller/TagController.java new file mode 100644 index 0000000..e16badc --- /dev/null +++ b/src/main/java/com/t3t/frontserver/tag/controller/TagController.java @@ -0,0 +1,28 @@ +package com.t3t.frontserver.tag.controller; + +import com.t3t.frontserver.book.model.dto.TagDto; +import com.t3t.frontserver.model.response.BaseResponse; +import com.t3t.frontserver.model.response.PageResponse; +import com.t3t.frontserver.tag.client.TagApiClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@Slf4j +@RequiredArgsConstructor +@Controller +public class TagController { + private final TagApiClient tagApiClient; + + @GetMapping("/tags") + public ResponseEntity>> getTagList( + @RequestParam(value = "pageNo", defaultValue = "0", required = false) int pageNo, + @RequestParam(value = "pageSize", defaultValue = "10", required = false) int pageSize, + @RequestParam(value = "sortBy", defaultValue = "tagId", required = false) String sortBy) { + + return tagApiClient.getTagList(pageNo, pageSize, sortBy); + } +}