Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

public interface AuthOperationUseCase {

void createdAuth(AuthCreateCommand command);
void createAuth(AuthCreateCommand command);

void updateAuth(AuthUpdateCommand command);



Expand All @@ -26,4 +28,20 @@ class AuthCreateCommand {
private final String tel;
}


@EqualsAndHashCode(callSuper = false)
@Builder
@Getter
@ToString
class AuthUpdateCommand {
private final Long uid;
private final String userId;
private final String password;
private final String userName;
private final String gender;
private final String birth;
private final String address;
private final String email;
private final String tel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public AuthService(AuthEntityRepository authEntityRepository) {

@Override
@Transactional
public void createdAuth(AuthCreateCommand command) {
public void createAuth(AuthCreateCommand command) {
Auth auth = Auth.builder()
.userId(command.getUserId())
.password(command.getPassword())
Expand All @@ -37,16 +37,31 @@ public void createdAuth(AuthCreateCommand command) {
}

@Override
public Long updateAuth(AuthUpdateCommand command) {
return null;
}
@Transactional
public void updateAuth(AuthUpdateCommand command) {
//회원이 존재하는지 확인
AuthEntity authEntity = authEntityRepository.findById(command.getUid()).stream().findAny()
.orElseThrow(() -> new CloudLibraryException(MessageType.NOT_FOUND));

@Override
public void deleteAuth(AuthDeleteCommand command) {
Auth auth = Auth.builder()
.uid(command.getUid())
.userId(command.getUserId())
.password(command.getPassword())
.userName(command.getUserName())
.gender(command.getGender())
.birth(command.getBirth())
.address(command.getAddress())
.email(command.getEmail())
.tel(command.getTel())
.build();
//있으면 수정
authEntity.update(auth);

}


@Override
@Transactional(readOnly = true)
public FindAuthResult getAuthInfo(AuthFindQuery query) {

Optional<Auth> result = authEntityRepository.findById(query.getUid()).stream().findAny()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,20 @@ public AuthEntity(Auth auth) {
this.email = auth.getEmail();
this.tel = auth.getTel();
}

/**
* 회원 정보 수정
*/

public void update(Auth auth) {
this.uid = auth.getUid();
this.userId = auth.getUserId();
this.password = auth.getPassword();
this.userName = auth.getUserName();
this.gender = Gender.find(auth.getGender());
this.birth = auth.getBirth();
this.address = auth.getAddress();
this.email = auth.getEmail();
this.tel = auth.getTel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void createAuth(@Valid @RequestBody AuthCreateRequest request) {
.tel(request.getTel())
.build();

authOperationUseCase.createdAuth(command);
authOperationUseCase.createAuth(command);
}

@PostMapping("/signin")
Expand All @@ -76,7 +76,21 @@ public ResponseEntity<ApiResponseView<AuthView>> getAuth(@PathVariable("uid") Lo

@PatchMapping("/update-state/{uid}")
@ApiOperation("회원수정")
public ResponseEntity<ApiResponseView<AuthCompactView>> updateAuth(@RequestBody AuthUpdateRequest request, @PathVariable("uid") Long uid) {
public ResponseEntity<ApiResponseView<AuthCompactView>> updateAuth( @PathVariable("uid") Long uid, @Valid @RequestBody AuthUpdateRequest request) {

var command = AuthOperationUseCase.AuthUpdateCommand.builder()
.uid(uid)
.userId(request.getUserId())
.password(request.getPassword())
.userName(request.getUserName())
.gender(request.getGender())
.birth(request.getBirth())
.address(request.getAddress())
.email(request.getEmail())
.tel(request.getTel())
.build();

authOperationUseCase.updateAuth(command);

return ResponseEntity.ok().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class AuthCreateRequest {
@NotBlank(message = "아이디는 필수값입니다")
private String userId;

@Pattern(regexp = "(?=.*[0-9])(?=.*[a-zA-Z])(?=.*\\W)(?=\\S+$).{10,16}", message = "비밀번호는 10~16자 영문 대 소문자, 숫자, 특수문자를 사용하세요.")
@Pattern(regexp = "(?=.*[0-9])(?=.*[a-zA-Z])(?=.*\\W)(?=\\S+$).{10,16}"
, message = "비밀번호는 10~16자 영문 대 소문자, 숫자, 특수문자를 사용하세요.")
@NotBlank(message = "비밀번호는 필수값입니다")
private String password;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,38 @@
import lombok.Setter;
import lombok.ToString;

import java.time.LocalDateTime;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

@Getter
@Setter
@ToString
@NoArgsConstructor
public class AuthUpdateRequest {
private Long uid;
@NotBlank(message = "아이디는 필수값입니다")
private String userId;

@Pattern(regexp = "(?=.*[0-9])(?=.*[a-zA-Z])(?=.*\\W)(?=\\S+$).{10,16}", message = "비밀번호는 10~16자 영문 대 소문자, 숫자, 특수문자를 사용하세요.")
@NotBlank(message = "비밀번호는 필수값입니다")
private String password;

@NotBlank(message = "이름은 필수값입니다")
private String userName;

@NotBlank(message = "성별은 필수값입니다")
private String gender;

@NotBlank(message = "생년월일은 필수값입니다")
private String birth;

@NotBlank(message = "주소는 필수값입니다")
private String address;

@Email(message = "올바른 이메일 주소를 입력해주세요")
@NotBlank(message = "이메일은 필수값입니다")
private String email;

@NotBlank(message = "전화번호는 필수값입니다")
private String tel;
}