해당 게시글은 개인 프로젝트인 "광고 관리 플랫폼 대행사 센터 제작" 중
#65 "광고 관리 (캠페인/소재) 정렬/페이징 기능 구현" 이슈를 다루고 있습니다.
public String creatives(
@PathVariable("clientId") String clientId,
@PathVariable Long campaignId,
ModelMap map
) {
CampaignWithCreativesResponse campaignWithCreatives = CampaignWithCreativesResponse.from(campaignService.getCampaignWithCreatives(campaignId));
ClientUserWithCampaignsResponse clientUserWithCampaignsResponse = ClientUserWithCampaignsResponse.from(manageService.getClientUserWithCampaigns(clientId));
map.addAttribute("clientUser", clientUserWithCampaignsResponse);
map.addAttribute("campaign", campaignWithCreatives);
map.addAttribute("creatives", campaignWithCreatives.creativeResponses());
public String creatives(
@PathVariable("clientId") String clientId,
@PathVariable Long campaignId,
@PageableDefault(size = 10, sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable,
ModelMap map
) {
Page<CreativeResponse> creatives = creativeService.searchCreatives(pageable, campaignId).map(CreativeResponse::from);
CampaignResponse campaign = CampaignResponse.from(campaignService.getCampaign(campaignId));
ClientUserWithCampaignsResponse clientUserWithCampaignsResponse = ClientUserWithCampaignsResponse.from(manageService.getClientUserWithCampaigns(clientId));
List<Integer> barNumbers = paginationService.getPaginationBarNumbers(pageable.getPageNumber(), creatives.getTotalPages());
map.addAttribute("clientUser", clientUserWithCampaignsResponse);
map.addAttribute("campaign", campaign);
map.addAttribute("creatives", creatives);
map.addAttribute("paginationBarNumbers", barNumbers);
map.addAttribute("totalCount", creativeService.getCreativeCount());
@Transactional(readOnly = true)
public Page<CreativeDto> searchCreatives(Pageable pageable) {
return creativeRepository.findByDeletedFalse(pageable).map(CreativeDto::from);
}
@Transactional(readOnly = true)
public Page<CreativeDto> searchCreatives(Pageable pageable, Long campaignId) {
return creativeRepository.findByDeletedFalseAndCampaign_Id(pageable, campaignId).map(CreativeDto::from);
}