Skip to content

Commit

Permalink
UMC-EWHA#31 Feat: add paging(작업중)
Browse files Browse the repository at this point in the history
  • Loading branch information
cje1903 committed Nov 20, 2022
1 parent 1aa2b9f commit 49756d5
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package cje.umcAssignment.controller;

import cje.umcAssignment.domain.PostRequestDto;
import cje.umcAssignment.domain.PostResponseDto;
import cje.umcAssignment.model.PostRequestDto;
import cje.umcAssignment.model.PostResponseDto;
import cje.umcAssignment.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cje.umcAssignment.domain;
package cje.umcAssignment.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cje.umcAssignment.domain;
package cje.umcAssignment.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cje.umcAssignment.domain;
package cje.umcAssignment.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
25 changes: 25 additions & 0 deletions umcAssignment/src/main/java/cje/umcAssignment/model/SearchDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cje.umcAssignment.model;

import lombok.Getter;
import lombok.Setter;

// paging을 위해
@Getter @Setter
public class SearchDto {
private int page; // 현재 페이지 번호
private int recordSize; // 페이지당 출력할 데이터 개수
private int pageSize; // 화면 하단에 출력할 페이지 사이즈
private String keyword; // 검색 키워드
private String SearchType; // 검색 유형

// 생성자
public SearchDto(){
this.page = 1;
this.recordSize = 10;
this.pageSize = 10;
}

public int getOffset() {
return (page-1) * recordSize;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cje.umcAssignment.repository;

import cje.umcAssignment.domain.Post;
import cje.umcAssignment.model.Post;

import java.util.List;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cje.umcAssignment.repository;

import cje.umcAssignment.domain.Post;
import cje.umcAssignment.model.Post;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package cje.umcAssignment.service;

import cje.umcAssignment.domain.PostRequestDto;
import cje.umcAssignment.domain.PostResponseDto;
import cje.umcAssignment.model.PostRequestDto;
import cje.umcAssignment.model.PostResponseDto;
import cje.umcAssignment.model.SearchDto;

import java.util.List;
import java.util.Optional;

public interface PostService {
/*
Expand All @@ -19,8 +19,9 @@ public interface PostService {

/*
* 모든 Post 보기
* paging 적용, SearchDto를 파라미터로 받기
* */
public List<PostResponseDto> findAll();
public List<PostResponseDto> findAll(SearchDto searchDto);

/*
* writer로 Post 보기
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package cje.umcAssignment.service;

import cje.umcAssignment.domain.Post;
import cje.umcAssignment.domain.PostRequestDto;
import cje.umcAssignment.domain.PostResponseDto;
import cje.umcAssignment.model.Post;
import cje.umcAssignment.model.PostRequestDto;
import cje.umcAssignment.model.PostResponseDto;
import cje.umcAssignment.repository.PostRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

@Service
@Transactional
Expand Down

0 comments on commit 49756d5

Please sign in to comment.