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/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/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/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 f03c1ef9..5a9bc89f 100644 --- a/src/main/resources/templates/admin/fragment/sidebar.html +++ b/src/main/resources/templates/admin/fragment/sidebar.html @@ -23,27 +23,27 @@
  • - + 도서 태그 관리
  • - + 도서 카테고리 관리
  • - + 도서 출판사 정보 관리
  • - + 도서 참여자 정보 관리
  • - + 도서 참여자 역할 정보 관리
  • 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 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 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 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