Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
수정 권한 받은 사용자 필드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Feb 28, 2024
1 parent 27d3cde commit 9486226
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.example.daemawiki.domain.auth.dto.request.SignupRequest;
import com.example.daemawiki.domain.document.component.CreateDocumentByUser;
import com.example.daemawiki.domain.document.repository.DocumentRepository;
import com.example.daemawiki.domain.file.model.DefaultProfile;
import com.example.daemawiki.domain.mail.repository.AuthMailRepository;
import com.example.daemawiki.domain.user.model.User;
Expand All @@ -11,6 +12,7 @@
import com.example.daemawiki.global.exception.h403.UnVerifiedEmailException;
import com.example.daemawiki.global.exception.h409.EmailAlreadyExistsException;
import com.example.daemawiki.global.exception.h500.ExecuteFailedException;
import org.eclipse.collections.api.factory.Lists;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
Expand All @@ -25,15 +27,17 @@ public class Signup {
private final GetMajorType getMajorType;
private final CreateDocumentByUser createDocumentByUser;
private final DefaultProfile defaultProfile;
private final DocumentRepository documentRepository;

public Signup(UserRepository userRepository,AuthMailRepository authMailRepository, PasswordEncoder passwordEncoder, Scheduler scheduler, GetMajorType getMajorType, CreateDocumentByUser createDocumentByUser, DefaultProfile defaultProfile) {
public Signup(UserRepository userRepository,AuthMailRepository authMailRepository, PasswordEncoder passwordEncoder, Scheduler scheduler, GetMajorType getMajorType, CreateDocumentByUser createDocumentByUser, DefaultProfile defaultProfile, DocumentRepository documentRepository) {
this.userRepository = userRepository;
this.authMailRepository = authMailRepository;
this.passwordEncoder = passwordEncoder;
this.scheduler = scheduler;
this.getMajorType = getMajorType;
this.createDocumentByUser = createDocumentByUser;
this.defaultProfile = defaultProfile;
this.documentRepository = documentRepository;
}

public Mono<Void> execute(SignupRequest request) {
Expand Down Expand Up @@ -62,9 +66,13 @@ public Mono<Void> execute(SignupRequest request) {

return userRepository.save(user)
.flatMap(savedUser -> createDocumentByUser.execute(savedUser)
.doOnNext(document -> savedUser.setDocumentId(document.getId()))
.flatMap(document -> userRepository.save(savedUser)))
.flatMap(savedUser -> authMailRepository.delete(savedUser.getEmail()));
.doOnNext(document -> {
document.getEditor().setCanEdit(Lists.mutable.of(user.getId()));
savedUser.setDocumentId(document.getId());
})
.flatMap(document -> Mono.when(userRepository.save(savedUser),
documentRepository.save(document)))
.then(authMailRepository.delete(savedUser.getEmail())));
})
.onErrorMap(e -> ExecuteFailedException.EXCEPTION);
}))).then();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
@Builder
Expand All @@ -14,6 +16,8 @@ public class DocumentEditor {

private UserDetailResponse updatedUser;

private List<String> canEdit;

public void update(UserDetailResponse updatedUser) {
this.updatedUser = updatedUser;
}
Expand Down

0 comments on commit 9486226

Please sign in to comment.