
[ UserApiController ]
@PostMapping("/users/join")
public ResponseEntity<?> join(@RequestBody UserRequest.JoinDTO reqDTO) {
UserResponse.UserJoinDTO respDTO = userService.join(reqDTO, reqDTO.getRole());
return ResponseEntity.ok(new ApiUtil<>(respDTO));
}
[ UserService ]
@Transactional
public UserResponse.UserJoinDTO join(UserRequest.JoinDTO reqDTO, Integer role) {
User user = userRepo.save(reqDTO.toEntity(role));
return new UserResponse.UserJoinDTO(user);
}
[ UserResponse ]
//유저 회원가입 DTO
@Data
public static class UserJoinDTO {
private Integer id;
private String email;
private String myName;
private String phone;
private String address;
private LocalDate birth;
@Builder
public UserJoinDTO(User user) {
this.id = user.getId();
this.email = user.getEmail();
this.myName = user.getMyName();
this.phone = user.getPhone();
this.address = user.getAddress();
this.birth = user.getBirth();
}
}
[ 포스트맨 ]

http://localhost:8080/users/join
[ 요청 파라미터 ]
{
"email" : "juho001@naver.com",
"myName" : "김성훈",
"password" : "1234",
"phone" : "010-7777-7777",
"birth" : "1985-05-05",
"address" : "부산 해운대구 리치동 305호"
}
[ 응답 바디 ]
{
"status": 200,
"msg": "성공",
"body": {
"id": 24,
"email": "juho001@naver.com",
"myName": "김성훈",
"phone": "010-7777-7777",
"address": "부산 해운대구 리치동 305호",
"birth": "1985-05-05"
}
}
Share article