Skip to content

Commit

Permalink
Merge pull request #18 from 2023-CMC-Hackerthon/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
AlmondBreez3 authored Nov 25, 2023
2 parents edbac5d + 918b3b4 commit b91778a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.hackathon.hackathon.domain.user.entity.LoginType;
import com.hackathon.hackathon.domain.user.entity.User;
import com.hackathon.hackathon.domain.user.exception.EmailAlreadyRegistered;
import com.hackathon.hackathon.domain.wallet.service.WalletService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -16,6 +17,7 @@
@RequiredArgsConstructor
public class UserDomainService {
private final UserAdaptor userAdaptor;
private final WalletService walletService;

public User login(LoginType loginType, String email){
User user = userAdaptor.findByEmail(email);
Expand All @@ -29,7 +31,8 @@ public User signUp(AuthInfo authInfo){
User user = User.builder()
.authInfo(authInfo)
.build();
System.out.println(user.getAuthInfo());
System.out.println(user.getId());
walletService.createInitialWallet(user);
return userAdaptor.save(user);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,30 @@ public SuccessResponse<Object> createWallet(User user, WalletRequestDTO walletRe

return apiResponse;
}
@Transactional
public SuccessResponse<Object> createInitialWallet(User user) {
Wallet wallet = Wallet.builder()
.name("나의 지갑")
.user(user)
.status(ACTIVE)
.build();

walletRepository.save(wallet);

WalletResponseDTO walletResponseDTO = WalletResponseDTO.builder()
.id(wallet.getId())
.userId(wallet.getUser().getId())
.name(wallet.getName())
.build();

SuccessResponse apiResponse = SuccessResponse.builder()
.code(200)
.message("success")
.data(walletResponseDTO)
.build();

return apiResponse;
}

public SuccessResponse<Object> getWallet(User user, Long walletId) {
List<Wallet> wallets = walletRepository.findAllByUserId(user.getId());
Expand Down

0 comments on commit b91778a

Please sign in to comment.