Skip to content

Commit

Permalink
#24 fix: 회원가입 api를 따로 분리한 관계로, 필수정보 api를 PATCH로 변경 및 language 를 list<…
Browse files Browse the repository at this point in the history
…String>로 변경
  • Loading branch information
shinhn committed Oct 28, 2022
1 parent d077bc2 commit a749334
Show file tree
Hide file tree
Showing 17 changed files with 215 additions and 273 deletions.
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
@@ -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;
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)
})
@PatchMapping("/essential-profile")
public ApplicationResponse<UserProfileRes> enterEssentialProfile(@ModelAttribute CreateUserEssentialProfileReq createUserEssentialProfileReq){
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("/edit-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
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<String> languageNames;
List<String> languageLevels;
}
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
10 changes: 4 additions & 6 deletions server/src/main/java/com/yogit/server/user/entity/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

This file was deleted.

This file was deleted.

24 changes: 14 additions & 10 deletions server/src/main/java/com/yogit/server/user/entity/User.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;

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

Expand Down
Loading

0 comments on commit a749334

Please sign in to comment.