Skip to content

Commit

Permalink
feat [#49] UserService ๊ตฌํ˜„
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivoryeee committed Jan 16, 2025
1 parent 6aba6b2 commit 8c71cd2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.confeti.api.user.dto.response;

import org.sopt.confeti.domain.user.User;

public record UserInfoResponse (Long userId, String profileUrl, String username){
public UserInfoResponse(User user) {
this(user.getId(), user.getUsername(), user.getProfilePath());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sopt.confeti.domain.user.application;

import org.sopt.confeti.api.user.dto.response.UserInfoResponse;
import lombok.RequiredArgsConstructor;
import org.sopt.confeti.domain.user.User;
import org.sopt.confeti.domain.user.infra.repository.UserRepository;
Expand All @@ -17,7 +18,14 @@ public User findById(Long userId) {
.orElseThrow(() -> new NotFoundException(ErrorMessage.NOT_FOUND));
return user;
}
}



public UserInfoResponse getUserInfo(Long userId) {
User user = this.userRepository.findById(userId)
.orElseThrow(() -> new NotFoundException(ErrorMessage.NOT_FOUND));
return new UserInfoResponse(
user.getId(),
user.getProfilePath(),
user.getUsername()
);
}
}

0 comments on commit 8c71cd2

Please sign in to comment.