Skip to content

Commit

Permalink
[feat] : 유저 정보 수정 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
realisshomyang committed Feb 5, 2024
1 parent 78d8a8d commit 97ad248
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/onnoff/onnoff/domain/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 97ad248

Please sign in to comment.