-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathBoardService.java
More file actions
34 lines (25 loc) · 917 Bytes
/
BoardService.java
File metadata and controls
34 lines (25 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.web.service;
import com.web.domain.Board;
import com.web.repository.BoardRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* Created by KimYJ on 2017-07-13.
*/
@Service
public class BoardService {
private final BoardRepository boardRepository;
public BoardService(BoardRepository boardRepository) {
this.boardRepository = boardRepository;
}
public Page<Board> findBoardList(Pageable pageable) {
pageable = PageRequest.of(pageable.getPageNumber() <= 0 ? 0 : pageable.getPageNumber() - 1, pageable.getPageSize());
return boardRepository.findAll(pageable);
}
public Optional<Board> findBoardByIdx(Long idx) {
return boardRepository.findById(idx);
}
}