feat: 회원가입 컨트롤러 생성
This commit is contained in:
@@ -1,8 +1,27 @@
|
||||
package com.ticketing.server.user.application;
|
||||
|
||||
import com.ticketing.server.user.application.request.SignUpRequest;
|
||||
import com.ticketing.server.user.service.UserServiceImpl;
|
||||
import javax.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
private final UserServiceImpl userService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> register(@RequestBody @Valid SignUpRequest signUpRequest) {
|
||||
userService.register(signUpRequest.toSignUp());
|
||||
return ResponseEntity.status(HttpStatus.CREATED).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ticketing.server.user.application.request;
|
||||
|
||||
import com.ticketing.server.global.validator.constraints.Phone;
|
||||
import com.ticketing.server.user.service.dto.SignUp;
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class SignUpRequest {
|
||||
|
||||
@NotEmpty(message = "이름은 필수 입니다.")
|
||||
private String name;
|
||||
|
||||
@NotEmpty(message = "이메일은 필수 입니다.")
|
||||
@Email(message = "이메일이 올바르지 않습니다.")
|
||||
private String email;
|
||||
|
||||
@NotEmpty(message = "패스워드는 필수 입니다.")
|
||||
private String password;
|
||||
|
||||
@NotEmpty(message = "휴대번호는 필수 입니다.")
|
||||
@Phone(message = "휴대번호가 올바르지 않습니다.")
|
||||
private String phone;
|
||||
|
||||
public SignUp toSignUp() {
|
||||
return new SignUp(name, email, password, phone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.ticketing.server.user.service.dto;
|
||||
|
||||
import com.ticketing.server.global.validator.constraints.Phone;
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import lombok.Getter;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
@Getter
|
||||
public class SignUp {
|
||||
|
||||
@NotEmpty(message = "이름은 필수 입니다.")
|
||||
private String name;
|
||||
|
||||
@NotEmpty(message = "이메일은 필수 입니다.")
|
||||
@Email(message = "이메일이 올바르지 않습니다.")
|
||||
private String email;
|
||||
|
||||
@NotEmpty(message = "패스워드는 필수 입니다.")
|
||||
private String password;
|
||||
|
||||
@NotEmpty(message = "휴대번호는 필수 입니다.")
|
||||
@Phone(message = "휴대번호가 올바르지 않습니다.")
|
||||
private String phone;
|
||||
|
||||
public SignUp(String name, String email, String password, String phone) {
|
||||
this.name = name;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String encodePassword(PasswordEncoder passwordEncoder) {
|
||||
return passwordEncoder.encode(password);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user