Skip to content

Commit

Permalink
#82 fix : userService 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
rivkode committed Apr 25, 2024
1 parent b1b9e03 commit dd81b1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public class UserController {

@Operation(summary = "나의 정보", description = "내 프로필 정보가 반환됩니다.")
@GetMapping(value = "/me/info")
public ResponseEntity<String> getMyInfo(@LoginUser String userId) {
public ResponseEntity<GetUserAccountResponse> getMyInfo(@LoginUser String userId) {

return ResponseEntity.status(HttpStatus.OK).body(userService.getUserAccount(userId));
return ResponseEntity.status(HttpStatus.OK).body(userService.getUserInfo(userId));
}

@Operation(summary = "유저 조회", description = "유저Id 기준으로 해당 유저를 반환합니다.")
Expand All @@ -44,7 +44,7 @@ public ResponseEntity<GetUserAccountResponse> getUser(@PathVariable("userId") St
}

@PostMapping
public ResponseEntity<CreateUserResponse> createUser(@Valid @RequestBody CreateUserRequest request) {
public ResponseEntity<String> createUser(@Valid @RequestBody CreateUserRequest request) {

return ResponseEntity.status(HttpStatus.CREATED).body(userService.createUser(request.email(), request.password(), request.name(), request.major()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public CheckDuplicateVolunteerEmailResponse checkDuplicateVolunteerEmailResponse
}

@Transactional
public CreateUserResponse createUser(
public String createUser(
String email,
String password,
String name,
Expand All @@ -62,23 +62,22 @@ public CreateUserResponse createUser(
.build();
userRepository.save(user);

return CreateUserResponse.from(user);
return user.getId();
}

public User getUser(String userId) {
return userRepository.findById(userId).orElseThrow(() -> new UserNotFoundException("존재하지 않는 유저입니다."));
}

public String getUserAccount(String userId) {
log.info("userId : " + userId);
return userId;
}

public GetUserAccountResponse getUserInfo(String userId) {
log.info("userId : " + userId);
User user = getUser(userId);

return GetUserAccountResponse.builder().build();
// return UserResponse.from(this.getUser(userId));
return GetUserAccountResponse.builder()
.email(user.getEmail().getEmail())
.major(user.getMajor().getMajor())
.name(user.getName().getName())
.temperature(user.getTemperature().getTemperature())
.build();
}

public List<User> getUsers(List<String> userIds) {
Expand Down Expand Up @@ -114,6 +113,7 @@ public Predicate toPredicate(Root<User> userRoot, CriteriaQuery<?> query, Criter
};
}

@Transactional
public void updateMyInfo(
String userId,
String email,
Expand Down

0 comments on commit dd81b1a

Please sign in to comment.