Skip to content

Commit

Permalink
feat : User 컨트롤러 레이어 Convert 및 DTO 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeyoungAhn committed Aug 6, 2023
1 parent 2246a32 commit b2380dc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
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());
}
}
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
) {
}
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) {
}

0 comments on commit b2380dc

Please sign in to comment.