liujie
2026-08-14 92a75a7b157e6fd6423df17cfd32015017bdb8c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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);
    }
}