Skip to content

Commit

Permalink
Merge pull request #32 from YogitTeam/feat/user-profile
Browse files Browse the repository at this point in the history
#24 refactor: 회원 폰번호 등록 (필수 정보 -> 회원가입으로 변경)
  • Loading branch information
shinhn authored Nov 6, 2022
2 parents 46ec3a1 + afbc751 commit fd57b74
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public class UserController {
@ApiImplicitParam(name = "userName", dataTypeClass = String.class, example = "강신현"),
@ApiImplicitParam(name = "userAge", dataTypeClass = int.class, example = "25"),
@ApiImplicitParam(name = "gender", dataTypeClass = Gender.class, example = "FEMALE"),
@ApiImplicitParam(name = "nationality", dataTypeClass = Nationality.class, example = "Korea"),
@ApiImplicitParam(name = "phoneNum", dataTypeClass = String.class, example = "01012345678")
@ApiImplicitParam(name = "nationality", dataTypeClass = Nationality.class, example = "Korea")
})
@PatchMapping("/essential-profile")
public ApplicationResponse<UserEssentialProfileRes> enterEssentialProfile(@ModelAttribute CreateUserEssentialProfileReq createUserEssentialProfileReq){
Expand Down Expand Up @@ -83,7 +82,13 @@ public ApplicationResponse<UserImagesRes> enterUserImage(@ModelAttribute CreateU
* @author 강신현
*/
@ApiOperation(value = "유저 추가 정보 입력")
@ApiImplicitParam(name = "userId", required = true, dataTypeClass = Long.class, example = "0")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", required = true, dataTypeClass = Long.class, example = "1"),
@ApiImplicitParam(name = "latitude", dataTypeClass = Float.class, example = "10.23"),
@ApiImplicitParam(name = "longitude", dataTypeClass = Float.class, example = "10.23"),
@ApiImplicitParam(name = "aboutMe", dataTypeClass = String.class, example = "캠핑 모임에 관심이 많습니다."),
@ApiImplicitParam(name = "city", dataTypeClass = Nationality.class, example = "SEOUL")
})
@PatchMapping("/additional-profile")
public ApplicationResponse<UserAdditionalProfileRes> enterAdditionalProfile(@ModelAttribute AddUserAdditionalProfileReq addUserAdditionalProfileReq){
return userService.enterAdditionalProfile(addUserAdditionalProfileReq);
Expand All @@ -93,7 +98,10 @@ public ApplicationResponse<UserAdditionalProfileRes> enterAdditionalProfile(@Mod
* 유저 회원가입 (일반)
*/
@ApiOperation(value = "유저 회원가입", notes = "sms 인증이 완료되어야 회원가입이 가능합니다.")
@ApiImplicitParam(name = "loginId", required = true, dataTypeClass = String.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "loginId", required = true, dataTypeClass = String.class, example = "kang123"),
@ApiImplicitParam(name = "phoneNum", required = true, dataTypeClass = String.class, example = "01012345678")
})
@PostMapping("/join")
public ApplicationResponse<Void> createUser(@ModelAttribute CreateUserReq createUserReq){
return userService.createUser(createUserReq);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class CreateUserEssentialProfileReq {
int userAge;
Gender gender;
Nationality nationality;
String phoneNum;

List<String> languageNames;
List<String> languageLevels;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
public class CreateUserReq {

String loginId;
String phoneNum;

public static User toEntityUser(CreateUserReq createUserReq){
return User.builder()
.loginId(createUserReq.getLoginId())
.phoneNum(createUserReq.getPhoneNum())
.build();
}
}
6 changes: 3 additions & 3 deletions server/src/main/java/com/yogit/server/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,20 @@ public class User extends BaseEntity {
private List<UserImage> userImages = new ArrayList<>();

@Builder
public User (String loginId){
public User (String loginId, String phoneNum){
this.loginId = loginId;
this.phoneNum = phoneNum;
}

public void addLanguage(Language language){
this.languages.add(language);
}

public void changeUserInfo(String userName, Integer userAge, Gender gender, Nationality nationality, String phoneNum){
public void changeUserInfo(String userName, Integer userAge, Gender gender, Nationality nationality){
if(userName != null) this.name = userName;
if(userAge != 0) this.age = userAge;
if(gender != null) this.gender = gender;
if(nationality != null) this.nationality = nationality;
if(phoneNum != null) this.phoneNum = phoneNum;
}

public void delUser(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class UserServiceImpl implements UserService {
public ApplicationResponse<UserEssentialProfileRes> enterEssentialProfile(CreateUserEssentialProfileReq createUserEssentialProfileReq){

User user = userRepository.findById(createUserEssentialProfileReq.getUserId()).orElseThrow(NotFoundUserException::new);
user.changeUserInfo(createUserEssentialProfileReq.getUserName(), createUserEssentialProfileReq.getUserAge(), createUserEssentialProfileReq.getGender(), createUserEssentialProfileReq.getNationality(), createUserEssentialProfileReq.getPhoneNum());
user.changeUserInfo(createUserEssentialProfileReq.getUserName(), createUserEssentialProfileReq.getUserAge(), createUserEssentialProfileReq.getGender(), createUserEssentialProfileReq.getNationality());

UserEssentialProfileRes userEssentialProfileRes = UserEssentialProfileRes.create(createUserEssentialProfileReq.getUserId(), createUserEssentialProfileReq.getUserName(), createUserEssentialProfileReq.getUserAge(), createUserEssentialProfileReq.getGender(), createUserEssentialProfileReq.getNationality());

Expand Down

0 comments on commit fd57b74

Please sign in to comment.