From 4190065cbfb1cb6ca23d5c8017f49214876bfce7 Mon Sep 17 00:00:00 2001 From: yang Date: Fri, 3 Nov 2023 16:38:03 +0900 Subject: [PATCH 01/14] =?UTF-8?q?RAC-107=20refactor=20:=20Senior=20?= =?UTF-8?q?=EA=B0=92=EA=B0=9D=EC=B2=B4=20=EC=82=AC=EC=9A=A9=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/senior/domain/entity/Account.java | 21 +++++++ .../domain/senior/domain/entity/Info.java | 33 +++++++++++ .../domain/senior/domain/entity/Profile.java | 34 +++++++++++ .../domain/senior/domain/entity/Senior.java | 57 ++++++------------- 4 files changed, 106 insertions(+), 39 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/senior/domain/entity/Account.java create mode 100644 src/main/java/com/postgraduate/domain/senior/domain/entity/Info.java create mode 100644 src/main/java/com/postgraduate/domain/senior/domain/entity/Profile.java diff --git a/src/main/java/com/postgraduate/domain/senior/domain/entity/Account.java b/src/main/java/com/postgraduate/domain/senior/domain/entity/Account.java new file mode 100644 index 00000000..8fb21548 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/senior/domain/entity/Account.java @@ -0,0 +1,21 @@ +package com.postgraduate.domain.senior.domain.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Embeddable +public class Account { + @Column(nullable = false) + private String account; + + @Column(nullable = false) + private String bank; +} diff --git a/src/main/java/com/postgraduate/domain/senior/domain/entity/Info.java b/src/main/java/com/postgraduate/domain/senior/domain/entity/Info.java new file mode 100644 index 00000000..30b5952c --- /dev/null +++ b/src/main/java/com/postgraduate/domain/senior/domain/entity/Info.java @@ -0,0 +1,33 @@ +package com.postgraduate.domain.senior.domain.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Embeddable +public class Info { + @Column(nullable = false) + private String college; + + @Column(nullable = false) + private String major; + + @Column(nullable = false) + private String postgradu; + + @Column(nullable = false) + private String professor; + + @Column(nullable = false) + private String lab; + + @Column(nullable = false) + private String field; +} diff --git a/src/main/java/com/postgraduate/domain/senior/domain/entity/Profile.java b/src/main/java/com/postgraduate/domain/senior/domain/entity/Profile.java new file mode 100644 index 00000000..5216eb65 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/senior/domain/entity/Profile.java @@ -0,0 +1,34 @@ +package com.postgraduate.domain.senior.domain.entity; + +import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.hibernate.annotations.ColumnDefault; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Embeddable +public class Profile { + private String info; + + private String target; + + private String chatLink; + + private String time; + + private Integer term; + + public void updateProfile(SeniorProfileRequest profileRequest) { + this.info = profileRequest.getInfo(); + this.target = profileRequest.getTarget(); + this.chatLink = profileRequest.getChatLink(); + this.time = profileRequest.getTime(); + } +} diff --git a/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java b/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java index 1fdd32c4..95b1189a 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java @@ -7,12 +7,14 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.DynamicInsert; @Entity @Builder @AllArgsConstructor @NoArgsConstructor @Getter +@DynamicInsert public class Senior { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -21,40 +23,6 @@ public class Senior { @OneToOne private User user; - @Column(nullable = false) - private String college; - - @Column(nullable = false) - private String major; - - @Column(nullable = false) - private String postgradu; - - @Column(nullable = false) - private String professor; - - @Column(nullable = false) - private String lab; - - @Column(nullable = false) - private String field; - - private String info; - - private String target; - - private String chatLink; - - private String time; - - private int term; - - @Column(nullable = false) - private String account; - - @Column(nullable = false) - private String bank; - @Column(nullable = false) private String certification; @@ -62,15 +30,26 @@ public class Senior { private String rrn; @Column(nullable = false) - private boolean status; + @Builder.Default + private Boolean status = false; @Column(nullable = false) private int hit; + @Embedded + private Info info; + + @Embedded + private Account account; + + @Embedded + private Profile profile; public void updateProfile(SeniorProfileRequest profileRequest) { - this.info = profileRequest.getInfo(); - this.target = profileRequest.getTarget(); - this.chatLink = profileRequest.getChatLink(); - this.time = profileRequest.getTime(); + profile.updateProfile(profileRequest); + } + + public void updateCertification(String certification) { + this.certification = certification; + this.status = false; } } From bae64ffacdc3cde53d0b069109855db6366bf0bc Mon Sep 17 00:00:00 2001 From: yang Date: Fri, 3 Nov 2023 16:38:08 +0900 Subject: [PATCH 02/14] =?UTF-8?q?RAC-107=20refactor=20:=20Senior=20?= =?UTF-8?q?=EA=B0=92=EA=B0=9D=EC=B2=B4=20=EC=82=AC=EC=9A=A9=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/mapper/MentoringMapper.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java b/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java index 08f2029e..01deb768 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/mapper/MentoringMapper.java @@ -17,10 +17,10 @@ public static AppliedMentoringInfo mapToExpectedAppliedInfo(Mentoring mentoring) .dates(dates) .seniorId(senior.getSeniorId()) .nickName(senior.getUser().getNickName()) - .postgradu(senior.getPostgradu()) - .professor(senior.getProfessor()) - .field(senior.getField()) - .chatLink(senior.getChatLink()) + .postgradu(senior.getInfo().getPostgradu()) + .professor(senior.getInfo().getProfessor()) + .field(senior.getInfo().getField()) + .chatLink(senior.getProfile().getChatLink()) .build(); } public static AppliedMentoringInfo mapToWaitingOrDoneAppliedInfo(Mentoring mentoring) { @@ -29,12 +29,12 @@ public static AppliedMentoringInfo mapToWaitingOrDoneAppliedInfo(Mentoring mento return AppliedMentoringInfo.builder() .mentoringId(mentoring.getMentoringId()) .dates(dates) - .term(senior.getTerm()) + .term(senior.getProfile().getTerm()) .seniorId(senior.getSeniorId()) .nickName(senior.getUser().getNickName()) - .postgradu(senior.getPostgradu()) - .professor(senior.getProfessor()) - .field(senior.getField()) + .postgradu(senior.getInfo().getPostgradu()) + .professor(senior.getInfo().getProfessor()) + .field(senior.getInfo().getField()) .build(); } public static AppliedMentoringDetailResponse mapToAppliedDetailInfo(Mentoring mentoring) { @@ -44,8 +44,8 @@ public static AppliedMentoringDetailResponse mapToAppliedDetailInfo(Mentoring me return AppliedMentoringDetailResponse.builder() .seniorId(senior.getSeniorId()) .nickName(senior.getUser().getNickName()) - .field(senior.getField()) - .professor(senior.getProfessor()) + .field(senior.getInfo().getField()) + .professor(senior.getInfo().getProfessor()) .topic(mentoring.getTopic()) .question(mentoring.getQuestion()) .dates(dates) From f6497c1b691f40610fbbf8df6ef09ecb89fbd1f8 Mon Sep 17 00:00:00 2001 From: yang Date: Fri, 3 Nov 2023 16:39:33 +0900 Subject: [PATCH 03/14] =?UTF-8?q?RAC-107=20feat=20:=20=EB=8C=80=ED=95=99?= =?UTF-8?q?=EC=9B=90=EC=83=9D=20=EC=9D=B8=EC=A6=9D=EC=9A=A9=20=EB=8B=A8?= =?UTF-8?q?=EC=9D=BC=20=EC=9A=94=EC=B2=AD=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/req/SeniorCertificationRequest.java | 12 ++++++++ .../application/mapper/SeniorMapper.java | 30 +++++++++++++++++-- .../usecase/SeniorUpdateUseCase.java | 27 ----------------- .../domain/service/SeniorUpdateService.java | 4 +++ 4 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorCertificationRequest.java delete mode 100644 src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorUpdateUseCase.java diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorCertificationRequest.java b/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorCertificationRequest.java new file mode 100644 index 00000000..67bef493 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorCertificationRequest.java @@ -0,0 +1,12 @@ +package com.postgraduate.domain.senior.application.dto.req; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +public class SeniorCertificationRequest { + private String certification; +} diff --git a/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java b/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java index 77315c4c..2b95ef03 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java +++ b/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java @@ -1,6 +1,9 @@ package com.postgraduate.domain.senior.application.mapper; import com.postgraduate.domain.senior.application.dto.req.SeniorSignUpRequest; +import com.postgraduate.domain.senior.application.dto.res.SeniorInfoResponse; +import com.postgraduate.domain.senior.domain.entity.Account; +import com.postgraduate.domain.senior.domain.entity.Info; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.user.domain.entity.User; @@ -9,16 +12,37 @@ 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)) + .rrn(request.getRrn()) + .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()) - .rrn(request.getRrn()) + .account(request.getAccount()) + .build(); + } + + public static SeniorInfoResponse mapToSeniorInfo(Senior senior, boolean certificationRegister, boolean profileRegister) { + return SeniorInfoResponse.builder() + .nickName(senior.getUser().getNickName()) + .profile(senior.getUser().getProfile()) + .certificationRegister(certificationRegister) + .profileRegister(profileRegister) .build(); } } diff --git a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorUpdateUseCase.java b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorUpdateUseCase.java deleted file mode 100644 index 964e6695..00000000 --- a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorUpdateUseCase.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.postgraduate.domain.senior.application.usecase; - -import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; -import com.postgraduate.domain.senior.domain.entity.Senior; -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; - -@Service -@Transactional -@RequiredArgsConstructor -public class SeniorUpdateUseCase { - private final SeniorGetService seniorGetService; - private final SeniorUpdateService seniorUpdateService; - private final SecurityUtils securityUtils; - - public void updateProfile(AuthDetails authDetails, SeniorProfileRequest profileRequest) { - User user = securityUtils.getLoggedInUser(authDetails); - Senior senior = seniorGetService.byUser(user); - seniorUpdateService.updateSeniorProfile(senior, profileRequest); - } -} diff --git a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java index 2f940181..92f60997 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java @@ -12,4 +12,8 @@ public class SeniorUpdateService { public void updateSeniorProfile(Senior senior, SeniorProfileRequest profileRequest) { senior.updateProfile(profileRequest); } + + public void updateCertification(Senior senior, String imageUrl) { + senior.updateCertification(imageUrl); + } } From 49706b359bfc2ec14072d15986c43b2e14a91c16 Mon Sep 17 00:00:00 2001 From: yang Date: Fri, 3 Nov 2023 16:39:48 +0900 Subject: [PATCH 04/14] =?UTF-8?q?RAC-107=20feat=20:=20=EB=8C=80=ED=95=99?= =?UTF-8?q?=EC=9B=90=EC=83=9D=20=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EA=B8=B0=EB=B3=B8=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/SeniorInfoResponse.java | 15 ++++++ .../usecase/SeniorMyPageUseCase.java | 47 +++++++++++++++++++ .../senior/presentation/SeniorController.java | 35 ++++++++++---- .../constant/SeniorResponseMessage.java | 6 ++- 4 files changed, 91 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorInfoResponse.java create mode 100644 src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorInfoResponse.java b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorInfoResponse.java new file mode 100644 index 00000000..f7a661d8 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorInfoResponse.java @@ -0,0 +1,15 @@ +package com.postgraduate.domain.senior.application.dto.res; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +@Builder +@Getter +@AllArgsConstructor +public class SeniorInfoResponse { + private String nickName; + private String profile; + private boolean certificationRegister; + private boolean profileRegister; +} diff --git a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java new file mode 100644 index 00000000..74d6fa7e --- /dev/null +++ b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java @@ -0,0 +1,47 @@ +package com.postgraduate.domain.senior.application.usecase; + +import com.postgraduate.domain.senior.application.dto.req.SeniorCertificationRequest; +import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; +import com.postgraduate.domain.senior.application.dto.res.SeniorInfoResponse; +import com.postgraduate.domain.senior.application.mapper.SeniorMapper; +import com.postgraduate.domain.senior.domain.entity.Profile; +import com.postgraduate.domain.senior.domain.entity.Senior; +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 java.util.Optional; + +import static java.util.Optional.ofNullable; + +@Service +@RequiredArgsConstructor +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); + Boolean status = senior.getStatus(); + Optional 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, SeniorProfileRequest profileRequest) { + User user = securityUtils.getLoggedInUser(authDetails); + Senior senior = seniorGetService.byUser(user); + seniorUpdateService.updateSeniorProfile(senior, profileRequest); + } +} diff --git a/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java b/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java index 7b382edc..d445796c 100644 --- a/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java +++ b/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java @@ -1,9 +1,11 @@ package com.postgraduate.domain.senior.presentation; +import com.postgraduate.domain.senior.application.dto.req.SeniorCertificationRequest; 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.usecase.SeniorMyPageUseCase; import com.postgraduate.domain.senior.application.usecase.SeniorSignUpUseCase; -import com.postgraduate.domain.senior.application.usecase.SeniorUpdateUseCase; import com.postgraduate.global.auth.AuthDetails; import com.postgraduate.global.dto.ResponseDto; import io.swagger.v3.oas.annotations.Operation; @@ -12,10 +14,8 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; -import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.SENIOR_CREATE; -import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.SENIOR_UPDATE; -import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.SUCCESS_SENIOR_SIGN_UP_MESSAGE; -import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.SUCCESS_UPDATE_PROFILE_MESSAGE; +import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.*; +import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.*; @RestController @@ -24,21 +24,36 @@ @Tag(name = "SENIOR Controller") public class SeniorController { private final SeniorSignUpUseCase signUpUseCase; - private final SeniorUpdateUseCase updateUseCase; + private final SeniorMyPageUseCase myPageUseCase; @PostMapping("/signup") @Operation(summary = "대학원생 가입 - 필수 과정만", description = "대학원생 회원가입 - 필수 과정만") public ResponseDto singUpSenior(@AuthenticationPrincipal AuthDetails authDetails, @RequestBody SeniorSignUpRequest signUpRequest) { signUpUseCase.signUp(authDetails, signUpRequest); - return ResponseDto.create(SENIOR_CREATE.getCode(), SUCCESS_SENIOR_SIGN_UP_MESSAGE.getMessage()); + return ResponseDto.create(SENIOR_CREATE.getCode(), CREATE_SENIOR.getMessage()); } @PatchMapping("/profile") @Operation(summary = "대학원생 프로필 등록", description = "소개글, 추천대상, 오픈채팅방 링크, 가능 시간대, 소통시간") public ResponseDto singUpSenior(@AuthenticationPrincipal AuthDetails authDetails, - @RequestBody SeniorProfileRequest profileRequest) { - updateUseCase.updateProfile(authDetails, profileRequest); - return ResponseDto.create(SENIOR_UPDATE.getCode(), SUCCESS_UPDATE_PROFILE_MESSAGE.getMessage()); + @RequestBody SeniorProfileRequest profileRequest) { + myPageUseCase.updateProfile(authDetails, profileRequest); + return ResponseDto.create(SENIOR_UPDATE.getCode(), UPDATE_PROFILE.getMessage()); + } + + @PatchMapping("/certification") + @Operation(summary = "대학원생 인증", description = "이미지 업로드 이후 url 담아서 요청") + public ResponseDto updateCertification(@AuthenticationPrincipal AuthDetails authDetails, + @RequestBody SeniorCertificationRequest certificationRequest) { + myPageUseCase.updateCertification(authDetails, certificationRequest); + return ResponseDto.create(SENIOR_UPDATE.getCode(), UPDATE_CERTIFICATION.getMessage()); + } + + @GetMapping("/me") + @Operation(summary = "대학원생 마이페이지 기본 정보", description = "닉네임, 프로필 사진, 인증 여부") + public ResponseDto getSeniorInfo(@AuthenticationPrincipal AuthDetails authDetails) { + SeniorInfoResponse seniorInfoResponse = myPageUseCase.seniorInfo(authDetails); + return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_INFO.getMessage(), seniorInfoResponse); } } diff --git a/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseMessage.java b/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseMessage.java index d13825bf..1caf9f41 100644 --- a/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseMessage.java +++ b/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseMessage.java @@ -6,8 +6,10 @@ @Getter @RequiredArgsConstructor public enum SeniorResponseMessage { - SUCCESS_SENIOR_SIGN_UP_MESSAGE("대학원생 가입에 성공하였습니다."), - SUCCESS_UPDATE_PROFILE_MESSAGE("대학원생 프로필 등록에 성공하였습니다"); + CREATE_SENIOR("대학원생 가입에 성공하였습니다."), + UPDATE_PROFILE("대학원생 프로필 등록에 성공하였습니다"), + GET_SENIOR_INFO("대학원생 정보 조회에 성공하였습니다"), + UPDATE_CERTIFICATION("대학원생 인증사진 업로드에 성공하였습니다"); private final String message; } From 0edff8eb975f874ee8a7944ea4258cd0df45f88d Mon Sep 17 00:00:00 2001 From: yang Date: Fri, 3 Nov 2023 16:49:30 +0900 Subject: [PATCH 05/14] =?UTF-8?q?RAC-107=20refactor=20:=20=EB=8C=80?= =?UTF-8?q?=ED=95=99=EC=9B=90=EC=83=9D=20=EC=9D=B8=EC=A6=9D=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20enum=EC=82=AC=EC=9A=A9=20=EB=B0=8F=203=EB=8B=A8?= =?UTF-8?q?=EA=B3=84=20=EB=B6=84=ED=95=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../senior/application/dto/res/SeniorInfoResponse.java | 3 ++- .../domain/senior/application/mapper/SeniorMapper.java | 3 ++- .../application/usecase/SeniorMyPageUseCase.java | 3 ++- .../domain/senior/domain/entity/Senior.java | 9 +++++++-- .../domain/senior/domain/entity/constant/Status.java | 10 ++++++++++ .../{entity => }/repository/SeniorRepository.java | 2 +- .../domain/senior/domain/service/SeniorGetService.java | 2 +- .../senior/domain/service/SeniorSaveService.java | 2 +- 8 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/senior/domain/entity/constant/Status.java rename src/main/java/com/postgraduate/domain/senior/domain/{entity => }/repository/SeniorRepository.java (83%) diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorInfoResponse.java b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorInfoResponse.java index f7a661d8..601fb7da 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorInfoResponse.java +++ b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorInfoResponse.java @@ -1,5 +1,6 @@ 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; @@ -10,6 +11,6 @@ public class SeniorInfoResponse { private String nickName; private String profile; - private boolean certificationRegister; + private Status certificationRegister; private boolean profileRegister; } diff --git a/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java b/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java index 2b95ef03..85df361b 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java +++ b/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java @@ -5,6 +5,7 @@ import com.postgraduate.domain.senior.domain.entity.Account; import com.postgraduate.domain.senior.domain.entity.Info; 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 { @@ -37,7 +38,7 @@ public static Account mapToAccount(SeniorSignUpRequest request) { .build(); } - public static SeniorInfoResponse mapToSeniorInfo(Senior senior, boolean certificationRegister, boolean profileRegister) { + public static SeniorInfoResponse mapToSeniorInfo(Senior senior, Status certificationRegister, boolean profileRegister) { return SeniorInfoResponse.builder() .nickName(senior.getUser().getNickName()) .profile(senior.getUser().getProfile()) diff --git a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java index 74d6fa7e..2926664e 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java +++ b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java @@ -6,6 +6,7 @@ import com.postgraduate.domain.senior.application.mapper.SeniorMapper; 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; @@ -28,7 +29,7 @@ public class SeniorMyPageUseCase { public SeniorInfoResponse seniorInfo(AuthDetails authDetails) { User user = securityUtils.getLoggedInUser(authDetails); Senior senior = seniorGetService.byUser(user); - Boolean status = senior.getStatus(); + Status status = senior.getStatus(); Optional profile = ofNullable(senior.getProfile()); return SeniorMapper.mapToSeniorInfo(senior, status, profile.isPresent()); } diff --git a/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java b/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java index 95b1189a..e15d102c 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java @@ -1,6 +1,7 @@ package com.postgraduate.domain.senior.domain.entity; import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; +import com.postgraduate.domain.senior.domain.entity.constant.Status; import com.postgraduate.domain.user.domain.entity.User; import jakarta.persistence.*; import lombok.AllArgsConstructor; @@ -9,6 +10,9 @@ import lombok.NoArgsConstructor; import org.hibernate.annotations.DynamicInsert; +import static com.postgraduate.domain.senior.domain.entity.constant.Status.NOT_APPROVE; +import static com.postgraduate.domain.senior.domain.entity.constant.Status.WAITING; + @Entity @Builder @AllArgsConstructor @@ -30,8 +34,9 @@ public class Senior { private String rrn; @Column(nullable = false) + @Enumerated(EnumType.STRING) @Builder.Default - private Boolean status = false; + private Status status = WAITING; @Column(nullable = false) private int hit; @@ -50,6 +55,6 @@ public void updateProfile(SeniorProfileRequest profileRequest) { public void updateCertification(String certification) { this.certification = certification; - this.status = false; + this.status = WAITING; } } diff --git a/src/main/java/com/postgraduate/domain/senior/domain/entity/constant/Status.java b/src/main/java/com/postgraduate/domain/senior/domain/entity/constant/Status.java new file mode 100644 index 00000000..6b4eda11 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/senior/domain/entity/constant/Status.java @@ -0,0 +1,10 @@ +package com.postgraduate.domain.senior.domain.entity.constant; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public enum Status { + NOT_APPROVE, WAITING, APPROVE +} diff --git a/src/main/java/com/postgraduate/domain/senior/domain/entity/repository/SeniorRepository.java b/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorRepository.java similarity index 83% rename from src/main/java/com/postgraduate/domain/senior/domain/entity/repository/SeniorRepository.java rename to src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorRepository.java index 7c5a0eeb..1af1bfb5 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/entity/repository/SeniorRepository.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorRepository.java @@ -1,4 +1,4 @@ -package com.postgraduate.domain.senior.domain.entity.repository; +package com.postgraduate.domain.senior.domain.repository; import com.postgraduate.domain.senior.domain.entity.Senior; import com.postgraduate.domain.user.domain.entity.User; diff --git a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java index efd0a796..bce902bf 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorGetService.java @@ -1,7 +1,7 @@ package com.postgraduate.domain.senior.domain.service; import com.postgraduate.domain.senior.domain.entity.Senior; -import com.postgraduate.domain.senior.domain.entity.repository.SeniorRepository; +import com.postgraduate.domain.senior.domain.repository.SeniorRepository; import com.postgraduate.domain.user.domain.entity.User; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorSaveService.java b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorSaveService.java index 24c39a5e..6c3d5b63 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorSaveService.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorSaveService.java @@ -1,7 +1,7 @@ package com.postgraduate.domain.senior.domain.service; import com.postgraduate.domain.senior.domain.entity.Senior; -import com.postgraduate.domain.senior.domain.entity.repository.SeniorRepository; +import com.postgraduate.domain.senior.domain.repository.SeniorRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; From ebf53291974cb2b8c63c5a9b807b8f8f09739351 Mon Sep 17 00:00:00 2001 From: yang Date: Fri, 3 Nov 2023 17:32:27 +0900 Subject: [PATCH 06/14] =?UTF-8?q?RAC-107=20fix=20:=20=EB=8C=80=ED=95=99?= =?UTF-8?q?=EC=9B=90=EC=83=9D=20=ED=94=84=EB=A1=9C=ED=95=84=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/senior/domain/entity/Profile.java | 10 ---------- .../domain/senior/domain/entity/Senior.java | 5 +++-- .../domain/senior/presentation/SeniorController.java | 8 ++++++++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/senior/domain/entity/Profile.java b/src/main/java/com/postgraduate/domain/senior/domain/entity/Profile.java index 5216eb65..41fd4a33 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/entity/Profile.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/entity/Profile.java @@ -1,13 +1,10 @@ package com.postgraduate.domain.senior.domain.entity; -import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; -import jakarta.persistence.Column; import jakarta.persistence.Embeddable; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.hibernate.annotations.ColumnDefault; @Getter @AllArgsConstructor @@ -24,11 +21,4 @@ public class Profile { private String time; private Integer term; - - public void updateProfile(SeniorProfileRequest profileRequest) { - this.info = profileRequest.getInfo(); - this.target = profileRequest.getTarget(); - this.chatLink = profileRequest.getChatLink(); - this.time = profileRequest.getTime(); - } } diff --git a/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java b/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java index e15d102c..fd8808c8 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java @@ -49,8 +49,9 @@ public class Senior { @Embedded private Profile profile; - public void updateProfile(SeniorProfileRequest profileRequest) { - profile.updateProfile(profileRequest); + + public void updateProfile(Profile profile) { + this.profile = profile; } public void updateCertification(String certification) { diff --git a/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java b/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java index d445796c..a0fed6cd 100644 --- a/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java +++ b/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java @@ -4,6 +4,7 @@ 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.application.usecase.SeniorMyPageUseCase; import com.postgraduate.domain.senior.application.usecase.SeniorSignUpUseCase; import com.postgraduate.global.auth.AuthDetails; @@ -56,4 +57,11 @@ public ResponseDto getSeniorInfo(@AuthenticationPrincipal Au SeniorInfoResponse seniorInfoResponse = myPageUseCase.seniorInfo(authDetails); return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_INFO.getMessage(), seniorInfoResponse); } + + @GetMapping("/me/profile") + @Operation(summary = "대학원생 마이페이지 프로필 보기") + public ResponseDto getSeniorProfile(@AuthenticationPrincipal AuthDetails authDetails) { + SeniorProfileResponse seniorProfile = myPageUseCase.getSeniorProfile(authDetails); + return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_PROFILE.getMessage(), seniorProfile); + } } From f4b3e60f1540ec85c8bba0cb7ffb6620aa14b161 Mon Sep 17 00:00:00 2001 From: yang Date: Fri, 3 Nov 2023 17:32:38 +0900 Subject: [PATCH 07/14] =?UTF-8?q?RAC-107=20feat=20:=20=EB=8C=80=ED=95=99?= =?UTF-8?q?=EC=9B=90=EC=83=9D=20=ED=94=84=EB=A1=9C=ED=95=84=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/SeniorProfileResponse.java | 13 +++++++++++++ .../application/mapper/SeniorMapper.java | 18 ++++++++++++++++++ .../usecase/SeniorMyPageUseCase.java | 13 ++++++++++++- .../domain/service/SeniorUpdateService.java | 5 +++-- .../constant/SeniorResponseMessage.java | 1 + 5 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorProfileResponse.java diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorProfileResponse.java b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorProfileResponse.java new file mode 100644 index 00000000..268bf0ee --- /dev/null +++ b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorProfileResponse.java @@ -0,0 +1,13 @@ +package com.postgraduate.domain.senior.application.dto.res; + +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; +} diff --git a/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java b/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java index 85df361b..1bfbcaef 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java +++ b/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java @@ -1,9 +1,12 @@ package com.postgraduate.domain.senior.application.mapper; +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; @@ -38,6 +41,15 @@ public static Account mapToAccount(SeniorSignUpRequest request) { .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()) @@ -46,4 +58,10 @@ public static SeniorInfoResponse mapToSeniorInfo(Senior senior, Status certifica .profileRegister(profileRegister) .build(); } + + public static SeniorProfileResponse mapToSeniorProfileInfo(Senior senior) { + return SeniorProfileResponse.builder() + .profile(senior.getProfile()) + .build(); + } } diff --git a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java index 2926664e..ac5a2fe9 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java +++ b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java @@ -3,6 +3,7 @@ import com.postgraduate.domain.senior.application.dto.req.SeniorCertificationRequest; import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; 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.Profile; import com.postgraduate.domain.senior.domain.entity.Senior; @@ -14,6 +15,7 @@ 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; @@ -21,6 +23,7 @@ @Service @RequiredArgsConstructor +@Transactional public class SeniorMyPageUseCase { private final SeniorGetService seniorGetService; private final SeniorUpdateService seniorUpdateService; @@ -43,6 +46,14 @@ public void updateCertification(AuthDetails authDetails, SeniorCertificationRequ public void updateProfile(AuthDetails authDetails, SeniorProfileRequest profileRequest) { User user = securityUtils.getLoggedInUser(authDetails); Senior senior = seniorGetService.byUser(user); - seniorUpdateService.updateSeniorProfile(senior, profileRequest); + Profile profile = SeniorMapper.mapToProfile(profileRequest); + seniorUpdateService.updateSeniorProfile(senior, profile); + } + + public SeniorProfileResponse getSeniorProfile(AuthDetails authDetails) { + User user = securityUtils.getLoggedInUser(authDetails); + Senior senior = seniorGetService.byUser(user); + SeniorProfileResponse seniorProfileResponse = SeniorMapper.mapToSeniorProfileInfo(senior); + return seniorProfileResponse; } } diff --git a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java index 92f60997..888ae8c2 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java @@ -1,6 +1,7 @@ package com.postgraduate.domain.senior.domain.service; import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; +import com.postgraduate.domain.senior.domain.entity.Profile; import com.postgraduate.domain.senior.domain.entity.Senior; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -9,8 +10,8 @@ @Service public class SeniorUpdateService { - public void updateSeniorProfile(Senior senior, SeniorProfileRequest profileRequest) { - senior.updateProfile(profileRequest); + public void updateSeniorProfile(Senior senior, Profile profile) { + senior.updateProfile(profile); } public void updateCertification(Senior senior, String imageUrl) { diff --git a/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseMessage.java b/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseMessage.java index 1caf9f41..e25770c7 100644 --- a/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseMessage.java +++ b/src/main/java/com/postgraduate/domain/senior/presentation/constant/SeniorResponseMessage.java @@ -9,6 +9,7 @@ public enum SeniorResponseMessage { CREATE_SENIOR("대학원생 가입에 성공하였습니다."), UPDATE_PROFILE("대학원생 프로필 등록에 성공하였습니다"), GET_SENIOR_INFO("대학원생 정보 조회에 성공하였습니다"), + GET_SENIOR_PROFILE("대학원생 프로필 조회에 성공하였습니다"), UPDATE_CERTIFICATION("대학원생 인증사진 업로드에 성공하였습니다"); private final String message; From 6ed836551996e106baabe96bf2f65e477ba27b81 Mon Sep 17 00:00:00 2001 From: yang Date: Fri, 3 Nov 2023 18:03:53 +0900 Subject: [PATCH 08/14] =?UTF-8?q?RAC-107=20refactor=20:=20=EB=8C=80?= =?UTF-8?q?=ED=95=99=EC=9B=90=EC=83=9D=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=ED=94=84=EB=A1=9C=ED=95=84=20=EB=93=B1=EB=A1=9D,?= =?UTF-8?q?=20=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EC=88=98=EC=A0=95=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 내용이 다름 --- .../SeniorProfileAndAccountPageRequest.java | 26 +++++++++++++++++++ .../dto/res/SeniorProfileResponse.java | 2 ++ .../application/mapper/SeniorMapper.java | 21 ++++++++++++++- .../usecase/SeniorMyPageUseCase.java | 8 +++--- .../usecase/SeniorSignUpUseCase.java | 13 ++++++++++ .../domain/senior/domain/entity/Account.java | 3 +++ .../domain/senior/domain/entity/Senior.java | 10 +++---- .../domain/service/SeniorUpdateService.java | 5 ++++ .../senior/presentation/SeniorController.java | 18 ++++++++++--- 9 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountPageRequest.java diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountPageRequest.java b/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountPageRequest.java new file mode 100644 index 00000000..98f2a171 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountPageRequest.java @@ -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 SeniorProfileAndAccountPageRequest { + @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; +} diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorProfileResponse.java b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorProfileResponse.java index 268bf0ee..40c4cc4d 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorProfileResponse.java +++ b/src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorProfileResponse.java @@ -1,5 +1,6 @@ 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; @@ -10,4 +11,5 @@ @AllArgsConstructor public class SeniorProfileResponse { private Profile profile; + private Account account; } diff --git a/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java b/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java index 1bfbcaef..7e57df3d 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java +++ b/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java @@ -1,5 +1,6 @@ package com.postgraduate.domain.senior.application.mapper; +import com.postgraduate.domain.senior.application.dto.req.SeniorProfileAndAccountPageRequest; 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; @@ -19,7 +20,6 @@ public static Senior mapToSenior(User user, SeniorSignUpRequest request) { .info(mapToInfo(request)) .certification(request.getCertification()) .account(mapToAccount(request)) - .rrn(request.getRrn()) .build(); } @@ -38,6 +38,24 @@ public static Account mapToAccount(SeniorSignUpRequest request) { return Account.builder() .bank(request.getBank()) .account(request.getAccount()) + .rrn(request.getRrn()) + .build(); + } + + public static Account mapToAccount(SeniorProfileAndAccountPageRequest profileAndAccountPageRequest) { + return Account.builder() + .bank(profileAndAccountPageRequest.getBank()) + .account(profileAndAccountPageRequest.getAccount()) + .rrn(profileAndAccountPageRequest.getRrn()) + .build(); + } + + public static Profile mapToProfile(SeniorProfileAndAccountPageRequest profileAndAccountPageRequest) { + return Profile.builder() + .info(profileAndAccountPageRequest.getInfo()) + .chatLink(profileAndAccountPageRequest.getChatLink()) + .target(profileAndAccountPageRequest.getTarget()) + .time(profileAndAccountPageRequest.getTime()) .build(); } @@ -62,6 +80,7 @@ public static SeniorInfoResponse mapToSeniorInfo(Senior senior, Status certifica public static SeniorProfileResponse mapToSeniorProfileInfo(Senior senior) { return SeniorProfileResponse.builder() .profile(senior.getProfile()) + .account(senior.getAccount()) .build(); } } diff --git a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java index ac5a2fe9..d10ed180 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java +++ b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java @@ -1,10 +1,11 @@ package com.postgraduate.domain.senior.application.usecase; import com.postgraduate.domain.senior.application.dto.req.SeniorCertificationRequest; -import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; +import com.postgraduate.domain.senior.application.dto.req.SeniorProfileAndAccountPageRequest; 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; @@ -43,11 +44,12 @@ public void updateCertification(AuthDetails authDetails, SeniorCertificationRequ seniorUpdateService.updateCertification(senior, certificationRequest.getCertification()); } - public void updateProfile(AuthDetails authDetails, SeniorProfileRequest profileRequest) { + public void updateProfile(AuthDetails authDetails, SeniorProfileAndAccountPageRequest profileRequest) { User user = securityUtils.getLoggedInUser(authDetails); Senior senior = seniorGetService.byUser(user); Profile profile = SeniorMapper.mapToProfile(profileRequest); - seniorUpdateService.updateSeniorProfile(senior, profile); + Account account = SeniorMapper.mapToAccount(profileRequest); + seniorUpdateService.updateSeniorProfileAndAccount(senior, profile, account); } public SeniorProfileResponse getSeniorProfile(AuthDetails authDetails) { diff --git a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorSignUpUseCase.java b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorSignUpUseCase.java index 7dd3e828..d1e7551c 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorSignUpUseCase.java +++ b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorSignUpUseCase.java @@ -1,9 +1,13 @@ package com.postgraduate.domain.senior.application.usecase; +import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; import com.postgraduate.domain.senior.application.dto.req.SeniorSignUpRequest; import com.postgraduate.domain.senior.application.mapper.SeniorMapper; +import com.postgraduate.domain.senior.domain.entity.Profile; import com.postgraduate.domain.senior.domain.entity.Senior; +import com.postgraduate.domain.senior.domain.service.SeniorGetService; import com.postgraduate.domain.senior.domain.service.SeniorSaveService; +import com.postgraduate.domain.senior.domain.service.SeniorUpdateService; import com.postgraduate.domain.user.domain.entity.User; import com.postgraduate.domain.user.domain.entity.constant.Role; import com.postgraduate.domain.user.domain.service.UserUpdateService; @@ -19,6 +23,8 @@ public class SeniorSignUpUseCase { private final UserUpdateService userUpdateService; private final SeniorSaveService seniorSaveService; + private final SeniorGetService seniorGetService; + private final SeniorUpdateService seniorUpdateService; private final SecurityUtils securityUtils; public void signUp(AuthDetails authDetails, SeniorSignUpRequest request) { @@ -27,4 +33,11 @@ public void signUp(AuthDetails authDetails, SeniorSignUpRequest request) { Senior senior = SeniorMapper.mapToSenior(user, request); seniorSaveService.saveSenior(senior); } + + public void updateProfile(AuthDetails authDetails, SeniorProfileRequest profileRequest) { + User user = securityUtils.getLoggedInUser(authDetails); + Senior senior = seniorGetService.byUser(user); + Profile profile = SeniorMapper.mapToProfile(profileRequest); + seniorUpdateService.updateSeniorProfile(senior, profile); + } } diff --git a/src/main/java/com/postgraduate/domain/senior/domain/entity/Account.java b/src/main/java/com/postgraduate/domain/senior/domain/entity/Account.java index 8fb21548..80e1ef48 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/entity/Account.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/entity/Account.java @@ -18,4 +18,7 @@ public class Account { @Column(nullable = false) private String bank; + + @Column(nullable = false) + private String rrn; } diff --git a/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java b/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java index fd8808c8..35bf55b6 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/entity/Senior.java @@ -1,6 +1,5 @@ package com.postgraduate.domain.senior.domain.entity; -import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; import com.postgraduate.domain.senior.domain.entity.constant.Status; import com.postgraduate.domain.user.domain.entity.User; import jakarta.persistence.*; @@ -10,7 +9,6 @@ import lombok.NoArgsConstructor; import org.hibernate.annotations.DynamicInsert; -import static com.postgraduate.domain.senior.domain.entity.constant.Status.NOT_APPROVE; import static com.postgraduate.domain.senior.domain.entity.constant.Status.WAITING; @Entity @@ -30,9 +28,6 @@ public class Senior { @Column(nullable = false) private String certification; - @Column(nullable = false) - private String rrn; - @Column(nullable = false) @Enumerated(EnumType.STRING) @Builder.Default @@ -54,6 +49,11 @@ public void updateProfile(Profile profile) { this.profile = profile; } + public void updateProfileAndAccount(Profile profile, Account account) { + this.profile = profile; + this.account = account; + } + public void updateCertification(String certification) { this.certification = certification; this.status = WAITING; diff --git a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java index 888ae8c2..e58305f2 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/service/SeniorUpdateService.java @@ -1,6 +1,7 @@ package com.postgraduate.domain.senior.domain.service; import com.postgraduate.domain.senior.application.dto.req.SeniorProfileRequest; +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 lombok.RequiredArgsConstructor; @@ -14,6 +15,10 @@ public void updateSeniorProfile(Senior senior, Profile profile) { senior.updateProfile(profile); } + public void updateSeniorProfileAndAccount(Senior senior, Profile profile, Account account) { + senior.updateProfileAndAccount(profile, account); + } + public void updateCertification(Senior senior, String imageUrl) { senior.updateCertification(imageUrl); } diff --git a/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java b/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java index a0fed6cd..535e27c7 100644 --- a/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java +++ b/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java @@ -1,6 +1,7 @@ package com.postgraduate.domain.senior.presentation; import com.postgraduate.domain.senior.application.dto.req.SeniorCertificationRequest; +import com.postgraduate.domain.senior.application.dto.req.SeniorProfileAndAccountPageRequest; 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; @@ -36,17 +37,17 @@ public ResponseDto singUpSenior(@AuthenticationPrincipal AuthDetails authDetails } @PatchMapping("/profile") - @Operation(summary = "대학원생 프로필 등록", description = "소개글, 추천대상, 오픈채팅방 링크, 가능 시간대, 소통시간") + @Operation(summary = "대학원생 프로필 등록") public ResponseDto singUpSenior(@AuthenticationPrincipal AuthDetails authDetails, - @RequestBody SeniorProfileRequest profileRequest) { - myPageUseCase.updateProfile(authDetails, profileRequest); + @RequestBody SeniorProfileRequest profileRequest) { + signUpUseCase.updateProfile(authDetails, profileRequest); return ResponseDto.create(SENIOR_UPDATE.getCode(), UPDATE_PROFILE.getMessage()); } @PatchMapping("/certification") @Operation(summary = "대학원생 인증", description = "이미지 업로드 이후 url 담아서 요청") public ResponseDto updateCertification(@AuthenticationPrincipal AuthDetails authDetails, - @RequestBody SeniorCertificationRequest certificationRequest) { + @RequestBody SeniorCertificationRequest certificationRequest) { myPageUseCase.updateCertification(authDetails, certificationRequest); return ResponseDto.create(SENIOR_UPDATE.getCode(), UPDATE_CERTIFICATION.getMessage()); } @@ -64,4 +65,13 @@ public ResponseDto getSeniorProfile(@AuthenticationPrinci SeniorProfileResponse seniorProfile = myPageUseCase.getSeniorProfile(authDetails); return ResponseDto.create(SENIOR_FIND.getCode(), GET_SENIOR_PROFILE.getMessage(), seniorProfile); } + + @PatchMapping("/me/profile") + @Operation(summary = "대학원생 프로필 수정") + public ResponseDto updateProfile(@AuthenticationPrincipal AuthDetails authDetails, + @RequestBody SeniorProfileAndAccountPageRequest profileAndAccountPageRequest) { + myPageUseCase.updateProfile(authDetails, profileAndAccountPageRequest); + return ResponseDto.create(SENIOR_UPDATE.getCode(), UPDATE_PROFILE.getMessage()); + } + } From 8a8d444f7393dab9dbd3807bb2c110e1968f6877 Mon Sep 17 00:00:00 2001 From: yang Date: Sat, 4 Nov 2023 13:35:23 +0900 Subject: [PATCH 09/14] =?UTF-8?q?RAC-107=20refactor=20:=20dto=EB=AA=85=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...PageRequest.java => SeniorProfileAndAccountRequest.java} | 2 +- .../domain/senior/application/mapper/SeniorMapper.java | 6 +++--- .../senior/application/usecase/SeniorMyPageUseCase.java | 4 ++-- .../domain/senior/presentation/SeniorController.java | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) rename src/main/java/com/postgraduate/domain/senior/application/dto/req/{SeniorProfileAndAccountPageRequest.java => SeniorProfileAndAccountRequest.java} (91%) diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountPageRequest.java b/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountRequest.java similarity index 91% rename from src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountPageRequest.java rename to src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountRequest.java index 98f2a171..9ca7266a 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountPageRequest.java +++ b/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountRequest.java @@ -8,7 +8,7 @@ @AllArgsConstructor @NoArgsConstructor @Getter -public class SeniorProfileAndAccountPageRequest { +public class SeniorProfileAndAccountRequest { @NotNull private String info; @NotNull diff --git a/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java b/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java index 7e57df3d..7a548efc 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java +++ b/src/main/java/com/postgraduate/domain/senior/application/mapper/SeniorMapper.java @@ -1,6 +1,6 @@ package com.postgraduate.domain.senior.application.mapper; -import com.postgraduate.domain.senior.application.dto.req.SeniorProfileAndAccountPageRequest; +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; @@ -42,7 +42,7 @@ public static Account mapToAccount(SeniorSignUpRequest request) { .build(); } - public static Account mapToAccount(SeniorProfileAndAccountPageRequest profileAndAccountPageRequest) { + public static Account mapToAccount(SeniorProfileAndAccountRequest profileAndAccountPageRequest) { return Account.builder() .bank(profileAndAccountPageRequest.getBank()) .account(profileAndAccountPageRequest.getAccount()) @@ -50,7 +50,7 @@ public static Account mapToAccount(SeniorProfileAndAccountPageRequest profileAnd .build(); } - public static Profile mapToProfile(SeniorProfileAndAccountPageRequest profileAndAccountPageRequest) { + public static Profile mapToProfile(SeniorProfileAndAccountRequest profileAndAccountPageRequest) { return Profile.builder() .info(profileAndAccountPageRequest.getInfo()) .chatLink(profileAndAccountPageRequest.getChatLink()) diff --git a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java index d10ed180..7a6ebb3f 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java +++ b/src/main/java/com/postgraduate/domain/senior/application/usecase/SeniorMyPageUseCase.java @@ -1,7 +1,7 @@ package com.postgraduate.domain.senior.application.usecase; import com.postgraduate.domain.senior.application.dto.req.SeniorCertificationRequest; -import com.postgraduate.domain.senior.application.dto.req.SeniorProfileAndAccountPageRequest; +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; @@ -44,7 +44,7 @@ public void updateCertification(AuthDetails authDetails, SeniorCertificationRequ seniorUpdateService.updateCertification(senior, certificationRequest.getCertification()); } - public void updateProfile(AuthDetails authDetails, SeniorProfileAndAccountPageRequest profileRequest) { + public void updateProfile(AuthDetails authDetails, SeniorProfileAndAccountRequest profileRequest) { User user = securityUtils.getLoggedInUser(authDetails); Senior senior = seniorGetService.byUser(user); Profile profile = SeniorMapper.mapToProfile(profileRequest); diff --git a/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java b/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java index 535e27c7..ceb914c7 100644 --- a/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java +++ b/src/main/java/com/postgraduate/domain/senior/presentation/SeniorController.java @@ -1,7 +1,7 @@ package com.postgraduate.domain.senior.presentation; import com.postgraduate.domain.senior.application.dto.req.SeniorCertificationRequest; -import com.postgraduate.domain.senior.application.dto.req.SeniorProfileAndAccountPageRequest; +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; @@ -69,7 +69,7 @@ public ResponseDto getSeniorProfile(@AuthenticationPrinci @PatchMapping("/me/profile") @Operation(summary = "대학원생 프로필 수정") public ResponseDto updateProfile(@AuthenticationPrincipal AuthDetails authDetails, - @RequestBody SeniorProfileAndAccountPageRequest profileAndAccountPageRequest) { + @RequestBody SeniorProfileAndAccountRequest profileAndAccountPageRequest) { myPageUseCase.updateProfile(authDetails, profileAndAccountPageRequest); return ResponseDto.create(SENIOR_UPDATE.getCode(), UPDATE_PROFILE.getMessage()); } From 3eade53e3a285aa9d3865c75fdbc558c2fc690f6 Mon Sep 17 00:00:00 2001 From: yang Date: Sat, 4 Nov 2023 22:50:54 +0900 Subject: [PATCH 10/14] =?UTF-8?q?RAC-107=20refactor=20:=20notnull=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../senior/application/dto/req/SeniorCertificationRequest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorCertificationRequest.java b/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorCertificationRequest.java index 67bef493..cc26e8ee 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorCertificationRequest.java +++ b/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorCertificationRequest.java @@ -1,5 +1,6 @@ package com.postgraduate.domain.senior.application.dto.req; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -8,5 +9,6 @@ @AllArgsConstructor @NoArgsConstructor public class SeniorCertificationRequest { + @NotNull private String certification; } From 789a29aaa1a5bff60768c8d4c7913d6723e955b8 Mon Sep 17 00:00:00 2001 From: yang Date: Sun, 5 Nov 2023 04:30:34 +0900 Subject: [PATCH 11/14] =?UTF-8?q?RAC-107=20feat=20:=20=EC=9D=B8=EA=B0=80?= =?UTF-8?q?=20code=20=EC=9D=B4=ED=9B=84=20=EC=B2=98=EB=A6=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/req/KakaoCodeRequest.java | 12 ++++++++ .../dto/res/KakaoTokenInfoResponse.java | 20 +++++++++++++ .../kakao/KakaoAccessTokenUseCase.java | 30 ++++++++++++++++++- .../usecase/kakao/KakaoSignInUseCase.java | 5 ++-- .../auth/presentation/AuthController.java | 7 ++--- 5 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/postgraduate/domain/auth/application/dto/req/KakaoCodeRequest.java create mode 100644 src/main/java/com/postgraduate/domain/auth/application/dto/res/KakaoTokenInfoResponse.java diff --git a/src/main/java/com/postgraduate/domain/auth/application/dto/req/KakaoCodeRequest.java b/src/main/java/com/postgraduate/domain/auth/application/dto/req/KakaoCodeRequest.java new file mode 100644 index 00000000..c14ffcfb --- /dev/null +++ b/src/main/java/com/postgraduate/domain/auth/application/dto/req/KakaoCodeRequest.java @@ -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; +} diff --git a/src/main/java/com/postgraduate/domain/auth/application/dto/res/KakaoTokenInfoResponse.java b/src/main/java/com/postgraduate/domain/auth/application/dto/res/KakaoTokenInfoResponse.java new file mode 100644 index 00000000..8636b00e --- /dev/null +++ b/src/main/java/com/postgraduate/domain/auth/application/dto/res/KakaoTokenInfoResponse.java @@ -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; +} diff --git a/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoAccessTokenUseCase.java b/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoAccessTokenUseCase.java index 05ac257a..fa961917 100644 --- a/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoAccessTokenUseCase.java +++ b/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoAccessTokenUseCase.java @@ -1,10 +1,14 @@ package com.postgraduate.domain.auth.application.usecase.kakao; import com.postgraduate.domain.auth.application.dto.res.KakaoAccessTokenResponse; +import com.postgraduate.domain.auth.application.dto.res.KakaoTokenInfoResponse; import com.postgraduate.domain.auth.application.dto.res.KakaoUserInfoResponse; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.MediaType; import org.springframework.stereotype.Service; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.function.client.WebClient; @RequiredArgsConstructor @@ -13,13 +17,37 @@ public class KakaoAccessTokenUseCase { @Value("${app-id.kakao}") private String APP_ID; + @Value("${kakao.redirect-uri}") + private String REDRECT_URI; + @Value("${kakao.authorization-grant-type}") + private String AUTHORIZATION_GRANT_TYPE; private final WebClient webClient; private static final String USER_INFO_URI = "https://kapi.kakao.com/v2/user/me"; private static final String VALIDATE_TOKEN_URI = "https://kapi.kakao.com/v1/user/access_token_info"; + public KakaoUserInfoResponse getKakaoToken(String code) { + MultiValueMap requestBody = getRequestBody(code); + KakaoTokenInfoResponse tokenInfoResponse = webClient.post() + .uri("https://kauth.kakao.com/oauth/token") + .headers(h -> h.setContentType(MediaType.APPLICATION_FORM_URLENCODED)) + .bodyValue(requestBody) + .retrieve() + .bodyToMono(KakaoTokenInfoResponse.class) + .block(); + return getUserInfo(tokenInfoResponse.getAccess_token()); + } - public KakaoUserInfoResponse getUserInfo(String accessToken) { + private MultiValueMap getRequestBody(String code) { + System.out.println(code); + MultiValueMap requestBody = new LinkedMultiValueMap<>(); + requestBody.add("grant_type", AUTHORIZATION_GRANT_TYPE); + requestBody.add("client_id", APP_ID); + requestBody.add("redirect_uri", REDRECT_URI); + requestBody.add("code", code); + return requestBody; + } + private KakaoUserInfoResponse getUserInfo(String accessToken) { verifyAccessToken(accessToken); return webClient.get() diff --git a/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoSignInUseCase.java b/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoSignInUseCase.java index e8e4f548..f70772d5 100644 --- a/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoSignInUseCase.java +++ b/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoSignInUseCase.java @@ -1,5 +1,6 @@ package com.postgraduate.domain.auth.application.usecase.kakao; +import com.postgraduate.domain.auth.application.dto.req.KakaoCodeRequest; import com.postgraduate.domain.auth.application.dto.res.AuthUserResponse; import com.postgraduate.domain.auth.application.dto.res.KakaoUserInfoResponse; import com.postgraduate.domain.auth.application.dto.req.SignUpRequest; @@ -22,8 +23,8 @@ public class KakaoSignInUseCase { private final UserGetService userGetService; @Transactional - public AuthUserResponse getUser(String token) { - KakaoUserInfoResponse userInfo = kakaoTokenUseCase.getUserInfo(token); + public AuthUserResponse getUser(KakaoCodeRequest codeRequest) { + KakaoUserInfoResponse userInfo = kakaoTokenUseCase.getKakaoToken(codeRequest.getCode()); Long socialId = userInfo.getId(); Optional user = userGetService.bySocialId(socialId); return AuthMapper.mapToAuthUser(user, socialId); diff --git a/src/main/java/com/postgraduate/domain/auth/presentation/AuthController.java b/src/main/java/com/postgraduate/domain/auth/presentation/AuthController.java index ed62a293..74eb0a7a 100644 --- a/src/main/java/com/postgraduate/domain/auth/presentation/AuthController.java +++ b/src/main/java/com/postgraduate/domain/auth/presentation/AuthController.java @@ -1,6 +1,6 @@ package com.postgraduate.domain.auth.presentation; -import com.postgraduate.domain.auth.application.dto.req.KakaoLoginRequest; +import com.postgraduate.domain.auth.application.dto.req.KakaoCodeRequest; import com.postgraduate.domain.auth.application.dto.req.SignUpRequest; import com.postgraduate.domain.auth.application.dto.res.AuthUserResponse; import com.postgraduate.domain.auth.application.dto.res.JwtTokenResponse; @@ -32,11 +32,10 @@ public class AuthController { @PostMapping("/login") @Operation(summary = "카카오 로그인", description = "회원인 경우 JWT를, 회원이 아닌 경우 socialId를 반환합니다(회원가입은 진행하지 않습니다).") - public ResponseDto authLogin(@RequestBody KakaoLoginRequest request) { - AuthUserResponse authUser = kakaoSignInUseCase.getUser(request.getAccessToken()); + public ResponseDto authLogin(@RequestBody KakaoCodeRequest tokenRequest) { + AuthUserResponse authUser = kakaoSignInUseCase.getUser(tokenRequest); if (authUser.getUser().isEmpty()) return ResponseDto.create(AUTH_NONE.getCode(), NOT_REGISTERED_USER_MESSAGE.getMessage(), authUser); - JwtTokenResponse jwtToken = jwtUseCase.signIn(authUser.getUser().get()); return ResponseDto.create(AUTH_ALREADY.getCode(), SUCCESS_AUTH_MESSAGE.getMessage(), jwtToken); } From 4c6d1d1bfb85e824557a5f06f75471fbbd7d1990 Mon Sep 17 00:00:00 2001 From: yang Date: Sun, 5 Nov 2023 04:30:43 +0900 Subject: [PATCH 12/14] =?UTF-8?q?RAC-107=20test=20:=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EC=9D=98=ED=95=9C=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/kakao/KakaoSignInUseCaseTest.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoSignInUseCaseTest.java b/src/test/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoSignInUseCaseTest.java index 720a77c1..cdce4070 100644 --- a/src/test/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoSignInUseCaseTest.java +++ b/src/test/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoSignInUseCaseTest.java @@ -1,5 +1,6 @@ package com.postgraduate.domain.auth.application.usecase.kakao; +import com.postgraduate.domain.auth.application.dto.req.KakaoCodeRequest; import com.postgraduate.domain.auth.application.dto.res.AuthUserResponse; import com.postgraduate.domain.auth.application.dto.res.KakaoUserInfoResponse; import com.postgraduate.domain.auth.application.dto.res.KakaoUserInfoResponse.KakaoAccount; @@ -26,20 +27,22 @@ class KakaoSignInUseCaseTest { KakaoSignInUseCase kakaoSignInUseCase; @Test void 첫_로그인_socialId_반환() { - String token = "abcd"; - given(kakaoAccessTokenUseCase.getUserInfo(token)).willReturn(new KakaoUserInfoResponse(10000L, new KakaoAccount())); + String code = "abcdefg"; + KakaoCodeRequest kakaoCodeRequest = new KakaoCodeRequest(code); + given(kakaoAccessTokenUseCase.getKakaoToken(code)).willReturn(new KakaoUserInfoResponse(10000L, new KakaoAccount())); given(userGetService.bySocialId(10000L)).willReturn(Optional.ofNullable(null)); - AuthUserResponse authUserResponse = kakaoSignInUseCase.getUser(token); + AuthUserResponse authUserResponse = kakaoSignInUseCase.getUser(kakaoCodeRequest); Assertions.assertThat(authUserResponse.getSocialId()).isEqualTo(10000L); Assertions.assertThat(authUserResponse.getUser().isEmpty()).isTrue(); } @Test void 기존_유저_로그인_user반환() { - String token = "abcd"; - given(kakaoAccessTokenUseCase.getUserInfo(token)).willReturn(new KakaoUserInfoResponse(10000L, new KakaoAccount())); + String code = "abcdefg"; + KakaoCodeRequest kakaoCodeRequest = new KakaoCodeRequest(code); + given(kakaoAccessTokenUseCase.getKakaoToken(code)).willReturn(new KakaoUserInfoResponse(10000L, new KakaoAccount())); given(userGetService.bySocialId(10000L)).willReturn(Optional.ofNullable(new User())); - AuthUserResponse authUserResponse = kakaoSignInUseCase.getUser(token); + AuthUserResponse authUserResponse = kakaoSignInUseCase.getUser(kakaoCodeRequest); Assertions.assertThat(authUserResponse.getSocialId()).isEqualTo(10000L); Assertions.assertThat(authUserResponse.getUser().isEmpty()).isFalse(); } From d54e70abba51a41c01976859bc9210b00bcc6df9 Mon Sep 17 00:00:00 2001 From: yang Date: Sun, 5 Nov 2023 04:35:58 +0900 Subject: [PATCH 13/14] =?UTF-8?q?RAC-107=20refactor=20:=20=EC=83=81?= =?UTF-8?q?=EC=88=98=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/usecase/kakao/KakaoAccessTokenUseCase.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoAccessTokenUseCase.java b/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoAccessTokenUseCase.java index fa961917..d2b2167a 100644 --- a/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoAccessTokenUseCase.java +++ b/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoAccessTokenUseCase.java @@ -22,13 +22,15 @@ public class KakaoAccessTokenUseCase { @Value("${kakao.authorization-grant-type}") private String AUTHORIZATION_GRANT_TYPE; private final WebClient webClient; + + private static final String KAKAO_TOKEN_URI = "https://kauth.kakao.com/oauth/token"; private static final String USER_INFO_URI = "https://kapi.kakao.com/v2/user/me"; private static final String VALIDATE_TOKEN_URI = "https://kapi.kakao.com/v1/user/access_token_info"; public KakaoUserInfoResponse getKakaoToken(String code) { MultiValueMap requestBody = getRequestBody(code); KakaoTokenInfoResponse tokenInfoResponse = webClient.post() - .uri("https://kauth.kakao.com/oauth/token") + .uri(KAKAO_TOKEN_URI) .headers(h -> h.setContentType(MediaType.APPLICATION_FORM_URLENCODED)) .bodyValue(requestBody) .retrieve() From 5f70d9f8326ecc3179f737cadae9f8d642e39e04 Mon Sep 17 00:00:00 2001 From: yang Date: Tue, 7 Nov 2023 16:22:01 +0900 Subject: [PATCH 14/14] =?UTF-8?q?RAC-107=20refactor=20:=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=B6=80?= =?UTF-8?q?=EB=B6=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/req/KakaoLoginRequest.java | 14 -------------- .../usecase/kakao/KakaoAccessTokenUseCase.java | 1 - 2 files changed, 15 deletions(-) delete mode 100644 src/main/java/com/postgraduate/domain/auth/application/dto/req/KakaoLoginRequest.java diff --git a/src/main/java/com/postgraduate/domain/auth/application/dto/req/KakaoLoginRequest.java b/src/main/java/com/postgraduate/domain/auth/application/dto/req/KakaoLoginRequest.java deleted file mode 100644 index 4378ccc5..00000000 --- a/src/main/java/com/postgraduate/domain/auth/application/dto/req/KakaoLoginRequest.java +++ /dev/null @@ -1,14 +0,0 @@ -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 KakaoLoginRequest { - @NotNull - private String accessToken; -} diff --git a/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoAccessTokenUseCase.java b/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoAccessTokenUseCase.java index d2b2167a..aa826d8b 100644 --- a/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoAccessTokenUseCase.java +++ b/src/main/java/com/postgraduate/domain/auth/application/usecase/kakao/KakaoAccessTokenUseCase.java @@ -40,7 +40,6 @@ public KakaoUserInfoResponse getKakaoToken(String code) { } private MultiValueMap getRequestBody(String code) { - System.out.println(code); MultiValueMap requestBody = new LinkedMultiValueMap<>(); requestBody.add("grant_type", AUTHORIZATION_GRANT_TYPE); requestBody.add("client_id", APP_ID);