From 97ad248d6ac7396ba3aff822676e5c09fdbe16a1 Mon Sep 17 00:00:00 2001 From: realisshomyang Date: Mon, 5 Feb 2024 23:16:05 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20:=20=EC=9C=A0=EC=A0=80=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/onnoff/onnoff/domain/user/User.java | 8 ++++++ .../domain/user/converter/UserConverter.java | 4 +-- .../domain/user/dto/UserRequestDTO.java | 27 +++++++++++++++++++ .../domain/user/service/UserServiceImpl.java | 10 +++++++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/onnoff/onnoff/domain/user/dto/UserRequestDTO.java diff --git a/src/main/java/com/onnoff/onnoff/domain/user/User.java b/src/main/java/com/onnoff/onnoff/domain/user/User.java index c12493d..edd83bc 100644 --- a/src/main/java/com/onnoff/onnoff/domain/user/User.java +++ b/src/main/java/com/onnoff/onnoff/domain/user/User.java @@ -6,6 +6,7 @@ import com.onnoff.onnoff.domain.off.memoir.entity.Memoir; import com.onnoff.onnoff.domain.on.resolution.entity.Resolution; import com.onnoff.onnoff.domain.on.worklog.entity.Worklog; +import com.onnoff.onnoff.domain.user.dto.UserRequestDTO; import com.onnoff.onnoff.domain.user.enums.ExperienceYear; import com.onnoff.onnoff.domain.user.enums.FieldOfWork; import com.onnoff.onnoff.domain.user.enums.SocialType; @@ -102,4 +103,11 @@ public void setUserStatusInactive(){ this.status = Status.INACTIVE; this.inactiveDate = LocalDateTime.now(); } + + public void updateUser(UserRequestDTO.ModifyUserDTO modifyUserDTO) { + this.nickname = modifyUserDTO.getNickname(); + this.fieldOfWork = modifyUserDTO.getFieldOfWork(); + this.job = modifyUserDTO.getJob(); + this.experienceYear = modifyUserDTO.getExperienceYear(); + } } diff --git a/src/main/java/com/onnoff/onnoff/domain/user/converter/UserConverter.java b/src/main/java/com/onnoff/onnoff/domain/user/converter/UserConverter.java index 03cd3ca..5074078 100644 --- a/src/main/java/com/onnoff/onnoff/domain/user/converter/UserConverter.java +++ b/src/main/java/com/onnoff/onnoff/domain/user/converter/UserConverter.java @@ -72,8 +72,8 @@ public static UserResponseDTO.UserDetailDTO toUserDetailDTO(User user){ .build(); } - public static UserResponseDTO.UserInfoResponseDTO toUserInfoResponseDTO(User user){ - return UserResponseDTO.UserInfoResponseDTO.builder() + public static UserResponseDTO.UserInformationResponseDTO toUserInformationResponseDTO(User user){ + return UserResponseDTO.UserInformationResponseDTO.builder() .nickname(user.getNickname()) .experienceYear(user.getExperienceYear()) .fieldOfWork(user.getFieldOfWork()) diff --git a/src/main/java/com/onnoff/onnoff/domain/user/dto/UserRequestDTO.java b/src/main/java/com/onnoff/onnoff/domain/user/dto/UserRequestDTO.java new file mode 100644 index 0000000..b0dead6 --- /dev/null +++ b/src/main/java/com/onnoff/onnoff/domain/user/dto/UserRequestDTO.java @@ -0,0 +1,27 @@ +package com.onnoff.onnoff.domain.user.dto; + +import com.onnoff.onnoff.domain.user.enums.ExperienceYear; +import com.onnoff.onnoff.domain.user.enums.FieldOfWork; +import com.onnoff.onnoff.domain.user.enums.SocialType; +import com.onnoff.onnoff.domain.user.enums.Status; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +public class UserRequestDTO { + + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class ModifyUserDTO{ + private String nickname; + private FieldOfWork fieldOfWork; + private String job; + private ExperienceYear experienceYear; + } + +} diff --git a/src/main/java/com/onnoff/onnoff/domain/user/service/UserServiceImpl.java b/src/main/java/com/onnoff/onnoff/domain/user/service/UserServiceImpl.java index a943a70..58000a9 100644 --- a/src/main/java/com/onnoff/onnoff/domain/user/service/UserServiceImpl.java +++ b/src/main/java/com/onnoff/onnoff/domain/user/service/UserServiceImpl.java @@ -4,6 +4,7 @@ import com.onnoff.onnoff.apiPayload.exception.GeneralException; import com.onnoff.onnoff.auth.UserContext; import com.onnoff.onnoff.domain.user.User; +import com.onnoff.onnoff.domain.user.dto.UserRequestDTO; import com.onnoff.onnoff.domain.user.enums.Status; import com.onnoff.onnoff.domain.user.repository.UserRepository; import lombok.RequiredArgsConstructor; @@ -62,6 +63,15 @@ public User withdrawUser(){ return user; } + @Transactional + @Override + public User modifyUser(UserRequestDTO.ModifyUserDTO modifyUserDTO){ + User user = UserContext.getUser(); + user.updateUser(modifyUserDTO); + userRepository.save(user); + return user; + } + @Transactional @Scheduled(cron = "0 0 0 * * *") // 매일 자정에 탈퇴 후 1달 지난 유저 디비 삭제 public void deleteInactiveUsers() {