-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: Modify member oauth field name
- Loading branch information
Showing
7 changed files
with
139 additions
and
1 deletion.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/com/ftw/hometerview/member/controller/MemberController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.ftw.hometerview.member.controller; | ||
|
||
import com.ftw.hometerview.core.domain.ResponseEntity; | ||
import com.ftw.hometerview.core.interceptor.AuthUtil; | ||
import com.ftw.hometerview.member.controller.dto.MemberDto; | ||
import com.ftw.hometerview.member.service.MemberServiceFacade; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("api/v1/member") | ||
public class MemberController { | ||
|
||
private final MemberServiceFacade memberService; | ||
|
||
@GetMapping("/my") | ||
public ResponseEntity<MemberDto> getLoginMemberInfo() { | ||
var memberInfo = this.memberService.getMemberInfo(AuthUtil.getCurrentMemberId()); | ||
return ResponseEntity.successResponse(memberInfo); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/ftw/hometerview/member/controller/dto/MemberDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.ftw.hometerview.member.controller.dto; | ||
|
||
import com.ftw.hometerview.member.domain.Member; | ||
import com.ftw.hometerview.member.domain.Member.Certification; | ||
import com.ftw.hometerview.place.controller.dto.PlaceDto.CompanyDetail; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public class MemberDto { | ||
|
||
String id; | ||
String nickname; | ||
Certification certification; | ||
CompanyDetail companyDetail; | ||
|
||
|
||
public static MemberDto of(Member member, CompanyDetail companyDetail) { | ||
return MemberDto.builder() | ||
.id(member.getId()) | ||
.nickname(member.getNickname()) | ||
.certification(member.getCertification()) | ||
.companyDetail(companyDetail) | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/ftw/hometerview/member/service/MemberService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.ftw.hometerview.member.service; | ||
|
||
import com.ftw.hometerview.core.domain.ResponseType; | ||
import com.ftw.hometerview.core.exception.NotFoundException; | ||
import com.ftw.hometerview.member.domain.Member; | ||
import com.ftw.hometerview.member.repository.MemberRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class MemberService { | ||
|
||
private final MemberRepository memberRepository; | ||
|
||
public Member getMemberById(String memberId) { | ||
return this.memberRepository.findById(memberId) | ||
.orElseThrow(() -> new NotFoundException(ResponseType.MEMBER_NOT_EXIST_ID)); | ||
|
||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/ftw/hometerview/member/service/MemberServiceFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.ftw.hometerview.member.service; | ||
|
||
|
||
import com.ftw.hometerview.member.controller.dto.MemberDto; | ||
import com.ftw.hometerview.member.domain.Member; | ||
import com.ftw.hometerview.place.controller.dto.PlaceDto; | ||
import com.ftw.hometerview.place.controller.dto.PlaceDto.CompanyDetail; | ||
import com.ftw.hometerview.place.service.PlaceServiceFacade; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class MemberServiceFacade { | ||
|
||
private final PlaceServiceFacade placeService; | ||
private final MemberService memberService; | ||
|
||
|
||
public MemberDto getMemberInfo(String memberId) { | ||
Member member = this.memberService.getMemberById(memberId); | ||
PlaceDto.CompanyDetail companyDetail = new CompanyDetail(); | ||
if (member.getCompanyId().isEmpty()) { | ||
companyDetail = placeService.getCompanyDetail(member.getCompanyId()); | ||
} | ||
return MemberDto.of(member, companyDetail); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters