-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from nhnacademy-be5-T3Team/feature/admin_tag
Feature/admin tag
- Loading branch information
Showing
22 changed files
with
885 additions
and
5 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/java/com/t3t/frontserver/category/adaptor/CategoryAdaptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<CategoryTreeResponse> getCategoryTreeByDepth(Integer startDepth, Integer maxDepth) { | ||
try { | ||
ResponseEntity<BaseResponse<List<CategoryTreeResponse>>> 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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/t3t/frontserver/category/service/CategoryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<CategoryTreeResponse> getCategoryTreeByDepth(Integer startDepth, Integer maxDepth) { | ||
return categoryAdaptor.getCategoryTreeByDepth(startDepth, maxDepth); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/t3t/frontserver/participant/adaptor/ParticipantAdaptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ParticipantDto> getParticipantList(int pageNo, int pageSize, String sortBy) { | ||
try { | ||
ResponseEntity<BaseResponse<PageResponse<ParticipantDto>>> 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)); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/t3t/frontserver/participant/adaptor/ParticipantRoleAdaptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ParticipantRoleDto> getParticipantRoleList(int pageNo, int pageSize, String sortBy) { | ||
try { | ||
ResponseEntity<BaseResponse<PageResponse<ParticipantRoleDto>>> 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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/com/t3t/frontserver/participant/controller/ParticipantRoleController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ParticipantRoleDto> 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"; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/t3t/frontserver/participant/service/ParticipantRoleService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ParticipantRoleDto> getParticipantRoleList(int pageNo, int pageSize, String sortBy) { | ||
return participantRoleAdaptor.getParticipantRoleList(pageNo, pageSize, sortBy); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/t3t/frontserver/participant/service/ParticipantService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ParticipantDto> getParticipantList(int pageNo, int pageSize, String sortBy) { | ||
return participantAdaptor.getParticipantList(pageNo, pageSize, sortBy); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/t3t/frontserver/publishers/adaptor/PublisherAdaptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<PublisherDto> getPublisherList(int pageNo, int pageSize, String sortBy) { | ||
try { | ||
ResponseEntity<BaseResponse<PageResponse<PublisherDto>>> 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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/com/t3t/frontserver/publishers/service/PublisherService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<PublisherDto> getPublisherList(int pageNo, int pageSize, String sortBy) { | ||
return publisherAdaptor.getPublisherList(pageNo, pageSize, sortBy); | ||
} | ||
} |
Oops, something went wrong.