-
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 #31 from WE-ARE-RACCOONS/RAC-100
Rac 100
- Loading branch information
Showing
26 changed files
with
466 additions
and
114 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/main/java/com/postgraduate/domain/auth/application/dto/req/KakaoCodeRequest.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.auth.application.dto.req; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.*; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public class KakaoCodeRequest { | ||
@NotNull | ||
private String code; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/postgraduate/domain/auth/application/dto/res/KakaoTokenInfoResponse.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,20 @@ | ||
package com.postgraduate.domain.auth.application.dto.res; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class KakaoTokenInfoResponse { | ||
private String access_token; | ||
private String token_type; | ||
private String refresh_token; | ||
private String id_token; | ||
private int expires_in; | ||
private String cope; | ||
private int refresh_token_expires_in; | ||
} |
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
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
...va/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountRequest.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.senior.application.dto.req; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public class SeniorProfileAndAccountRequest { | ||
@NotNull | ||
private String info; | ||
@NotNull | ||
private String target; | ||
@NotNull | ||
private String chatLink; | ||
@NotNull | ||
private String time; | ||
@NotNull | ||
private String account; | ||
@NotNull | ||
private String bank; | ||
@NotNull | ||
private String rrn; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorInfoResponse.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.senior.application.dto.res; | ||
|
||
import com.postgraduate.domain.senior.domain.entity.constant.Status; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
public class SeniorInfoResponse { | ||
private String nickName; | ||
private String profile; | ||
private Status certificationRegister; | ||
private boolean profileRegister; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorProfileResponse.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,15 @@ | ||
package com.postgraduate.domain.senior.application.dto.res; | ||
|
||
import com.postgraduate.domain.senior.domain.entity.Account; | ||
import com.postgraduate.domain.senior.domain.entity.Profile; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
public class SeniorProfileResponse { | ||
private Profile profile; | ||
private Account account; | ||
} |
66 changes: 64 additions & 2 deletions
66
src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.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 |
---|---|---|
@@ -1,24 +1,86 @@ | ||
package com.postgraduate.domain.senior.application.mapper; | ||
|
||
import com.postgraduate.domain.senior.application.dto.req.SeniorProfileAndAccountRequest; | ||
import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; | ||
import com.postgraduate.domain.senior.application.dto.req.SeniorSignUpRequest; | ||
import com.postgraduate.domain.senior.application.dto.res.SeniorInfoResponse; | ||
import com.postgraduate.domain.senior.application.dto.res.SeniorProfileResponse; | ||
import com.postgraduate.domain.senior.domain.entity.Account; | ||
import com.postgraduate.domain.senior.domain.entity.Info; | ||
import com.postgraduate.domain.senior.domain.entity.Profile; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import com.postgraduate.domain.senior.domain.entity.constant.Status; | ||
import com.postgraduate.domain.user.domain.entity.User; | ||
|
||
public class SeniorMapper { | ||
|
||
public static Senior mapToSenior(User user, SeniorSignUpRequest request) { | ||
return Senior.builder() | ||
.user(user) | ||
.info(mapToInfo(request)) | ||
.certification(request.getCertification()) | ||
.account(mapToAccount(request)) | ||
.build(); | ||
} | ||
|
||
public static Info mapToInfo(SeniorSignUpRequest request) { | ||
return Info.builder() | ||
.college(request.getCollege()) | ||
.major(request.getMajor()) | ||
.postgradu(request.getPostgradu()) | ||
.professor(request.getProfessor()) | ||
.lab(request.getLab()) | ||
.field(request.getField()) | ||
.certification(request.getCertification()) | ||
.account(request.getAccount()) | ||
.build(); | ||
} | ||
|
||
public static Account mapToAccount(SeniorSignUpRequest request) { | ||
return Account.builder() | ||
.bank(request.getBank()) | ||
.account(request.getAccount()) | ||
.rrn(request.getRrn()) | ||
.build(); | ||
} | ||
|
||
public static Account mapToAccount(SeniorProfileAndAccountRequest profileAndAccountPageRequest) { | ||
return Account.builder() | ||
.bank(profileAndAccountPageRequest.getBank()) | ||
.account(profileAndAccountPageRequest.getAccount()) | ||
.rrn(profileAndAccountPageRequest.getRrn()) | ||
.build(); | ||
} | ||
|
||
public static Profile mapToProfile(SeniorProfileAndAccountRequest profileAndAccountPageRequest) { | ||
return Profile.builder() | ||
.info(profileAndAccountPageRequest.getInfo()) | ||
.chatLink(profileAndAccountPageRequest.getChatLink()) | ||
.target(profileAndAccountPageRequest.getTarget()) | ||
.time(profileAndAccountPageRequest.getTime()) | ||
.build(); | ||
} | ||
|
||
public static Profile mapToProfile(SeniorProfileRequest profileRequest) { | ||
return Profile.builder() | ||
.info(profileRequest.getInfo()) | ||
.chatLink(profileRequest.getChatLink()) | ||
.target(profileRequest.getTarget()) | ||
.time(profileRequest.getTime()) | ||
.build(); | ||
} | ||
|
||
public static SeniorInfoResponse mapToSeniorInfo(Senior senior, Status certificationRegister, boolean profileRegister) { | ||
return SeniorInfoResponse.builder() | ||
.nickName(senior.getUser().getNickName()) | ||
.profile(senior.getUser().getProfile()) | ||
.certificationRegister(certificationRegister) | ||
.profileRegister(profileRegister) | ||
.build(); | ||
} | ||
|
||
public static SeniorProfileResponse mapToSeniorProfileInfo(Senior senior) { | ||
return SeniorProfileResponse.builder() | ||
.profile(senior.getProfile()) | ||
.account(senior.getAccount()) | ||
.build(); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.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,61 @@ | ||
package com.postgraduate.domain.senior.application.usecase; | ||
|
||
import com.postgraduate.domain.senior.application.dto.req.SeniorCertificationRequest; | ||
import com.postgraduate.domain.senior.application.dto.req.SeniorProfileAndAccountRequest; | ||
import com.postgraduate.domain.senior.application.dto.res.SeniorInfoResponse; | ||
import com.postgraduate.domain.senior.application.dto.res.SeniorProfileResponse; | ||
import com.postgraduate.domain.senior.application.mapper.SeniorMapper; | ||
import com.postgraduate.domain.senior.domain.entity.Account; | ||
import com.postgraduate.domain.senior.domain.entity.Profile; | ||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import com.postgraduate.domain.senior.domain.entity.constant.Status; | ||
import com.postgraduate.domain.senior.domain.service.SeniorGetService; | ||
import com.postgraduate.domain.senior.domain.service.SeniorUpdateService; | ||
import com.postgraduate.domain.user.domain.entity.User; | ||
import com.postgraduate.global.auth.AuthDetails; | ||
import com.postgraduate.global.config.security.util.SecurityUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.Optional; | ||
|
||
import static java.util.Optional.ofNullable; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class SeniorMyPageUseCase { | ||
private final SeniorGetService seniorGetService; | ||
private final SeniorUpdateService seniorUpdateService; | ||
private final SecurityUtils securityUtils; | ||
|
||
public SeniorInfoResponse seniorInfo(AuthDetails authDetails) { | ||
User user = securityUtils.getLoggedInUser(authDetails); | ||
Senior senior = seniorGetService.byUser(user); | ||
Status status = senior.getStatus(); | ||
Optional<Profile> profile = ofNullable(senior.getProfile()); | ||
return SeniorMapper.mapToSeniorInfo(senior, status, profile.isPresent()); | ||
} | ||
|
||
public void updateCertification(AuthDetails authDetails, SeniorCertificationRequest certificationRequest) { | ||
User user = securityUtils.getLoggedInUser(authDetails); | ||
Senior senior = seniorGetService.byUser(user); | ||
seniorUpdateService.updateCertification(senior, certificationRequest.getCertification()); | ||
} | ||
|
||
public void updateProfile(AuthDetails authDetails, SeniorProfileAndAccountRequest profileRequest) { | ||
User user = securityUtils.getLoggedInUser(authDetails); | ||
Senior senior = seniorGetService.byUser(user); | ||
Profile profile = SeniorMapper.mapToProfile(profileRequest); | ||
Account account = SeniorMapper.mapToAccount(profileRequest); | ||
seniorUpdateService.updateSeniorProfileAndAccount(senior, profile, account); | ||
} | ||
|
||
public SeniorProfileResponse getSeniorProfile(AuthDetails authDetails) { | ||
User user = securityUtils.getLoggedInUser(authDetails); | ||
Senior senior = seniorGetService.byUser(user); | ||
SeniorProfileResponse seniorProfileResponse = SeniorMapper.mapToSeniorProfileInfo(senior); | ||
return seniorProfileResponse; | ||
} | ||
} |
Oops, something went wrong.