Skip to content

Commit

Permalink
GETP-172 feat: 내 피플 정보 조회 DTO에 전화번호 필드 추가 (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
scv1702 authored Aug 6, 2024
1 parent 1254bd9 commit 4780524
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import es.princip.getp.domain.people.query.dto.people.CardPeopleResponse;
import es.princip.getp.domain.people.query.dto.people.DetailPeopleResponse;
import es.princip.getp.domain.people.query.dto.people.PeopleResponse;
import es.princip.getp.domain.people.query.dto.people.MyPeopleResponse;
import es.princip.getp.domain.people.query.dto.people.PublicDetailPeopleResponse;
import es.princip.getp.domain.people.query.dto.peopleProfile.DetailPeopleProfileResponse;
import org.springframework.data.domain.Page;
Expand All @@ -16,7 +16,7 @@ public interface PeopleDao {

PublicDetailPeopleResponse findPublicDetailPeopleById(Long peopleId);

PeopleResponse findByMemberId(Long memberId);
MyPeopleResponse findByMemberId(Long memberId);

DetailPeopleProfileResponse findDetailPeopleProfileByMemberId(Long memberId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import es.princip.getp.domain.people.exception.NotRegisteredPeopleProfileException;
import es.princip.getp.domain.people.query.dto.people.CardPeopleResponse;
import es.princip.getp.domain.people.query.dto.people.DetailPeopleResponse;
import es.princip.getp.domain.people.query.dto.people.PeopleResponse;
import es.princip.getp.domain.people.query.dto.people.MyPeopleResponse;
import es.princip.getp.domain.people.query.dto.people.PublicDetailPeopleResponse;
import es.princip.getp.domain.people.query.dto.peopleProfile.CardPeopleProfileResponse;
import es.princip.getp.domain.people.query.dto.peopleProfile.DetailPeopleProfileResponse;
Expand Down Expand Up @@ -154,14 +154,15 @@ public PublicDetailPeopleResponse findPublicDetailPeopleById(final Long peopleId
}

@Override
public PeopleResponse findByMemberId(final Long memberId) {
public MyPeopleResponse findByMemberId(final Long memberId) {
return Optional.ofNullable(
queryFactory.select(
Projections.constructor(
PeopleResponse.class,
MyPeopleResponse.class,
people.peopleId,
people.info.email.value,
member.nickname.value,
member.phoneNumber.value,
member.profileImage.uri,
people.info.peopleType,
Expressions.asNumber(0).as("completedProjectsCount"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

import java.time.LocalDateTime;

public record PeopleResponse(
public record MyPeopleResponse(
Long peopleId,
String email,
String nickname,
String phoneNumber,
String profileImageUri,
PeopleType peopleType,
Integer completedProjectsCount,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package es.princip.getp.domain.people.query.presentation;

import es.princip.getp.domain.people.query.dao.PeopleDao;
import es.princip.getp.domain.people.query.dto.people.PeopleResponse;
import es.princip.getp.domain.people.query.dto.people.MyPeopleResponse;
import es.princip.getp.infra.dto.response.ApiResponse;
import es.princip.getp.infra.dto.response.ApiResponse.ApiSuccessResult;
import es.princip.getp.infra.security.details.PrincipalDetails;
Expand All @@ -28,10 +28,10 @@ public class MyPeopleQueryController {
*/
@GetMapping
@PreAuthorize("hasRole('PEOPLE') and isAuthenticated()")
public ResponseEntity<ApiSuccessResult<PeopleResponse>> getMyPeople(
public ResponseEntity<ApiSuccessResult<MyPeopleResponse>> getMyPeople(
@AuthenticationPrincipal final PrincipalDetails principalDetails) {
final Long memberId = principalDetails.getMember().getMemberId();
final PeopleResponse response = peopleDao.findByMemberId(memberId);
final MyPeopleResponse response = peopleDao.findByMemberId(memberId);
return ApiResponse.success(HttpStatus.OK, response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import es.princip.getp.domain.people.query.dto.people.CardPeopleResponse;
import es.princip.getp.domain.people.query.dto.people.DetailPeopleResponse;
import es.princip.getp.domain.people.query.dto.people.PeopleResponse;
import es.princip.getp.domain.people.query.dto.people.MyPeopleResponse;
import es.princip.getp.domain.people.query.dto.people.PublicDetailPeopleResponse;
import es.princip.getp.domain.people.query.dto.peopleProfile.DetailPeopleProfileResponse;
import es.princip.getp.domain.people.query.infra.PeopleDaoConfig;
Expand Down Expand Up @@ -66,7 +66,7 @@ void findPublicDetailPeopleById() {
@Test
@DisplayName("멤버 ID로 피플 정보를 조회한다.")
void findByMemberId() {
PeopleResponse response = peopleDao.findByMemberId(1L);
MyPeopleResponse response = peopleDao.findByMemberId(1L);

log.info("response: {}", response);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import es.princip.getp.domain.people.command.domain.PeopleType;
import es.princip.getp.domain.people.query.dao.PeopleDao;
import es.princip.getp.domain.people.query.dto.people.PeopleResponse;
import es.princip.getp.domain.people.query.presentation.description.response.PeopleResponseDescription;
import es.princip.getp.domain.people.query.dto.people.MyPeopleResponse;
import es.princip.getp.domain.people.query.presentation.description.response.MyPeopleResponseDescription;
import es.princip.getp.infra.annotation.WithCustomMockUser;
import es.princip.getp.infra.security.details.PrincipalDetails;
import es.princip.getp.infra.support.AbstractControllerTest;
Expand All @@ -20,6 +20,7 @@
import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_PEOPLE;
import static es.princip.getp.domain.member.fixture.EmailFixture.EMAIL;
import static es.princip.getp.domain.member.fixture.NicknameFixture.NICKNAME;
import static es.princip.getp.domain.member.fixture.PhoneNumberFixture.PHONE_NUMBER;
import static es.princip.getp.domain.member.fixture.ProfileImageFixture.profileImage;
import static es.princip.getp.infra.util.HeaderDescriptorHelper.authorizationHeaderDescriptor;
import static es.princip.getp.infra.util.PayloadDocumentationHelper.responseFields;
Expand All @@ -34,23 +35,25 @@ class MyPeopleQueryControllerTest extends AbstractControllerTest {
@MockBean
private PeopleDao peopleDao;

@DisplayName("피플은 자신의 정보를 조회할 수 있다.")
@Nested
@DisplayName("내 피플 정보 조회")
class GetMyPeople {

private ResultActions perform() throws Exception {
return mockMvc.perform(get("/people/me")
.header("Authorization", "Bearer ${ACCESS_TOKEN}"));
}

@WithCustomMockUser(memberType = ROLE_PEOPLE)
@Test
@WithCustomMockUser(memberType = ROLE_PEOPLE)
@DisplayName("피플은 자신의 정보를 조회할 수 있다.")
public void getMyPeople(PrincipalDetails principalDetails) throws Exception {
Long memberId = principalDetails.getMember().getMemberId();
PeopleResponse response = new PeopleResponse(
MyPeopleResponse response = new MyPeopleResponse(
1L,
EMAIL,
NICKNAME,
PHONE_NUMBER,
profileImage(1L).getUri(),
PeopleType.INDIVIDUAL,
0,
Expand All @@ -64,13 +67,13 @@ public void getMyPeople(PrincipalDetails principalDetails) throws Exception {
.andExpect(status().isOk())
.andDo(restDocs.document(
requestHeaders(authorizationHeaderDescriptor()),
responseFields(PeopleResponseDescription.description())
responseFields(MyPeopleResponseDescription.description())
))
.andDo(print());
}

@WithCustomMockUser(memberType = ROLE_CLIENT)
@Test
@WithCustomMockUser(memberType = ROLE_CLIENT)
public void getMyPeople_WhenMemberTypeIsClient_ShouldFail() throws Exception {
expectForbidden(perform());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import static es.princip.getp.infra.util.FieldDescriptorHelper.getDescriptor;
import static org.springframework.restdocs.snippet.Attributes.key;

public class PeopleResponseDescription {
public class MyPeopleResponseDescription {

public static FieldDescriptor[] description() {
return new FieldDescriptor[] {
getDescriptor("peopleId", "피플 ID"),
getDescriptor("email", "이메일"),
getDescriptor("nickname", "닉네임"),
getDescriptor("phoneNumber", "전화번호"),
getDescriptor("profileImageUri", "프로필 이미지 URI"),
getDescriptor("peopleType", "피플 유형")
.attributes(key("format").value("TEAM, INDIVIDUAL")),
Expand Down

0 comments on commit 4780524

Please sign in to comment.