|
@@ -100,21 +100,23 @@ public class BoardService {
|
|
|
Board board = new Board(req);
|
|
Board board = new Board(req);
|
|
|
repository.save(board);
|
|
repository.save(board);
|
|
|
|
|
|
|
|
- List<BoardFileDTO> fileList = new ArrayList<>();
|
|
|
|
|
- for (int i = 0; i < file.size(); i++) {
|
|
|
|
|
- BoardFileDTO dto = new BoardFileDTO();
|
|
|
|
|
- dto.setFilePath("/"+req.getType()+"/Board" + board.getId()+"/"+file.get(i).getOriginalFilename());
|
|
|
|
|
- dto.setBoardId(board);
|
|
|
|
|
- fileList.add(dto);
|
|
|
|
|
|
|
+ if (file != null) {
|
|
|
|
|
+ List<BoardFileDTO> fileList = new ArrayList<>();
|
|
|
|
|
+ for (MultipartFile multipartFile : file) {
|
|
|
|
|
+ BoardFileDTO dto = new BoardFileDTO();
|
|
|
|
|
+ dto.setFilePath("/" + req.getType() + "/Board" + board.getId() + "/" + multipartFile.getOriginalFilename());
|
|
|
|
|
+ dto.setBoardId(board);
|
|
|
|
|
+ fileList.add(dto);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ insertFile(fileList);
|
|
|
|
|
+
|
|
|
|
|
+ String osPath = osProperty();
|
|
|
|
|
+ if (!file.isEmpty()) {
|
|
|
|
|
+ String filePath = osPath + "/" + req.getType() + "/Board" + board.getId()+"/";
|
|
|
|
|
+ fileUpload(filePath, file);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- insertFile(fileList);
|
|
|
|
|
-
|
|
|
|
|
- String osPath = osProperty();
|
|
|
|
|
- if (!file.isEmpty()) {
|
|
|
|
|
- String filePath = osPath + "/" + req.getType() + "/Board" + board.getId()+"/";
|
|
|
|
|
- fileUpload(filePath, file);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@@ -124,7 +126,6 @@ public class BoardService {
|
|
|
BoardFile file = new BoardFile(dto);
|
|
BoardFile file = new BoardFile(dto);
|
|
|
fList.add(file);
|
|
fList.add(file);
|
|
|
}
|
|
}
|
|
|
- log.info(fList.get(0).getFilePath());
|
|
|
|
|
fileRepository.saveAll(fList);
|
|
fileRepository.saveAll(fList);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -163,4 +164,17 @@ public class BoardService {
|
|
|
public Optional<Board> getBoardDetail(BoardReq req) {
|
|
public Optional<Board> getBoardDetail(BoardReq req) {
|
|
|
return repository.findById(req.getId());
|
|
return repository.findById(req.getId());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public SuccessRes updateBoardDetail(BoardReq req) {
|
|
|
|
|
+ Board board = repository.findById(req.getId()).orElseThrow(() -> new EntityNotFoundException("Board Not Found"));
|
|
|
|
|
+ board.updateContent(req.getContent());
|
|
|
|
|
+ return new SuccessRes("200", "update success");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public SuccessRes deleteBoard(BoardReq req) {
|
|
|
|
|
+ Board board = repository.findById(req.getId()).orElseThrow(() -> new EntityNotFoundException("Board Not Found"));
|
|
|
|
|
+ repository.delete(board);
|
|
|
|
|
+ return new SuccessRes("200", "delete success");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|