package com.tourguide.api.guide;
|
|
import com.tourguide.common.api.ApiResponse;
|
import com.tourguide.modules.user.dto.GuideReceivingOptionResponse;
|
import com.tourguide.modules.user.dto.GuideReceivingStartRequest;
|
import com.tourguide.modules.user.entity.GuideReceivingSession;
|
import com.tourguide.modules.user.service.GuideReceivingService;
|
import com.tourguide.security.AppUserPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
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/receiving")
|
public class GuideReceivingController {
|
private final GuideReceivingService receivingService;
|
|
public GuideReceivingController(GuideReceivingService receivingService) {
|
this.receivingService = receivingService;
|
}
|
|
@GetMapping("/options")
|
public ApiResponse<GuideReceivingOptionResponse> options(@AuthenticationPrincipal AppUserPrincipal principal) {
|
return ApiResponse.success(receivingService.options(principal.getUserId()));
|
}
|
|
@GetMapping("/current")
|
public ApiResponse<GuideReceivingSession> current(@AuthenticationPrincipal AppUserPrincipal principal) {
|
return ApiResponse.success(receivingService.current(principal.getUserId()));
|
}
|
|
@PostMapping("/start")
|
public ApiResponse<GuideReceivingSession> start(@AuthenticationPrincipal AppUserPrincipal principal,
|
@Valid @RequestBody GuideReceivingStartRequest request) {
|
return ApiResponse.success(receivingService.start(principal.getUserId(), request));
|
}
|
|
@PutMapping("/stop")
|
public ApiResponse<Void> stop(@AuthenticationPrincipal AppUserPrincipal principal) {
|
receivingService.stop(principal.getUserId());
|
return ApiResponse.success(null);
|
}
|
|
@PutMapping("/finish")
|
public ApiResponse<Void> finish(@AuthenticationPrincipal AppUserPrincipal principal) {
|
receivingService.finish(principal.getUserId());
|
return ApiResponse.success(null);
|
}
|
}
|