diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/entity/QnaResponseDto.java b/backend/src/main/java/com/edufocus/edufocus/qna/entity/QnaResponseDto.java index 3ef0b6a..ee7c768 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/entity/QnaResponseDto.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/entity/QnaResponseDto.java @@ -14,6 +14,7 @@ import java.util.Date; public class QnaResponseDto { + private Long id; private String title; private String username; private String content; @@ -22,7 +23,7 @@ public class QnaResponseDto { public static QnaResponseDto toEntity(Qna qna) { return new QnaResponseDto( - + qna.getId(), qna.getTitle(), qna.getUser().getName(), qna.getContent(), diff --git a/backend/src/main/java/com/edufocus/edufocus/user/controller/UserController.java b/backend/src/main/java/com/edufocus/edufocus/user/controller/UserController.java index 12e4b56..5b36459 100644 --- a/backend/src/main/java/com/edufocus/edufocus/user/controller/UserController.java +++ b/backend/src/main/java/com/edufocus/edufocus/user/controller/UserController.java @@ -50,11 +50,14 @@ public class UserController { Map resultMap = new HashMap<>(); HttpStatus status = HttpStatus.ACCEPTED; - String name= user.getName(); - resultMap.put("name",name); + + try { User loginUser = userService.login(user); if (loginUser != null) { + + String name = loginUser.getName(); + resultMap.put("name",name); String accessToken = jwtUtil.createAccessToken(String.valueOf(loginUser.getId())); String refreshToken = jwtUtil.createRefreshToken(String.valueOf(loginUser.getId())); diff --git a/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserService.java b/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserService.java index 4f3733a..f661fd1 100644 --- a/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserService.java +++ b/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserService.java @@ -11,5 +11,5 @@ public interface UserService { User userInfo(Long id) throws Exception; void sendEamail(User user) throws Exception; void userCheck(Long id) throws Exception; - + String getUserName(Long id) throws Exception; } diff --git a/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserServiceImpl.java index 2c39b06..554d971 100644 --- a/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserServiceImpl.java @@ -136,6 +136,13 @@ public class UserServiceImpl implements UserService{ sendEamail(user); } } + + @Override + public String getUserName(Long id) throws Exception { + + return userRepository.findById(id).get().getName(); + } + public String getTempPassword() { char[] charSet = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};