From 89976c6314db2ecd5018505fe76e5d0154048454 Mon Sep 17 00:00:00 2001 From: yujinKim Date: Thu, 16 May 2024 07:50:26 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat=20:=20=EA=B4=80=EB=A6=AC=EC=9E=90=20vi?= =?UTF-8?q?ew=20-=20=ED=83=9C=EA=B7=B8=20=EC=A0=84=EC=B2=B4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontserver/tag/adaptor/TagAdaptor.java | 45 +++++++++++ .../frontserver/tag/client/TagApiClient.java | 31 +++++++ .../tag/controller/TagController.java | 41 ++++++++++ .../frontserver/tag/service/TagService.java | 21 +++++ .../templates/admin/fragment/sidebar.html | 2 +- .../templates/admin/page/tagList.html | 81 +++++++++++++++++++ 6 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/t3t/frontserver/tag/adaptor/TagAdaptor.java create mode 100644 src/main/java/com/t3t/frontserver/tag/service/TagService.java create mode 100644 src/main/resources/templates/admin/page/tagList.html diff --git a/src/main/java/com/t3t/frontserver/tag/adaptor/TagAdaptor.java b/src/main/java/com/t3t/frontserver/tag/adaptor/TagAdaptor.java new file mode 100644 index 00000000..33ce7da3 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/tag/adaptor/TagAdaptor.java @@ -0,0 +1,45 @@ +package com.t3t.frontserver.tag.adaptor; + +import com.t3t.frontserver.book.model.dto.TagDto; +import com.t3t.frontserver.common.exception.ApiDataFetchException; +import com.t3t.frontserver.model.response.BaseResponse; +import com.t3t.frontserver.model.response.PageResponse; +import com.t3t.frontserver.tag.client.TagApiClient; +import com.t3t.frontserver.util.FeignClientUtils; +import feign.FeignException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; + +import java.util.Objects; + +@Slf4j +@Component +@RequiredArgsConstructor +public class TagAdaptor { + private final TagApiClient tagApiClient; + + public PageResponse getTagList(int pageNo, int pageSize, String sortBy) { + try { + ResponseEntity>> response = tagApiClient.getTagList(pageNo, pageSize, sortBy); + if (response.getStatusCode() == HttpStatus.OK) { + return Objects.requireNonNull(response.getBody()).getData(); + } + return null; + } catch (FeignException e) { + log.error(e.getMessage()); + throw new ApiDataFetchException(FeignClientUtils.getMessageFromFeignException(e)); + } + } + + public TagDto getTag(Long tagId) { + try { + return Objects.requireNonNull(tagApiClient.getTag(tagId).getBody()).getData(); + } catch (FeignException e) { + log.error(e.getMessage()); + throw new ApiDataFetchException(FeignClientUtils.getMessageFromFeignException(e)); + } + } +} diff --git a/src/main/java/com/t3t/frontserver/tag/client/TagApiClient.java b/src/main/java/com/t3t/frontserver/tag/client/TagApiClient.java index a8dfdc4b..b306f920 100644 --- a/src/main/java/com/t3t/frontserver/tag/client/TagApiClient.java +++ b/src/main/java/com/t3t/frontserver/tag/client/TagApiClient.java @@ -6,15 +6,46 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestParam; @FeignClient(name = "tagApiClient", url = "${t3t.feignClient.url}") public interface TagApiClient { + /** + * 태그 목록 조회 + * @param pageNo 태그 목록의 페이지 번호 (기본값: 0). + * @param pageSize 페이지 당 항목 수 (기본값: 10). + * @param sortBy 정렬 기준 필드 (기본값: tagId). + * @return 200 OK, 태그 목록을 포함한 ResponseEntity.
+ * 204 NO_CONTENT, 데이터가 없는 경우 메시지 반환 + * @author Yujin-nKim(김유진) + */ @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); + + /** + * 태그 수정 요청 + * @param tagId 수정할 태그의 식별자 + * @param tagName 태그 이름 + * @return 200 OK, 메세지 + * @author Yujin-nKim(김유진) + */ + @PutMapping("/t3t/bookstore/tags/{tagId}") + ResponseEntity> modifyTag(@PathVariable Long tagId, @RequestParam String tagName); + + /** + * 태그 상세 조회 + * @param tagId 수정할 태그의 식별자 + * @return 태그 상세 + * @author Yujin-nKim(김유진) + */ + @GetMapping("/t3t/bookstore/tags/{tagId}") + ResponseEntity> getTag(@PathVariable Long tagId); + } diff --git a/src/main/java/com/t3t/frontserver/tag/controller/TagController.java b/src/main/java/com/t3t/frontserver/tag/controller/TagController.java index e16badc4..119af353 100644 --- a/src/main/java/com/t3t/frontserver/tag/controller/TagController.java +++ b/src/main/java/com/t3t/frontserver/tag/controller/TagController.java @@ -4,11 +4,14 @@ import com.t3t.frontserver.model.response.BaseResponse; import com.t3t.frontserver.model.response.PageResponse; import com.t3t.frontserver.tag.client.TagApiClient; +import com.t3t.frontserver.tag.service.TagService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; @Slf4j @@ -16,6 +19,7 @@ @Controller public class TagController { private final TagApiClient tagApiClient; + private final TagService tagService; @GetMapping("/tags") public ResponseEntity>> getTagList( @@ -25,4 +29,41 @@ public ResponseEntity>> getTagList( return tagApiClient.getTagList(pageNo, pageSize, sortBy); } + + /** + * 태그 목록 조회 + * @param pageNo 태그 목록의 페이지 번호 (기본값: 0). + * @param pageSize 페이지 당 항목 수 (기본값: 10). + * @param sortBy 정렬 기준 필드 (기본값: tagId). + * @return 태그 목록 페이지 + * @author Yujin-nKim(김유진) + */ + @GetMapping("/admin/tags") + public String getTagListAdmin(Model model, + @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) { + + PageResponse tagList = tagService.getTagList(pageNo, pageSize, sortBy); + + if (tagList != null) { + int blockLimit = 5; // 현재 페이지 앞뒤로 보여줄 개수 설정 + int nowPage = tagList.getPageNo() + 1; + int startPage = Math.max(nowPage - blockLimit, 1); + int endPage = Math.min(nowPage + blockLimit, tagList.getTotalPages()); + + model.addAttribute("nowPage", nowPage); + model.addAttribute("startPage", startPage); + model.addAttribute("endPage", endPage); + model.addAttribute("tagList", tagList.getContent()); + } + return "admin/page/tagList"; + } + + @GetMapping("/admin/tags/{tagId}/edit") + public String getModifyTagAdmin(Model model, @PathVariable Long tagId){ + TagDto tag = tagService.getTag(tagId); + model.addAttribute("tag", tag); + return "admin/page/editTag"; + } } diff --git a/src/main/java/com/t3t/frontserver/tag/service/TagService.java b/src/main/java/com/t3t/frontserver/tag/service/TagService.java new file mode 100644 index 00000000..abda7093 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/tag/service/TagService.java @@ -0,0 +1,21 @@ +package com.t3t.frontserver.tag.service; + +import com.t3t.frontserver.book.model.dto.TagDto; +import com.t3t.frontserver.model.response.PageResponse; +import com.t3t.frontserver.tag.adaptor.TagAdaptor; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class TagService { + private final TagAdaptor tagAdaptor; + + public PageResponse getTagList(int pageNo, int pageSize, String sortBy) { + return tagAdaptor.getTagList(pageNo, pageSize, sortBy); + } + + public TagDto getTag(Long tagId) { + return tagAdaptor.getTag(tagId); + } +} diff --git a/src/main/resources/templates/admin/fragment/sidebar.html b/src/main/resources/templates/admin/fragment/sidebar.html index ecc4056f..d5f411c5 100644 --- a/src/main/resources/templates/admin/fragment/sidebar.html +++ b/src/main/resources/templates/admin/fragment/sidebar.html @@ -23,7 +23,7 @@
  • - + 도서 태그 관리
  • diff --git a/src/main/resources/templates/admin/page/tagList.html b/src/main/resources/templates/admin/page/tagList.html new file mode 100644 index 00000000..6f92404a --- /dev/null +++ b/src/main/resources/templates/admin/page/tagList.html @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
    CheckBoxTag IdTag Name
    등록된 태그가 없습니다.
    +
    + +
    + + +
    + \ No newline at end of file From 6786b3cc49f4ea5ff79dd28b286aca986d683ecf Mon Sep 17 00:00:00 2001 From: yujinKim Date: Thu, 16 May 2024 08:13:32 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat=20:=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=EA=B4=80=EB=A6=AC=EC=9E=90=20view=20-=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../category/adaptor/CategoryAdaptor.java | 36 +++++++ .../controller/CategoryController.java | 10 ++ .../category/service/CategoryService.java | 18 ++++ .../templates/admin/fragment/sidebar.html | 2 +- .../templates/admin/page/categoryList.html | 98 +++++++++++++++++++ 5 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/t3t/frontserver/category/adaptor/CategoryAdaptor.java create mode 100644 src/main/java/com/t3t/frontserver/category/service/CategoryService.java create mode 100644 src/main/resources/templates/admin/page/categoryList.html diff --git a/src/main/java/com/t3t/frontserver/category/adaptor/CategoryAdaptor.java b/src/main/java/com/t3t/frontserver/category/adaptor/CategoryAdaptor.java new file mode 100644 index 00000000..549c0dc2 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/category/adaptor/CategoryAdaptor.java @@ -0,0 +1,36 @@ +package com.t3t.frontserver.category.adaptor; + +import com.t3t.frontserver.category.client.CategoryApiClient; +import com.t3t.frontserver.category.response.CategoryTreeResponse; +import com.t3t.frontserver.common.exception.ApiDataFetchException; +import com.t3t.frontserver.model.response.BaseResponse; +import com.t3t.frontserver.util.FeignClientUtils; +import feign.FeignException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Objects; + +@Slf4j +@Component +@RequiredArgsConstructor +public class CategoryAdaptor { + private final CategoryApiClient categoryApiClient; + + public List getCategoryTreeByDepth(Integer startDepth, Integer maxDepth) { + try { + ResponseEntity>> response = categoryApiClient.getCategoryTreeByDepth(startDepth, maxDepth); + if (response.getStatusCode() == HttpStatus.OK) { + return Objects.requireNonNull(response.getBody()).getData(); + } + return null; + } catch (FeignException e) { + log.error(e.getMessage()); + throw new ApiDataFetchException(FeignClientUtils.getMessageFromFeignException(e)); + } + } +} diff --git a/src/main/java/com/t3t/frontserver/category/controller/CategoryController.java b/src/main/java/com/t3t/frontserver/category/controller/CategoryController.java index 57a8c7ca..16c0cdf3 100644 --- a/src/main/java/com/t3t/frontserver/category/controller/CategoryController.java +++ b/src/main/java/com/t3t/frontserver/category/controller/CategoryController.java @@ -2,11 +2,13 @@ import com.t3t.frontserver.category.client.CategoryApiClient; import com.t3t.frontserver.category.response.CategoryTreeResponse; +import com.t3t.frontserver.category.service.CategoryService; 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.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -17,9 +19,17 @@ @Controller public class CategoryController { private final CategoryApiClient categoryApiClient; + private final CategoryService categoryService; @GetMapping("/categories") ResponseEntity>> getCategoryTreeByDepth(@RequestParam Integer startDepth, @RequestParam Integer maxDepth) { return categoryApiClient.getCategoryTreeByDepth(startDepth, maxDepth); } + + @GetMapping("/admin/categories") + public String getCategoryListAdmin(Model model) { + List categoryList = categoryService.getCategoryTreeByDepth(1, 2); + model.addAttribute("categoryList", categoryList); + return "admin/page/categoryList"; + } } diff --git a/src/main/java/com/t3t/frontserver/category/service/CategoryService.java b/src/main/java/com/t3t/frontserver/category/service/CategoryService.java new file mode 100644 index 00000000..f39e1c26 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/category/service/CategoryService.java @@ -0,0 +1,18 @@ +package com.t3t.frontserver.category.service; + +import com.t3t.frontserver.category.adaptor.CategoryAdaptor; +import com.t3t.frontserver.category.response.CategoryTreeResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@RequiredArgsConstructor +public class CategoryService { + private final CategoryAdaptor categoryAdaptor; + + public List getCategoryTreeByDepth(Integer startDepth, Integer maxDepth) { + return categoryAdaptor.getCategoryTreeByDepth(startDepth, maxDepth); + } +} diff --git a/src/main/resources/templates/admin/fragment/sidebar.html b/src/main/resources/templates/admin/fragment/sidebar.html index d5f411c5..7be9712f 100644 --- a/src/main/resources/templates/admin/fragment/sidebar.html +++ b/src/main/resources/templates/admin/fragment/sidebar.html @@ -28,7 +28,7 @@
  • - + 도서 카테고리 관리
  • diff --git a/src/main/resources/templates/admin/page/categoryList.html b/src/main/resources/templates/admin/page/categoryList.html new file mode 100644 index 00000000..fb99d4cc --- /dev/null +++ b/src/main/resources/templates/admin/page/categoryList.html @@ -0,0 +1,98 @@ + + + + + + + + + + +
    + + +
    + \ No newline at end of file From 6042771a614c895f8115872a313ec1e2f52709b2 Mon Sep 17 00:00:00 2001 From: yujinKim Date: Thu, 16 May 2024 08:26:21 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat=20:=20Publisher=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=EC=9E=90=20view=20-=20=EC=A0=84=EC=B2=B4=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../publishers/adaptor/PublisherAdaptor.java | 36 ++++++++ .../controller/PublisherController.java | 25 ++++++ .../publishers/service/PublisherService.java | 17 ++++ .../templates/admin/fragment/sidebar.html | 2 +- .../templates/admin/page/publisherList.html | 83 +++++++++++++++++++ 5 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/t3t/frontserver/publishers/adaptor/PublisherAdaptor.java create mode 100644 src/main/java/com/t3t/frontserver/publishers/service/PublisherService.java create mode 100644 src/main/resources/templates/admin/page/publisherList.html diff --git a/src/main/java/com/t3t/frontserver/publishers/adaptor/PublisherAdaptor.java b/src/main/java/com/t3t/frontserver/publishers/adaptor/PublisherAdaptor.java new file mode 100644 index 00000000..166ad654 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/publishers/adaptor/PublisherAdaptor.java @@ -0,0 +1,36 @@ +package com.t3t.frontserver.publishers.adaptor; + +import com.t3t.frontserver.book.model.dto.PublisherDto; +import com.t3t.frontserver.common.exception.ApiDataFetchException; +import com.t3t.frontserver.model.response.BaseResponse; +import com.t3t.frontserver.model.response.PageResponse; +import com.t3t.frontserver.publishers.client.PublisherApiClient; +import com.t3t.frontserver.util.FeignClientUtils; +import feign.FeignException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; + +import java.util.Objects; + +@Slf4j +@Component +@RequiredArgsConstructor +public class PublisherAdaptor { + private final PublisherApiClient publisherApiClient; + + public PageResponse getPublisherList(int pageNo, int pageSize, String sortBy) { + try { + ResponseEntity>> response = publisherApiClient.getPublisherList(pageNo, pageSize, sortBy); + if (response.getStatusCode() == HttpStatus.OK) { + return Objects.requireNonNull(response.getBody()).getData(); + } + return null; + } catch (FeignException e) { + log.error(e.getMessage()); + throw new ApiDataFetchException(FeignClientUtils.getMessageFromFeignException(e)); + } + } +} diff --git a/src/main/java/com/t3t/frontserver/publishers/controller/PublisherController.java b/src/main/java/com/t3t/frontserver/publishers/controller/PublisherController.java index 9b40ca26..9f7b8ebf 100644 --- a/src/main/java/com/t3t/frontserver/publishers/controller/PublisherController.java +++ b/src/main/java/com/t3t/frontserver/publishers/controller/PublisherController.java @@ -4,10 +4,12 @@ import com.t3t.frontserver.model.response.BaseResponse; import com.t3t.frontserver.model.response.PageResponse; import com.t3t.frontserver.publishers.client.PublisherApiClient; +import com.t3t.frontserver.publishers.service.PublisherService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -17,6 +19,7 @@ public class PublisherController { private final PublisherApiClient publisherApiClient; + private final PublisherService publisherService; @GetMapping("/publishers") public ResponseEntity>> getPublisherList( @@ -26,4 +29,26 @@ public ResponseEntity>> getPublisherList return publisherApiClient.getPublisherList(pageNo, pageSize, sortBy); } + + @GetMapping("/admin/publishers") + public String getPublisherListAdmin(Model model, + @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) { + + PageResponse publisherList = publisherService.getPublisherList(pageNo, 20, sortBy); + + if (publisherList != null) { + int blockLimit = 5; // 현재 페이지 앞뒤로 보여줄 개수 설정 + int nowPage = publisherList.getPageNo() + 1; + int startPage = Math.max(nowPage - blockLimit, 1); + int endPage = Math.min(nowPage + blockLimit, publisherList.getTotalPages()); + + model.addAttribute("nowPage", nowPage); + model.addAttribute("startPage", startPage); + model.addAttribute("endPage", endPage); + model.addAttribute("publisherList", publisherList.getContent()); + } + return "admin/page/publisherList"; + } } diff --git a/src/main/java/com/t3t/frontserver/publishers/service/PublisherService.java b/src/main/java/com/t3t/frontserver/publishers/service/PublisherService.java new file mode 100644 index 00000000..56cfdaeb --- /dev/null +++ b/src/main/java/com/t3t/frontserver/publishers/service/PublisherService.java @@ -0,0 +1,17 @@ +package com.t3t.frontserver.publishers.service; + +import com.t3t.frontserver.book.model.dto.PublisherDto; +import com.t3t.frontserver.model.response.PageResponse; +import com.t3t.frontserver.publishers.adaptor.PublisherAdaptor; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class PublisherService { + private final PublisherAdaptor publisherAdaptor; + + public PageResponse getPublisherList(int pageNo, int pageSize, String sortBy) { + return publisherAdaptor.getPublisherList(pageNo, pageSize, sortBy); + } +} diff --git a/src/main/resources/templates/admin/fragment/sidebar.html b/src/main/resources/templates/admin/fragment/sidebar.html index 7be9712f..5b024132 100644 --- a/src/main/resources/templates/admin/fragment/sidebar.html +++ b/src/main/resources/templates/admin/fragment/sidebar.html @@ -33,7 +33,7 @@
  • - + 도서 출판사 정보 관리
  • diff --git a/src/main/resources/templates/admin/page/publisherList.html b/src/main/resources/templates/admin/page/publisherList.html new file mode 100644 index 00000000..4206c68a --- /dev/null +++ b/src/main/resources/templates/admin/page/publisherList.html @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    CheckBoxPublisher IdPublisher NamePublisher Email
    등록된 출판사가 없습니다.
    +
    + +
    + + +
    + \ No newline at end of file From c16686c4d2fff893ffbbec21c92cef31f15b7a89 Mon Sep 17 00:00:00 2001 From: yujinKim Date: Thu, 16 May 2024 08:44:26 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat=20:=20Participant,=20ParticipantRole?= =?UTF-8?q?=20=EA=B4=80=EB=A6=AC=EC=9E=90=20view=20-=20=EC=A0=84=EC=B2=B4?= =?UTF-8?q?=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adaptor/ParticipantAdaptor.java | 36 ++++++++ .../adaptor/ParticipantRoleAdaptor.java | 36 ++++++++ .../controller/ParticipantController.java | 25 ++++++ .../controller/ParticipantRoleController.java | 41 +++++++++ .../service/ParticipantRoleService.java | 17 ++++ .../service/ParticipantService.java | 17 ++++ .../templates/admin/fragment/sidebar.html | 4 +- .../templates/admin/page/participantList.html | 83 +++++++++++++++++++ .../admin/page/participantRoleList.html | 83 +++++++++++++++++++ 9 files changed, 340 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/t3t/frontserver/participant/adaptor/ParticipantAdaptor.java create mode 100644 src/main/java/com/t3t/frontserver/participant/adaptor/ParticipantRoleAdaptor.java create mode 100644 src/main/java/com/t3t/frontserver/participant/controller/ParticipantRoleController.java create mode 100644 src/main/java/com/t3t/frontserver/participant/service/ParticipantRoleService.java create mode 100644 src/main/java/com/t3t/frontserver/participant/service/ParticipantService.java create mode 100644 src/main/resources/templates/admin/page/participantList.html create mode 100644 src/main/resources/templates/admin/page/participantRoleList.html diff --git a/src/main/java/com/t3t/frontserver/participant/adaptor/ParticipantAdaptor.java b/src/main/java/com/t3t/frontserver/participant/adaptor/ParticipantAdaptor.java new file mode 100644 index 00000000..3a09c548 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/participant/adaptor/ParticipantAdaptor.java @@ -0,0 +1,36 @@ +package com.t3t.frontserver.participant.adaptor; + +import com.t3t.frontserver.common.exception.ApiDataFetchException; +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.util.FeignClientUtils; +import feign.FeignException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; + +import java.util.Objects; + +@Slf4j +@Component +@RequiredArgsConstructor +public class ParticipantAdaptor { + private final ParticipantApiClient participantApiClient; + + public PageResponse getParticipantList(int pageNo, int pageSize, String sortBy) { + try { + ResponseEntity>> response = participantApiClient.getParticipantList(pageNo, pageSize, sortBy); + if (response.getStatusCode() == HttpStatus.OK) { + return Objects.requireNonNull(response.getBody()).getData(); + } + return null; + } catch (FeignException e) { + log.error(e.getMessage()); + throw new ApiDataFetchException(FeignClientUtils.getMessageFromFeignException(e)); + } + } +} diff --git a/src/main/java/com/t3t/frontserver/participant/adaptor/ParticipantRoleAdaptor.java b/src/main/java/com/t3t/frontserver/participant/adaptor/ParticipantRoleAdaptor.java new file mode 100644 index 00000000..163263b9 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/participant/adaptor/ParticipantRoleAdaptor.java @@ -0,0 +1,36 @@ +package com.t3t.frontserver.participant.adaptor; + +import com.t3t.frontserver.common.exception.ApiDataFetchException; +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.ParticipantRoleDto; +import com.t3t.frontserver.util.FeignClientUtils; +import feign.FeignException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; + +import java.util.Objects; + +@Slf4j +@Component +@RequiredArgsConstructor +public class ParticipantRoleAdaptor { + private final ParticipantApiClient participantApiClient; + + public PageResponse getParticipantRoleList(int pageNo, int pageSize, String sortBy) { + try { + ResponseEntity>> response = participantApiClient.getParticipantRoleList(pageNo, pageSize, sortBy); + if (response.getStatusCode() == HttpStatus.OK) { + return Objects.requireNonNull(response.getBody()).getData(); + } + return null; + } catch (FeignException e) { + log.error(e.getMessage()); + throw new ApiDataFetchException(FeignClientUtils.getMessageFromFeignException(e)); + } + } +} diff --git a/src/main/java/com/t3t/frontserver/participant/controller/ParticipantController.java b/src/main/java/com/t3t/frontserver/participant/controller/ParticipantController.java index 09328493..6f2980db 100644 --- a/src/main/java/com/t3t/frontserver/participant/controller/ParticipantController.java +++ b/src/main/java/com/t3t/frontserver/participant/controller/ParticipantController.java @@ -5,10 +5,12 @@ import com.t3t.frontserver.participant.client.ParticipantApiClient; import com.t3t.frontserver.participant.dto.ParticipantDto; import com.t3t.frontserver.participant.dto.ParticipantRoleDto; +import com.t3t.frontserver.participant.service.ParticipantService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -17,6 +19,7 @@ @Controller public class ParticipantController { private final ParticipantApiClient participantApiClient; + private final ParticipantService participantService; @GetMapping("/participants") ResponseEntity>> getParticipantList( @@ -35,4 +38,26 @@ ResponseEntity>> getParticipantRol return participantApiClient.getParticipantRoleList(pageNo, pageSize, sortBy); } + + @GetMapping("/admin/participants") + public String getParticipantListAdmin(Model model, + @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) { + + PageResponse participantList = participantService.getParticipantList(pageNo, 20, sortBy); + + if (participantList != null) { + int blockLimit = 5; // 현재 페이지 앞뒤로 보여줄 개수 설정 + int nowPage = participantList.getPageNo() + 1; + int startPage = Math.max(nowPage - blockLimit, 1); + int endPage = Math.min(nowPage + blockLimit, participantList.getTotalPages()); + + model.addAttribute("nowPage", nowPage); + model.addAttribute("startPage", startPage); + model.addAttribute("endPage", endPage); + model.addAttribute("participantList", participantList.getContent()); + } + return "admin/page/participantList"; + } } diff --git a/src/main/java/com/t3t/frontserver/participant/controller/ParticipantRoleController.java b/src/main/java/com/t3t/frontserver/participant/controller/ParticipantRoleController.java new file mode 100644 index 00000000..05199c0f --- /dev/null +++ b/src/main/java/com/t3t/frontserver/participant/controller/ParticipantRoleController.java @@ -0,0 +1,41 @@ +package com.t3t.frontserver.participant.controller; + +import com.t3t.frontserver.book.model.dto.PublisherDto; +import com.t3t.frontserver.model.response.PageResponse; +import com.t3t.frontserver.participant.dto.ParticipantRoleDto; +import com.t3t.frontserver.participant.service.ParticipantRoleService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@Slf4j +@RequiredArgsConstructor +@Controller +public class ParticipantRoleController { + private final ParticipantRoleService participantRoleService; + + @GetMapping("/admin/participantRoles") + public String getParticipantRoleListAdmin(Model model, + @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) { + + PageResponse participantRoleList = participantRoleService.getParticipantRoleList(pageNo, 20, sortBy); + + if (participantRoleList != null) { + int blockLimit = 5; // 현재 페이지 앞뒤로 보여줄 개수 설정 + int nowPage = participantRoleList.getPageNo() + 1; + int startPage = Math.max(nowPage - blockLimit, 1); + int endPage = Math.min(nowPage + blockLimit, participantRoleList.getTotalPages()); + + model.addAttribute("nowPage", nowPage); + model.addAttribute("startPage", startPage); + model.addAttribute("endPage", endPage); + model.addAttribute("participantRoleList", participantRoleList.getContent()); + } + return "admin/page/participantRoleList"; + } +} diff --git a/src/main/java/com/t3t/frontserver/participant/service/ParticipantRoleService.java b/src/main/java/com/t3t/frontserver/participant/service/ParticipantRoleService.java new file mode 100644 index 00000000..2156db59 --- /dev/null +++ b/src/main/java/com/t3t/frontserver/participant/service/ParticipantRoleService.java @@ -0,0 +1,17 @@ +package com.t3t.frontserver.participant.service; + +import com.t3t.frontserver.model.response.PageResponse; +import com.t3t.frontserver.participant.adaptor.ParticipantRoleAdaptor; +import com.t3t.frontserver.participant.dto.ParticipantRoleDto; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ParticipantRoleService { + private final ParticipantRoleAdaptor participantRoleAdaptor; + + public PageResponse getParticipantRoleList(int pageNo, int pageSize, String sortBy) { + return participantRoleAdaptor.getParticipantRoleList(pageNo, pageSize, sortBy); + } +} diff --git a/src/main/java/com/t3t/frontserver/participant/service/ParticipantService.java b/src/main/java/com/t3t/frontserver/participant/service/ParticipantService.java new file mode 100644 index 00000000..d0b05eef --- /dev/null +++ b/src/main/java/com/t3t/frontserver/participant/service/ParticipantService.java @@ -0,0 +1,17 @@ +package com.t3t.frontserver.participant.service; + +import com.t3t.frontserver.model.response.PageResponse; +import com.t3t.frontserver.participant.adaptor.ParticipantAdaptor; +import com.t3t.frontserver.participant.dto.ParticipantDto; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ParticipantService { + private final ParticipantAdaptor participantAdaptor; + + public PageResponse getParticipantList(int pageNo, int pageSize, String sortBy) { + return participantAdaptor.getParticipantList(pageNo, pageSize, sortBy); + } +} diff --git a/src/main/resources/templates/admin/fragment/sidebar.html b/src/main/resources/templates/admin/fragment/sidebar.html index 5b024132..0dea5bd4 100644 --- a/src/main/resources/templates/admin/fragment/sidebar.html +++ b/src/main/resources/templates/admin/fragment/sidebar.html @@ -38,12 +38,12 @@
  • - + 도서 참여자 정보 관리
  • - + 도서 참여자 역할 정보 관리
  • diff --git a/src/main/resources/templates/admin/page/participantList.html b/src/main/resources/templates/admin/page/participantList.html new file mode 100644 index 00000000..a9a1d8ed --- /dev/null +++ b/src/main/resources/templates/admin/page/participantList.html @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    CheckBoxParticipant IdParticipant NameParticipant Email
    등록된 참여자가 없습니다.
    +
    + +
    + + +
    + \ No newline at end of file diff --git a/src/main/resources/templates/admin/page/participantRoleList.html b/src/main/resources/templates/admin/page/participantRoleList.html new file mode 100644 index 00000000..993fd6fa --- /dev/null +++ b/src/main/resources/templates/admin/page/participantRoleList.html @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    CheckBoxParticipantRole IdParticipantRole roleNameEnParticipantRole roleNameKr
    등록된 참여자 역할이 없습니다.
    +
    + +
    + + +
    + \ No newline at end of file From 69ff41cef8a6959dc5b577a9a078378a7ab58be7 Mon Sep 17 00:00:00 2001 From: yujinKim Date: Thu, 16 May 2024 11:28:46 +0900 Subject: [PATCH 5/6] =?UTF-8?q?fix=20:=20url=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/main/page/mypageOrder.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/templates/main/page/mypageOrder.html b/src/main/resources/templates/main/page/mypageOrder.html index 1df8729e..d775d22f 100644 --- a/src/main/resources/templates/main/page/mypageOrder.html +++ b/src/main/resources/templates/main/page/mypageOrder.html @@ -122,7 +122,7 @@
    From f402db3e1e9994f2349268d7605cc0543ef5bdb5 Mon Sep 17 00:00:00 2001 From: yujinKim Date: Thu, 16 May 2024 11:31:42 +0900 Subject: [PATCH 6/6] =?UTF-8?q?fix=20:=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/main/page/detail.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/resources/templates/main/page/detail.html b/src/main/resources/templates/main/page/detail.html index 87aa9006..126d9234 100644 --- a/src/main/resources/templates/main/page/detail.html +++ b/src/main/resources/templates/main/page/detail.html @@ -154,13 +154,13 @@