Skip to content

Commit

Permalink
Merge pull request #25 from YogitTeam/feat/user-login
Browse files Browse the repository at this point in the history
#24 feat: 유저 회원가입 API 기능 구현 및 그로 인한 관련 API 수정
  • Loading branch information
shinhn authored Oct 28, 2022
2 parents d085407 + 80a1dd1 commit e466d1c
Show file tree
Hide file tree
Showing 23 changed files with 279 additions and 297 deletions.
2 changes: 2 additions & 0 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ 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 "-을 제거해주세요.";

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<MessageDTO> messages = new ArrayList<>();
messages.add(new MessageDTO(smsSendReq.getPhoneNum(), "Yogit \n 인증번호: "+certification));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
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.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.entity.Gender;
import com.yogit.server.user.entity.Nationality;
import com.yogit.server.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
Expand All @@ -33,37 +34,36 @@ 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)
})
@PostMapping("/essential-profile")
public ApplicationResponse<UserProfileRes> enterEssentialProfile(@ModelAttribute CreateUserEssentialProfileReq createUserEssentialProfileReq){
@PatchMapping("/essential-profile")
public ApplicationResponse<UserEssentialProfileRes> enterEssentialProfile(@ModelAttribute CreateUserEssentialProfileReq createUserEssentialProfileReq){
return userService.enterEssentialProfile(createUserEssentialProfileReq);
}

/**
* 유저 필수 정보 수정
* @author 강신현
*/
@ApiOperation(value = "유저 필수 정보 수정", notes = "수정할 정보들만 입력해주세요, Language 중에 하나라도 변경사항이 있다면 유저의 모든 Language 를 입력하여 요청해주세요")
@ApiImplicitParam(name = "userId", required = true, dataTypeClass = Long.class, example = "0")
@PatchMapping("/essential-profile")
public ApplicationResponse<UserProfileRes> 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<UserProfileRes> 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<UserProfileRes> 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<UserProfileRes> getProfile(@PathVariable Long userId){
// return userService.getProfile(userId);
// }

/**
* 유저 Profile 삭제
Expand Down Expand Up @@ -97,4 +97,19 @@ public ApplicationResponse<UserImagesRes> enterUserImage(@ModelAttribute CreateU
public ApplicationResponse<UserAdditionalProfileRes> enterAdditionalProfile(@ModelAttribute AddUserAdditionalProfileReq addUserAdditionalProfileReq){
return userService.enterAdditionalProfile(addUserAdditionalProfileReq);
}

/**
* 유저 회원가입 (일반)
*/
@ApiOperation(value = "유저 회원가입", notes = "sms 인증이 완료되어야 회원가입이 가능합니다.")
@ApiImplicitParam(name = "loginId", required = true, dataTypeClass = String.class)
@PostMapping("/join")
public ApplicationResponse<Void> createUser(@ModelAttribute CreateUserReq createUserReq){
return userService.createUser(createUserReq);
}


/**
* 유저 로그인
*/
}
Original file line number Diff line number Diff line change
@@ -1,41 +1,25 @@
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
public class CreateUserEssentialProfileReq {

Long userId;

String userName;
int userAge;
Gender gender;
Nationality nationality;

LanguageName languageName1;
LanguageLevel languageLevel1;

LanguageName languageName2;
LanguageLevel languageLevel2;

LanguageName languageName3;
LanguageLevel languageLevel3;

LanguageName languageName4;
LanguageLevel languageLevel4;

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();
}
List<String> languageNames;
List<String> languageLevels;
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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<String> languageNames = new ArrayList<>();
List<String> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();

Expand All @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading

0 comments on commit e466d1c

Please sign in to comment.