diff --git a/src/main/java/com/kakaoteck/golagola/domain/auth/controller/AuthController.java b/src/main/java/com/kakaoteck/golagola/domain/auth/controller/AuthController.java index 030e680..b2dde28 100644 --- a/src/main/java/com/kakaoteck/golagola/domain/auth/controller/AuthController.java +++ b/src/main/java/com/kakaoteck/golagola/domain/auth/controller/AuthController.java @@ -31,7 +31,6 @@ public class AuthController { @Operation(summary = "회원가입 추가정보 진행", description = "(nickname, gender, role) 저장") @PostMapping("/join") public ApiResponse join(@RequestBody AuthRequest authRequest, @AuthenticationPrincipal CustomOAuth2User customUser) { -// String username = customUser.getUsername(); // 1. UserEntity 가져오기 UserEntity userEntity = customUser.getUserEntity(); @@ -42,7 +41,6 @@ public ApiResponse join(@RequestBody AuthRequest authRequest, @Authentic userEntity.setPhoneNum(authRequest.phoneNumber()); userEntity.setRole(authRequest.role()); - // 5. SecurityContextHolder에 새로운 Authentication 객체로 업데이트 UserDTO updatedUserDTO = customUser.getUserDTO(); updatedUserDTO.setNickname(authRequest.nickName()); updatedUserDTO.setGender(authRequest.gender()); @@ -52,13 +50,17 @@ public ApiResponse join(@RequestBody AuthRequest authRequest, @Authentic Buyer buyer = Buyer.builder() .user(userEntity) - .address(authRequest.address()) + .roadAddress(authRequest.roadAddress()) + .zipCode(authRequest.zipCode()) + .detailAdress(authRequest.detailAdress()) .build(); userEntity.setBuyer(buyer); // UserEntity에 Buyer 설정 } else if (Role.SELLER == authRequest.role()) { Seller seller = Seller.builder() .user(userEntity) - .address(authRequest.address()) + .roadAddress(authRequest.roadAddress()) + .zipCode(authRequest.zipCode()) + .detailAdress(authRequest.detailAdress()) .build(); userEntity.setSeller(seller); // UserEntity에 Seller 설정 } else { @@ -68,10 +70,6 @@ public ApiResponse join(@RequestBody AuthRequest authRequest, @Authentic // 4. 업데이트된 UserEntity 저장 (Cascade 옵션으로 인해 Buyer/Seller도 저장됨) authService.saveUser(userEntity); -// CustomOAuth2User updatedCustomOAuth2User = new CustomOAuth2User(updatedUserDTO, userEntity); -// Authentication newAuth = new UsernamePasswordAuthenticationToken(updatedCustomOAuth2User, null, updatedCustomOAuth2User.getAuthorities()); -// SecurityContextHolder.getContext().setAuthentication(newAuth); - return ApiResponse.onSuccess("회원가입 성공"); } diff --git a/src/main/java/com/kakaoteck/golagola/domain/auth/dto/AuthRequest.java b/src/main/java/com/kakaoteck/golagola/domain/auth/dto/AuthRequest.java index f276216..d40f576 100644 --- a/src/main/java/com/kakaoteck/golagola/domain/auth/dto/AuthRequest.java +++ b/src/main/java/com/kakaoteck/golagola/domain/auth/dto/AuthRequest.java @@ -7,7 +7,9 @@ public record AuthRequest( String nickName, Gender gender, String phoneNumber, - String address, + String roadAddress, + String zipCode, + String detailAdress, Role role ) { } diff --git a/src/main/java/com/kakaoteck/golagola/domain/buyer/dto/BuyerRequest.java b/src/main/java/com/kakaoteck/golagola/domain/buyer/dto/BuyerRequest.java index 559d5b1..55ca3b1 100644 --- a/src/main/java/com/kakaoteck/golagola/domain/buyer/dto/BuyerRequest.java +++ b/src/main/java/com/kakaoteck/golagola/domain/buyer/dto/BuyerRequest.java @@ -18,8 +18,10 @@ public record BuyerRequest( @Builder public record MyPagePutDto( + String roadAddress, + String zipCode, + String detailAdress, String nickname, - String address, String phoneNum ) {} } diff --git a/src/main/java/com/kakaoteck/golagola/domain/buyer/dto/BuyerResponse.java b/src/main/java/com/kakaoteck/golagola/domain/buyer/dto/BuyerResponse.java index 43b4c53..ace4a12 100644 --- a/src/main/java/com/kakaoteck/golagola/domain/buyer/dto/BuyerResponse.java +++ b/src/main/java/com/kakaoteck/golagola/domain/buyer/dto/BuyerResponse.java @@ -10,7 +10,9 @@ public record BuyerResponse( String email, Role role, - String address, + String roadAddress, // 도로명 주소 + String zipCode, // 우편 번호 + String detailAdress, // 세부주소 String realName, Gender gender, String phoneNum, diff --git a/src/main/java/com/kakaoteck/golagola/domain/buyer/entity/Buyer.java b/src/main/java/com/kakaoteck/golagola/domain/buyer/entity/Buyer.java index e6c0a81..b7c4134 100644 --- a/src/main/java/com/kakaoteck/golagola/domain/buyer/entity/Buyer.java +++ b/src/main/java/com/kakaoteck/golagola/domain/buyer/entity/Buyer.java @@ -32,12 +32,16 @@ public class Buyer extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long buyerId; - private String address; // @Column(nullable = false) + private String roadAddress; // 도로명 주소 + private String zipCode; // 우편 번호 + private String detailAdress; // 세부주소 + @OneToOne // Buyer는 하나의 UserEntity와만 연결됩니다. @JoinColumn(name = "user_id", nullable = false) private UserEntity user; + // @Enumerated(EnumType.STRING) // @Column(nullable = false) // private Role role = Role.valueOf("BUYER"); @@ -52,7 +56,9 @@ public class Buyer extends BaseEntity { private List orderList; public void updateProfile(BuyerRequest.MyPagePutDto request) { - this.address = request.address(); + this.roadAddress = request.roadAddress(); + this.zipCode = request.zipCode(); + this.detailAdress = request.detailAdress(); this.user.setNickname(request.nickname()); // 참조entity에서 UserEntity에 업데이트 this.user.setPhoneNum(request.phoneNum()); // 참조entity에서 UserEntity에 업데이트 } diff --git a/src/main/java/com/kakaoteck/golagola/domain/buyer/service/BuyerService.java b/src/main/java/com/kakaoteck/golagola/domain/buyer/service/BuyerService.java index a1dc507..fbf2950 100644 --- a/src/main/java/com/kakaoteck/golagola/domain/buyer/service/BuyerService.java +++ b/src/main/java/com/kakaoteck/golagola/domain/buyer/service/BuyerService.java @@ -25,7 +25,9 @@ public static BuyerResponse getMyPage(Buyer buyer) { return BuyerResponse.builder() .email(buyer.getUser().getEmail()) .role(buyer.getUser().getRole()) - .address(buyer.getAddress()) + .roadAddress(buyer.getRoadAddress()) + .zipCode(buyer.getZipCode()) + .detailAdress(buyer.getDetailAdress()) .realName(buyer.getUser().getName()) .gender(buyer.getUser().getGender()) .phoneNum(buyer.getUser().getPhoneNum()) @@ -43,7 +45,9 @@ public BuyerResponse updateMyPage(Buyer buyer, BuyerRequest.MyPagePutDto request return BuyerResponse.builder() .email(savedBuyer.getUser().getEmail()) .role(savedBuyer.getUser().getRole()) - .address(savedBuyer.getAddress()) + .roadAddress(savedBuyer.getRoadAddress()) + .zipCode(savedBuyer.getZipCode()) + .detailAdress(savedBuyer.getDetailAdress()) .realName(savedBuyer.getUser().getName()) .gender(savedBuyer.getUser().getGender()) .phoneNum(savedBuyer.getUser().getPhoneNum()) diff --git a/src/main/java/com/kakaoteck/golagola/domain/seller/dto/SellerRequest.java b/src/main/java/com/kakaoteck/golagola/domain/seller/dto/SellerRequest.java index 7691c69..e79ae42 100644 --- a/src/main/java/com/kakaoteck/golagola/domain/seller/dto/SellerRequest.java +++ b/src/main/java/com/kakaoteck/golagola/domain/seller/dto/SellerRequest.java @@ -19,8 +19,10 @@ public record SellerRequest( ) { @Builder public record MyPagePutDto( + String roadAddress, + String zipCode, + String detailAdress, String nickname, - String address, String phoneNum ) {} } diff --git a/src/main/java/com/kakaoteck/golagola/domain/seller/dto/SellerResponse.java b/src/main/java/com/kakaoteck/golagola/domain/seller/dto/SellerResponse.java index be57834..1db3b3f 100644 --- a/src/main/java/com/kakaoteck/golagola/domain/seller/dto/SellerResponse.java +++ b/src/main/java/com/kakaoteck/golagola/domain/seller/dto/SellerResponse.java @@ -12,7 +12,9 @@ public record SellerResponse( String realName, Gender gender, String email, - String address, + String roadAddress, // 도로명 주소 + String zipCode, // 우편 번호 + String detailAdress, // 세부주소 String phoneNum, Role role, LocalDate registerDate diff --git a/src/main/java/com/kakaoteck/golagola/domain/seller/entity/Seller.java b/src/main/java/com/kakaoteck/golagola/domain/seller/entity/Seller.java index ea82dd2..cc856ed 100644 --- a/src/main/java/com/kakaoteck/golagola/domain/seller/entity/Seller.java +++ b/src/main/java/com/kakaoteck/golagola/domain/seller/entity/Seller.java @@ -37,7 +37,9 @@ public class Seller extends BaseEntity{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long sellerId; - private String address; // @Column(nullable = false) + private String roadAddress; // 도로명 주소 + private String zipCode; // 우편 번호 + private String detailAdress; // 세부주소 @OneToOne // Seller는 하나의 UserEntity와만 연결됩니다. @JoinColumn(name = "user_id", nullable = false) @@ -51,7 +53,9 @@ public class Seller extends BaseEntity{ private List orderList = new ArrayList<>(); public void updateProfile(SellerRequest.MyPagePutDto request) { - this.address = request.address(); + this.roadAddress = request.roadAddress(); + this.zipCode = request.zipCode(); + this.detailAdress = request.detailAdress(); this.user.setNickname(request.nickname()); // 참조entity에서 UserEntity에 업데이트 this.user.setPhoneNum(request.phoneNum()); // 참조entity에서 UserEntity에 업데이트 } diff --git a/src/main/java/com/kakaoteck/golagola/domain/seller/service/SellerService.java b/src/main/java/com/kakaoteck/golagola/domain/seller/service/SellerService.java index 5a2c8e7..80bc049 100644 --- a/src/main/java/com/kakaoteck/golagola/domain/seller/service/SellerService.java +++ b/src/main/java/com/kakaoteck/golagola/domain/seller/service/SellerService.java @@ -23,7 +23,9 @@ public SellerResponse getMyPage(Seller seller) { return SellerResponse.builder() .email(seller.getUser().getEmail()) .role(seller.getUser().getRole()) - .address(seller.getAddress()) + .roadAddress(seller.getRoadAddress()) + .zipCode(seller.getZipCode()) + .detailAdress(seller.getDetailAdress()) .realName(seller.getUser().getName()) .gender(seller.getUser().getGender()) .phoneNum(seller.getUser().getPhoneNum()) @@ -42,7 +44,9 @@ public SellerResponse updateMyPage(Seller seller, SellerRequest.MyPagePutDto req return SellerResponse.builder() .email(savedSeller.getUser().getEmail()) .role(savedSeller.getUser().getRole()) - .address(savedSeller.getAddress()) + .roadAddress(savedSeller.getRoadAddress()) + .zipCode(savedSeller.getZipCode()) + .detailAdress(savedSeller.getDetailAdress()) .realName(savedSeller.getUser().getName()) .gender(savedSeller.getUser().getGender()) .phoneNum(savedSeller.getUser().getPhoneNum()) diff --git a/src/main/java/com/kakaoteck/golagola/security/jwt/JWTFilter.java b/src/main/java/com/kakaoteck/golagola/security/jwt/JWTFilter.java index c8f218c..9b74e16 100644 --- a/src/main/java/com/kakaoteck/golagola/security/jwt/JWTFilter.java +++ b/src/main/java/com/kakaoteck/golagola/security/jwt/JWTFilter.java @@ -112,7 +112,6 @@ else if (userEntity.getRole() == Role.SELLER){ authToken = new UsernamePasswordAuthenticationToken(seller, null, customOAuth2User.getAuthoritiesForRole(Role.SELLER)); // Seller에 맞는 권한 설정 } else{ - System.out.println("여기 걸리냐/?!!!!!!"); authToken = new UsernamePasswordAuthenticationToken(customOAuth2User, null, customOAuth2User.getAuthorities()); // 스프링 시큐리티 인증 토큰 생성, 스프링 시큐리티에서 세션을 생성해가지고 토큰을 등록하고 있음. } SecurityContextHolder.getContext().setAuthentication(authToken); // 세션에 사용자 등록