Skip to content

Commit

Permalink
refactor: DTO 의 NoArgsConstructor 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
JuneParkCode committed Aug 3, 2024
1 parent be9bd18 commit 386201d
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -30,7 +31,7 @@
@Entity(name = "users")
@Getter
@Builder
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@ToString
@EntityListeners(AuditingEntityListener.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Getter
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class UserCreateDto {
private String name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.talkka.server.user.dto;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -9,7 +10,7 @@
@Getter
@Builder
@ToString
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class UserCreateReqDto {
private String nickname;
Expand Down
2 changes: 0 additions & 2 deletions server/src/main/java/com/talkka/server/user/dto/UserDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Getter
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class UserDto {
private Long userId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.talkka.server.user.dto;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Getter
@Builder
@ToString
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor
public class UserRespDto {
private Long userId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.talkka.server.user.dto;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -9,7 +10,7 @@
@Getter
@Builder
@ToString
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class UserUpdateReqDto {
private String nickname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,13 @@ public UserDto createUser(UserCreateDto userCreateDto) {
public UserDto updateUser(Long userId, UserUpdateReqDto reqDto) {
UserEntity user = userRepository.findById(userId)
.orElseThrow(() -> new BadRequestException("존재하지 않는 유저입니다."));
// 중복 닉네임 체크

if (!reqDto.getNickname().equals(user.getNickname())
&& this.isDuplicatedNickname(reqDto.getNickname())) {
throw new BadRequestException("중복된 닉네임 입니다.");
}
UserEntity updatedUser = UserEntity.builder() // refactoring 필요함.
.userId(userId)
.nickname(reqDto.getNickname())
.oauthProvider(user.getOauthProvider())
.accessToken(user.getAccessToken())
.grade(user.getGrade())
.createdAt(user.getCreatedAt())
.updatedAt(user.getUpdatedAt())
.busReviews(user.getBusReviews())
.build();
UserEntity savedUser = userRepository.save(updatedUser);
user.setNickname(reqDto.getNickname());
UserEntity savedUser = userRepository.save(user);

return UserDto.of(savedUser);
}
Expand Down

0 comments on commit 386201d

Please sign in to comment.