liujie
2026-07-30 280ef5100bece9b40ac51736aef037704a52a4ca
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
package com.tourguide.api.guide;
 
import com.tourguide.common.api.ApiResponse;
import com.tourguide.modules.system.dto.GuideNotificationResponse;
import com.tourguide.modules.system.service.GuideNotificationService;
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.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
@RestController
@RequestMapping("/api/guide/notifications")
public class GuideNotificationController {
    private final GuideNotificationService notificationService;
 
    public GuideNotificationController(GuideNotificationService notificationService) {
        this.notificationService = notificationService;
    }
 
    @GetMapping
    public ApiResponse<List<GuideNotificationResponse>> list(@AuthenticationPrincipal AppUserPrincipal principal) {
        return ApiResponse.success(notificationService.list(principal.getUserId()));
    }
 
    @PutMapping("/{id}/read")
    public ApiResponse<Void> markRead(@AuthenticationPrincipal AppUserPrincipal principal, @PathVariable String id) {
        notificationService.markRead(principal.getUserId(), id);
        return ApiResponse.success();
    }
}