Skip to content

Commit

Permalink
[PC-272] fix: 유저 중복 신고할 수 있도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
devchlee12 committed Jan 28, 2025
1 parent fc57567 commit 48443f7
Showing 1 changed file with 0 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.yapp.domain.report.dto.request.UserReportRequest;
import org.yapp.domain.user.User;
import org.yapp.domain.user.application.UserService;
import org.yapp.error.dto.ReportErrorCode;
import org.yapp.error.exception.ApplicationException;

@Service
@RequiredArgsConstructor
Expand All @@ -27,15 +25,8 @@ public class ReportService {
public Report reportUser(Long reporterId, UserReportRequest userReportRequest) {
User reporter = userService.getUserById(reporterId);
User reportedUser = userService.getUserById(userReportRequest.getReportedUserId());
if (isUserReportedAlready(reporter, reportedUser)) {
throw new ApplicationException(ReportErrorCode.ALREADY_REPORTED);
}
Report report = Report.builder().reporter(reporter).reportedUser(reportedUser)
.reason(userReportRequest.getReason()).build();
return reportRepository.save(report);
}

private boolean isUserReportedAlready(User reporter, User reportedUser) {
return reportRepository.existsReportByReporterAndReportedUser(reporter, reportedUser);
}
}

0 comments on commit 48443f7

Please sign in to comment.