-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from kakao-tech-campus-2nd-step3/fix/ISSUE-129
MemberService <-> SecurityBeanGenerator 순환 참조 문제 해결
- Loading branch information
Showing
33 changed files
with
312 additions
and
166 deletions.
There are no files selected for viewing
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
47 changes: 0 additions & 47 deletions
47
src/main/java/poomasi/domain/auth/signup/service/SignupService.java
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/main/java/poomasi/domain/auth/token/refreshtoken/service/RefreshTokenService.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
23 changes: 11 additions & 12 deletions
23
src/main/java/poomasi/domain/auth/token/reissue/controller/ReissueTokenController.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,30 +1,29 @@ | ||
package poomasi.domain.auth.token.reissue.controller; | ||
|
||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.access.annotation.Secured; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import poomasi.domain.auth.security.userdetail.UserDetailsImpl; | ||
import poomasi.domain.auth.token.reissue.dto.ReissueRequest; | ||
import poomasi.domain.auth.token.reissue.dto.ReissueResponse; | ||
import poomasi.domain.auth.token.reissue.service.ReissueTokenService; | ||
import poomasi.domain.member.entity.Member; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class ReissueTokenController { | ||
|
||
@Autowired | ||
private ReissueTokenService reissueTokenService; | ||
private final ReissueTokenService reissueTokenService; | ||
|
||
@Secured({"ROLE_FARMER", "ROLE_CUSTOMER"}) | ||
@PostMapping("/api/reissue") | ||
public ResponseEntity<ReissueResponse> reissue(@AuthenticationPrincipal UserDetailsImpl userDetails, @RequestBody ReissueRequest reissueRequest){ | ||
Member member = userDetails.getMember(); | ||
return ResponseEntity.ok(reissueTokenService.reissueToken(member.getId(), reissueRequest)); | ||
public ResponseEntity<ReissueResponse> reissue(@RequestHeader(HttpHeaders.AUTHORIZATION) String authorizationHeader, | ||
@RequestBody ReissueRequest reissueRequest){ | ||
|
||
String accessToken = authorizationHeader.replace("Bearer ", ""); | ||
|
||
return ResponseEntity.ok(reissueTokenService.reissueToken(accessToken, reissueRequest)); | ||
} | ||
|
||
} |
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
2 changes: 2 additions & 0 deletions
2
src/main/java/poomasi/domain/image/repository/ImageRepository.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
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
14 changes: 14 additions & 0 deletions
14
src/main/java/poomasi/domain/member/_profile/controller/MemberProfileController.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,14 @@ | ||
package poomasi.domain.member._profile.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import poomasi.domain.member._profile.service.MemberProfileService; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("api/member/profile") | ||
public class MemberProfileController { | ||
|
||
private final MemberProfileService memberProfileService; | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/poomasi/domain/member/_profile/dto/request/MemberProfileRequest.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 poomasi.domain.member._profile.dto.request; | ||
|
||
|
||
public record MemberProfileRequest() { | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/poomasi/domain/member/_profile/dto/response/CommonProfileResponse.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 poomasi.domain.member._profile.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import poomasi.domain.image.entity.Image; | ||
import poomasi.domain.member._profile.entity.MemberProfile; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@AllArgsConstructor | ||
public class CommonProfileResponse implements MemberProfileResponse { | ||
String phoneNumber; | ||
boolean isBanned; | ||
LocalDateTime createdAt; | ||
Image profileImage; | ||
|
||
public static CommonProfileResponse fromEntity(MemberProfile profile) { | ||
return new CommonProfileResponse( | ||
profile.getPhoneNumber(), | ||
profile.isBanned(), | ||
profile.getCreatedAt(), | ||
profile.getProfileImage() | ||
); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/poomasi/domain/member/_profile/dto/response/CustomerProfileResponse.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,28 @@ | ||
package poomasi.domain.member._profile.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import poomasi.domain.image.entity.Image; | ||
import poomasi.domain.member._profile.entity.CustomerProfile; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@AllArgsConstructor | ||
public class CustomerProfileResponse implements MemberProfileResponse{ | ||
String phoneNumber; | ||
String address; | ||
String addressDetail; | ||
boolean isBanned; | ||
LocalDateTime createdAt; | ||
Image profileImage; | ||
|
||
public static CustomerProfileResponse fromEntity(CustomerProfile profile) { | ||
return new CustomerProfileResponse( | ||
profile.getPhoneNumber(), | ||
profile.getAddress(), | ||
profile.getAddressDetail(), | ||
profile.isBanned(), | ||
profile.getCreatedAt(), | ||
profile.getProfileImage() | ||
); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/poomasi/domain/member/_profile/dto/response/FarmerProfileResponse.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,39 @@ | ||
package poomasi.domain.member._profile.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import poomasi.domain.image.entity.Image; | ||
import poomasi.domain.member._profile.entity.FarmerProfile; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@AllArgsConstructor | ||
public class FarmerProfileResponse implements MemberProfileResponse { | ||
String phoneNumber; | ||
boolean isBanned; | ||
LocalDateTime createdAt; | ||
Image profileImage; | ||
String storeName; | ||
String farmName; | ||
List<String> businessRegistrationNumbers; | ||
String storeAddress; | ||
String storeAddressDetail; | ||
String farmAddress; | ||
String farmAddressDetail; | ||
|
||
public static FarmerProfileResponse fromEntity(FarmerProfile profile) { | ||
return new FarmerProfileResponse( | ||
profile.getPhoneNumber(), | ||
profile.isBanned(), | ||
profile.getCreatedAt(), | ||
profile.getProfileImage(), | ||
profile.getStoreName(), | ||
profile.getFarmName(), | ||
profile.getBusinessRegistrationNumbers(), | ||
profile.getStoreAddress(), | ||
profile.getStoreAddressDetail(), | ||
profile.getFarmAddress(), | ||
profile.getFarmAddressDetail() | ||
); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/poomasi/domain/member/_profile/dto/response/MemberProfileResponse.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,18 @@ | ||
package poomasi.domain.member._profile.dto.response; | ||
|
||
import poomasi.domain.member._profile.entity.CustomerProfile; | ||
import poomasi.domain.member._profile.entity.FarmerProfile; | ||
import poomasi.domain.member._profile.entity.MemberProfile; | ||
|
||
public interface MemberProfileResponse { | ||
|
||
static MemberProfileResponse fromEntity(MemberProfile profile) { | ||
if (profile instanceof FarmerProfile farmerProfile) { | ||
return FarmerProfileResponse.fromEntity(farmerProfile); | ||
} else if (profile instanceof CustomerProfile customerProfile) { | ||
return CustomerProfileResponse.fromEntity(customerProfile); | ||
} else { | ||
return CommonProfileResponse.fromEntity(profile); | ||
} | ||
} | ||
} |
Oops, something went wrong.