diff --git a/src/main/java/hamsung/hamsung_project/entity/Recruit.java b/src/main/java/hamsung/hamsung_project/entity/Recruit.java index 8f79149..1eff63a 100644 --- a/src/main/java/hamsung/hamsung_project/entity/Recruit.java +++ b/src/main/java/hamsung/hamsung_project/entity/Recruit.java @@ -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()); diff --git a/src/main/java/hamsung/hamsung_project/service/RecruitsService.java b/src/main/java/hamsung/hamsung_project/service/RecruitsService.java index 2e2738a..533c31d 100644 --- a/src/main/java/hamsung/hamsung_project/service/RecruitsService.java +++ b/src/main/java/hamsung/hamsung_project/service/RecruitsService.java @@ -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=commentRepository.findAllByRecruitId(id); -// commentRepository.deleteById(id); + //FK 연관관계 때문에 게시글에 딸린 comments 먼저 삭제. + List comment=commentRepository.findAllByRecruitId(id); + commentRepository.deleteAll(comment); recruitsRepository.deleteById(id); return true; } else {