Skip to content

Commit

Permalink
refactor(user) : 유저 컬럼 추가 및 리스폰스 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Woongbin06 committed Mar 23, 2024
1 parent 782510e commit d4ece7f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/main/java/com/sickgyun/server/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public class User {
@Embedded
private Contact contact;

private Boolean isGraduated;

private Long cardinal;

@OneToOne(
fetch = FetchType.LAZY,
mappedBy = "writer"
Expand All @@ -52,10 +56,12 @@ public User(String name, String email) {
this.email = email;
}

public User(String name, String email, Contact contact) {
public User(String name, String email, Contact contact, Boolean isGraduated, Long cardinal) {
this.name = name;
this.email = email;
this.contact = contact;
this.isGraduated = isGraduated;
this.cardinal = cardinal;
}

public void update(User user) {
Expand All @@ -67,5 +73,7 @@ public void updateUser(User user) {
this.email = user.getEmail();
this.name = user.getName();
this.contact = user.getContact();
this.isGraduated = user.getIsGraduated();
this.cardinal = user.getCardinal();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
public record UserRequest(
String name,
String email,
Contact contact
Contact contact,
Long cardinal,
Boolean isGraduated
) {

public User toEntity() {
return new User(name, email, contact);
return new User(name, email, contact, isGraduated, cardinal);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.sickgyun.server.user.presentation.dto;

import com.sickgyun.server.user.domain.User;
import com.sickgyun.server.user.domain.value.Contact;

public record UserResponse(
Long id,
String name,
String email,
Contact contact
String phoneNumber,
Boolean isGraduated,
Long cardinal
) {

public static UserResponse from(User user) {
return new UserResponse(user.getId(), user.getName(), user.getEmail(), user.getContact());
return new UserResponse(user.getId(), user.getName(), user.getEmail(), user.getContact().getPhone(),
user.getIsGraduated(), user.getCardinal());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ public User updateUser(User user) {

public void update(User updatableUser, User user) {
updatableUser.updateUser(user);
userRepository.save(updatableUser);
}
}

0 comments on commit d4ece7f

Please sign in to comment.