Merge branch 'BE/userinfo' into 'backend'
feat: qna 수정 See merge request s11-webmobile1-sub2/S11P12A701!94
This commit is contained in:
commit
5bdd170f1f
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user