Skip to content

Commit

Permalink
Merge pull request #74 from TeamViewMore/feat/#63-user-refactor
Browse files Browse the repository at this point in the history
[REFACTOR] UserEntity의 boolean 필드 래퍼 클래스로 변경
  • Loading branch information
7beunseo authored Aug 5, 2024
2 parents 5c5f37c + 7a16a2b commit fcb0403
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 34 deletions.
18 changes: 3 additions & 15 deletions src/main/java/com/viewmore/poksin/dto/user/UpdateUserDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,9 @@ public class UpdateUserDTO {
// 주소
private String address;
// 전화번호 공개 비공개 여부
private boolean phoneOpen;
private Boolean phoneOpen;
// 긴급 연락처 공개 비공개 여부
private boolean emergencyOpen;
private Boolean emergencyOpen;
// 주소 공개 비공개 여부
private boolean addressOpen;

public boolean getphoneOpen() {
return phoneOpen;
}

public boolean getEmergencyOpen() {
return emergencyOpen;
}

public boolean getAddressOpen() {
return addressOpen;
}
private Boolean addressOpen;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class UserResponseDTO {
public static UserResponseDTO toDto(UserEntity entity, LocalDateTime lastChated) {
return UserResponseDTO.builder()
.username(entity.getUsername())
.phoneNum(entity.getphoneOpen() ? entity.getPhoneNum() : null)
.phoneNum(entity.getPhoneOpen() ? entity.getPhoneNum() : null)
.emergencyNum(entity.getEmergencyOpen() ? entity.getEmergencyNum() : null)
.address(entity.getAddressOpen() ? entity.getAddress() : null)
.role(entity.getRole())
Expand Down
24 changes: 6 additions & 18 deletions src/main/java/com/viewmore/poksin/entity/UserEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public class UserEntity extends MainUserEntity{
// 주소
private String address;
// 전화번호 공개 비공개 여부
private boolean phoneOpen;
private Boolean phoneOpen;
// 긴급 연락처 공개 비공개 여부
private boolean emergencyOpen;
private Boolean emergencyOpen;
// 주소 공개 비공개 여부
private boolean addressOpen;
private Boolean addressOpen;

@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
private List<EvidenceEntity> evidences = new ArrayList<>();
Expand All @@ -44,26 +44,14 @@ public UserEntity(String username, String password, String phoneNum, String emer
this.addressOpen = addressOpen;
}

public boolean getphoneOpen() {
return phoneOpen;
}

public boolean getEmergencyOpen() {
return emergencyOpen;
}

public boolean getAddressOpen() {
return addressOpen;
}

public void updateUser(UpdateUserDTO updateUserDTO) {
this.address = updateUserDTO.getAddress() == null ? this.address : updateUserDTO.getAddress();
this.emergencyNum = updateUserDTO.getEmergencyNum() == null ? this.emergencyNum : updateUserDTO.getEmergencyNum();
this.phoneNum = updateUserDTO.getPhoneNum() == null ? this.phoneNum : updateUserDTO.getPhoneNum();
this.phoneOpen = updateUserDTO.getphoneOpen();
this.emergencyOpen = updateUserDTO.getEmergencyOpen();
this.addressOpen = updateUserDTO.getAddressOpen();

this.phoneOpen = updateUserDTO.getPhoneOpen() == null ? this.phoneOpen : updateUserDTO.getPhoneOpen();
this.emergencyOpen = updateUserDTO.getEmergencyOpen() == null ? this.emergencyOpen : updateUserDTO.getEmergencyOpen();
this.addressOpen = updateUserDTO.getAddressOpen() == null ? this.addressOpen : updateUserDTO.getAddressOpen();
}

}

0 comments on commit fcb0403

Please sign in to comment.