Skip to content

Commit

Permalink
[REFACTOR] remove unuse method and add more test
Browse files Browse the repository at this point in the history
  • Loading branch information
nogamsung committed Feb 3, 2024
1 parent 200378b commit ad4a95e
Show file tree
Hide file tree
Showing 6 changed files with 474 additions and 461 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@ private EducationUpdateRequest(Long educationId,
this.isCurrent = isCurrent;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
EducationUpdateRequest that = (EducationUpdateRequest) o;
return Objects.equals(educationId, that.educationId)
&& Objects.equals(institutionName, that.institutionName)
&& Objects.equals(startedAt, that.startedAt)
&& Objects.equals(endedAt, that.endedAt)
&& Objects.equals(isCurrent, that.isCurrent);
}

public int hashCode(User user) {
return Objects.hash(educationId, user, institutionName, startedAt, endedAt, isCurrent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Objects;
Expand Down Expand Up @@ -51,17 +50,6 @@ private PortfolioUpdateRequest(Long portfolioId, String portfolioName, String po
this.media = media;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PortfolioUpdateRequest that = (PortfolioUpdateRequest) o;
return Objects.equals(portfolioId, that.portfolioId)
&& Objects.equals(portfolioName, that.portfolioName)
&& Objects.equals(portfolioUrl, that.portfolioUrl)
&& media == that.media;
}

public int hashCode(User user) {
return Objects.hash(portfolioId, user, portfolioName, portfolioUrl, Media.valueOf(media));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
Expand Down Expand Up @@ -53,17 +52,6 @@ private SkillUpdateRequest(Long skillId, String skillName, Boolean isExperienced
this.level = level;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SkillUpdateRequest that = (SkillUpdateRequest) o;
return Objects.equals(skillId, that.skillId)
&& Objects.equals(skillName, that.skillName)
&& level == that.level
&& Objects.equals(isExperienced, that.isExperienced);
}

public int hashCode(User user) {
return Objects.hash(skillId, user, skillName, Level.valueOf(level), isExperienced);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@ToString
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@ApiModel(value = "경력 업데이트 요청")
public class WorkUpdateRequest {
public class WorkUpdateRequest{

@ApiModelProperty(position = 1, required = true, value = "경력 식별자")
private Long workId;
Expand Down Expand Up @@ -70,19 +70,6 @@ private WorkUpdateRequest(Long workId,
this.isCurrent = isCurrent;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
WorkUpdateRequest that = (WorkUpdateRequest) o;
return Objects.equals(workId, that.workId)
&& Objects.equals(corporationName, that.corporationName)
&& Objects.equals(workDescription, that.workDescription)
&& Objects.equals(startedAt, that.startedAt)
&& Objects.equals(endedAt, that.endedAt)
&& Objects.equals(isCurrent, that.isCurrent);
}

public int hashCode(User user) {
return Objects.hash(workId, user, corporationName, workDescription, startedAt, endedAt, isCurrent);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.gabojait.gabojaitspring.api.service.profile;

import com.gabojait.gabojaitspring.common.response.PageData;
import com.gabojait.gabojaitspring.api.dto.profile.request.*;
import com.gabojait.gabojaitspring.api.dto.profile.response.*;
import com.gabojait.gabojaitspring.api.vo.profile.ProfileVO;
import com.gabojait.gabojaitspring.common.exception.CustomException;
import com.gabojait.gabojaitspring.common.response.PageData;
import com.gabojait.gabojaitspring.common.util.FileUtility;
import com.gabojait.gabojaitspring.domain.offer.Offer;
import com.gabojait.gabojaitspring.domain.profile.*;
import com.gabojait.gabojaitspring.domain.review.Review;
import com.gabojait.gabojaitspring.domain.team.TeamMember;
import com.gabojait.gabojaitspring.domain.user.Position;
import com.gabojait.gabojaitspring.domain.user.User;
import com.gabojait.gabojaitspring.common.exception.CustomException;
import com.gabojait.gabojaitspring.repository.favorite.FavoriteRepository;
import com.gabojait.gabojaitspring.repository.offer.OfferRepository;
import com.gabojait.gabojaitspring.repository.profile.EducationRepository;
Expand Down Expand Up @@ -85,8 +85,6 @@ public ProfileFindOtherResponse findOtherProfile(long myUserId, long otherUserId
Boolean isFavorite = null;

if (myUserId != otherUserId) {
User myUser = findUser(myUserId);

offers = offerRepository.findAllByUserId(otherUserId, myUserId);
isFavorite = favoriteRepository.existsUser(myUserId, otherUserId);

Expand Down Expand Up @@ -197,7 +195,7 @@ public void updateEducations(User user, List<EducationUpdateRequest> requests) {
educationRepository.save(request.toEntity(user));
else
currentEducations.stream()
.filter(currentEducation -> request.getEducationId().equals(currentEducation.getId()))
.filter(currentEducation -> currentEducation.getId().equals(request.getEducationId()))
.findFirst()
.ifPresent(currentEducation -> {
currentEducations.remove(currentEducation);
Expand Down Expand Up @@ -432,19 +430,6 @@ private User findUser(long userId) {
});
}

/**
* 회원 단건 조회 |
* 404(USER_NOT_FOUND)
* @param username 회원 아이디
* @return 회원
*/
private User findUser(String username) {
return userRepository.findByUsername(username)
.orElseThrow(() -> {
throw new CustomException(USER_NOT_FOUND);
});
}

/**
* 프로필 정보 조회 |
* @param user 회원
Expand Down
Loading

0 comments on commit ad4a95e

Please sign in to comment.