Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: 내 정보 조회 API 구현 #33

Merged
merged 2 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions src/main/java/slvtwn/khu/toyouserver/application/UserService.java

This file was deleted.

25 changes: 11 additions & 14 deletions src/main/java/slvtwn/khu/toyouserver/common/SessionUserService.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package slvtwn.khu.toyouserver.common;

import org.springframework.stereotype.Service;
import slvtwn.khu.toyouserver.application.UserService;
import slvtwn.khu.toyouserver.domain.SessionUser;
import slvtwn.khu.toyouserver.domain.User;
import slvtwn.khu.toyouserver.exception.ToyouException;
Expand All @@ -11,19 +10,17 @@
@Service
public class SessionUserService {

private final SessionUserRepository sessionUserRepository;
private final SessionUserRepository sessionUserRepository;
private final UserRepository userRepository;

private final UserRepository userRepository;
public SessionUserService(SessionUserRepository sessionUserRepository, UserRepository userRepository) {
this.sessionUserRepository = sessionUserRepository;
this.userRepository = userRepository;
}

public SessionUserService(SessionUserRepository sessionUserRepository, UserRepository userRepository,
UserService userService) {
this.sessionUserRepository = sessionUserRepository;
this.userRepository = userRepository;
}

public User findUserBySessionId(String sessionId) {
SessionUser bySessionId = sessionUserRepository.findBySessionId(sessionId);
return userRepository.findById(bySessionId.getUserId())
.orElseThrow(() -> new ToyouException(ErrorType.USER_NOT_FOUND));
}
public User findUserBySessionId(String sessionId) {
SessionUser bySessionId = sessionUserRepository.findBySessionId(sessionId);
return userRepository.findById(bySessionId.getUserId())
.orElseThrow(() -> new ToyouException(ErrorType.USER_NOT_FOUND));
}
}
7 changes: 6 additions & 1 deletion src/main/java/slvtwn/khu/toyouserver/dto/UserResponse.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package slvtwn.khu.toyouserver.dto;

import java.time.LocalDate;
import slvtwn.khu.toyouserver.domain.User;

public record UserResponse(Long id, String name, LocalDate birthday, String imageUrl) {
public record UserResponse(Long id, String name, LocalDate birthday, String introduction, String imageUrl) {

public static UserResponse of(User user) {
return new UserResponse(user.getId(), user.getName(), user.getBirthday(), user.getIntroduction(), user.getProfilePicture());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import slvtwn.khu.toyouserver.application.UserService;
import slvtwn.khu.toyouserver.common.UserAuthentication;
import slvtwn.khu.toyouserver.domain.User;
import slvtwn.khu.toyouserver.dto.UserResponse;
Expand All @@ -12,10 +11,8 @@
@RestController
public class UserController {

private final UserService userService;

@GetMapping("/users")
public UserResponse findUser(@UserAuthentication User user) {
return userService.findUser(user.getId());
}
@GetMapping("/me")
public UserResponse getProfile(@UserAuthentication User user) {
return UserResponse.of(user);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/java/slvtwn/khu/toyouserver/response/ResponseService.java

This file was deleted.

This file was deleted.