diff --git a/src/main/java/com/fullcar/core/response/SuccessCode.java b/src/main/java/com/fullcar/core/response/SuccessCode.java index fc6f1c4..61cc47e 100644 --- a/src/main/java/com/fullcar/core/response/SuccessCode.java +++ b/src/main/java/com/fullcar/core/response/SuccessCode.java @@ -21,7 +21,8 @@ public enum SuccessCode { AVAILABLE_NICKNAME(OK, "사용 가능한 닉네임"), UPDATE_SUCCESS(OK, "수정 성공"), CODE_VERIFICATION_SUCCESS(OK, "인증 성공"), - WITHDRAW_SUCCESS(OK, "탈퇴 성공"); + WITHDRAW_SUCCESS(OK, "탈퇴 성공"), + SAVE_DEVICE_TOKEN_SUCCESS(OK, "디바이스 토큰 등록 성공"); private final HttpStatus status; private final String message; diff --git a/src/main/java/com/fullcar/member/application/member/MemberService.java b/src/main/java/com/fullcar/member/application/member/MemberService.java index e964864..8684983 100644 --- a/src/main/java/com/fullcar/member/application/member/MemberService.java +++ b/src/main/java/com/fullcar/member/application/member/MemberService.java @@ -3,13 +3,11 @@ import com.fullcar.core.exception.CustomException; import com.fullcar.core.exception.NotFoundException; import com.fullcar.core.response.ErrorCode; -import com.fullcar.member.application.auth.AppleAuthService; -import com.fullcar.member.application.auth.KakaoAuthService; -import com.fullcar.member.domain.car.CarRepository; -import com.fullcar.member.domain.mail.MailRepository; import com.fullcar.member.domain.member.*; +import com.fullcar.member.presentation.member.dto.request.DeviceTokenRequestDto; import com.fullcar.member.presentation.member.dto.request.NicknameRequestDto; import com.fullcar.member.presentation.member.dto.request.OnBoardingRequestDto; +import com.fullcar.member.presentation.member.dto.response.DeviceTokenResponseDto; import com.fullcar.member.presentation.member.dto.response.MemberGetResponseDto; import com.fullcar.member.presentation.member.dto.response.NicknameResponseDto; import com.fullcar.member.presentation.member.dto.response.OnBoardingResponseDto; @@ -59,4 +57,13 @@ public NicknameResponseDto checkNicknameDuplication(NicknameRequestDto nicknameR .build(); } } + + @Transactional + public DeviceTokenResponseDto postDeviceToken(Member member, DeviceTokenRequestDto deviceTokenRequestDto) { + memberRepository.saveAndFlush(member.saveDeviceToken(deviceTokenRequestDto)); + + return DeviceTokenResponseDto.builder() + .deviceToken(deviceTokenRequestDto.getDeviceToken()) + .build(); + } } diff --git a/src/main/java/com/fullcar/member/domain/member/Member.java b/src/main/java/com/fullcar/member/domain/member/Member.java index eca9466..a935330 100644 --- a/src/main/java/com/fullcar/member/domain/member/Member.java +++ b/src/main/java/com/fullcar/member/domain/member/Member.java @@ -2,6 +2,7 @@ import com.fullcar.member.domain.car.CarId; import com.fullcar.member.domain.auth.SocialId; +import com.fullcar.member.presentation.member.dto.request.DeviceTokenRequestDto; import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Builder; @@ -107,4 +108,9 @@ public Member deleted() { this.gender = null; return this; } + + public Member saveDeviceToken(DeviceTokenRequestDto deviceTokenRequestDto) { + this.deviceToken = deviceTokenRequestDto.getDeviceToken(); + return this; + } } diff --git a/src/main/java/com/fullcar/member/presentation/member/MemberController.java b/src/main/java/com/fullcar/member/presentation/member/MemberController.java index 6643d68..d6e88b4 100644 --- a/src/main/java/com/fullcar/member/presentation/member/MemberController.java +++ b/src/main/java/com/fullcar/member/presentation/member/MemberController.java @@ -7,6 +7,7 @@ import com.fullcar.member.domain.member.Member; import com.fullcar.member.domain.member.service.MailService; import com.fullcar.member.presentation.member.dto.request.*; +import com.fullcar.member.presentation.member.dto.response.DeviceTokenResponseDto; import com.fullcar.member.presentation.member.dto.response.MemberGetResponseDto; import com.fullcar.member.presentation.member.dto.response.NicknameResponseDto; import com.fullcar.member.presentation.member.dto.response.OnBoardingResponseDto; @@ -84,4 +85,15 @@ public ApiResponse checkMailAuthenticationCode(@CurrentMember Member mem mailService.checkMailAuthenticationCode(member, codeRequestDto); return ApiResponse.success(SuccessCode.CODE_VERIFICATION_SUCCESS); } + + @Operation(summary = "디바이스 토큰 등록 API") + @ApiResponses({ + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "디바이스 토큰 등록 성공"), + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content) + }) + @PostMapping("/device-token") + public ApiResponse postDeviceToken(@CurrentMember Member member, @RequestBody DeviceTokenRequestDto deviceTokenRequestDto) { + DeviceTokenResponseDto responseDto = memberService.postDeviceToken(member, deviceTokenRequestDto); + return ApiResponse.success(SuccessCode.SAVE_DEVICE_TOKEN_SUCCESS, responseDto); + } } diff --git a/src/main/java/com/fullcar/member/presentation/member/dto/request/DeviceTokenRequestDto.java b/src/main/java/com/fullcar/member/presentation/member/dto/request/DeviceTokenRequestDto.java new file mode 100644 index 0000000..33d3eb4 --- /dev/null +++ b/src/main/java/com/fullcar/member/presentation/member/dto/request/DeviceTokenRequestDto.java @@ -0,0 +1,15 @@ +package com.fullcar.member.presentation.member.dto.request; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class DeviceTokenRequestDto { + @Schema(description = "디바이스 토큰", example = "123") + private String deviceToken; +} diff --git a/src/main/java/com/fullcar/member/presentation/member/dto/response/DeviceTokenResponseDto.java b/src/main/java/com/fullcar/member/presentation/member/dto/response/DeviceTokenResponseDto.java new file mode 100644 index 0000000..3fc0141 --- /dev/null +++ b/src/main/java/com/fullcar/member/presentation/member/dto/response/DeviceTokenResponseDto.java @@ -0,0 +1,13 @@ +package com.fullcar.member.presentation.member.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +@Getter +@Builder +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class DeviceTokenResponseDto { + @Schema(description = "디바이스 토큰", example = "123") + private String deviceToken; +}