-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
0af0815
commit e089392
Showing
8 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...aon/onjung/account/application/dto/response/UpdateUserNotificationAllowedResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.daon.onjung.account.application.dto.response; | ||
|
||
import com.daon.onjung.account.domain.User; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class UpdateUserNotificationAllowedResponseDto { | ||
|
||
@JsonProperty("notification_allowed") | ||
private final Boolean notificationAllowed; | ||
|
||
@Builder | ||
public UpdateUserNotificationAllowedResponseDto( | ||
Boolean notificationAllowed | ||
) { | ||
this.notificationAllowed = notificationAllowed; | ||
} | ||
|
||
public static UpdateUserNotificationAllowedResponseDto fromEntity(User user) { | ||
return UpdateUserNotificationAllowedResponseDto.builder() | ||
.notificationAllowed(user.getNotificationAllowed()) | ||
.build(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ava/com/daon/onjung/account/application/service/UpdateUserNotificationAllowedService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.daon.onjung.account.application.service; | ||
|
||
import com.daon.onjung.account.application.dto.response.UpdateUserNotificationAllowedResponseDto; | ||
import com.daon.onjung.account.application.usecase.UpdateUserNotificationAllowedUseCase; | ||
import com.daon.onjung.account.domain.User; | ||
import com.daon.onjung.account.repository.mysql.UserRepository; | ||
import com.daon.onjung.core.exception.error.ErrorCode; | ||
import com.daon.onjung.core.exception.type.CommonException; | ||
import com.daon.onjung.security.domain.mysql.Account; | ||
import com.daon.onjung.security.domain.service.AccountService; | ||
import com.daon.onjung.security.repository.mysql.AccountRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.UUID; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class UpdateUserNotificationAllowedService implements UpdateUserNotificationAllowedUseCase { | ||
|
||
private final UserRepository userRepository; | ||
|
||
private final AccountService accountService; | ||
private final AccountRepository accountRepository; | ||
|
||
@Override | ||
@Transactional | ||
public UpdateUserNotificationAllowedResponseDto execute(UUID accountId) { | ||
|
||
// Account 조회 | ||
Account account = userRepository.findById(accountId) | ||
.orElseThrow(() -> new CommonException(ErrorCode.NOT_FOUND_RESOURCE)); | ||
|
||
// Notification 허용 여부 업데이트 | ||
account = accountService.updateNotificationAllowed(account); | ||
accountRepository.save(account); | ||
|
||
return UpdateUserNotificationAllowedResponseDto.fromEntity((User) account); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ava/com/daon/onjung/account/application/usecase/UpdateUserNotificationAllowedUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.daon.onjung.account.application.usecase; | ||
|
||
import com.daon.onjung.account.application.dto.response.UpdateUserNotificationAllowedResponseDto; | ||
import com.daon.onjung.core.annotation.bean.UseCase; | ||
|
||
import java.util.UUID; | ||
|
||
@UseCase | ||
public interface UpdateUserNotificationAllowedUseCase { | ||
|
||
UpdateUserNotificationAllowedResponseDto execute(UUID accountId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters