Skip to content

Commit

Permalink
RAC-341 fix : 선배 프로필 수정시 seniorId반환
Browse files Browse the repository at this point in the history
  • Loading branch information
ywj9811 committed Apr 11, 2024
1 parent 047adfd commit 3f1142f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.postgraduate.domain.senior.application.dto.res;

public record SeniorProfileUpdateResponse(Long seniorId) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.postgraduate.domain.salary.domain.service.SalaryGetService;
import com.postgraduate.domain.salary.domain.service.SalaryUpdateService;
import com.postgraduate.domain.senior.application.dto.req.*;
import com.postgraduate.domain.senior.application.dto.res.SeniorProfileUpdateResponse;
import com.postgraduate.domain.senior.application.utils.SeniorUtils;
import com.postgraduate.domain.senior.domain.entity.Profile;
import com.postgraduate.domain.senior.domain.entity.Senior;
Expand Down Expand Up @@ -76,7 +77,7 @@ public void saveAccount(User user, SeniorAccountRequest accountRequest) {
updateSalaryAccount(senior, account);
}

public void updateSeniorMyPageProfile(User user, SeniorMyPageProfileRequest myPageProfileRequest) {
public SeniorProfileUpdateResponse updateSeniorMyPageProfile(User user, SeniorMyPageProfileRequest myPageProfileRequest) {
seniorUtils.checkKeyword(myPageProfileRequest.keyword());
Senior senior = seniorGetService.byUser(user);
Profile profile = mapToProfile(myPageProfileRequest);
Expand All @@ -85,6 +86,7 @@ public void updateSeniorMyPageProfile(User user, SeniorMyPageProfileRequest myPa
List<AvailableCreateRequest> availableCreateRequests = myPageProfileRequest.times();
List<Available> sortedAvailable = sortAvailable(availableCreateRequests, senior);
sortedAvailable.forEach(availableSaveService::save);
return new SeniorProfileUpdateResponse(senior.getSeniorId());
}

public void updateSeniorMyPageUserAccount(User user, SeniorMyPageUserAccountRequest myPageUserAccountRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public ResponseDto<SeniorMyPageProfileResponse> getSeniorProfile(@Authentication

@PatchMapping("/me/profile")
@Operation(summary = "대학원생 마이페이지 프로필 수정 | 토큰 필요")
public ResponseDto<Void> updateSeniorProfile(@AuthenticationPrincipal User user,
public ResponseDto<SeniorProfileUpdateResponse> updateSeniorProfile(@AuthenticationPrincipal User user,
@RequestBody @Valid SeniorMyPageProfileRequest myPageProfileRequest) {
seniorManageUseCase.updateSeniorMyPageProfile(user, myPageProfileRequest);
return ResponseDto.create(SENIOR_UPDATE.getCode(), UPDATE_MYPAGE_PROFILE.getMessage());
SeniorProfileUpdateResponse updateResponse = seniorManageUseCase.updateSeniorMyPageProfile(user, myPageProfileRequest);
return ResponseDto.create(SENIOR_UPDATE.getCode(), UPDATE_MYPAGE_PROFILE.getMessage(), updateResponse);
}

@GetMapping("/me/account")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.postgraduate.domain.salary.domain.service.SalaryGetService;
import com.postgraduate.domain.salary.domain.service.SalaryUpdateService;
import com.postgraduate.domain.senior.application.dto.req.*;
import com.postgraduate.domain.senior.application.dto.res.SeniorProfileUpdateResponse;
import com.postgraduate.domain.senior.application.utils.SeniorUtils;
import com.postgraduate.domain.senior.domain.entity.Info;
import com.postgraduate.domain.senior.domain.entity.Profile;
Expand Down Expand Up @@ -39,6 +40,7 @@
import static com.postgraduate.domain.senior.domain.entity.constant.Status.APPROVE;
import static com.postgraduate.domain.user.domain.entity.constant.Role.SENIOR;
import static java.lang.Boolean.TRUE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.BDDMockito.*;

Expand Down Expand Up @@ -182,12 +184,14 @@ void updateSeniorMyPage() {
given(seniorGetService.byUser(user))
.willReturn(senior);

seniorManageUseCase.updateSeniorMyPageProfile(user, request);
SeniorProfileUpdateResponse response = seniorManageUseCase.updateSeniorMyPageProfile(user, request);

verify(seniorUpdateService, times(1))
.updateMyPageProfile(any(Senior.class), any(SeniorMyPageProfileRequest.class), any(Profile.class));
verify(availableDeleteService, times(1))
.delete(senior);
assertThat(response.seniorId())
.isEqualTo(senior.getSeniorId());
}

@Test
Expand Down

0 comments on commit 3f1142f

Please sign in to comment.