Skip to content

Commit

Permalink
Merge pull request #82 from soma-baekgu/feature/BG-351-device-token-i…
Browse files Browse the repository at this point in the history
…ssue

[BG-351]: 디바이스 토큰 등록 API 이슈 (1h / 2h)
  • Loading branch information
GGHDMS authored Aug 12, 2024
2 parents 14085e1 + 862113c commit ce6b488
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

Expand All @@ -38,7 +39,7 @@ class UserController(
@PostMapping("/devices")
override fun registerUserDevice(
@AuthenticationPrincipal token: JwtAuthentication,
@ModelAttribute @Valid userDeviceDto: UserDeviceCreateRequest,
@RequestBody @Valid userDeviceDto: UserDeviceCreateRequest,
): ResponseEntity<Void> {
userFacadeService.registerUserDevice(userDeviceDto.toDto(userId = token.id))
return ResponseEntity.status(HttpStatus.CREATED).build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.responses.ApiResponses
import io.swagger.v3.oas.annotations.tags.Tag
import jakarta.validation.Valid
import jakarta.validation.constraints.Email
import org.springframework.http.ResponseEntity
import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.web.bind.annotation.ModelAttribute

@Tag(name = "users", description = "유저 API")
interface UserSwagger {
Expand All @@ -26,9 +22,7 @@ interface UserSwagger {
),
],
)
fun checkEmail(
@Email email: EmailExistsRequest,
): ResponseEntity<ApiResult<EmailExistsResponse>>
fun checkEmail(email: EmailExistsRequest): ResponseEntity<ApiResult<EmailExistsResponse>>

@Operation(summary = "fcm 디바이스 토큰 등록", description = "fcm 푸시 알림 전송용 토큰을 등록합니다.")
@ApiResponses(
Expand All @@ -40,7 +34,7 @@ interface UserSwagger {
],
)
fun registerUserDevice(
@AuthenticationPrincipal token: JwtAuthentication,
@ModelAttribute @Valid userDeviceDto: UserDeviceCreateRequest,
token: JwtAuthentication,
userDeviceDto: UserDeviceCreateRequest,
): ResponseEntity<Void>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import com.backgu.amaker.api.user.dto.UserDeviceDto
import com.backgu.amaker.domain.user.Device
import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.NotEmpty
import jakarta.validation.constraints.NotNull

data class UserDeviceCreateRequest(
@field:NotEmpty
@field:NotNull(message = "디바이스 종류는 필수입니다.")
@Schema(description = "디바이스 종류(IOS, ANDROID)", example = "ANDROID")
val device: Device,
@field:NotEmpty
@field:NotEmpty(message = "fcm 디바이스 토큰은 필수입니다.")
@Schema(description = "fcm 디바이스 토큰", example = "jafelijefaeflkefkfeijeif")
val token: String,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ class UserFacadeService(
) {
fun existsByEmail(email: String): EmailExistsDto = EmailExistsDto.of(user = userService.findByEmail(email))

@Transactional
fun registerUserDevice(userDeviceDto: UserDeviceDto): UserDeviceDto = UserDeviceDto.of(userDeviceService.save(userDeviceDto.toDomain()))
}

0 comments on commit ce6b488

Please sign in to comment.