diff --git a/src/main/java/com/fullcar/member/application/member/MemberMapper.java b/src/main/java/com/fullcar/member/application/member/MemberMapper.java new file mode 100644 index 0000000..31363d0 --- /dev/null +++ b/src/main/java/com/fullcar/member/application/member/MemberMapper.java @@ -0,0 +1,19 @@ +package com.fullcar.member.application.member; + +import com.fullcar.member.domain.member.Member; +import com.fullcar.member.presentation.member.dto.response.MemberGetResponseDto; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor(access = AccessLevel.PROTECTED) +public class MemberMapper { + + public MemberGetResponseDto toDto(Member member) { + return MemberGetResponseDto.builder() + .nickname(member.getNickname()) + .companyName(member.getCompany().getCompanyName()) + .build(); + } +} diff --git a/src/main/java/com/fullcar/member/application/member/MemberService.java b/src/main/java/com/fullcar/member/application/member/MemberService.java index 1bbd936..764bd42 100644 --- a/src/main/java/com/fullcar/member/application/member/MemberService.java +++ b/src/main/java/com/fullcar/member/application/member/MemberService.java @@ -4,6 +4,7 @@ import com.fullcar.core.response.ErrorCode; import com.fullcar.member.domain.member.*; import com.fullcar.member.presentation.member.dto.request.CompanyRequestDto; +import com.fullcar.member.presentation.member.dto.response.MemberGetResponseDto; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -15,6 +16,7 @@ public class MemberService { private final MemberRepository memberRepository; private final CompanyMapper companyMapper; + private final MemberMapper memberMapper; /** * 회원을 식별자로 조회합니다. @@ -33,4 +35,9 @@ public void registerCompany(Member member, CompanyRequestDto companyRequestDto) Company company = companyMapper.toEntity(companyRequestDto); findByMemberId(member.getId()).updateCompany(company); } + + @Transactional(readOnly = true) + public MemberGetResponseDto getMember(Member member) { + return memberMapper.toDto(member); + } } diff --git a/src/main/java/com/fullcar/member/presentation/member/MemberController.java b/src/main/java/com/fullcar/member/presentation/member/MemberController.java index 6e3bc1b..17a696c 100644 --- a/src/main/java/com/fullcar/member/presentation/member/MemberController.java +++ b/src/main/java/com/fullcar/member/presentation/member/MemberController.java @@ -6,16 +6,14 @@ import com.fullcar.member.application.member.MemberService; import com.fullcar.member.domain.member.Member; import com.fullcar.member.presentation.member.dto.request.CompanyRequestDto; +import com.fullcar.member.presentation.member.dto.response.MemberGetResponseDto; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController @RequiredArgsConstructor @@ -35,4 +33,15 @@ public ApiResponse postCompany(@CurrentMember Member member, @RequestBod memberService.registerCompany(member, companyRequestDto); return ApiResponse.success(SuccessCode.REGISTER_SUCCESS); } + + @Operation(summary = "회원 정보 조회 API") + @ApiResponses({ + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "조회 성공"), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content) + }) + @GetMapping() + public ApiResponse getMember(@CurrentMember Member member) { + MemberGetResponseDto response = memberService.getMember(member); + return ApiResponse.success(SuccessCode.READ_SUCCESS, response); + } } diff --git a/src/main/java/com/fullcar/member/presentation/member/dto/response/MemberGetResponseDto.java b/src/main/java/com/fullcar/member/presentation/member/dto/response/MemberGetResponseDto.java new file mode 100644 index 0000000..91df648 --- /dev/null +++ b/src/main/java/com/fullcar/member/presentation/member/dto/response/MemberGetResponseDto.java @@ -0,0 +1,18 @@ +package com.fullcar.member.presentation.member.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +@Getter +@Builder +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Schema(description = "회원 정보 응답 모델") +public class MemberGetResponseDto { + + @Schema(description = "회원 닉네임", example = "피곤한 물개") + private String nickname; + + @Schema(description = "회사명", example = "현대 자동차") + private String companyName; +}