-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : User 컨트롤러 레이어 Convert 및 DTO 추가
- Loading branch information
1 parent
2246a32
commit b2380dc
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/main/java/com/prgrms/board/user/controller/dto/UserControllerConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.prgrms.board.user.controller.dto; | ||
|
||
import com.prgrms.board.user.service.dto.UserDetailedParam; | ||
import com.prgrms.board.user.service.dto.UserShortResult; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class UserControllerConverter { | ||
public UserDetailedParam toUserDetailedParam(UserDetailedRequest request) { | ||
return new UserDetailedParam( | ||
request.name(), | ||
request.age(), | ||
request.hobby() | ||
); | ||
} | ||
|
||
public UserShortResponse toUserResponse(UserShortResult result) { | ||
return new UserShortResponse(result.id()); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/prgrms/board/user/controller/dto/UserDetailedRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.prgrms.board.user.controller.dto; | ||
|
||
import jakarta.validation.constraints.*; | ||
|
||
public record UserDetailedRequest( | ||
@NotBlank | ||
@Size(min = 2, max = 20) | ||
String name, | ||
|
||
@NotNull | ||
@Min(value = 0) | ||
@Max(value = 120) | ||
Integer age, | ||
|
||
String hobby | ||
) { | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/prgrms/board/user/controller/dto/UserShortResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.prgrms.board.user.controller.dto; | ||
|
||
public record UserShortResponse(Long id) { | ||
} | ||
|