feat: qna 수정
This commit is contained in:
parent
25f7343b04
commit
1711fcaf95
@ -34,7 +34,7 @@ public class MailServiceImpl implements MailService {
|
|||||||
redisUtil.setDataExpire(code, email, 60 * 5L);
|
redisUtil.setDataExpire(code, email, 60 * 5L);
|
||||||
|
|
||||||
SimpleMailMessage mail = createEmail(email, "[EDUFOCUS] 비밀번호 찾기 안내", code);
|
SimpleMailMessage mail = createEmail(email, "[EDUFOCUS] 비밀번호 찾기 안내", code);
|
||||||
mailSender.send(mail);
|
//mailSender.send(mail);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,6 +71,7 @@ public class QnaController {
|
|||||||
User findUser = userRepository.findById(userId).orElse(null);
|
User findUser = userRepository.findById(userId).orElse(null);
|
||||||
|
|
||||||
if (findUser.getRole() != UserRole.ADMIN) {
|
if (findUser.getRole() != UserRole.ADMIN) {
|
||||||
|
System.out.println("role 안맞음");
|
||||||
throw new RuntimeException("update 실패");
|
throw new RuntimeException("update 실패");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +89,7 @@ public class QnaController {
|
|||||||
Long userId = Long.parseLong(jwtUtil.getUserId(token));
|
Long userId = Long.parseLong(jwtUtil.getUserId(token));
|
||||||
User findUser = userRepository.findById(userId).orElse(null);
|
User findUser = userRepository.findById(userId).orElse(null);
|
||||||
|
|
||||||
|
System.out.println("delete answer");
|
||||||
if (findUser.getRole() != UserRole.ADMIN) {
|
if (findUser.getRole() != UserRole.ADMIN) {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
@ -55,11 +55,13 @@ public class QnaServiceImpl implements QnaService {
|
|||||||
@Override
|
@Override
|
||||||
public QnaResponseDto updateQna(Long id, QnaRequestDto qnaRequestDto, Long userId) {
|
public QnaResponseDto updateQna(Long id, QnaRequestDto qnaRequestDto, Long userId) {
|
||||||
|
|
||||||
|
System.out.println("userId:" + userId);
|
||||||
|
|
||||||
Qna qna = qnaRepository.findById(id).orElse(null);
|
Qna qna = qnaRepository.findById(id).orElse(null);
|
||||||
|
System.out.println("quesiton에 있는거: " + qna.getUser().getId());
|
||||||
User user = userRepository.findById(userId).orElse(null);
|
User user = userRepository.findById(userId).orElse(null);
|
||||||
if (qna.getUser().getId() == userId) {
|
|
||||||
qnaRepository.delete(qna);
|
if (qna.getUser().getId() != userId) {
|
||||||
} else {
|
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user