diff --git a/server/src/main/java/com/yogit/server/applelogin/controller/AppleController.java b/server/src/main/java/com/yogit/server/applelogin/controller/AppleController.java index 62553e9..260ff0d 100644 --- a/server/src/main/java/com/yogit/server/applelogin/controller/AppleController.java +++ b/server/src/main/java/com/yogit/server/applelogin/controller/AppleController.java @@ -64,6 +64,7 @@ public TokenResponse signUpApple(@RequestBody ServicesResponse servicesResponse) @PostMapping(value = "/apps/to/endpoint") @ResponseBody public void appsToEndpoint(@RequestBody AppsResponse appsResponse) { + System.out.println("애플 계정 탈퇴했습니다."); logger.debug("[/path/to/endpoint] RequestBody ‣ " + appsResponse.getPayload()); } diff --git a/server/src/main/java/com/yogit/server/applelogin/model/Account.java b/server/src/main/java/com/yogit/server/applelogin/model/Account.java new file mode 100644 index 0000000..f29b7b1 --- /dev/null +++ b/server/src/main/java/com/yogit/server/applelogin/model/Account.java @@ -0,0 +1,19 @@ +package com.yogit.server.applelogin.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import net.minidev.json.JSONObject; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Account { + + private String state; + private String code; // authorization_token + private String id_token; // identity_token + private JSONObject user; // 애플에서 제공하는 유저 정보 + private String identifier; + private Boolean hasRequirementInfo; // 유저 필수정보 입력 여부 +} diff --git a/server/src/main/java/com/yogit/server/applelogin/model/ServicesResponse.java b/server/src/main/java/com/yogit/server/applelogin/model/ServicesResponse.java index 4108fe8..2624fa8 100644 --- a/server/src/main/java/com/yogit/server/applelogin/model/ServicesResponse.java +++ b/server/src/main/java/com/yogit/server/applelogin/model/ServicesResponse.java @@ -10,7 +10,9 @@ public class ServicesResponse { private String state; - private String code; - private String id_token; - private JSONObject user; + private String code; // authorization_token + private String id_token; // identity_token + private JSONObject user; // 애플에서 제공하는 유저 정보 + private String identifier; + private Boolean hasRequirementInfo; // 유저 필수정보 입력 여부 } diff --git a/server/src/main/java/com/yogit/server/applelogin/model/TokenResponse.java b/server/src/main/java/com/yogit/server/applelogin/model/TokenResponse.java index b3442ed..a328cd5 100644 --- a/server/src/main/java/com/yogit/server/applelogin/model/TokenResponse.java +++ b/server/src/main/java/com/yogit/server/applelogin/model/TokenResponse.java @@ -20,4 +20,8 @@ public class TokenResponse { // 유저 엔티티 생성 후 res private String name; private String email; + + //추가적인 응답 필드 + private String userType; // ex)apple + private Account account; } diff --git a/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java b/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java index 8824dbf..c125773 100644 --- a/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java +++ b/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java @@ -1,9 +1,11 @@ package com.yogit.server.applelogin.service; +import com.yogit.server.applelogin.model.Account; import com.yogit.server.applelogin.model.ServicesResponse; import com.yogit.server.applelogin.model.TokenResponse; import com.yogit.server.applelogin.util.AppleUtils; import com.yogit.server.user.dto.request.CreateUserAppleReq; +import com.yogit.server.user.entity.UserType; import com.yogit.server.user.service.UserService; import lombok.RequiredArgsConstructor; import net.minidev.json.JSONObject; @@ -69,7 +71,7 @@ public TokenResponse requestCodeValidations(ServicesResponse serviceResponse, St tokenResponse = appleUtils.validateAuthorizationGrantCode(client_secret, code); // 유저 생성 - CreateUserAppleReq createUserAppleReq = new CreateUserAppleReq(email, tokenResponse.getRefresh_token(),fullName); + CreateUserAppleReq createUserAppleReq = new CreateUserAppleReq(email, tokenResponse.getRefresh_token(),fullName, UserType.APPLE); userService.createUserApple(createUserAppleReq); tokenResponse.setName(fullName); @@ -80,6 +82,9 @@ else if (client_secret != null && code == null && refresh_token != null) { tokenResponse = appleUtils.validateAnExistingRefreshToken(client_secret, refresh_token); } + tokenResponse.setAccount(new Account(serviceResponse.getState(), code, serviceResponse.getId_token(), user, serviceResponse.getIdentifier(), serviceResponse.getHasRequirementInfo())); + tokenResponse.setUserType(UserType.APPLE.toString()); + return tokenResponse; } diff --git a/server/src/main/java/com/yogit/server/user/dto/request/CreateUserAppleReq.java b/server/src/main/java/com/yogit/server/user/dto/request/CreateUserAppleReq.java index e43c918..02c83b8 100644 --- a/server/src/main/java/com/yogit/server/user/dto/request/CreateUserAppleReq.java +++ b/server/src/main/java/com/yogit/server/user/dto/request/CreateUserAppleReq.java @@ -1,6 +1,7 @@ package com.yogit.server.user.dto.request; import com.yogit.server.user.entity.User; +import com.yogit.server.user.entity.UserType; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -13,9 +14,10 @@ public class CreateUserAppleReq { String loginId; String refresh_token; String name; + UserType userType; public static User toEntityUserApple(CreateUserAppleReq createUserAppleReq){ - User user = new User(createUserAppleReq.loginId, createUserAppleReq.refresh_token, createUserAppleReq.name); + User user = new User(createUserAppleReq.loginId, createUserAppleReq.refresh_token, createUserAppleReq.name, createUserAppleReq.userType); return user; } } diff --git a/server/src/main/java/com/yogit/server/user/entity/User.java b/server/src/main/java/com/yogit/server/user/entity/User.java index 425bf04..6009fd7 100644 --- a/server/src/main/java/com/yogit/server/user/entity/User.java +++ b/server/src/main/java/com/yogit/server/user/entity/User.java @@ -72,6 +72,9 @@ public class User extends BaseEntity { @OneToMany(mappedBy = "user") private List userImages = new ArrayList<>(); + @Enumerated(EnumType.STRING) + private UserType userType; + @Builder public User (String loginId, String phoneNum){ this.loginId = loginId; @@ -84,6 +87,13 @@ public User (String loginId, String refresh_token, String name){ this.name = name; } + public User (String loginId, String refresh_token, String name, UserType userType){ + this.loginId = loginId; + this.refresh_token = refresh_token; + this.name = name; + this.userType = userType; + } + public void addLanguage(Language language){ this.languages.add(language); } diff --git a/server/src/main/java/com/yogit/server/user/entity/UserType.java b/server/src/main/java/com/yogit/server/user/entity/UserType.java new file mode 100644 index 0000000..59bb5d2 --- /dev/null +++ b/server/src/main/java/com/yogit/server/user/entity/UserType.java @@ -0,0 +1,5 @@ +package com.yogit.server.user.entity; +// 가입 경로 +public enum UserType { + APPLE +}