Skip to content

Commit

Permalink
Merge pull request #9 from CodingWasabi/feature-4/member
Browse files Browse the repository at this point in the history
[FEAT] - 회원 정보 조회
  • Loading branch information
daehwan2yo authored Dec 27, 2021
2 parents 4c48596 + a7429f1 commit 5a323c2
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public boolean validate(String jwtToken) {
Jws<Claims> claimsJws = Jwts.parser()
.setSigningKey(key)
.parseClaimsJws(jwtToken);

return claimsJws.getBody().getExpiration().before(new Date());
return !claimsJws.getBody().getExpiration().before(new Date());
} catch (Exception e) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class MemberAdaptor implements UserDetails {

@Getter
public final Member member;
private final Member member;

public MemberAdaptor(Member member) {
this.member = member;
Expand Down
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
Expand Up @@ -16,8 +16,8 @@
import java.util.HashMap;
import java.util.Map;

import static com.codingwasabi.trti.domain.member.MemberAPI.OAUTH_JOIN;
import static com.codingwasabi.trti.domain.member.MemberAPI.OAUTH_LOGIN;
import static com.codingwasabi.trti.domain.member.model.enumValue.MemberAuthMessage.OAUTH_JOIN;
import static com.codingwasabi.trti.domain.member.model.enumValue.MemberAuthMessage.OAUTH_LOGIN;

@RestController
@RequiredArgsConstructor
Expand Down
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
@@ -1,11 +1,11 @@
package com.codingwasabi.trti.domain.member;
package com.codingwasabi.trti.domain.member.model.enumValue;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum MemberAPI {
public enum MemberAuthMessage {
OAUTH_LOGIN("LOGIN"),
OAUTH_JOIN("JOIN");

Expand Down
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 5a323c2

Please sign in to comment.