Skip to content

Commit

Permalink
πŸ”₯[FEAT]-#4- νšŒμ› 정보 쑰회
Browse files Browse the repository at this point in the history
## κ°œμš”
MemberAPI : getMemberInfo()
ν˜„μž¬ 둜그인된 νšŒμ›μ˜ 정보λ₯Ό λΆˆλŸ¬μ˜¨λ‹€.
  • Loading branch information
daehwan2yo committed Dec 27, 2021
1 parent d7c6d71 commit 4149673
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package com.codingwasabi.trti.domain.member;

import com.codingwasabi.trti.domain.member.model.entity.Member;
import com.codingwasabi.trti.domain.member.model.response.ResponseMyInfoDto;

public interface MemberService {
ResponseMyInfoDto getMemberInfo(Member member);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
package com.codingwasabi.trti.domain.member.impl;

import com.codingwasabi.trti.config.auth.security.MemberAdaptor;
import com.codingwasabi.trti.domain.member.MemberService;
import com.codingwasabi.trti.domain.member.model.response.ResponseMyInfoDto;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/my")
public class MemberController {
private final MemberService memberService;

@GetMapping("/info")
public ResponseEntity<ResponseMyInfoDto> getMyInfo(@AuthenticationPrincipal MemberAdaptor memberAdaptor) {
return ResponseEntity.ok()
.body(memberService.getMemberInfo(memberAdaptor.getMember()));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
package com.codingwasabi.trti.domain.member.impl;

public class MemberServiceImpl {
import com.codingwasabi.trti.domain.member.MemberService;
import com.codingwasabi.trti.domain.member.model.entity.Member;
import com.codingwasabi.trti.domain.member.model.response.ResponseMyInfoDto;
import org.springframework.stereotype.Service;

@Service
public class MemberServiceImpl implements MemberService {
@Override
public ResponseMyInfoDto getMemberInfo(Member member) {
return ResponseMyInfoDto.getEntity(member);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.codingwasabi.trti.domain.member.model.response;

import com.codingwasabi.trti.domain.member.model.entity.Member;
import com.codingwasabi.trti.domain.member.model.enumValue.Gender;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
@AllArgsConstructor
public class ResponseMyInfoDto {
private Long id;
private String nickname;
private String email;
private String image;
private String ageRange;
private Gender gender;

public static ResponseMyInfoDto getEntity(Member member) {
return ResponseMyInfoDto.builder()
.id(member.getId())
.nickname(member.getNickname())
.email(member.getEmail())
.image(member.getImagePath())
.ageRange(member.getAgeRange())
.gender(member.getGender())
.build();
}
}

0 comments on commit 4149673

Please sign in to comment.