-
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.
fix: ✏️ 사용자 로그 관리 정책 변경에 따른 Device API 수정 (#104)
* fix: 배포 파이프라인 이미지 빌드 버전 추가 * fix: device entity os & model 필드 제거 * fix: device token dto model, os 필드 제거 * fix: device_dto to_entity() 메서드 복구 * fix: device update 메서드 호출 시, activate 상태로 변경 * fix: device 등록 비지니스 로직 수정 * test: device controller unit test에서 model, os 제거 * fix: device_fixture model, os 필드 제거 * rename: fixture token 변경 상수명 수정 * fix: device entity 조회 시 활성화 조건 추가 * fix: device usecase 테스트 시나리오 수정 * fix: device 쿼리 자동 조건문 수정 * test: origin_token에 대한 정보가 없는 경우 new_token 등록 * fix: @sql_restriction 제거 * test: 수정 요청 & 기존 토큰 없을 시, 수정 토큰으로 신규 등록 테스트 * fix: device_register_service 로직 수정 * fix: device_dto new_token 필드 제거 * test: device controller unit test 수정 * fix: device 응답 객체 생성 시 요청 토큰이 아닌 서버 토큰을 응답으로 사용 * fix: device_register_service 제거 && 로직 단순화 * fix: 사용자가 보낸 토큰이 서버에서 비활성화 상태일 때 예외처리 * test: test case 요청 수정 * rename: device -> device_token으로 수정 * rename: device_token entity to_string 수정 * rename: device token put 요청 응답 key 수정 * docs: device put api 스웨거 수정 * fix: device controller 경로 수정 * test: device_token controller unit test 변경된 url 및 응답 포맷 반영 * test: device_fixture -> device_token_fixture * test: 단일 token에 대한 시나리오로 테스트 수정 및 비활성화 토큰 요청 에러 케이스 추가 * fix: register_device_token 파사드 패턴 적용 * fix: device_token_unregister 파사드 패턴 적용 * test: device token 단위 테스트 분리 * test: device_token_unregister_service_test 분리 * fix: user_account_use_case 파사드 패턴 적용 * test: user_account_usecase unit test 분리 * fix: device entity os & model 필드 제거 * fix: device token dto model, os 필드 제거 * fix: device_dto to_entity() 메서드 복구 * fix: device update 메서드 호출 시, activate 상태로 변경 * fix: device 등록 비지니스 로직 수정 * test: device controller unit test에서 model, os 제거 * fix: device_fixture model, os 필드 제거 * rename: fixture token 변경 상수명 수정 * fix: device entity 조회 시 활성화 조건 추가 * fix: device usecase 테스트 시나리오 수정 * fix: device 쿼리 자동 조건문 수정 * test: origin_token에 대한 정보가 없는 경우 new_token 등록 * fix: @sql_restriction 제거 * test: 수정 요청 & 기존 토큰 없을 시, 수정 토큰으로 신규 등록 테스트 * fix: device_register_service 로직 수정 * fix: device_dto new_token 필드 제거 * test: device controller unit test 수정 * fix: device 응답 객체 생성 시 요청 토큰이 아닌 서버 토큰을 응답으로 사용 * fix: device_register_service 제거 && 로직 단순화 * fix: 사용자가 보낸 토큰이 서버에서 비활성화 상태일 때 예외처리 * test: test case 요청 수정 * rename: device -> device_token으로 수정 * rename: device_token entity to_string 수정 * rename: device token put 요청 응답 key 수정 * docs: device put api 스웨거 수정 * fix: device controller 경로 수정 * test: device_token controller unit test 변경된 url 및 응답 포맷 반영 * test: device_fixture -> device_token_fixture * test: 단일 token에 대한 시나리오로 테스트 수정 및 비활성화 토큰 요청 에러 케이스 추가 * fix: register_device_token 파사드 패턴 적용 * fix: device_token_unregister 파사드 패턴 적용 * test: device token 단위 테스트 분리 * test: device_token_unregister_service_test 분리 * fix: user_account_use_case 파사드 패턴 적용 * test: user_account_usecase unit test 분리 * fix: user_profile_update_dto merge conflict
- Loading branch information
1 parent
35710d0
commit 772b23f
Showing
33 changed files
with
1,003 additions
and
955 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
48 changes: 0 additions & 48 deletions
48
pennyway-app-external-api/src/main/java/kr/co/pennyway/api/apis/users/dto/DeviceDto.java
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
...yway-app-external-api/src/main/java/kr/co/pennyway/api/apis/users/dto/DeviceTokenDto.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 kr.co.pennyway.api.apis.users.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import kr.co.pennyway.domain.domains.device.domain.DeviceToken; | ||
import kr.co.pennyway.domain.domains.user.domain.User; | ||
|
||
public class DeviceTokenDto { | ||
@Schema(title = "디바이스 등록 요청") | ||
public record RegisterReq( | ||
@Schema(description = "디바이스 FCM 토큰", requiredMode = Schema.RequiredMode.REQUIRED) | ||
@NotBlank(message = "token은 필수입니다.") | ||
String token | ||
) { | ||
public DeviceToken toEntity(User user) { | ||
return DeviceToken.of(token, user); | ||
} | ||
} | ||
|
||
@Schema(title = "디바이스 등록 응답") | ||
public record RegisterRes( | ||
@Schema(title = "디바이스 ID") | ||
Long id, | ||
@Schema(title = "디바이스 토큰") | ||
String token | ||
) { | ||
public static RegisterRes of(Long id, String token) { | ||
return new RegisterRes(id, token); | ||
} | ||
} | ||
} |
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
...pp-external-api/src/main/java/kr/co/pennyway/api/apis/users/mapper/DeviceTokenMapper.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 kr.co.pennyway.api.apis.users.mapper; | ||
|
||
import kr.co.pennyway.api.apis.users.dto.DeviceTokenDto; | ||
import kr.co.pennyway.common.annotation.Mapper; | ||
import kr.co.pennyway.domain.domains.device.domain.DeviceToken; | ||
|
||
@Mapper | ||
public class DeviceTokenMapper { | ||
public static DeviceTokenDto.RegisterRes toRegisterRes(DeviceToken deviceToken) { | ||
return DeviceTokenDto.RegisterRes.of(deviceToken.getId(), deviceToken.getToken()); | ||
} | ||
} |
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
84 changes: 0 additions & 84 deletions
84
...ternal-api/src/main/java/kr/co/pennyway/api/apis/users/service/DeviceRegisterService.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
...l-api/src/main/java/kr/co/pennyway/api/apis/users/service/DeviceTokenRegisterService.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,39 @@ | ||
package kr.co.pennyway.api.apis.users.service; | ||
|
||
import kr.co.pennyway.domain.domains.device.domain.DeviceToken; | ||
import kr.co.pennyway.domain.domains.device.exception.DeviceTokenErrorCode; | ||
import kr.co.pennyway.domain.domains.device.exception.DeviceTokenErrorException; | ||
import kr.co.pennyway.domain.domains.device.service.DeviceTokenService; | ||
import kr.co.pennyway.domain.domains.user.domain.User; | ||
import kr.co.pennyway.domain.domains.user.exception.UserErrorCode; | ||
import kr.co.pennyway.domain.domains.user.exception.UserErrorException; | ||
import kr.co.pennyway.domain.domains.user.service.UserService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class DeviceTokenRegisterService { | ||
private final UserService userService; | ||
private final DeviceTokenService deviceTokenService; | ||
|
||
@Transactional | ||
public DeviceToken execute(Long userId, String token) { | ||
User user = userService.readUser(userId).orElseThrow(() -> new UserErrorException(UserErrorCode.NOT_FOUND)); | ||
DeviceToken deviceToken = getOrCreateDevice(user, token); | ||
|
||
if (!deviceToken.isActivated()) { | ||
throw new DeviceTokenErrorException(DeviceTokenErrorCode.NOT_ACTIVATED_DEVICE); | ||
} | ||
|
||
return deviceToken; | ||
} | ||
|
||
private DeviceToken getOrCreateDevice(User user, String token) { | ||
return deviceTokenService.readDeviceByUserIdAndToken(user.getId(), token) | ||
.orElseGet(() -> deviceTokenService.createDevice(DeviceToken.of(token, user))); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...api/src/main/java/kr/co/pennyway/api/apis/users/service/DeviceTokenUnregisterService.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,33 @@ | ||
package kr.co.pennyway.api.apis.users.service; | ||
|
||
import kr.co.pennyway.domain.domains.device.domain.DeviceToken; | ||
import kr.co.pennyway.domain.domains.device.exception.DeviceTokenErrorCode; | ||
import kr.co.pennyway.domain.domains.device.exception.DeviceTokenErrorException; | ||
import kr.co.pennyway.domain.domains.device.service.DeviceTokenService; | ||
import kr.co.pennyway.domain.domains.user.domain.User; | ||
import kr.co.pennyway.domain.domains.user.exception.UserErrorCode; | ||
import kr.co.pennyway.domain.domains.user.exception.UserErrorException; | ||
import kr.co.pennyway.domain.domains.user.service.UserService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class DeviceTokenUnregisterService { | ||
private final UserService userService; | ||
private final DeviceTokenService deviceTokenService; | ||
|
||
@Transactional | ||
public void execute(Long userId, String token) { | ||
User user = userService.readUser(userId).orElseThrow(() -> new UserErrorException(UserErrorCode.NOT_FOUND)); | ||
|
||
DeviceToken deviceToken = deviceTokenService.readDeviceByUserIdAndToken(user.getId(), token).orElseThrow( | ||
() -> new DeviceTokenErrorException(DeviceTokenErrorCode.NOT_FOUND_DEVICE) | ||
); | ||
|
||
deviceTokenService.deleteDevice(deviceToken); | ||
} | ||
} |
Oops, something went wrong.