Merge pull request #120 from TeamBNBN/BE/user

feat: user login, qna 조회 수정
This commit is contained in:
김기창 2024-07-26 13:23:46 +09:00 committed by GitHub
commit c99d3cc7ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 4 deletions

View File

@ -14,6 +14,7 @@ import java.util.Date;
public class QnaResponseDto { public class QnaResponseDto {
private Long id;
private String title; private String title;
private String username; private String username;
private String content; private String content;
@ -22,7 +23,7 @@ public class QnaResponseDto {
public static QnaResponseDto toEntity(Qna qna) public static QnaResponseDto toEntity(Qna qna)
{ {
return new QnaResponseDto( return new QnaResponseDto(
qna.getId(),
qna.getTitle(), qna.getTitle(),
qna.getUser().getName(), qna.getUser().getName(),
qna.getContent(), qna.getContent(),

View File

@ -50,11 +50,14 @@ public class UserController {
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
HttpStatus status = HttpStatus.ACCEPTED; HttpStatus status = HttpStatus.ACCEPTED;
String name= user.getName();
resultMap.put("name",name);
try { try {
User loginUser = userService.login(user); User loginUser = userService.login(user);
if (loginUser != null) { if (loginUser != null) {
String name = loginUser.getName();
resultMap.put("name",name);
String accessToken = jwtUtil.createAccessToken(String.valueOf(loginUser.getId())); String accessToken = jwtUtil.createAccessToken(String.valueOf(loginUser.getId()));
String refreshToken = jwtUtil.createRefreshToken(String.valueOf(loginUser.getId())); String refreshToken = jwtUtil.createRefreshToken(String.valueOf(loginUser.getId()));

View File

@ -11,5 +11,5 @@ public interface UserService {
User userInfo(Long id) throws Exception; User userInfo(Long id) throws Exception;
void sendEamail(User user) throws Exception; void sendEamail(User user) throws Exception;
void userCheck(Long id) throws Exception; void userCheck(Long id) throws Exception;
String getUserName(Long id) throws Exception;
} }

View File

@ -136,6 +136,13 @@ public class UserServiceImpl implements UserService{
sendEamail(user); sendEamail(user);
} }
} }
@Override
public String getUserName(Long id) throws Exception {
return userRepository.findById(id).get().getName();
}
public String getTempPassword() { public String getTempPassword() {
char[] charSet = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 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'}; 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};