Skip to content

Commit 2f5df09

Browse files
committed
♻️ refactor: UserMapper에 toSignupResponse() 추가
1 parent 5d6071c commit 2f5df09

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

backend/src/main/java/io/f1/backend/domain/user/app/UserService.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package io.f1.backend.domain.user.app;
22

3+
import static io.f1.backend.domain.user.mapper.UserMapper.toSignupResponse;
4+
35
import io.f1.backend.domain.user.dao.UserRepository;
46
import io.f1.backend.domain.user.dto.SessionUser;
57
import io.f1.backend.domain.user.dto.SignupRequestDto;
68
import io.f1.backend.domain.user.dto.SignupResponseDto;
79
import io.f1.backend.domain.user.entity.User;
810
import io.f1.backend.global.util.SecurityUtils;
9-
1011
import jakarta.servlet.http.HttpSession;
11-
1212
import lombok.RequiredArgsConstructor;
13-
1413
import org.springframework.stereotype.Service;
1514
import org.springframework.transaction.annotation.Transactional;
1615

@@ -32,7 +31,7 @@ public SignupResponseDto signup(HttpSession session, SignupRequestDto signupRequ
3231
updateSessionAfterSignup(session, user);
3332
SecurityUtils.setAuthentication(user);
3433

35-
return SignupResponseDto.toDto(user);
34+
return toSignupResponse(user);
3635
}
3736

3837
private SessionUser extractSessionUser(HttpSession session) {
@@ -63,7 +62,7 @@ private void validateDuplicateNickname(String nickname) {
6362

6463
private User updateUserNickname(Long userId, String nickname) {
6564
User user =
66-
userRepository.findById(userId).orElseThrow(() -> new RuntimeException("사용자 없음"));
65+
userRepository.findById(userId).orElseThrow(() -> new RuntimeException("사용자 없음"));
6766
user.updateNickname(nickname);
6867

6968
return userRepository.save(user);
Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
package io.f1.backend.domain.user.dto;
22

3-
import io.f1.backend.domain.user.entity.User;
3+
public record SignupResponseDto(Long id, String nickname) {
44

5-
import lombok.AllArgsConstructor;
6-
import lombok.Builder;
7-
import lombok.Getter;
8-
import lombok.NoArgsConstructor;
9-
10-
@Getter
11-
@Builder
12-
@NoArgsConstructor
13-
@AllArgsConstructor
14-
public class SignupResponseDto {
15-
16-
private Long id;
17-
private String nickname;
18-
19-
public static SignupResponseDto toDto(User user) {
20-
return SignupResponseDto.builder().id(user.getId()).nickname(user.getNickname()).build();
21-
}
225
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.f1.backend.domain.user.mapper;
2+
3+
import io.f1.backend.domain.user.dto.SignupResponseDto;
4+
import io.f1.backend.domain.user.entity.User;
5+
6+
public class UserMapper {
7+
8+
private UserMapper() {
9+
}
10+
11+
public static SignupResponseDto toSignupResponse(User user) {
12+
return new SignupResponseDto(user.getId(), user.getNickname());
13+
}
14+
}

0 commit comments

Comments
 (0)