diff --git a/umcAssignment/src/main/java/cje/umcAssignment/controller/PostController.java b/umcAssignment/src/main/java/cje/umcAssignment/controller/PostController.java index e1ffb1f..f6ba8d7 100644 --- a/umcAssignment/src/main/java/cje/umcAssignment/controller/PostController.java +++ b/umcAssignment/src/main/java/cje/umcAssignment/controller/PostController.java @@ -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; diff --git a/umcAssignment/src/main/java/cje/umcAssignment/domain/Post.java b/umcAssignment/src/main/java/cje/umcAssignment/model/Post.java similarity index 96% rename from umcAssignment/src/main/java/cje/umcAssignment/domain/Post.java rename to umcAssignment/src/main/java/cje/umcAssignment/model/Post.java index 857f909..1d0b96d 100644 --- a/umcAssignment/src/main/java/cje/umcAssignment/domain/Post.java +++ b/umcAssignment/src/main/java/cje/umcAssignment/model/Post.java @@ -1,4 +1,4 @@ -package cje.umcAssignment.domain; +package cje.umcAssignment.model; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/umcAssignment/src/main/java/cje/umcAssignment/domain/PostRequestDto.java b/umcAssignment/src/main/java/cje/umcAssignment/model/PostRequestDto.java similarity index 89% rename from umcAssignment/src/main/java/cje/umcAssignment/domain/PostRequestDto.java rename to umcAssignment/src/main/java/cje/umcAssignment/model/PostRequestDto.java index a2ab065..0784254 100644 --- a/umcAssignment/src/main/java/cje/umcAssignment/domain/PostRequestDto.java +++ b/umcAssignment/src/main/java/cje/umcAssignment/model/PostRequestDto.java @@ -1,7 +1,6 @@ -package cje.umcAssignment.domain; +package cje.umcAssignment.model; import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Getter; import lombok.Setter; diff --git a/umcAssignment/src/main/java/cje/umcAssignment/domain/PostResponseDto.java b/umcAssignment/src/main/java/cje/umcAssignment/model/PostResponseDto.java similarity index 93% rename from umcAssignment/src/main/java/cje/umcAssignment/domain/PostResponseDto.java rename to umcAssignment/src/main/java/cje/umcAssignment/model/PostResponseDto.java index 36a6eb9..d2d99e4 100644 --- a/umcAssignment/src/main/java/cje/umcAssignment/domain/PostResponseDto.java +++ b/umcAssignment/src/main/java/cje/umcAssignment/model/PostResponseDto.java @@ -1,4 +1,4 @@ -package cje.umcAssignment.domain; +package cje.umcAssignment.model; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/umcAssignment/src/main/java/cje/umcAssignment/model/SearchDto.java b/umcAssignment/src/main/java/cje/umcAssignment/model/SearchDto.java new file mode 100644 index 0000000..bebfae4 --- /dev/null +++ b/umcAssignment/src/main/java/cje/umcAssignment/model/SearchDto.java @@ -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; + } +} diff --git a/umcAssignment/src/main/java/cje/umcAssignment/repository/PostRepository.java b/umcAssignment/src/main/java/cje/umcAssignment/repository/PostRepository.java index 881f0a5..9f4fc81 100644 --- a/umcAssignment/src/main/java/cje/umcAssignment/repository/PostRepository.java +++ b/umcAssignment/src/main/java/cje/umcAssignment/repository/PostRepository.java @@ -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; diff --git a/umcAssignment/src/main/java/cje/umcAssignment/repository/SpringDataJpaPostRepository.java b/umcAssignment/src/main/java/cje/umcAssignment/repository/SpringDataJpaPostRepository.java index 62a4b14..1bbd4b4 100644 --- a/umcAssignment/src/main/java/cje/umcAssignment/repository/SpringDataJpaPostRepository.java +++ b/umcAssignment/src/main/java/cje/umcAssignment/repository/SpringDataJpaPostRepository.java @@ -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; diff --git a/umcAssignment/src/main/java/cje/umcAssignment/service/PostService.java b/umcAssignment/src/main/java/cje/umcAssignment/service/PostService.java index 6aa5ef3..4b91ff9 100644 --- a/umcAssignment/src/main/java/cje/umcAssignment/service/PostService.java +++ b/umcAssignment/src/main/java/cje/umcAssignment/service/PostService.java @@ -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 { /* @@ -19,8 +19,9 @@ public interface PostService { /* * 모든 Post 보기 + * paging 적용, SearchDto를 파라미터로 받기 * */ - public List findAll(); + public List findAll(SearchDto searchDto); /* * writer로 Post 보기 diff --git a/umcAssignment/src/main/java/cje/umcAssignment/service/PostServiceImpl.java b/umcAssignment/src/main/java/cje/umcAssignment/service/PostServiceImpl.java index 17def82..3d5edd9 100644 --- a/umcAssignment/src/main/java/cje/umcAssignment/service/PostServiceImpl.java +++ b/umcAssignment/src/main/java/cje/umcAssignment/service/PostServiceImpl.java @@ -1,8 +1,8 @@ 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; @@ -10,7 +10,6 @@ import javax.transaction.Transactional; import java.util.ArrayList; import java.util.List; -import java.util.Optional; @Service @Transactional