-
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.
✨ Feature - Additional User APIs (#48)
* chore: Article Command Role * feat: Update Notification Status In User API * feat: Update Device Token In User API * feat: Connection Controller & Service
- Loading branch information
1 parent
9368745
commit 4df40d5
Showing
8 changed files
with
168 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
12 changes: 12 additions & 0 deletions
12
...src/main/java/org/dongguk/dscd/wooahan/api/user/dto/request/UpdateUserDeviceTokenDto.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 org.dongguk.dscd.wooahan.api.user.dto.request; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record UpdateUserDeviceTokenDto( | ||
|
||
@JsonProperty("device_token") | ||
@NotNull | ||
String deviceToken | ||
) { | ||
} |
12 changes: 12 additions & 0 deletions
12
...n/java/org/dongguk/dscd/wooahan/api/user/dto/request/UpdateUserNotificationStatusDto.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 org.dongguk.dscd.wooahan.api.user.dto.request; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record UpdateUserNotificationStatusDto( | ||
|
||
@JsonProperty("is_allowed_notification") | ||
@NotNull | ||
Boolean isAllowedNotification | ||
) { | ||
} |
32 changes: 32 additions & 0 deletions
32
...src/main/java/org/dongguk/dscd/wooahan/api/user/service/UpdateUserDeviceTokenService.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,32 @@ | ||
package org.dongguk.dscd.wooahan.api.user.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.dongguk.dscd.wooahan.api.core.exception.error.ErrorCode; | ||
import org.dongguk.dscd.wooahan.api.core.exception.type.CommonException; | ||
import org.dongguk.dscd.wooahan.api.user.domain.mysql.User; | ||
import org.dongguk.dscd.wooahan.api.user.dto.request.UpdateUserDeviceTokenDto; | ||
import org.dongguk.dscd.wooahan.api.user.repository.mysql.UserRepository; | ||
import org.dongguk.dscd.wooahan.api.user.usecase.UpdateUserDeviceTokenUseCase; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.UUID; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class UpdateUserDeviceTokenService implements UpdateUserDeviceTokenUseCase { | ||
|
||
private final UserRepository userRepository; | ||
|
||
@Override | ||
@Transactional | ||
public void execute( | ||
UUID accountId, | ||
UpdateUserDeviceTokenDto requestDto | ||
) { | ||
User user = userRepository.findById(accountId) | ||
.orElseThrow(() -> new CommonException(ErrorCode.NOT_FOUND_USER)); | ||
|
||
user.updateDeviceToken(requestDto.deviceToken()); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...n/java/org/dongguk/dscd/wooahan/api/user/service/UpdateUserNotificationStatusService.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,31 @@ | ||
package org.dongguk.dscd.wooahan.api.user.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.dongguk.dscd.wooahan.api.core.exception.error.ErrorCode; | ||
import org.dongguk.dscd.wooahan.api.core.exception.type.CommonException; | ||
import org.dongguk.dscd.wooahan.api.user.domain.mysql.User; | ||
import org.dongguk.dscd.wooahan.api.user.dto.request.UpdateUserNotificationStatusDto; | ||
import org.dongguk.dscd.wooahan.api.user.dto.request.UpdateUserNotificationTimeDto; | ||
import org.dongguk.dscd.wooahan.api.user.repository.mysql.UserRepository; | ||
import org.dongguk.dscd.wooahan.api.user.usecase.UpdateUserNotificationStatusUseCase; | ||
import org.dongguk.dscd.wooahan.api.user.usecase.UpdateUserNotificationTimeUseCase; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.UUID; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class UpdateUserNotificationStatusService implements UpdateUserNotificationStatusUseCase { | ||
|
||
private final UserRepository userRepository; | ||
|
||
@Override | ||
@Transactional | ||
public void execute(UUID accountId, UpdateUserNotificationStatusDto requestDto) { | ||
User user = userRepository.findById(accountId) | ||
.orElseThrow(() -> new CommonException(ErrorCode.NOT_FOUND_USER)); | ||
|
||
user.updateIsAllowedNotification(requestDto.isAllowedNotification()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...src/main/java/org/dongguk/dscd/wooahan/api/user/usecase/UpdateUserDeviceTokenUseCase.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,18 @@ | ||
package org.dongguk.dscd.wooahan.api.user.usecase; | ||
|
||
import org.dongguk.dscd.wooahan.api.user.dto.request.UpdateUserDeviceTokenDto; | ||
|
||
import java.util.UUID; | ||
|
||
public interface UpdateUserDeviceTokenUseCase { | ||
/** | ||
* 사용자 알림 시간 수정 | ||
* @param accountId 계정 ID | ||
* @param requestDto 요청 DTO | ||
*/ | ||
void execute( | ||
UUID accountId, | ||
UpdateUserDeviceTokenDto requestDto | ||
); | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...n/java/org/dongguk/dscd/wooahan/api/user/usecase/UpdateUserNotificationStatusUseCase.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,18 @@ | ||
package org.dongguk.dscd.wooahan.api.user.usecase; | ||
|
||
import org.dongguk.dscd.wooahan.api.user.dto.request.UpdateUserNotificationStatusDto; | ||
|
||
import java.util.UUID; | ||
|
||
public interface UpdateUserNotificationStatusUseCase { | ||
/** | ||
* 사용자 알림 시간 수정 | ||
* @param accountId 계정 ID | ||
* @param requestDto 요청 DTO | ||
*/ | ||
void execute( | ||
UUID accountId, | ||
UpdateUserNotificationStatusDto requestDto | ||
); | ||
|
||
} |