-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBookService.java
More file actions
35 lines (27 loc) · 989 Bytes
/
BookService.java
File metadata and controls
35 lines (27 loc) · 989 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
35
package com.example.javaweb.service;
import com.example.javaweb.db.Repository;
import com.example.javaweb.model.Board;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class BookService {
@Autowired
private Repository repository;
public Board create(Board board) {
return repository.save(board);
}
public void delete(Long id) {
repository.delete(id);
}
public Board update(Long id, Board updateData) {
Board updatedBoard = repository.get(id);
if (updateData.content != null) updatedBoard.content = updateData.content;
if (updateData.subject != null) updatedBoard.subject = updateData.subject;
if (updateData.writer != null) updatedBoard.writer = updateData.writer;
return repository.update(id, updatedBoard);
}
public List<Board> selectAll() {
return repository.getAll();
}
}