feat: qna 수정

This commit is contained in:
박정민 2024-08-07 17:44:27 +09:00
parent 25f7343b04
commit 1711fcaf95
3 changed files with 8 additions and 4 deletions

View File

@ -34,7 +34,7 @@ public class MailServiceImpl implements MailService {
redisUtil.setDataExpire(code, email, 60 * 5L);
SimpleMailMessage mail = createEmail(email, "[EDUFOCUS] 비밀번호 찾기 안내", code);
mailSender.send(mail);
//mailSender.send(mail);
}
@Override

View File

@ -71,6 +71,7 @@ public class QnaController {
User findUser = userRepository.findById(userId).orElse(null);
if (findUser.getRole() != UserRole.ADMIN) {
System.out.println("role 안맞음");
throw new RuntimeException("update 실패");
}
@ -88,6 +89,7 @@ public class QnaController {
Long userId = Long.parseLong(jwtUtil.getUserId(token));
User findUser = userRepository.findById(userId).orElse(null);
System.out.println("delete answer");
if (findUser.getRole() != UserRole.ADMIN) {
throw new RuntimeException();
}

View File

@ -55,11 +55,13 @@ public class QnaServiceImpl implements QnaService {
@Override
public QnaResponseDto updateQna(Long id, QnaRequestDto qnaRequestDto, Long userId) {
System.out.println("userId:" + userId);
Qna qna = qnaRepository.findById(id).orElse(null);
System.out.println("quesiton에 있는거: " + qna.getUser().getId());
User user = userRepository.findById(userId).orElse(null);
if (qna.getUser().getId() == userId) {
qnaRepository.delete(qna);
} else {
if (qna.getUser().getId() != userId) {
throw new RuntimeException();
}