Skip to content

Commit

Permalink
♻️ Refactor: 회원 정보 수정 API 분리 (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnsugyeong authored Jun 2, 2024
1 parent 422c4c5 commit 5e3e1d2
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 0 deletions.
10 changes: 10 additions & 0 deletions moodoodle-api/src/main/java/zzangdol/user/business/UserFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import zzangdol.user.implement.UserCommandService;
import zzangdol.user.presentation.dto.request.PushNotificationRequest;
import zzangdol.user.presentation.dto.request.UserInfoUpdateRequest;
import zzangdol.user.presentation.dto.request.UserNicknameUpdateRequest;
import zzangdol.user.presentation.dto.request.UserNotificationTimeUpdateRequest;
import zzangdol.user.presentation.dto.response.UserInfoResponse;
import zzangdol.user.domain.User;

Expand All @@ -22,6 +24,14 @@ public UserInfoResponse updateUserInfo(User user, UserInfoUpdateRequest request)
return UserMapper.toUserInfoResponse(userCommandService.updateUserInfo(user, request));
}

public UserInfoResponse updateUserNickname(User user, UserNicknameUpdateRequest request) {
return UserMapper.toUserInfoResponse(userCommandService.updateUserNickname(user, request));
}

public UserInfoResponse updateUserNotificationTime(User user, UserNotificationTimeUpdateRequest request) {
return UserMapper.toUserInfoResponse(userCommandService.updateUserNotificationTime(user, request));
}

public boolean withDrawUser(User user) {
userCommandService.withDrawUser(user);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
import zzangdol.user.domain.User;
import zzangdol.user.presentation.dto.request.PushNotificationRequest;
import zzangdol.user.presentation.dto.request.UserInfoUpdateRequest;
import zzangdol.user.presentation.dto.request.UserNicknameUpdateRequest;
import zzangdol.user.presentation.dto.request.UserNotificationTimeUpdateRequest;

public interface UserCommandService {

User updateUserInfo(User user, UserInfoUpdateRequest request);

User updateUserNickname(User user, UserNicknameUpdateRequest request);

User updateUserNotificationTime(User user, UserNotificationTimeUpdateRequest request);

User handlePushNotifications(User user, PushNotificationRequest request);

void withDrawUser(User user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import zzangdol.user.domain.User;
import zzangdol.user.presentation.dto.request.PushNotificationRequest;
import zzangdol.user.presentation.dto.request.UserInfoUpdateRequest;
import zzangdol.user.presentation.dto.request.UserNicknameUpdateRequest;
import zzangdol.user.presentation.dto.request.UserNotificationTimeUpdateRequest;

@RequiredArgsConstructor
@Transactional
Expand All @@ -32,6 +34,18 @@ public User updateUserInfo(User user, UserInfoUpdateRequest request) {
return user;
}

@Override
public User updateUserNickname(User user, UserNicknameUpdateRequest request) {
user.updateNickname(request.getNickname());
return user;
}

@Override
public User updateUserNotificationTime(User user, UserNotificationTimeUpdateRequest request) {
user.updateNotificationTime(request.getNotificationTime());
return user;
}

@Override
public User handlePushNotifications(User user, PushNotificationRequest request) {
user.updatePushNotificationsEnabled(request.getPushNotificationsEnabled());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import zzangdol.user.presentation.dto.request.PushNotificationRequest;
import zzangdol.user.presentation.dto.request.TestPushNotificationRequest;
import zzangdol.user.presentation.dto.request.UserInfoUpdateRequest;
import zzangdol.user.presentation.dto.request.UserNicknameUpdateRequest;
import zzangdol.user.presentation.dto.request.UserNotificationTimeUpdateRequest;
import zzangdol.user.presentation.dto.response.UserInfoResponse;

@RequiredArgsConstructor
Expand Down Expand Up @@ -49,6 +51,24 @@ public ResponseDto<UserInfoResponse> updateUserInfo(@AuthUser User user, @Reques
return ResponseDto.onSuccess(userFacade.updateUserInfo(user, request));
}

@Operation(
summary = "사용자 닉네임 수정 🔑",
description = "사용자의 닉네임을 수정합니다."
)
@PatchMapping("/nickname")
public ResponseDto<UserInfoResponse> updateUserNickname(@AuthUser User user, @RequestBody UserNicknameUpdateRequest request) {
return ResponseDto.onSuccess(userFacade.updateUserNickname(user, request));
}

@Operation(
summary = "사용자 알림 시간 수정 🔑",
description = "사용자의 알림 시간을 수정합니다."
)
@PatchMapping("/notification-time")
public ResponseDto<UserInfoResponse> updateUserNotificationTime(@AuthUser User user, @RequestBody UserNotificationTimeUpdateRequest request) {
return ResponseDto.onSuccess(userFacade.updateUserNotificationTime(user, request));
}

@Operation(
summary = "Push 알림 허용 / 거부 🔑",
description = "사용자가 Push 알림을 허용하거나 거부합니다."
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package zzangdol.user.presentation.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class UserNicknameUpdateRequest {

@Schema(example = "짱짱돌")
private String nickname;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package zzangdol.user.presentation.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class UserNotificationTimeUpdateRequest {

@Schema(example = "20:00")
private LocalTime notificationTime;

}

0 comments on commit 5e3e1d2

Please sign in to comment.