Skip to content

Commit

Permalink
[FIX] Member 테이블 중복 Row 삭제처리 (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeobi01 authored Dec 4, 2024
1 parent 02ae087 commit 4cdc8bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.scg.stop.project.repository;

import com.scg.stop.project.domain.Member;
import org.springframework.data.jpa.repository.JpaRepository;

public interface MemberRepository extends JpaRepository<Member, Long> {
}
10 changes: 4 additions & 6 deletions src/main/java/com/scg/stop/project/service/ProjectService.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,18 @@
import com.scg.stop.project.dto.response.CommentResponse;
import com.scg.stop.project.dto.response.ProjectDetailResponse;
import com.scg.stop.project.dto.response.ProjectResponse;
import com.scg.stop.project.repository.CommentRepository;
import com.scg.stop.project.repository.FavoriteProjectRepository;
import com.scg.stop.project.repository.LikeRepository;
import com.scg.stop.project.repository.ProjectRepository;
import com.scg.stop.project.repository.*;
import com.scg.stop.global.exception.BadRequestException;
import com.scg.stop.global.exception.ExceptionCode;
import com.scg.stop.global.infrastructure.EmailService;
import com.scg.stop.project.domain.Inquiry;
import com.scg.stop.project.domain.Project;
import com.scg.stop.project.dto.request.InquiryRequest;
import com.scg.stop.project.dto.response.InquiryDetailResponse;
import com.scg.stop.project.repository.InquiryRepository;
import com.scg.stop.project.repository.ProjectRepository;
import com.scg.stop.user.domain.User;
import com.scg.stop.user.repository.UserRepository;
import jakarta.persistence.EntityManager;
import org.hibernate.Hibernate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -54,6 +49,7 @@ public class ProjectService {
private final EventPeriodRepository eventPeriodRepository;
private final UserRepository userRepository;
private final InquiryRepository inquiryRepository;
private final MemberRepository memberRepository;
private final EmailService emailService;

@Value("${spring.mail.adminEmail}")
Expand Down Expand Up @@ -98,6 +94,8 @@ public ProjectDetailResponse updateProject(Long projectId, ProjectRequest projec
.orElseThrow(() -> new BadRequestException(ExceptionCode.NOT_FOUND_PROJECT_POSTER));

Project newProject = projectRequest.toEntity(projectId, thumbnail, poster);

memberRepository.deleteAll(project.getMembers());
project.update(newProject);

return ProjectDetailResponse.of(user, project);
Expand Down

0 comments on commit 4cdc8bc

Please sign in to comment.