-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#117 [fix] 모델 회원가입 로직 변경 #121
Changes from 4 commits
2e145b5
0ab6210
95480b7
b3e8e07
b4bddbd
b08bcf5
f4780b9
f393450
4080b66
fd6d9ad
27f9c37
16b71a8
d29b719
b506c91
8a58519
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,11 +38,13 @@ | |
import com.moddy.server.domain.user.Gender; | ||
import com.moddy.server.domain.user.Role; | ||
import com.moddy.server.domain.user.User; | ||
import com.moddy.server.domain.user.repository.UserRepository; | ||
import com.moddy.server.external.kakao.service.KakaoSocialService; | ||
import com.moddy.server.external.s3.S3Service; | ||
import com.moddy.server.service.auth.AuthService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.hibernate.Length; | ||
import org.springframework.beans.BeanUtils; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Sort; | ||
|
@@ -60,6 +62,7 @@ | |
public class ModelService { | ||
|
||
private final ModelJpaRepository modelJpaRepository; | ||
private final UserRepository userRepository; | ||
private final DesignerJpaRepository designerJpaRepository; | ||
private final HairModelApplicationJpaRepository hairModelApplicationJpaRepository; | ||
private final HairServiceOfferJpaRepository hairServiceOfferJpaRepository; | ||
|
@@ -69,7 +72,6 @@ public class ModelService { | |
private final PreferRegionJpaRepository preferRegionJpaRepository; | ||
private final RegionJpaRepository regionJpaRepository; | ||
private final HairServiceRecordJpaRepository hairServiceRecordJpaRepository; | ||
private final KakaoSocialService kakaoSocialService; | ||
private final AuthService authService; | ||
private final S3Service s3Service; | ||
|
||
|
@@ -240,20 +242,19 @@ public void updateOfferAgreeStatus(Long offerId){ | |
} | ||
|
||
@Transactional | ||
public UserCreateResponse createModel(String baseUrl, String code, ModelCreateRequest request) { | ||
public UserCreateResponse createModel(Long userId, ModelCreateRequest request) { | ||
|
||
String kakaoId = kakaoSocialService.getIdFromKakao(baseUrl, code); | ||
User user = userRepository.findById(userId).orElseThrow(() -> new NotFoundException(ErrorCode.USER_NOT_FOUND_EXCEPTION)); | ||
|
||
Model model = Model.builder() | ||
.kakaoId(user.getKakaoId()) | ||
.name(request.name()) | ||
.year(request.year()) | ||
.gender(request.gender()) | ||
.phoneNumber(request.phoneNumber()) | ||
.isMarketingAgree(request.isMarketingAgree()) | ||
.profileImgUrl(s3Service.getDefaultProfileImageUrl()) | ||
.kakaoId(kakaoId) | ||
.role(Role.MODEL) | ||
.build(); | ||
.year(request.year()).build(); | ||
|
||
modelJpaRepository.save(model); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p2 find by id를 통해 기존 user를 불러온 뒤, 해당 setter를 통해 해당 user의 정보를 update 한 뒤, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Builder를 통해 Model 객체를 만들어서 저장을 하게 되면 기존에 만들어진 userId에 대한 정보를 이어받아서 Model만 생성되는 것이 아니라 새로운 User 정보도 생성된다는 문제가 있습니다! 기존의 User가 1번 이였다면, 2번 유저를 가르키고 있는 Model이 만들어 지는데 혹시 이러한 방법을 하는게 맞을까요..? -- 제 코드가 문제가 있을 수도 있어서 방금 수정 코드 다시 올려두었습니다! User 2 번이 생성안되고 Model 객체가 User 1을 참조할 수 있는 방법 좀 더 생각해서 PR 올릴께욤! |
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p2
access token 관련 오류이기 때문에 400이 아닌 401 에러인 것 같습니다..!