package com.tourguide.api.guide; import com.tourguide.common.api.ApiResponse; import com.tourguide.modules.user.dto.GuidePushDeviceRequest; import com.tourguide.modules.user.service.GuidePushDeviceService; import com.tourguide.security.AppUserPrincipal; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; @RestController @RequestMapping("/api/guide/push-device") public class GuidePushDeviceController { private final GuidePushDeviceService pushDeviceService; public GuidePushDeviceController(GuidePushDeviceService pushDeviceService) { this.pushDeviceService = pushDeviceService; } @PutMapping public ApiResponse bind(@AuthenticationPrincipal AppUserPrincipal principal, @Valid @RequestBody GuidePushDeviceRequest request) { pushDeviceService.bind(principal.getUserId(), request.getCid(), request.getPlatform()); return ApiResponse.success(); } @DeleteMapping public ApiResponse unbind(@AuthenticationPrincipal AppUserPrincipal principal) { pushDeviceService.unbind(principal.getUserId()); return ApiResponse.success(); } }