From ae449069956edb84fdeefcb4ae5b1b6cc66184b4 Mon Sep 17 00:00:00 2001 From: shinhn Date: Sun, 23 Oct 2022 16:27:18 +0900 Subject: [PATCH 1/4] =?UTF-8?q?#21=20feat:=20@Value=20=EA=B4=80=EB=A0=A8?= =?UTF-8?q?=20=EC=97=90=EB=9F=AC=20TODO=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/yogit/server/sms/service/SmsService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/com/yogit/server/sms/service/SmsService.java b/server/src/main/java/com/yogit/server/sms/service/SmsService.java index c105b0a..9ed4928 100644 --- a/server/src/main/java/com/yogit/server/sms/service/SmsService.java +++ b/server/src/main/java/com/yogit/server/sms/service/SmsService.java @@ -40,7 +40,7 @@ public class SmsService { private String secretKey; @Value("01046270562") - private String phoneNum; + private String phoneNum; // TODO 위 3가지 변수와 다르게 @Value(application.yml)값이 다른 값으로 불러와지는 문제가 있음, 일단 값을 yml에서 가져오지 않고 바로 넣어주는 식으로 임시 해결 public String send(SmsSendReq smsSendReq) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException, JsonProcessingException, URISyntaxException { // if(smsSendReq.getPhoneNum().contains("-")) return "-을 제거해주세요."; @@ -48,11 +48,11 @@ public String send(SmsSendReq smsSendReq) throws UnsupportedEncodingException, N System.out.println(serviceId); System.out.println(accessKey); System.out.println(secretKey); - System.out.println(phoneNum); // TODO 위 3가지 변수와 다르게 @Value(application.yml)값이 다른 값으로 불러와지는 문제가 있음, 일단 값을 yml에서 가져오지 않고 바로 넣어주는 식으로 임시 해결 + System.out.println(phoneNum); String certification = Integer.toString((int)(Math.random() * (99999 - 10000 + 1)) + 10000); - Long time = System.currentTimeMillis(); + Long time = System.currentTimeMillis(); List messages = new ArrayList<>(); messages.add(new MessageDTO(smsSendReq.getPhoneNum(), "Yogit \n 인증번호: "+certification)); From 1f1bfb88df5b385b948ba2543298881049fafa66 Mon Sep 17 00:00:00 2001 From: shinhn Date: Wed, 26 Oct 2022 13:33:20 +0900 Subject: [PATCH 2/4] =?UTF-8?q?#24=20feat:=20build.gradle=20-=20jwt=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80,=20user=20password=20=EC=82=AD=EC=A0=9C=20(s?= =?UTF-8?q?ms=EC=9D=B8=EC=A6=9D=EC=9C=BC=EB=A1=9C=20=EB=8C=80=EC=B2=B4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/build.gradle | 2 ++ server/src/main/java/com/yogit/server/user/entity/User.java | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/build.gradle b/server/build.gradle index 3bd2fb2..915df2e 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -35,6 +35,8 @@ dependencies { // S3 implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' + // JWT + implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1' } tasks.named('test') { 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 932e1b8..258589a 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 @@ -33,10 +33,9 @@ public class User extends BaseEntity { @OneToMany(mappedBy = "user") private List languages = new ArrayList<>(); - private String loginId; // TODO 애플 로그인 성공시, 구현 - private String passWord; // TODO 애플 로그인 성공시, 구현 + private String loginId; private String name; - private String profileImg; // 프로필 대표 이미지 TODO image 연동 되면, 구현 + private String profileImg; private String aboutMe; // 300자 이내 From d077bc2f5117d8c7d45bc8ae3841fed4088ad919 Mon Sep 17 00:00:00 2001 From: shinhn Date: Wed, 26 Oct 2022 22:28:58 +0900 Subject: [PATCH 3/4] =?UTF-8?q?#24=20feat:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/controller/UserController.java | 29 ++++++++++++++----- .../CreateUserEssentialProfileReq.java | 11 ++----- .../user/dto/request/CreateUserReq.java | 20 +++++++++++++ .../com/yogit/server/user/entity/User.java | 9 ++---- .../exception/UserDuplicationLoginId.java | 9 ++++++ .../user/exception/UserExceptionList.java | 3 +- .../user/repository/UserRepository.java | 1 + .../server/user/service/UserService.java | 7 ++--- .../server/user/service/UserServiceImpl.java | 18 ++++++++---- 9 files changed, 73 insertions(+), 34 deletions(-) create mode 100644 server/src/main/java/com/yogit/server/user/dto/request/CreateUserReq.java create mode 100644 server/src/main/java/com/yogit/server/user/exception/UserDuplicationLoginId.java diff --git a/server/src/main/java/com/yogit/server/user/controller/UserController.java b/server/src/main/java/com/yogit/server/user/controller/UserController.java index 645a165..f4ea6cc 100644 --- a/server/src/main/java/com/yogit/server/user/controller/UserController.java +++ b/server/src/main/java/com/yogit/server/user/controller/UserController.java @@ -1,14 +1,14 @@ package com.yogit.server.user.controller; import com.yogit.server.global.dto.ApplicationResponse; -import com.yogit.server.user.dto.request.AddUserAdditionalProfileReq; -import com.yogit.server.user.dto.request.CreateUserEssentialProfileReq; -import com.yogit.server.user.dto.request.CreateUserImageReq; -import com.yogit.server.user.dto.request.EditUserEssentialProfileReq; +import com.yogit.server.user.dto.request.*; import com.yogit.server.user.dto.response.UserAdditionalProfileRes; import com.yogit.server.user.dto.response.UserImagesRes; import com.yogit.server.user.dto.response.UserProfileRes; -import com.yogit.server.user.entity.*; +import com.yogit.server.user.entity.Gender; +import com.yogit.server.user.entity.LanguageLevel; +import com.yogit.server.user.entity.LanguageName; +import com.yogit.server.user.entity.Nationality; import com.yogit.server.user.service.UserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -38,7 +38,7 @@ public class UserController { @ApiImplicitParam(name = "languageName1", required = true, dataTypeClass = LanguageName.class), @ApiImplicitParam(name = "languageLevel1", required = true, dataTypeClass = LanguageLevel.class) }) - @PostMapping("/essential-profile") + @PatchMapping("/essential-profile") public ApplicationResponse enterEssentialProfile(@ModelAttribute CreateUserEssentialProfileReq createUserEssentialProfileReq){ return userService.enterEssentialProfile(createUserEssentialProfileReq); } @@ -49,7 +49,7 @@ public ApplicationResponse enterEssentialProfile(@ModelAttribute */ @ApiOperation(value = "유저 필수 정보 수정", notes = "수정할 정보들만 입력해주세요, Language 중에 하나라도 변경사항이 있다면 유저의 모든 Language 를 입력하여 요청해주세요") @ApiImplicitParam(name = "userId", required = true, dataTypeClass = Long.class, example = "0") - @PatchMapping("/essential-profile") + @PatchMapping("/edit-essential-profile") public ApplicationResponse editEssentialProfile(@ModelAttribute EditUserEssentialProfileReq editUserEssentialProfileReq){ return userService.editEssentialProfile(editUserEssentialProfileReq); } @@ -97,4 +97,19 @@ public ApplicationResponse enterUserImage(@ModelAttribute CreateU public ApplicationResponse enterAdditionalProfile(@ModelAttribute AddUserAdditionalProfileReq addUserAdditionalProfileReq){ return userService.enterAdditionalProfile(addUserAdditionalProfileReq); } + + /** + * 유저 회원가입 (일반) + */ + @ApiOperation(value = "유저 회원가입", notes = "sms 인증이 완료되어야 회원가입이 가능합니다.") + @ApiImplicitParam(name = "loginId", required = true, dataTypeClass = String.class) + @PostMapping("/join") + public ApplicationResponse createUser(@ModelAttribute CreateUserReq createUserReq){ + return userService.createUser(createUserReq); + } + + + /** + * 유저 로그인 + */ } diff --git a/server/src/main/java/com/yogit/server/user/dto/request/CreateUserEssentialProfileReq.java b/server/src/main/java/com/yogit/server/user/dto/request/CreateUserEssentialProfileReq.java index bb9f990..3d8d7d1 100644 --- a/server/src/main/java/com/yogit/server/user/dto/request/CreateUserEssentialProfileReq.java +++ b/server/src/main/java/com/yogit/server/user/dto/request/CreateUserEssentialProfileReq.java @@ -10,6 +10,8 @@ @Data public class CreateUserEssentialProfileReq { + Long userId; + String userName; int userAge; Gender gender; @@ -29,13 +31,4 @@ public class CreateUserEssentialProfileReq { LanguageName languageName5; LanguageLevel languageLevel5; - - public static User toEntityUser(CreateUserEssentialProfileReq createUserEssentialProfileReq){ - return User.builder() - .name(createUserEssentialProfileReq.getUserName()) - .age(createUserEssentialProfileReq.getUserAge()) - .gender(createUserEssentialProfileReq.getGender()) - .nationality(createUserEssentialProfileReq.getNationality()) - .build(); - } } diff --git a/server/src/main/java/com/yogit/server/user/dto/request/CreateUserReq.java b/server/src/main/java/com/yogit/server/user/dto/request/CreateUserReq.java new file mode 100644 index 0000000..853c756 --- /dev/null +++ b/server/src/main/java/com/yogit/server/user/dto/request/CreateUserReq.java @@ -0,0 +1,20 @@ +package com.yogit.server.user.dto.request; + +import com.yogit.server.user.entity.User; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class CreateUserReq { + + String loginId; + + public static User toEntityUser(CreateUserReq createUserReq){ + return User.builder() + .loginId(createUserReq.getLoginId()) + .build(); + } +} 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 258589a..5581726 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 @@ -70,13 +70,8 @@ public class User extends BaseEntity { private List userImages = new ArrayList<>(); @Builder - public User (String name, int age, Gender gender, Nationality nationality){ - this.name = name; - this.age = age; - this.memberTemp = 0; - this.gender = gender; - this.nationality = nationality; - this.userStatus = UserStatus.ACTIVE; + public User (String loginId){ + this.loginId = loginId; } public void addLanguage(Language language){ diff --git a/server/src/main/java/com/yogit/server/user/exception/UserDuplicationLoginId.java b/server/src/main/java/com/yogit/server/user/exception/UserDuplicationLoginId.java new file mode 100644 index 0000000..a7f2efe --- /dev/null +++ b/server/src/main/java/com/yogit/server/user/exception/UserDuplicationLoginId.java @@ -0,0 +1,9 @@ +package com.yogit.server.user.exception; + +import static com.yogit.server.user.exception.UserExceptionList.DUPLICATE_LOGIN_ID; + +public class UserDuplicationLoginId extends UserException { + public UserDuplicationLoginId() { + super(DUPLICATE_LOGIN_ID.getCODE(), DUPLICATE_LOGIN_ID.getHTTPSTATUS(), DUPLICATE_LOGIN_ID.getMESSAGE()); + } +} diff --git a/server/src/main/java/com/yogit/server/user/exception/UserExceptionList.java b/server/src/main/java/com/yogit/server/user/exception/UserExceptionList.java index c2acfb0..f17b24f 100644 --- a/server/src/main/java/com/yogit/server/user/exception/UserExceptionList.java +++ b/server/src/main/java/com/yogit/server/user/exception/UserExceptionList.java @@ -11,7 +11,8 @@ @RequiredArgsConstructor public enum UserExceptionList { - NOT_FOUND_ID("U0001", NOT_FOUND,"존재하지 않는 아이디입니다."); + NOT_FOUND_ID("U0001", NOT_FOUND,"존재하지 않는 아이디입니다."), + DUPLICATE_LOGIN_ID("U0002", CONFLICT,"이미 존재하는 아이디입니다."); private final String CODE; private final HttpStatus HTTPSTATUS; diff --git a/server/src/main/java/com/yogit/server/user/repository/UserRepository.java b/server/src/main/java/com/yogit/server/user/repository/UserRepository.java index da70705..f0bcd93 100644 --- a/server/src/main/java/com/yogit/server/user/repository/UserRepository.java +++ b/server/src/main/java/com/yogit/server/user/repository/UserRepository.java @@ -4,4 +4,5 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface UserRepository extends JpaRepository { + boolean existsByLoginId(String loginId); } diff --git a/server/src/main/java/com/yogit/server/user/service/UserService.java b/server/src/main/java/com/yogit/server/user/service/UserService.java index d5f3cc6..16f2093 100644 --- a/server/src/main/java/com/yogit/server/user/service/UserService.java +++ b/server/src/main/java/com/yogit/server/user/service/UserService.java @@ -1,10 +1,7 @@ package com.yogit.server.user.service; import com.yogit.server.global.dto.ApplicationResponse; -import com.yogit.server.user.dto.request.AddUserAdditionalProfileReq; -import com.yogit.server.user.dto.request.CreateUserEssentialProfileReq; -import com.yogit.server.user.dto.request.CreateUserImageReq; -import com.yogit.server.user.dto.request.EditUserEssentialProfileReq; +import com.yogit.server.user.dto.request.*; import com.yogit.server.user.dto.response.UserAdditionalProfileRes; import com.yogit.server.user.dto.response.UserImagesRes; import com.yogit.server.user.dto.response.UserProfileRes; @@ -21,4 +18,6 @@ public interface UserService { ApplicationResponse enterUserImage(CreateUserImageReq createUserImageReq); ApplicationResponse enterAdditionalProfile(AddUserAdditionalProfileReq addUserAdditionalProfileReq); + + ApplicationResponse createUser(CreateUserReq createUserReq); } diff --git a/server/src/main/java/com/yogit/server/user/service/UserServiceImpl.java b/server/src/main/java/com/yogit/server/user/service/UserServiceImpl.java index 91d8dbd..8f14522 100644 --- a/server/src/main/java/com/yogit/server/user/service/UserServiceImpl.java +++ b/server/src/main/java/com/yogit/server/user/service/UserServiceImpl.java @@ -2,15 +2,13 @@ import com.yogit.server.global.dto.ApplicationResponse; import com.yogit.server.s3.AwsS3Service; -import com.yogit.server.user.dto.request.AddUserAdditionalProfileReq; -import com.yogit.server.user.dto.request.CreateUserEssentialProfileReq; -import com.yogit.server.user.dto.request.CreateUserImageReq; -import com.yogit.server.user.dto.request.EditUserEssentialProfileReq; +import com.yogit.server.user.dto.request.*; import com.yogit.server.user.dto.response.UserAdditionalProfileRes; import com.yogit.server.user.dto.response.UserImagesRes; import com.yogit.server.user.dto.response.UserProfileRes; import com.yogit.server.user.entity.*; import com.yogit.server.user.exception.NotFoundUserException; +import com.yogit.server.user.exception.UserDuplicationLoginId; import com.yogit.server.user.repository.*; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -35,7 +33,7 @@ public class UserServiceImpl implements UserService { @Override public ApplicationResponse enterEssentialProfile(CreateUserEssentialProfileReq createUserEssentialProfileReq){ - User user = userRepository.save(createUserEssentialProfileReq.toEntityUser(createUserEssentialProfileReq)); + User user = userRepository.findById(createUserEssentialProfileReq.getUserId()).orElseThrow(); UserProfileRes userProfileRes = UserProfileRes.create(user); @@ -248,9 +246,17 @@ public ApplicationResponse enterAdditionalProfile(AddU userAdditionalProfileRes.getInterests().add(interestName); } + return ApplicationResponse.ok(userAdditionalProfileRes); + } + @Override + @Transactional + public ApplicationResponse createUser(CreateUserReq createUserReq){ + if(userRepository.existsByLoginId(createUserReq.getLoginId())) throw new UserDuplicationLoginId(); - return ApplicationResponse.ok(userAdditionalProfileRes); + userRepository.save(createUserReq.toEntityUser(createUserReq)); + + return ApplicationResponse.ok(); } } From a7493345c1140749125a72c41ca2f5aee9937a26 Mon Sep 17 00:00:00 2001 From: shinhn Date: Fri, 28 Oct 2022 22:49:37 +0900 Subject: [PATCH 4/4] =?UTF-8?q?#24=20fix:=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20api=EB=A5=BC=20=EB=94=B0=EB=A1=9C=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=ED=95=9C=20=EA=B4=80=EA=B3=84=EB=A1=9C,=20=ED=95=84?= =?UTF-8?q?=EC=88=98=EC=A0=95=EB=B3=B4=20api=EB=A5=BC=20PATCH=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20language=20=EB=A5=BC=20list=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yogit/server/config/SwaggerConfig.java | 7 - .../user/controller/UserController.java | 40 +-- .../CreateUserEssentialProfileReq.java | 21 +- .../request/EditUserEssentialProfileReq.java | 28 +-- .../dto/response/UserEssentialProfileRes.java | 44 ++++ .../user/dto/response/UserProfileRes.java | 42 +--- .../com/yogit/server/user/entity/City.java | 2 +- .../yogit/server/user/entity/CountryCode.java | 2 +- .../yogit/server/user/entity/Interest.java | 2 +- .../yogit/server/user/entity/Language.java | 10 +- .../server/user/entity/LanguageLevel.java | 9 - .../server/user/entity/LanguageName.java | 10 - .../com/yogit/server/user/entity/User.java | 24 +- .../yogit/server/user/entity/UserImage.java | 2 +- .../server/user/entity/UserInterest.java | 2 +- .../server/user/service/UserService.java | 13 +- .../server/user/service/UserServiceImpl.java | 230 ++++++++---------- 17 files changed, 215 insertions(+), 273 deletions(-) create mode 100644 server/src/main/java/com/yogit/server/user/dto/response/UserEssentialProfileRes.java delete mode 100644 server/src/main/java/com/yogit/server/user/entity/LanguageLevel.java delete mode 100644 server/src/main/java/com/yogit/server/user/entity/LanguageName.java diff --git a/server/src/main/java/com/yogit/server/config/SwaggerConfig.java b/server/src/main/java/com/yogit/server/config/SwaggerConfig.java index 23ca3c2..9e7538b 100644 --- a/server/src/main/java/com/yogit/server/config/SwaggerConfig.java +++ b/server/src/main/java/com/yogit/server/config/SwaggerConfig.java @@ -1,20 +1,13 @@ package com.yogit.server.config; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.*; import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.contexts.SecurityContext; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; -import java.util.Arrays; -import java.util.List; - @Configuration @EnableSwagger2// 기능을 활성화하는 어노테이션입니다. SwaggerConfig.java 가 아니라 어플리케이션에 추가해도 동작합니다. public class SwaggerConfig { diff --git a/server/src/main/java/com/yogit/server/user/controller/UserController.java b/server/src/main/java/com/yogit/server/user/controller/UserController.java index f4ea6cc..116219f 100644 --- a/server/src/main/java/com/yogit/server/user/controller/UserController.java +++ b/server/src/main/java/com/yogit/server/user/controller/UserController.java @@ -1,13 +1,14 @@ package com.yogit.server.user.controller; import com.yogit.server.global.dto.ApplicationResponse; -import com.yogit.server.user.dto.request.*; +import com.yogit.server.user.dto.request.AddUserAdditionalProfileReq; +import com.yogit.server.user.dto.request.CreateUserEssentialProfileReq; +import com.yogit.server.user.dto.request.CreateUserImageReq; +import com.yogit.server.user.dto.request.CreateUserReq; import com.yogit.server.user.dto.response.UserAdditionalProfileRes; +import com.yogit.server.user.dto.response.UserEssentialProfileRes; import com.yogit.server.user.dto.response.UserImagesRes; -import com.yogit.server.user.dto.response.UserProfileRes; import com.yogit.server.user.entity.Gender; -import com.yogit.server.user.entity.LanguageLevel; -import com.yogit.server.user.entity.LanguageName; import com.yogit.server.user.entity.Nationality; import com.yogit.server.user.service.UserService; import io.swagger.annotations.Api; @@ -33,13 +34,12 @@ public class UserController { @ApiImplicitParams({ @ApiImplicitParam(name = "userName", required = true, dataTypeClass = String.class), @ApiImplicitParam(name = "userAge", required = true, dataTypeClass = int.class, example = "0"), + @ApiImplicitParam(name = "userId", required = true, dataTypeClass = Long.class, example = "0"), @ApiImplicitParam(name = "gender", required = true, dataTypeClass = Gender.class), - @ApiImplicitParam(name = "nationality", required = true, dataTypeClass = Nationality.class), - @ApiImplicitParam(name = "languageName1", required = true, dataTypeClass = LanguageName.class), - @ApiImplicitParam(name = "languageLevel1", required = true, dataTypeClass = LanguageLevel.class) + @ApiImplicitParam(name = "nationality", required = true, dataTypeClass = Nationality.class) }) @PatchMapping("/essential-profile") - public ApplicationResponse enterEssentialProfile(@ModelAttribute CreateUserEssentialProfileReq createUserEssentialProfileReq){ + public ApplicationResponse enterEssentialProfile(@ModelAttribute CreateUserEssentialProfileReq createUserEssentialProfileReq){ return userService.enterEssentialProfile(createUserEssentialProfileReq); } @@ -47,23 +47,23 @@ public ApplicationResponse enterEssentialProfile(@ModelAttribute * 유저 필수 정보 수정 * @author 강신현 */ - @ApiOperation(value = "유저 필수 정보 수정", notes = "수정할 정보들만 입력해주세요, Language 중에 하나라도 변경사항이 있다면 유저의 모든 Language 를 입력하여 요청해주세요") - @ApiImplicitParam(name = "userId", required = true, dataTypeClass = Long.class, example = "0") - @PatchMapping("/edit-essential-profile") - public ApplicationResponse editEssentialProfile(@ModelAttribute EditUserEssentialProfileReq editUserEssentialProfileReq){ - return userService.editEssentialProfile(editUserEssentialProfileReq); - } +// @ApiOperation(value = "유저 필수 정보 수정", notes = "수정할 정보들만 입력해주세요, Language 중에 하나라도 변경사항이 있다면 유저의 모든 Language 를 입력하여 요청해주세요") +// @ApiImplicitParam(name = "userId", required = true, dataTypeClass = Long.class, example = "0") +// @PatchMapping("/edit-essential-profile") +// public ApplicationResponse editEssentialProfile(@ModelAttribute EditUserEssentialProfileReq editUserEssentialProfileReq){ +// return userService.editEssentialProfile(editUserEssentialProfileReq); +// } /** * 유저 Profile 조회 * @author 강신현 */ - @ApiOperation(value = "유저 Profile 조회") - @ApiImplicitParam(name = "userId", required = true, dataTypeClass = Long.class, example = "0") - @GetMapping("/prifile/{userId}") - public ApplicationResponse getProfile(@PathVariable Long userId){ - return userService.getProfile(userId); - } +// @ApiOperation(value = "유저 Profile 조회") +// @ApiImplicitParam(name = "userId", required = true, dataTypeClass = Long.class, example = "0") +// @GetMapping("/prifile/{userId}") +// public ApplicationResponse getProfile(@PathVariable Long userId){ +// return userService.getProfile(userId); +// } /** * 유저 Profile 삭제 diff --git a/server/src/main/java/com/yogit/server/user/dto/request/CreateUserEssentialProfileReq.java b/server/src/main/java/com/yogit/server/user/dto/request/CreateUserEssentialProfileReq.java index 3d8d7d1..6a7319e 100644 --- a/server/src/main/java/com/yogit/server/user/dto/request/CreateUserEssentialProfileReq.java +++ b/server/src/main/java/com/yogit/server/user/dto/request/CreateUserEssentialProfileReq.java @@ -1,10 +1,13 @@ package com.yogit.server.user.dto.request; -import com.yogit.server.user.entity.*; +import com.yogit.server.user.entity.Gender; +import com.yogit.server.user.entity.Nationality; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + @NoArgsConstructor @AllArgsConstructor @Data @@ -17,18 +20,6 @@ public class CreateUserEssentialProfileReq { Gender gender; Nationality nationality; - LanguageName languageName1; - LanguageLevel languageLevel1; - - LanguageName languageName2; - LanguageLevel languageLevel2; - - LanguageName languageName3; - LanguageLevel languageLevel3; - - LanguageName languageName4; - LanguageLevel languageLevel4; - - LanguageName languageName5; - LanguageLevel languageLevel5; + List languageNames; + List languageLevels; } diff --git a/server/src/main/java/com/yogit/server/user/dto/request/EditUserEssentialProfileReq.java b/server/src/main/java/com/yogit/server/user/dto/request/EditUserEssentialProfileReq.java index 23762a9..f2d3de9 100644 --- a/server/src/main/java/com/yogit/server/user/dto/request/EditUserEssentialProfileReq.java +++ b/server/src/main/java/com/yogit/server/user/dto/request/EditUserEssentialProfileReq.java @@ -17,18 +17,18 @@ public class EditUserEssentialProfileReq { Gender gender; Nationality nationality; - LanguageName languageName1; - LanguageLevel languageLevel1; - - LanguageName languageName2; - LanguageLevel languageLevel2; - - LanguageName languageName3; - LanguageLevel languageLevel3; - - LanguageName languageName4; - LanguageLevel languageLevel4; - - LanguageName languageName5; - LanguageLevel languageLevel5; +// LanguageName languageName1; +// LanguageLevel languageLevel1; +// +// LanguageName languageName2; +// LanguageLevel languageLevel2; +// +// LanguageName languageName3; +// LanguageLevel languageLevel3; +// +// LanguageName languageName4; +// LanguageLevel languageLevel4; +// +// LanguageName languageName5; +// LanguageLevel languageLevel5; } diff --git a/server/src/main/java/com/yogit/server/user/dto/response/UserEssentialProfileRes.java b/server/src/main/java/com/yogit/server/user/dto/response/UserEssentialProfileRes.java new file mode 100644 index 0000000..80434d1 --- /dev/null +++ b/server/src/main/java/com/yogit/server/user/dto/response/UserEssentialProfileRes.java @@ -0,0 +1,44 @@ +package com.yogit.server.user.dto.response; + +import com.yogit.server.user.dto.request.CreateUserEssentialProfileReq; +import com.yogit.server.user.entity.Gender; +import com.yogit.server.user.entity.Nationality; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class UserEssentialProfileRes { + + Long userId; + + String userName; + Integer userAge; + Gender gender; + Nationality nationality; + + List languageNames = new ArrayList<>(); + List languageLevels = new ArrayList<>(); + + public static UserEssentialProfileRes create(CreateUserEssentialProfileReq createUserEssentialProfileReq){ + UserEssentialProfileRes userEssentialProfileRes = new UserEssentialProfileRes(); + + userEssentialProfileRes.userId = createUserEssentialProfileReq.getUserId(); + userEssentialProfileRes.userName = createUserEssentialProfileReq.getUserName(); + userEssentialProfileRes.userAge = createUserEssentialProfileReq.getUserAge(); + userEssentialProfileRes.gender = createUserEssentialProfileReq.getGender(); + userEssentialProfileRes.nationality = createUserEssentialProfileReq.getNationality(); + + return userEssentialProfileRes; + } + + public void addLanguage(String languageName, String languageLevel){ + this.languageNames.add(languageName); + this.languageLevels.add(languageLevel); + } +} diff --git a/server/src/main/java/com/yogit/server/user/dto/response/UserProfileRes.java b/server/src/main/java/com/yogit/server/user/dto/response/UserProfileRes.java index 0932caa..6fa7c58 100644 --- a/server/src/main/java/com/yogit/server/user/dto/response/UserProfileRes.java +++ b/server/src/main/java/com/yogit/server/user/dto/response/UserProfileRes.java @@ -1,6 +1,8 @@ package com.yogit.server.user.dto.response; -import com.yogit.server.user.entity.*; +import com.yogit.server.user.entity.Gender; +import com.yogit.server.user.entity.Nationality; +import com.yogit.server.user.entity.User; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -23,21 +25,6 @@ public class UserProfileRes { // String login_id; //TODO // String pass_word; //TODO - LanguageName languageName1; - LanguageLevel languageLevel1; - - LanguageName languageName2; - LanguageLevel languageLevel2; - - LanguageName languageName3; - LanguageLevel languageLevel3; - - LanguageName languageName4; - LanguageLevel languageLevel4; - - LanguageName languageName5; - LanguageLevel languageLevel5; - public static UserProfileRes create(User user){ UserProfileRes userProfileRes = new UserProfileRes(); @@ -52,27 +39,4 @@ public static UserProfileRes create(User user){ return userProfileRes; } - - public void addLanguage(Language language){ - if(this.languageName1 == null){ - this.languageName1 = language.getName(); - this.languageLevel1 = language.getLevel(); - } - else if(this.languageName2 == null){ - this.languageName2 = language.getName(); - this.languageLevel2 = language.getLevel(); - } - else if(this.languageName3 == null){ - this.languageName3 = language.getName(); - this.languageLevel3 = language.getLevel(); - } - else if(this.languageName4 == null){ - this.languageName4 = language.getName(); - this.languageLevel4 = language.getLevel(); - } - else{ - this.languageName5 = language.getName(); - this.languageLevel5 = language.getLevel(); - } - } } diff --git a/server/src/main/java/com/yogit/server/user/entity/City.java b/server/src/main/java/com/yogit/server/user/entity/City.java index 8c4bf20..ad5bcc7 100644 --- a/server/src/main/java/com/yogit/server/user/entity/City.java +++ b/server/src/main/java/com/yogit/server/user/entity/City.java @@ -17,7 +17,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class City extends BaseEntity { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "city_id") private Long id; diff --git a/server/src/main/java/com/yogit/server/user/entity/CountryCode.java b/server/src/main/java/com/yogit/server/user/entity/CountryCode.java index 18dbe9d..9111601 100644 --- a/server/src/main/java/com/yogit/server/user/entity/CountryCode.java +++ b/server/src/main/java/com/yogit/server/user/entity/CountryCode.java @@ -12,7 +12,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class CountryCode extends BaseEntity { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "country_code_id") private Long id; diff --git a/server/src/main/java/com/yogit/server/user/entity/Interest.java b/server/src/main/java/com/yogit/server/user/entity/Interest.java index 4ddb9a2..2ec88c6 100644 --- a/server/src/main/java/com/yogit/server/user/entity/Interest.java +++ b/server/src/main/java/com/yogit/server/user/entity/Interest.java @@ -15,7 +15,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Interest extends BaseEntity { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "interest_id") private Long id; diff --git a/server/src/main/java/com/yogit/server/user/entity/Language.java b/server/src/main/java/com/yogit/server/user/entity/Language.java index 3f9fec0..96fa2cf 100644 --- a/server/src/main/java/com/yogit/server/user/entity/Language.java +++ b/server/src/main/java/com/yogit/server/user/entity/Language.java @@ -10,21 +10,19 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Language extends BaseEntity { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "language_id") private Long id; @ManyToOne(fetch = FetchType.LAZY) private User user; - @Enumerated(EnumType.STRING) - private LanguageName name; + private String name; - @Enumerated(EnumType.STRING) - private LanguageLevel level; + private String level; @Builder - public Language (User user, LanguageName name, LanguageLevel level){ + public Language (User user, String name, String level){ this.name = name; this.level = level; diff --git a/server/src/main/java/com/yogit/server/user/entity/LanguageLevel.java b/server/src/main/java/com/yogit/server/user/entity/LanguageLevel.java deleted file mode 100644 index 92d3559..0000000 --- a/server/src/main/java/com/yogit/server/user/entity/LanguageLevel.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.yogit.server.user.entity; - -public enum LanguageLevel { - Beginner, - Elementary, - Intermediate, - Fluent, - Native, -} diff --git a/server/src/main/java/com/yogit/server/user/entity/LanguageName.java b/server/src/main/java/com/yogit/server/user/entity/LanguageName.java deleted file mode 100644 index 3bd8d1d..0000000 --- a/server/src/main/java/com/yogit/server/user/entity/LanguageName.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.yogit.server.user.entity; - -import io.swagger.annotations.ApiModel; - -public enum LanguageName { - Korean, - English, - Japanese, - Chinese -} 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 5581726..75a9f05 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 @@ -1,12 +1,16 @@ package com.yogit.server.user.entity; -import com.yogit.server.board.entity.*; +import com.yogit.server.board.entity.BoardUser; +import com.yogit.server.board.entity.BookMark; +import com.yogit.server.board.entity.ClipBoard; +import com.yogit.server.board.entity.Comment; import com.yogit.server.config.domain.BaseEntity; -import com.yogit.server.user.dto.request.EditUserEssentialProfileReq; -import lombok.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; import javax.persistence.*; - import java.util.ArrayList; import java.util.List; @@ -16,7 +20,7 @@ public class User extends BaseEntity { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "user_id") private Long id; @@ -78,11 +82,11 @@ public void addLanguage(Language language){ this.languages.add(language); } - public void changeUserInfo(EditUserEssentialProfileReq editUserEssentialProfileReq){ - if(editUserEssentialProfileReq.getUserName() != null) this.name = editUserEssentialProfileReq.getUserName(); - if(editUserEssentialProfileReq.getUserAge() != null) this.age = editUserEssentialProfileReq.getUserAge(); - if(editUserEssentialProfileReq.getGender() != null) this.gender = editUserEssentialProfileReq.getGender(); - if(editUserEssentialProfileReq.getNationality() != null) this.nationality = editUserEssentialProfileReq.getNationality(); + 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; } public void delUser(){ diff --git a/server/src/main/java/com/yogit/server/user/entity/UserImage.java b/server/src/main/java/com/yogit/server/user/entity/UserImage.java index bd15702..2b94e62 100644 --- a/server/src/main/java/com/yogit/server/user/entity/UserImage.java +++ b/server/src/main/java/com/yogit/server/user/entity/UserImage.java @@ -13,7 +13,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class UserImage extends BaseEntity { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "user_image_id") private Long id; diff --git a/server/src/main/java/com/yogit/server/user/entity/UserInterest.java b/server/src/main/java/com/yogit/server/user/entity/UserInterest.java index 28061a2..2392aa6 100644 --- a/server/src/main/java/com/yogit/server/user/entity/UserInterest.java +++ b/server/src/main/java/com/yogit/server/user/entity/UserInterest.java @@ -13,7 +13,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class UserInterest extends BaseEntity { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "user_interest_id") private Long id; diff --git a/server/src/main/java/com/yogit/server/user/service/UserService.java b/server/src/main/java/com/yogit/server/user/service/UserService.java index 16f2093..35229b2 100644 --- a/server/src/main/java/com/yogit/server/user/service/UserService.java +++ b/server/src/main/java/com/yogit/server/user/service/UserService.java @@ -1,17 +1,20 @@ package com.yogit.server.user.service; import com.yogit.server.global.dto.ApplicationResponse; -import com.yogit.server.user.dto.request.*; +import com.yogit.server.user.dto.request.AddUserAdditionalProfileReq; +import com.yogit.server.user.dto.request.CreateUserEssentialProfileReq; +import com.yogit.server.user.dto.request.CreateUserImageReq; +import com.yogit.server.user.dto.request.CreateUserReq; import com.yogit.server.user.dto.response.UserAdditionalProfileRes; +import com.yogit.server.user.dto.response.UserEssentialProfileRes; import com.yogit.server.user.dto.response.UserImagesRes; -import com.yogit.server.user.dto.response.UserProfileRes; public interface UserService { - ApplicationResponse enterEssentialProfile(CreateUserEssentialProfileReq createUserEssentialProfileReq); + ApplicationResponse enterEssentialProfile(CreateUserEssentialProfileReq createUserEssentialProfileReq); - ApplicationResponse editEssentialProfile(EditUserEssentialProfileReq editUserEssentialProfileReq); + //ApplicationResponse editEssentialProfile(EditUserEssentialProfileReq editUserEssentialProfileReq); - ApplicationResponse getProfile(Long userId); + //ApplicationResponse getProfile(Long userId); ApplicationResponse delProfile(Long userId); diff --git a/server/src/main/java/com/yogit/server/user/service/UserServiceImpl.java b/server/src/main/java/com/yogit/server/user/service/UserServiceImpl.java index 8f14522..a6657f0 100644 --- a/server/src/main/java/com/yogit/server/user/service/UserServiceImpl.java +++ b/server/src/main/java/com/yogit/server/user/service/UserServiceImpl.java @@ -2,10 +2,13 @@ import com.yogit.server.global.dto.ApplicationResponse; import com.yogit.server.s3.AwsS3Service; -import com.yogit.server.user.dto.request.*; +import com.yogit.server.user.dto.request.AddUserAdditionalProfileReq; +import com.yogit.server.user.dto.request.CreateUserEssentialProfileReq; +import com.yogit.server.user.dto.request.CreateUserImageReq; +import com.yogit.server.user.dto.request.CreateUserReq; import com.yogit.server.user.dto.response.UserAdditionalProfileRes; +import com.yogit.server.user.dto.response.UserEssentialProfileRes; import com.yogit.server.user.dto.response.UserImagesRes; -import com.yogit.server.user.dto.response.UserProfileRes; import com.yogit.server.user.entity.*; import com.yogit.server.user.exception.NotFoundUserException; import com.yogit.server.user.exception.UserDuplicationLoginId; @@ -31,149 +34,110 @@ public class UserServiceImpl implements UserService { @Transactional @Override - public ApplicationResponse enterEssentialProfile(CreateUserEssentialProfileReq createUserEssentialProfileReq){ + public ApplicationResponse enterEssentialProfile(CreateUserEssentialProfileReq createUserEssentialProfileReq){ User user = userRepository.findById(createUserEssentialProfileReq.getUserId()).orElseThrow(); + user.changeUserInfo(createUserEssentialProfileReq.getUserName(), createUserEssentialProfileReq.getUserAge(), createUserEssentialProfileReq.getGender(), createUserEssentialProfileReq.getNationality()); - UserProfileRes userProfileRes = UserProfileRes.create(user); + UserEssentialProfileRes userEssentialProfileRes = UserEssentialProfileRes.create(createUserEssentialProfileReq); - // language 추가 - if(createUserEssentialProfileReq.getLanguageName1() != null && createUserEssentialProfileReq.getLanguageLevel1() != null){ + for(int i=0;i < createUserEssentialProfileReq.getLanguageNames().size(); i++){ Language language = Language.builder() .user(user) - .name(createUserEssentialProfileReq.getLanguageName1()) - .level(createUserEssentialProfileReq.getLanguageLevel1()) + .name(createUserEssentialProfileReq.getLanguageNames().get(i)) + .level(createUserEssentialProfileReq.getLanguageLevels().get(i)) .build(); languageRepository.save(language); - userProfileRes.addLanguage(language); - } - - if(createUserEssentialProfileReq.getLanguageName2() != null && createUserEssentialProfileReq.getLanguageLevel2() != null){ - Language language = Language.builder() - .user(user) - .name(createUserEssentialProfileReq.getLanguageName2()) - .level(createUserEssentialProfileReq.getLanguageLevel2()) - .build(); - languageRepository.save(language); - userProfileRes.addLanguage(language); - } - - if(createUserEssentialProfileReq.getLanguageName3() != null && createUserEssentialProfileReq.getLanguageLevel3() != null){ - Language language = Language.builder() - .user(user) - .name(createUserEssentialProfileReq.getLanguageName3()) - .level(createUserEssentialProfileReq.getLanguageLevel3()) - .build(); - languageRepository.save(language); - userProfileRes.addLanguage(language); - } - - if(createUserEssentialProfileReq.getLanguageName4() != null && createUserEssentialProfileReq.getLanguageLevel4() != null){ - Language language = Language.builder() - .user(user) - .name(createUserEssentialProfileReq.getLanguageName4()) - .level(createUserEssentialProfileReq.getLanguageLevel4()) - .build(); - languageRepository.save(language); - userProfileRes.addLanguage(language); - } - - if(createUserEssentialProfileReq.getLanguageName5() != null && createUserEssentialProfileReq.getLanguageLevel5() != null){ - Language language = Language.builder() - .user(user) - .name(createUserEssentialProfileReq.getLanguageName5()) - .level(createUserEssentialProfileReq.getLanguageLevel5()) - .build(); - languageRepository.save(language); - userProfileRes.addLanguage(language); - } - - return ApplicationResponse.create("created", userProfileRes); - } - @Transactional - @Override - public ApplicationResponse editEssentialProfile(EditUserEssentialProfileReq editUserEssentialProfileReq){ - - User user = userRepository.findById(editUserEssentialProfileReq.getUserId()).orElseThrow(NotFoundUserException::new); - user.changeUserInfo(editUserEssentialProfileReq); - - UserProfileRes userProfileRes = UserProfileRes.create(user); - - if(editUserEssentialProfileReq.getLanguageName1() != null){ - // 기존 language 들 삭제 - languageRepository.deleteAllByUserId(user.getId()); - - // language 추가 - if(editUserEssentialProfileReq.getLanguageName1() != null && editUserEssentialProfileReq.getLanguageLevel1() != null){ - Language language = Language.builder() - .user(user) - .name(editUserEssentialProfileReq.getLanguageName1()) - .level(editUserEssentialProfileReq.getLanguageLevel1()) - .build(); - languageRepository.save(language); - userProfileRes.addLanguage(language); - } - - if(editUserEssentialProfileReq.getLanguageName2() != null && editUserEssentialProfileReq.getLanguageLevel2() != null){ - Language language = Language.builder() - .user(user) - .name(editUserEssentialProfileReq.getLanguageName2()) - .level(editUserEssentialProfileReq.getLanguageLevel2()) - .build(); - languageRepository.save(language); - userProfileRes.addLanguage(language); - } - - if(editUserEssentialProfileReq.getLanguageName3() != null && editUserEssentialProfileReq.getLanguageLevel3() != null){ - Language language = Language.builder() - .user(user) - .name(editUserEssentialProfileReq.getLanguageName3()) - .level(editUserEssentialProfileReq.getLanguageLevel3()) - .build(); - languageRepository.save(language); - userProfileRes.addLanguage(language); - } - - if(editUserEssentialProfileReq.getLanguageName4() != null && editUserEssentialProfileReq.getLanguageLevel4() != null){ - Language language = Language.builder() - .user(user) - .name(editUserEssentialProfileReq.getLanguageName4()) - .level(editUserEssentialProfileReq.getLanguageLevel4()) - .build(); - languageRepository.save(language); - userProfileRes.addLanguage(language); - } - - if(editUserEssentialProfileReq.getLanguageName5() != null && editUserEssentialProfileReq.getLanguageLevel5() != null){ - Language language = Language.builder() - .user(user) - .name(editUserEssentialProfileReq.getLanguageName5()) - .level(editUserEssentialProfileReq.getLanguageLevel5()) - .build(); - languageRepository.save(language); - userProfileRes.addLanguage(language); - } + userEssentialProfileRes.addLanguage(createUserEssentialProfileReq.getLanguageNames().get(i), createUserEssentialProfileReq.getLanguageLevels().get(i)); } - return ApplicationResponse.ok(userProfileRes); + return ApplicationResponse.create("created", userEssentialProfileRes); } - @Override - public ApplicationResponse getProfile(Long userId){ - User user = userRepository.findById(userId).orElseThrow(NotFoundUserException::new); - - UserProfileRes userProfileRes = UserProfileRes.create(user); - - List languages = languageRepository.findAllByUserId(userId); - if(!languages.isEmpty()){ - for(Language l : languages){ - userProfileRes.addLanguage(l); - } - } - - return ApplicationResponse.ok(userProfileRes); - } +// @Transactional +// @Override +// public ApplicationResponse editEssentialProfile(EditUserEssentialProfileReq editUserEssentialProfileReq){ +// +// User user = userRepository.findById(editUserEssentialProfileReq.getUserId()).orElseThrow(NotFoundUserException::new); +// user.changeUserInfo(editUserEssentialProfileReq); +// +// UserProfileRes userProfileRes = UserProfileRes.create(user); +// +// if(editUserEssentialProfileReq.getLanguageName1() != null){ +// // 기존 language 들 삭제 +// languageRepository.deleteAllByUserId(user.getId()); +// +// // language 추가 +// if(editUserEssentialProfileReq.getLanguageName1() != null && editUserEssentialProfileReq.getLanguageLevel1() != null){ +// Language language = Language.builder() +// .user(user) +// .name(editUserEssentialProfileReq.getLanguageName1()) +// .level(editUserEssentialProfileReq.getLanguageLevel1()) +// .build(); +// languageRepository.save(language); +// userProfileRes.addLanguage(language); +// } +// +// if(editUserEssentialProfileReq.getLanguageName2() != null && editUserEssentialProfileReq.getLanguageLevel2() != null){ +// Language language = Language.builder() +// .user(user) +// .name(editUserEssentialProfileReq.getLanguageName2()) +// .level(editUserEssentialProfileReq.getLanguageLevel2()) +// .build(); +// languageRepository.save(language); +// userProfileRes.addLanguage(language); +// } +// +// if(editUserEssentialProfileReq.getLanguageName3() != null && editUserEssentialProfileReq.getLanguageLevel3() != null){ +// Language language = Language.builder() +// .user(user) +// .name(editUserEssentialProfileReq.getLanguageName3()) +// .level(editUserEssentialProfileReq.getLanguageLevel3()) +// .build(); +// languageRepository.save(language); +// userProfileRes.addLanguage(language); +// } +// +// if(editUserEssentialProfileReq.getLanguageName4() != null && editUserEssentialProfileReq.getLanguageLevel4() != null){ +// Language language = Language.builder() +// .user(user) +// .name(editUserEssentialProfileReq.getLanguageName4()) +// .level(editUserEssentialProfileReq.getLanguageLevel4()) +// .build(); +// languageRepository.save(language); +// userProfileRes.addLanguage(language); +// } +// +// if(editUserEssentialProfileReq.getLanguageName5() != null && editUserEssentialProfileReq.getLanguageLevel5() != null){ +// Language language = Language.builder() +// .user(user) +// .name(editUserEssentialProfileReq.getLanguageName5()) +// .level(editUserEssentialProfileReq.getLanguageLevel5()) +// .build(); +// languageRepository.save(language); +// userProfileRes.addLanguage(language); +// } +// } +// +// return ApplicationResponse.ok(userProfileRes); +// } + +// @Override +// public ApplicationResponse getProfile(Long userId){ +// User user = userRepository.findById(userId).orElseThrow(NotFoundUserException::new); +// +// UserProfileRes userProfileRes = UserProfileRes.create(user); +// +// List languages = languageRepository.findAllByUserId(userId); +// if(!languages.isEmpty()){ +// for(Language l : languages){ +// userProfileRes.addLanguage(l); +// } +// } +// +// return ApplicationResponse.ok(userProfileRes); +// } @Override @Transactional @@ -255,7 +219,7 @@ public ApplicationResponse createUser(CreateUserReq createUserReq){ if(userRepository.existsByLoginId(createUserReq.getLoginId())) throw new UserDuplicationLoginId(); - userRepository.save(createUserReq.toEntityUser(createUserReq)); + userRepository.save(CreateUserReq.toEntityUser(createUserReq)); return ApplicationResponse.ok(); }