Skip to content

Commit

Permalink
recruit/delete 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
1224kang committed Jul 9, 2024
1 parent 4e42e00 commit e7604b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/main/java/hamsung/hamsung_project/entity/Recruit.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ public static Recruit createRecruit(RecruitsRequestsDto requestDto, User user) {
recruit.setCategory(requestDto.getCategory());
recruit.setPlace(requestDto.getPlace());
recruit.setCapacity(requestDto.getCapacity());
recruit.setIsRecruit(requestDto.getIsRecruit());
recruit.setView(requestDto.getView());
recruit.setIsRecruit(false);
recruit.setView(0);
// createdAt 등 필요한 설정 추가 가능
return recruit;
}




public static Recruit updateRecruit(RecruitsRequestsDto dto,Recruit target){
target.setTitle(dto.getTitle());
target.setDescription(dto.getDescription());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ public RecruitsResponseDto updateRecruits(Long id,RecruitsRequestsDto requestsDt
public boolean deleteRecruit(Long id){
Recruit target=recruitsRepository.findById(id).orElseThrow(()->new IllegalArgumentException("해당 게시글을 찾을 수 없습니다."));
if (recruitsRepository.existsById(id)) {
// List<Comment> comment=commentRepository.findAllByRecruitId(id);
// commentRepository.deleteById(id);
//FK 연관관계 때문에 게시글에 딸린 comments 먼저 삭제.
List<Comment> comment=commentRepository.findAllByRecruitId(id);
commentRepository.deleteAll(comment);
recruitsRepository.deleteById(id);
return true;
} else {
Expand Down

0 comments on commit e7604b4

Please sign in to comment.