Skip to content

Commit

Permalink
chore: 검증로직 private 메서드화
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekks committed Dec 15, 2024
1 parent c82df53 commit d93ffb0
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions main/src/main/java/org/sopt/makers/crew/main/entity/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,34 +103,70 @@ public UserActivityVO getRecentActivityVO() {
public boolean updateIfChanged(User playgroundUser) {
boolean isUpdated = false;

if (!Objects.equals(this.name, playgroundUser.getName())) {
this.name = playgroundUser.getName();
if (validateAndUpdateName(playgroundUser.getName())) {
isUpdated = true;
}

if (!Objects.equals(this.orgId, playgroundUser.getId())) {
this.orgId = playgroundUser.getId();
if (validateAndUpdateOrgId(playgroundUser.getId())) {
isUpdated = true;
}

if (!Objects.equals(this.activities, playgroundUser.getActivities())) {
this.activities = playgroundUser.getActivities();
if (validateAndUpdateActivities(playgroundUser.getActivities())) {
isUpdated = true;
}

if (!Objects.equals(this.profileImage, playgroundUser.getProfileImage())) {
this.profileImage = playgroundUser.getProfileImage();
if (validateAndUpdateProfileImage(playgroundUser.getProfileImage())) {
isUpdated = true;
}

if (!Objects.equals(this.phone, playgroundUser.getPhone())) {
this.phone = playgroundUser.getPhone();
if (validateAndUpdatePhone(playgroundUser.getPhone())) {
isUpdated = true;
}

return isUpdated;
}

private boolean validateAndUpdateName(String newName) {
if (!Objects.equals(this.name, newName)) {
this.name = newName;
return true;
}
return false;
}

private boolean validateAndUpdateOrgId(Integer newOrgId) {
if (!Objects.equals(this.orgId, newOrgId)) {
this.orgId = newOrgId;
return true;
}
return false;
}

private boolean validateAndUpdateActivities(List<UserActivityVO> newActivities) {
if (!Objects.equals(this.activities, newActivities)) {
this.activities = newActivities;
return true;
}
return false;
}

private boolean validateAndUpdateProfileImage(String newProfileImage) {
if (!Objects.equals(this.profileImage, newProfileImage)) {
this.profileImage = newProfileImage;
return true;
}
return false;
}

private boolean validateAndUpdatePhone(String newPhone) {
if (!Objects.equals(this.phone, newPhone)) {
this.phone = newPhone;
return true;
}
return false;
}


public List<UserActivityVO> getActivities() {
return activities;
}
Expand Down

0 comments on commit d93ffb0

Please sign in to comment.