Skip to content

Commit

Permalink
feat: 카카오아이디로 유저정보 조회 api 추가(참여인원,내용저장x) (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
suubinkim committed Jan 17, 2022
1 parent c208bda commit fe8c208
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,12 @@ public ResultResponseDto updateUsername(@ModelAttribute UserRequestDto requestDt
public List<UserChallengeResponseDto> getChallengesByUser(@AuthenticationPrincipal UserDetailsImpl userDetails) {
return challengeHistoryService.getChallengesByUser(userDetails.getUser());
}

/**
* 유저 카카오 아이디로 정보 조회 API
*/
@GetMapping("/user/{kakaoId}")
public UserResponseDto getChatUser(@PathVariable String kakaoId) {
return userService.getChatUser(kakaoId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
@Setter
public class ChatMessageDto {
private String roomId;
private String sender;
private String message;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ public class ChatRoomResponseDto {
private Long roomId;
private String name;
private String createdDate;
private String creator;

public ChatRoomResponseDto(ChatRoom chatRoom) {
this.roomId = chatRoom.getId();
this.name= chatRoom.getName();
this.createdDate = chatRoom.getCreatedDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));;
this.createdDate = chatRoom.getCreatedDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
this.creator = chatRoom.getUser().getKakaoId();
}

}
11 changes: 11 additions & 0 deletions src/main/java/shop/fevertime/backend/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import shop.fevertime.backend.dto.response.FeedResponseDto;
import shop.fevertime.backend.dto.response.UserChallengeResponseDto;
import shop.fevertime.backend.dto.response.UserResponseDto;
import shop.fevertime.backend.exception.ApiRequestException;
import shop.fevertime.backend.repository.ChallengeHistoryRepository;
import shop.fevertime.backend.repository.ChallengeRepository;
Expand Down Expand Up @@ -93,4 +94,14 @@ public void updateUsername(User user, UserRequestDto requestDto) {

findUser.updateUsername(requestDto.getUsername());
}

//카카오 아이디로 유저 정보 가져오기
@Transactional
public UserResponseDto getChatUser(String kakaoId) {
User findUser = userRepository.findByKakaoId(kakaoId).orElseThrow(
() -> new ApiRequestException("해당 아이디가 존재하지 않습니다.")
);
return new UserResponseDto(findUser);
}

}

0 comments on commit fe8c208

Please sign in to comment.