-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from WE-ARE-RACCOONS/RAC-153
RAC-153 refactor : DB수정 및 요구사항 변경에 따른 리팩토링
- Loading branch information
Showing
82 changed files
with
1,446 additions
and
935 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/java/com/postgraduate/domain/account/application/mapper/AccountMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.postgraduate.domain.account.application.mapper; | ||
|
||
import com.postgraduate.domain.account.domain.entity.Account; | ||
import com.postgraduate.domain.senior.application.dto.req.SeniorAccountRequest; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
|
||
public class AccountMapper { | ||
public static Account mapToAccount(Senior senior, SeniorAccountRequest accountRequest) { | ||
return Account.builder() | ||
.senior(senior) | ||
.accountNumber(accountRequest.getAccountNumber()) | ||
.accountHolder(accountRequest.getAccountHolder()) | ||
.bank(accountRequest.getBank()) | ||
.name(accountRequest.getName()) | ||
.rrn(accountRequest.getRrn()) | ||
.build(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/postgraduate/domain/account/domain/entity/Account.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.postgraduate.domain.account.domain.entity; | ||
|
||
import com.postgraduate.domain.senior.application.dto.req.SeniorAccountRequest; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public class Account { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long accountId; | ||
|
||
@Column(nullable = false) | ||
private String accountNumber; | ||
|
||
@Column(nullable = false) | ||
private String bank; | ||
|
||
@Column(nullable = false) | ||
private String accountHolder; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
|
||
@Column(nullable = false) | ||
private String rrn; | ||
|
||
@OneToOne | ||
private Senior senior; | ||
|
||
public void updateAccount(SeniorAccountRequest accountRequest) { | ||
this.accountNumber = accountRequest.getAccountNumber(); | ||
this.bank = accountRequest.getBank(); | ||
this.accountHolder = accountRequest.getAccountHolder(); | ||
this.name = accountRequest.getName(); | ||
this.rrn = accountRequest.getRrn(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/postgraduate/domain/account/domain/repository/AccountRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.postgraduate.domain.account.domain.repository; | ||
|
||
import com.postgraduate.domain.account.domain.entity.Account; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface AccountRepository extends JpaRepository<Account, Long> { | ||
Optional<Account> findBySenior(Senior senior); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/postgraduate/domain/account/domain/service/AccountGetService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.postgraduate.domain.account.domain.service; | ||
|
||
import com.postgraduate.domain.account.domain.entity.Account; | ||
import com.postgraduate.domain.account.domain.repository.AccountRepository; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Optional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AccountGetService { | ||
private final AccountRepository accountRepository; | ||
|
||
public Optional<Account> bySenior(Senior senior) { | ||
return accountRepository.findBySenior(senior); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/postgraduate/domain/account/domain/service/AccountSaveService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.postgraduate.domain.account.domain.service; | ||
|
||
import com.postgraduate.domain.account.domain.entity.Account; | ||
import com.postgraduate.domain.account.domain.repository.AccountRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AccountSaveService { | ||
private final AccountRepository accountRepository; | ||
|
||
public void saveAccount(Account account) { | ||
accountRepository.save(account); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/postgraduate/domain/account/domain/service/AccountUpdateService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.postgraduate.domain.account.domain.service; | ||
|
||
import com.postgraduate.domain.account.domain.entity.Account; | ||
import com.postgraduate.domain.senior.application.dto.req.SeniorAccountRequest; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class AccountUpdateService { | ||
public void updateAccount(Account account, SeniorAccountRequest accountRequest) { | ||
account.updateAccount(accountRequest); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/com/postgraduate/domain/auth/application/dto/req/SeniorChangeRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.postgraduate.domain.auth.application.dto.req; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class SeniorChangeRequest { | ||
@NotNull | ||
private String major; | ||
@NotNull | ||
private String postgradu; | ||
@NotNull | ||
private String professor; | ||
@NotNull | ||
private String lab; | ||
@NotNull | ||
private String field; | ||
@NotNull | ||
private String keyword; | ||
@NotNull | ||
private String certification; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/com/postgraduate/domain/auth/application/usecase/SignUpUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.postgraduate.domain.auth.application.usecase; | ||
|
||
import com.postgraduate.domain.auth.application.dto.req.SeniorChangeRequest; | ||
import com.postgraduate.domain.auth.application.dto.req.SeniorSignUpRequest; | ||
import com.postgraduate.domain.auth.application.dto.req.SignUpRequest; | ||
import com.postgraduate.domain.senior.application.mapper.SeniorMapper; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import com.postgraduate.domain.senior.domain.service.SeniorSaveService; | ||
import com.postgraduate.domain.user.application.mapper.UserMapper; | ||
import com.postgraduate.domain.user.domain.entity.User; | ||
import com.postgraduate.domain.user.domain.entity.constant.Role; | ||
import com.postgraduate.domain.user.domain.service.UserGetService; | ||
import com.postgraduate.domain.user.domain.service.UserSaveService; | ||
import com.postgraduate.domain.user.domain.service.UserUpdateService; | ||
import com.postgraduate.domain.wish.application.mapper.WishMapper; | ||
import com.postgraduate.domain.wish.domain.entity.Wish; | ||
import com.postgraduate.domain.wish.domain.service.WishSaveService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Transactional | ||
@Service | ||
@RequiredArgsConstructor | ||
public class SignUpUseCase { | ||
private final UserSaveService userSaveService; | ||
private final UserUpdateService userUpdateService; | ||
private final UserGetService userGetService; | ||
private final WishSaveService wishSaveService; | ||
private final SeniorSaveService seniorSaveService; | ||
|
||
public User userSignUp(SignUpRequest request) { | ||
User user = UserMapper.mapToUser(request); | ||
Wish wish = WishMapper.mapToWish(user, request); | ||
wishSaveService.saveWish(wish); | ||
userSaveService.saveUser(user); | ||
return user; | ||
} | ||
|
||
public User seniorSignUp(SeniorSignUpRequest request) { | ||
User user = UserMapper.mapToUser(request); | ||
userSaveService.saveUser(user); | ||
Senior senior = SeniorMapper.mapToSenior(user, request); | ||
seniorSaveService.saveSenior(senior); | ||
return senior.getUser(); | ||
} | ||
|
||
|
||
public User changeSenior(User user, SeniorChangeRequest changeRequest) { | ||
Senior senior = SeniorMapper.mapToSenior(user, changeRequest); //todo : 예외 처리 | ||
seniorSaveService.saveSenior(senior); | ||
userUpdateService.updateRole(user.getUserId(), Role.SENIOR); | ||
return userGetService.getUser(user.getUserId()); | ||
} | ||
} |
Oops, something went wrong.