-
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.
MemberId String 으로 수정 MemberController 추가
- Loading branch information
RungDaRongDa
committed
Jan 19, 2024
1 parent
3d6963c
commit d037fda
Showing
26 changed files
with
274 additions
and
38 deletions.
There are no files selected for viewing
34 changes: 32 additions & 2 deletions
34
flick-adapter/http/src/main/java/sigma/http/member/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 |
---|---|---|
@@ -1,11 +1,41 @@ | ||
package sigma.http.member; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.bind.annotation.*; | ||
import sigma.application.auth.interactor.NewTokenUseCase; | ||
import sigma.application.member.interactor.MemberFindUseCase; | ||
import sigma.application.member.interactor.response.MemberFindByNameResponse; | ||
import sigma.application.member.interactor.response.MemberFindOneResponse; | ||
import sigma.http.member.request.SetFirebaseTokenRequest; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping(value = "/member") | ||
@RequiredArgsConstructor | ||
public class MemberController { | ||
private final MemberFindUseCase memberFindUseCase; | ||
private final NewTokenUseCase newTokenUseCase; | ||
|
||
|
||
//권한 추가(Student) | ||
@GetMapping("/findOne") | ||
public MemberFindOneResponse findOne(@RequestHeader(value = "Authorization") String token){ | ||
return memberFindUseCase.findOne(token.substring("Bearer".length()).trim()); | ||
} | ||
|
||
@GetMapping("/search/{memberName}") | ||
public List<MemberFindByNameResponse> findByName(@PathVariable(value = "memberName") String name){ | ||
return memberFindUseCase.findByName(name); | ||
} | ||
|
||
@GetMapping("/newAccessToken") | ||
public String newAccessToKen(@RequestHeader(value = "RefreshToken") String token){ | ||
return newTokenUseCase.newAccessToKen(token); | ||
} | ||
|
||
@PostMapping("/setFirebase/{memberId}") | ||
public void setFirebaseToken(@PathVariable(value = "memberId") String memberId, @RequestBody SetFirebaseTokenRequest setFirebaseTokenRequest){ | ||
return;newTokenUseCase.setNewFirebaseToken(memberId,setFirebaseTokenRequest.firebaseToken()); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
flick-adapter/http/src/main/java/sigma/http/member/request/SetFirebaseTokenRequest.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,5 @@ | ||
package sigma.http.member.request; | ||
|
||
public record SetFirebaseTokenRequest( | ||
String firebaseToken | ||
) { } |
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
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
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
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
29 changes: 29 additions & 0 deletions
29
flick-core/application/src/main/java/sigma/application/auth/interactor/NewTokenUseCase.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 sigma.application.auth.interactor; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import sigma.application.auth.outport.TokenPort; | ||
import sigma.application.member.outport.MemberDBPort; | ||
import sigma.domain.member.model.Member; | ||
import sigma.domain.member.model.value.Role; | ||
|
||
import java.util.Optional; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class NewTokenUseCase { | ||
private final TokenPort tokenPort; | ||
private final MemberDBPort memberDBPort; | ||
|
||
public String newAccessToKen(String token) { | ||
final String id = tokenPort.parseToken(token, "REFRESH"); | ||
final Role role = memberDBPort.findById(id).orElseThrow().role(); // 이거 고칠 수 있나? | ||
return tokenPort.newAccessToken(id,role); | ||
} | ||
|
||
public void setNewFirebaseToken(String memberId, String firebaseToken) { | ||
Member member = memberDBPort.getById(memberId); | ||
|
||
// login 부분 알아야 될것 같음 | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
...core/application/src/main/java/sigma/application/member/interactor/MemberFindUseCase.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,38 @@ | ||
package sigma.application.member.interactor; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.stereotype.Component; | ||
import sigma.application.member.interactor.response.MemberFindByNameResponse; | ||
import sigma.application.member.interactor.response.MemberFindOneResponse; | ||
import sigma.application.member.outport.MemberDBPort; | ||
import sigma.domain.member.model.Member; | ||
import sigma.domain.member.model.event.MemberRegisteredEvent; | ||
import sigma.domain.member.model.value.StudentInfo; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class MemberFindUseCase { | ||
private final MemberDBPort memberDBPort; | ||
private final ApplicationEventPublisher applicationEventPublisher; | ||
|
||
|
||
public MemberFindOneResponse findOne(final String token){ | ||
// 들어올 때 인증한 멤버 가져오기 | ||
//지금은 그 부분이 어딘지 모르겠음 | ||
return null; | ||
} | ||
|
||
public List<MemberFindByNameResponse> findByName(String name) { | ||
List<Member> members = memberDBPort.findByName(name); | ||
List<MemberFindByNameResponse> result = new ArrayList<>(); | ||
for (Member member : members) { | ||
result.add(new MemberFindByNameResponse(member.id(),member.studentInfo(),member.memberInfo())); | ||
// applicationEventPublisher.publishEvent(new MemberRegisteredEvent(member.id())); | ||
} | ||
return result; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../src/main/java/sigma/application/member/interactor/response/MemberFindByNameResponse.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,11 @@ | ||
package sigma.application.member.interactor.response; | ||
|
||
import sigma.domain.member.model.value.MemberId; | ||
import sigma.domain.member.model.value.MemberInfo; | ||
import sigma.domain.member.model.value.StudentInfo; | ||
|
||
public record MemberFindByNameResponse( | ||
MemberId memberId, | ||
StudentInfo studentInfo, | ||
MemberInfo memberInfo | ||
) { } |
17 changes: 17 additions & 0 deletions
17
...ion/src/main/java/sigma/application/member/interactor/response/MemberFindOneResponse.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,17 @@ | ||
package sigma.application.member.interactor.response; | ||
|
||
import sigma.domain.account.model.Account; | ||
import sigma.domain.member.model.value.MemberId; | ||
import sigma.domain.member.model.value.MemberInfo; | ||
import sigma.domain.member.model.value.Role; | ||
import sigma.domain.member.model.value.StudentInfo; | ||
|
||
import java.util.List; | ||
|
||
public record MemberFindOneResponse( | ||
MemberId memberId, | ||
StudentInfo studentInfo, | ||
MemberInfo memberInfo, | ||
Role role, | ||
List<Account> accounts | ||
) { } |
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
Oops, something went wrong.