Skip to content

Commit

Permalink
[FIX] 소원 조회 시 닉네임 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
wlwpfh committed Dec 18, 2024
1 parent e89e1b7 commit 31be01b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.sopterm.makeawish.repository.abuse;

import com.sopterm.makeawish.domain.abuse.AbuseLog;
import com.sopterm.makeawish.domain.user.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface AbuseLogRepository extends JpaRepository<AbuseLog, Long> {
@Query(value = "SELECT COUNT(AL) FROM ABUSE_LOG AL WHERE AL.user_id = :userId and AL.created_at >= (now() - interval '7 days')", nativeQuery = true)
Integer countAbuseLogByUserIdDuringWeekend(@Param("userId") Long userId);

void deleteByUser(User user);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.sopterm.makeawish.repository.abuse;

import com.sopterm.makeawish.domain.abuse.AbuseUser;
import com.sopterm.makeawish.domain.user.User;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Optional;

public interface AbuseUserRepository extends JpaRepository<AbuseUser, Long> {
Optional<AbuseUser> findAbuseUserByUserId(Long userId);
void deleteByUser(User user);
}
10 changes: 10 additions & 0 deletions src/main/java/com/sopterm/makeawish/service/AbuseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,14 @@ private User getUser(Long userId) {
return userRepository.findById(userId)
.orElseThrow(() -> new EntityNotFoundException(INVALID_USER.getMessage()));
}

@Transactional
public void deleteAbuseLogByUser(User user){
abuseLogRepository.deleteByUser(user);
}

@Transactional
public void deleteAbuseUserByUser(User user){
abuseUserRepository.deleteByUser(user);
}
}
3 changes: 3 additions & 0 deletions src/main/java/com/sopterm/makeawish/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class UserService {
private final AccountCheckService accountCheckService;
private final AbuseService abuseService;


@Value("${popbill.businessNumber}")
private String corpNum;
private static final int ABUSE_CAUTION_COUNT = 4;
Expand All @@ -60,6 +61,8 @@ public void deleteUser(Long userId) {
wish.getPresents().forEach(presentRepository::delete);
wishRepository.delete(wish);
});
abuseService.deleteAbuseLogByUser(user);
abuseService.deleteAbuseUserByUser(user);
userRepository.delete(user);
}

Expand Down

0 comments on commit 31be01b

Please sign in to comment.