Skip to content

Commit

Permalink
Merge pull request #40 from YAPP-Github/feat/ISSUE-39
Browse files Browse the repository at this point in the history
  • Loading branch information
Seokyeong237 authored Feb 2, 2024
2 parents eb46c7e + d5a4eee commit 015e741
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,6 +16,7 @@
public class MemberService {
private final MemberRepository memberRepository;
private final CompanyMapper companyMapper;
private final MemberMapper memberMapper;

/**
* 회원을 식별자로 조회합니다.
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,4 +33,15 @@ public ApiResponse<Object> 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<MemberGetResponseDto> getMember(@CurrentMember Member member) {
MemberGetResponseDto response = memberService.getMember(member);
return ApiResponse.success(SuccessCode.READ_SUCCESS, response);
}
}
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 015e741

Please sign in to comment.