diff --git a/src/main/java/com/postgraduate/domain/auth/application/dto/req/SignUpRequest.java b/src/main/java/com/postgraduate/domain/auth/application/dto/req/SignUpRequest.java index 01805319..364051e3 100644 --- a/src/main/java/com/postgraduate/domain/auth/application/dto/req/SignUpRequest.java +++ b/src/main/java/com/postgraduate/domain/auth/application/dto/req/SignUpRequest.java @@ -12,5 +12,7 @@ public class SignUpRequest { @NotNull private Long socialId; @NotNull + private String phoneNumber; + @NotNull private String nickName; } diff --git a/src/main/java/com/postgraduate/domain/auth/application/dto/res/AuthUserResponse.java b/src/main/java/com/postgraduate/domain/auth/application/dto/res/AuthUserResponse.java index 8535bf9b..a2b86c2d 100644 --- a/src/main/java/com/postgraduate/domain/auth/application/dto/res/AuthUserResponse.java +++ b/src/main/java/com/postgraduate/domain/auth/application/dto/res/AuthUserResponse.java @@ -4,13 +4,11 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; -import lombok.NoArgsConstructor; import java.util.Optional; @Builder @Getter -@NoArgsConstructor @AllArgsConstructor public class AuthUserResponse { private Optional user; diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/DoneMentoringInfo.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/DoneMentoringInfo.java new file mode 100644 index 00000000..9148f9cc --- /dev/null +++ b/src/main/java/com/postgraduate/domain/mentoring/application/dto/DoneMentoringInfo.java @@ -0,0 +1,21 @@ +package com.postgraduate.domain.mentoring.application.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + + +@Getter +@Builder +@AllArgsConstructor +public class DoneMentoringInfo { + Long mentoringId; + Long seniorId; + String nickName; + String postgradu; + String field; + String professor; + String date; + int term; +} \ No newline at end of file diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/AppliedMentoringInfo.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/ExpectedMentoringInfo.java similarity index 75% rename from src/main/java/com/postgraduate/domain/mentoring/application/dto/AppliedMentoringInfo.java rename to src/main/java/com/postgraduate/domain/mentoring/application/dto/ExpectedMentoringInfo.java index 95076682..97a33994 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/dto/AppliedMentoringInfo.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/dto/ExpectedMentoringInfo.java @@ -1,5 +1,6 @@ package com.postgraduate.domain.mentoring.application.dto; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -8,14 +9,14 @@ @Getter @Builder @AllArgsConstructor -public class AppliedMentoringInfo { +public class ExpectedMentoringInfo { Long mentoringId; Long seniorId; String nickName; String postgradu; String field; String professor; - String[] dates; + String date; int term; String chatLink; } \ No newline at end of file diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/WaitingMentoringInfo.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/WaitingMentoringInfo.java new file mode 100644 index 00000000..c97bf989 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/mentoring/application/dto/WaitingMentoringInfo.java @@ -0,0 +1,19 @@ +package com.postgraduate.domain.mentoring.application.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + + +@Getter +@Builder +@AllArgsConstructor +public class WaitingMentoringInfo { + Long mentoringId; + Long seniorId; + String nickName; + String postgradu; + String field; + String major; + int term; +} \ No newline at end of file diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/AppliedMentoringResponse.java b/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/AppliedMentoringResponse.java index fed717fd..b1dc08aa 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/AppliedMentoringResponse.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/dto/res/AppliedMentoringResponse.java @@ -1,6 +1,5 @@ package com.postgraduate.domain.mentoring.application.dto.res; -import com.postgraduate.domain.mentoring.application.dto.AppliedMentoringInfo; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -11,5 +10,5 @@ @Builder @AllArgsConstructor public class AppliedMentoringResponse { - List appliedMentoringInfos; + List appliedMentoringInfos; } 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 1bf7af76..3a59e2a3 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 @@ -1,6 +1,8 @@ package com.postgraduate.domain.mentoring.application.mapper; -import com.postgraduate.domain.mentoring.application.dto.AppliedMentoringInfo; +import com.postgraduate.domain.mentoring.application.dto.DoneMentoringInfo; +import com.postgraduate.domain.mentoring.application.dto.ExpectedMentoringInfo; +import com.postgraduate.domain.mentoring.application.dto.WaitingMentoringInfo; import com.postgraduate.domain.mentoring.application.dto.req.MentoringApplyRequest; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringDetailResponse; @@ -13,32 +15,45 @@ import java.util.stream.Stream; public class MentoringMapper { - public static AppliedMentoringInfo mapToExpectedAppliedInfo(Mentoring mentoring) { + public static ExpectedMentoringInfo mapToExpectedInfo(Mentoring mentoring) { Senior senior = mentoring.getSenior(); - String[] dates = mentoring.getDate().split(","); - return AppliedMentoringInfo.builder() + return ExpectedMentoringInfo.builder() .mentoringId(mentoring.getMentoringId()) - .dates(dates) .seniorId(senior.getSeniorId()) .nickName(senior.getUser().getNickName()) .postgradu(senior.getInfo().getPostgradu()) .professor(senior.getInfo().getProfessor()) .field(senior.getInfo().getField()) + .term(senior.getProfile().getTerm()) + .date(mentoring.getDate()) .chatLink(senior.getProfile().getChatLink()) .build(); } - public static AppliedMentoringInfo mapToWaitingOrDoneAppliedInfo(Mentoring mentoring) { + + public static DoneMentoringInfo mapToDoneInfo(Mentoring mentoring) { Senior senior = mentoring.getSenior(); - String[] dates = mentoring.getDate().split(","); - return AppliedMentoringInfo.builder() + return DoneMentoringInfo.builder() .mentoringId(mentoring.getMentoringId()) - .dates(dates) - .term(senior.getProfile().getTerm()) .seniorId(senior.getSeniorId()) .nickName(senior.getUser().getNickName()) .postgradu(senior.getInfo().getPostgradu()) .professor(senior.getInfo().getProfessor()) .field(senior.getInfo().getField()) + .term(senior.getProfile().getTerm()) + .date(mentoring.getDate()) + .build(); + } + + public static WaitingMentoringInfo mapToWaitingInfo(Mentoring mentoring) { + Senior senior = mentoring.getSenior(); + return WaitingMentoringInfo.builder() + .mentoringId(mentoring.getMentoringId()) + .term(senior.getProfile().getTerm()) + .seniorId(senior.getSeniorId()) + .nickName(senior.getUser().getNickName()) + .postgradu(senior.getInfo().getPostgradu()) + .major(senior.getInfo().getMajor()) + .field(senior.getInfo().getField()) .build(); } public static AppliedMentoringDetailResponse mapToAppliedDetailInfo(Mentoring mentoring) { diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java index d7ace4c9..5f11e4d6 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringInfoUseCase.java @@ -1,6 +1,8 @@ package com.postgraduate.domain.mentoring.application.usecase; -import com.postgraduate.domain.mentoring.application.dto.AppliedMentoringInfo; +import com.postgraduate.domain.mentoring.application.dto.DoneMentoringInfo; +import com.postgraduate.domain.mentoring.application.dto.ExpectedMentoringInfo; +import com.postgraduate.domain.mentoring.application.dto.WaitingMentoringInfo; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringDetailResponse; import com.postgraduate.domain.mentoring.application.dto.res.AppliedMentoringResponse; import com.postgraduate.domain.mentoring.application.dto.res.SeniorMentoringDetailResponse; @@ -22,8 +24,7 @@ import java.util.List; import java.util.stream.Collectors; -import static com.postgraduate.domain.mentoring.domain.entity.constant.Status.DONE; -import static com.postgraduate.domain.mentoring.domain.entity.constant.Status.WAITING; +import static com.postgraduate.domain.mentoring.domain.entity.constant.Status.*; @Service @Transactional @@ -33,9 +34,21 @@ public class MentoringInfoUseCase { private final CheckIsMyMentoringUseCase checkIsMyMentoringUseCase; private final SeniorGetService seniorGetService; - public AppliedMentoringResponse getMentorings(Status status, User user) { - List mentorings = mentoringGetService.mentoringByUser(user, status); - return getCategories(status, mentorings); + + public AppliedMentoringDetailResponse getMentoringDetail(User user, Long mentoringId) { + Mentoring mentoring = checkIsMyMentoringUseCase.byUser(user, mentoringId); + if (mentoring.getStatus() != WAITING) { + throw new MentoringNotWaitingException(); + } + return MentoringMapper.mapToAppliedDetailInfo(mentoring); + } + + public SeniorMentoringDetailResponse getSeniorMentoringDetail(User user, Long mentoringId) { + Mentoring mentoring = checkIsMyMentoringUseCase.bySenior(user, mentoringId); + if (mentoring.getStatus() == DONE) { + throw new MentoringDoneException(); + } + return MentoringMapper.mapToSeniorMentoringDetail(mentoring); } public List getSeniorMentorings(Status status, User user) { @@ -45,39 +58,42 @@ public List getSeniorMentorings(Status status, User use return mentorings.stream().map(MentoringMapper::mapToSeniorMentoring).collect(Collectors.toList()); } - private AppliedMentoringResponse getCategories(Status status, List mentorings) { - List appliedMentoringInfos = new ArrayList<>(); + public AppliedMentoringResponse getMentorings(Status status, User user) { + List mentorings = mentoringGetService.mentoringByUser(user, status); + return getCategories(status, mentorings); + } - switch (status) { - case WAITING, DONE -> { - for (Mentoring mentoring : mentorings) { - appliedMentoringInfos.add(MentoringMapper.mapToWaitingOrDoneAppliedInfo(mentoring)); - } - return new AppliedMentoringResponse(appliedMentoringInfos); - } + private AppliedMentoringResponse getCategories(Status status, List mentorings) { + if (status == WAITING) { + return getWaiting(mentorings); + } + if (status == EXPECTED) { + return getExpected(mentorings); + } + return getDone(mentorings); + } - default -> { - for (Mentoring mentoring : mentorings) { - appliedMentoringInfos.add(MentoringMapper.mapToExpectedAppliedInfo(mentoring)); - } - return new AppliedMentoringResponse(appliedMentoringInfos); - } + private AppliedMentoringResponse getWaiting(List mentorings) { + List waitingMentoringInfos = new ArrayList<>(); + for (Mentoring mentoring : mentorings) { + waitingMentoringInfos.add(MentoringMapper.mapToWaitingInfo(mentoring)); } + return new AppliedMentoringResponse(waitingMentoringInfos); } - public AppliedMentoringDetailResponse getMentoringDetail(User user, Long mentoringId) { - Mentoring mentoring = checkIsMyMentoringUseCase.byUser(user, mentoringId); - if (mentoring.getStatus() != WAITING) { - throw new MentoringNotWaitingException(); + private AppliedMentoringResponse getExpected(List mentorings) { + List expectedMentoringInfos = new ArrayList<>(); + for (Mentoring mentoring : mentorings) { + expectedMentoringInfos.add(MentoringMapper.mapToExpectedInfo(mentoring)); } - return MentoringMapper.mapToAppliedDetailInfo(mentoring); + return new AppliedMentoringResponse(expectedMentoringInfos); } - public SeniorMentoringDetailResponse getSeniorMentoringDetail(User user, Long mentoringId) { - Mentoring mentoring = checkIsMyMentoringUseCase.bySenior(user, mentoringId); - if (mentoring.getStatus() == DONE) { - throw new MentoringDoneException(); + private AppliedMentoringResponse getDone(List mentorings) { + List doneMentoringInfos = new ArrayList<>(); + for (Mentoring mentoring : mentorings) { + doneMentoringInfos.add(MentoringMapper.mapToDoneInfo(mentoring)); } - return MentoringMapper.mapToSeniorMentoringDetail(mentoring); + return new AppliedMentoringResponse(doneMentoringInfos); } } diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountRequest.java b/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountRequest.java index 9ca7266a..2aeb7c19 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountRequest.java +++ b/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileAndAccountRequest.java @@ -18,9 +18,11 @@ public class SeniorProfileAndAccountRequest { @NotNull private String time; @NotNull + private String oneLiner; + @NotNull + private String keyword; + @NotNull private String account; @NotNull private String bank; - @NotNull - private String rrn; } diff --git a/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileRequest.java b/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileRequest.java index 6fc8e61e..dfa4ef5d 100644 --- a/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileRequest.java +++ b/src/main/java/com/postgraduate/domain/senior/application/dto/req/SeniorProfileRequest.java @@ -17,4 +17,8 @@ public class SeniorProfileRequest { private String chatLink; @NotNull private String time; + @NotNull + private String oneLiner; + @NotNull + private String keyword; } 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 31a54f67..6affd8bc 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 @@ -46,7 +46,6 @@ public static Account mapToAccount(SeniorProfileAndAccountRequest profileAndAcco return Account.builder() .bank(profileAndAccountPageRequest.getBank()) .account(profileAndAccountPageRequest.getAccount()) - .rrn(profileAndAccountPageRequest.getRrn()) .build(); } @@ -56,6 +55,8 @@ public static Profile mapToProfile(SeniorProfileAndAccountRequest profileAndAcco .chatLink(profileAndAccountPageRequest.getChatLink()) .target(profileAndAccountPageRequest.getTarget()) .time(profileAndAccountPageRequest.getTime()) + .oneLiner(profileAndAccountPageRequest.getOneLiner()) + .keyword(profileAndAccountPageRequest.getKeyword()) .build(); } @@ -63,6 +64,8 @@ public static Profile mapToProfile(SeniorProfileRequest profileRequest) { return Profile.builder() .info(profileRequest.getInfo()) .chatLink(profileRequest.getChatLink()) + .oneLiner(profileRequest.getOneLiner()) + .keyword(profileRequest.getKeyword()) .target(profileRequest.getTarget()) .time(profileRequest.getTime()) .build(); 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 1f060040..a6d0971b 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 @@ -11,7 +11,6 @@ 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; -import com.postgraduate.global.config.security.util.SecurityUtils; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; 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 80e1ef48..9ae638f1 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 @@ -21,4 +21,9 @@ public class Account { @Column(nullable = false) private String rrn; + + public void updateAccount(Account account) { + this.account = account.getAccount(); + this.bank = account.getBank(); + } } 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 41fd4a33..936027ca 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 @@ -14,11 +14,16 @@ public class Profile { private String info; + private String oneLiner; + + private String keyword; + private String target; private String chatLink; private String time; - private Integer term; + @Builder.Default + private Integer term = 40; } 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 35bf55b6..c1ae9e96 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 @@ -51,7 +51,7 @@ public void updateProfile(Profile profile) { public void updateProfileAndAccount(Profile profile, Account account) { this.profile = profile; - this.account = account; + account.updateAccount(account); } public void updateCertification(String certification) { 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 654f4108..60322dfe 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 @@ -7,7 +7,7 @@ @RequiredArgsConstructor public enum SeniorResponseMessage { CREATE_SENIOR("대학원생 가입에 성공하였습니다."), - UPDATE_PROFILE("대학원생 프로필 등록에 성공하였습니다"), + UPDATE_PROFILE("대학원생 프로필 수정에 성공하였습니다"), GET_SENIOR_INFO("대학원생 정보 조회에 성공하였습니다"), GET_SENIOR_PROFILE("대학원생 프로필 조회에 성공하였습니다"), UPDATE_CERTIFICATION("대학원생 인증사진 업로드에 성공하였습니다"), diff --git a/src/main/java/com/postgraduate/domain/user/application/dto/req/UserHopeRequest.java b/src/main/java/com/postgraduate/domain/user/application/dto/req/UserHopeRequest.java new file mode 100644 index 00000000..913076f2 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/user/application/dto/req/UserHopeRequest.java @@ -0,0 +1,12 @@ +package com.postgraduate.domain.user.application.dto.req; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class UserHopeRequest { + private String major; + private String field; + private boolean receive; +} diff --git a/src/main/java/com/postgraduate/domain/user/application/mapper/UserMapper.java b/src/main/java/com/postgraduate/domain/user/application/mapper/UserMapper.java index 8c50b8ba..a2780e2c 100644 --- a/src/main/java/com/postgraduate/domain/user/application/mapper/UserMapper.java +++ b/src/main/java/com/postgraduate/domain/user/application/mapper/UserMapper.java @@ -1,7 +1,9 @@ package com.postgraduate.domain.user.application.mapper; import com.postgraduate.domain.auth.application.dto.req.SignUpRequest; +import com.postgraduate.domain.user.application.dto.req.UserHopeRequest; import com.postgraduate.domain.user.application.dto.res.UserInfoResponse; +import com.postgraduate.domain.user.domain.entity.Hope; import com.postgraduate.domain.user.domain.entity.User; public class UserMapper { @@ -17,6 +19,16 @@ public static User mapToUser(SignUpRequest request) { return User.builder() .socialId(request.getSocialId()) .nickName(request.getNickName()) + .phoneNumber(request.getPhoneNumber()) + .hope(new Hope()) + .build(); + } + + public static Hope mapToHope(UserHopeRequest hopeRequest) { + return Hope.builder() + .major(hopeRequest.getMajor()) + .field(hopeRequest.getField()) + .receive(hopeRequest.isReceive()) .build(); } } diff --git a/src/main/java/com/postgraduate/domain/user/application/usecase/UserMyPageUseCase.java b/src/main/java/com/postgraduate/domain/user/application/usecase/UserMyPageUseCase.java index 0023bae5..296c9056 100644 --- a/src/main/java/com/postgraduate/domain/user/application/usecase/UserMyPageUseCase.java +++ b/src/main/java/com/postgraduate/domain/user/application/usecase/UserMyPageUseCase.java @@ -1,7 +1,9 @@ package com.postgraduate.domain.user.application.usecase; +import com.postgraduate.domain.user.application.dto.req.UserHopeRequest; import com.postgraduate.domain.user.application.dto.res.UserInfoResponse; import com.postgraduate.domain.user.application.mapper.UserMapper; +import com.postgraduate.domain.user.domain.entity.Hope; import com.postgraduate.domain.user.domain.entity.User; import com.postgraduate.domain.user.domain.service.UserGetService; import com.postgraduate.domain.user.domain.service.UserUpdateService; @@ -28,6 +30,11 @@ public void updateProfile(User user, String profile) { userUpdateService.updateProfile(user.getUserId(), profile); } + public void updateHope(User user, UserHopeRequest hopeRequest) { + Hope hope = UserMapper.mapToHope(hopeRequest); + userUpdateService.updateHope(user.getUserId(), hope); + } + public boolean duplicatedNickName(String nickName) { return userGetService.byNickName(nickName).isEmpty(); } diff --git a/src/main/java/com/postgraduate/domain/user/domain/entity/Hope.java b/src/main/java/com/postgraduate/domain/user/domain/entity/Hope.java new file mode 100644 index 00000000..7f1942e9 --- /dev/null +++ b/src/main/java/com/postgraduate/domain/user/domain/entity/Hope.java @@ -0,0 +1,20 @@ +package com.postgraduate.domain.user.domain.entity; + +import jakarta.persistence.Embeddable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +@AllArgsConstructor +@Builder +@Getter +@Embeddable +public class Hope { + private String major; + private String field; + private Boolean receive; + + public Hope() { + this.receive = false; + } +} diff --git a/src/main/java/com/postgraduate/domain/user/domain/entity/User.java b/src/main/java/com/postgraduate/domain/user/domain/entity/User.java index 4844c03d..1cbe56a8 100644 --- a/src/main/java/com/postgraduate/domain/user/domain/entity/User.java +++ b/src/main/java/com/postgraduate/domain/user/domain/entity/User.java @@ -23,12 +23,14 @@ public class User { @Column(nullable = false, unique = true) private Long socialId; -// @Column(unique = true) email은 여러 소셜을 사용하면 unique가 깨질 수 있음 private String email; @Column(nullable = false, unique = true) private String nickName; + @Column(nullable = false) + private String phoneNumber; + @Column(nullable = false) @Builder.Default //이후에 기본 이미지 생기면 수정이 필요할 듯 private String profile = "default"; @@ -41,6 +43,9 @@ public class User { @Builder.Default private Role role = Role.USER; + @Embedded + private Hope hope; + @Column(nullable = false) @CreationTimestamp private LocalDate createdAt; @@ -59,4 +64,8 @@ public void updateRole(Role role) { public void updateProfile(String profile) { this.profile = profile; } + + public void updateHope(Hope hope) { + this.hope = hope; + } } diff --git a/src/main/java/com/postgraduate/domain/user/domain/service/UserUpdateService.java b/src/main/java/com/postgraduate/domain/user/domain/service/UserUpdateService.java index 00865680..0c153547 100644 --- a/src/main/java/com/postgraduate/domain/user/domain/service/UserUpdateService.java +++ b/src/main/java/com/postgraduate/domain/user/domain/service/UserUpdateService.java @@ -1,5 +1,6 @@ package com.postgraduate.domain.user.domain.service; +import com.postgraduate.domain.user.domain.entity.Hope; import com.postgraduate.domain.user.domain.entity.User; import com.postgraduate.domain.user.domain.entity.constant.Role; import com.postgraduate.domain.user.domain.repository.UserRepository; @@ -25,4 +26,9 @@ public void updateProfile(Long userId, String profile) { User user = userRepository.findById(userId).get(); user.updateProfile(profile); } + + public void updateHope(Long userId, Hope hope) { + User user = userRepository.findById(userId).get(); + user.updateHope(hope); + } } diff --git a/src/main/java/com/postgraduate/domain/user/presentation/UserController.java b/src/main/java/com/postgraduate/domain/user/presentation/UserController.java index 273c4905..9c7862fe 100644 --- a/src/main/java/com/postgraduate/domain/user/presentation/UserController.java +++ b/src/main/java/com/postgraduate/domain/user/presentation/UserController.java @@ -1,5 +1,6 @@ package com.postgraduate.domain.user.presentation; +import com.postgraduate.domain.user.application.dto.req.UserHopeRequest; import com.postgraduate.domain.user.application.dto.req.UserNickNameRequest; import com.postgraduate.domain.user.application.dto.req.UserProfileRequest; import com.postgraduate.domain.user.application.dto.res.UserInfoResponse; @@ -50,4 +51,11 @@ public ResponseDto updateProfile(@AuthenticationPrincipal User user, @RequestBod myPageUseCase.updateProfile(user, userProfileRequest.getProfile()); return ResponseDto.create(USER_UPDATE.getCode(), UPDATE_USER_INFO.getMessage()); } + + @PatchMapping("/hope") + @Operation(description = "대학생 희망 학과, 분야 및 수신 동의 업데이트") + public ResponseDto updateHope(@AuthenticationPrincipal User user, @RequestBody UserHopeRequest userHopeRequest) { + myPageUseCase.updateHope(user, userHopeRequest); + return ResponseDto.create(USER_UPDATE.getCode(), UPDATE_USER_INFO.getMessage()); + } }