Skip to content

Commit

Permalink
Merge pull request #33 from Princess-in-silvertown/feat/32
Browse files Browse the repository at this point in the history
Feat: 내 정보 조회 API 구현
  • Loading branch information
woosung1223 authored Aug 18, 2024
2 parents 5b8d31d + 1e30a73 commit 866ada6
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 170 deletions.
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.

0 comments on commit 866ada6

Please sign in to comment.