package com.ga.common.notification;

import com.ga.common.model.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "알림")
@RestController
@RequestMapping("/api/notifications")
@RequiredArgsConstructor
public class NotificationController {

    private final NotificationService service;

    @GetMapping
    public ApiResponse<List<NotificationVO>> list() {
        return ApiResponse.ok(service.myNotifications());
    }

    @GetMapping("/unread-count")
    public ApiResponse<Integer> unreadCount() {
        return ApiResponse.ok(service.unreadCount());
    }

    @PutMapping("/{notiId}/read")
    public ApiResponse<Void> markRead(@PathVariable Long notiId) {
        service.markRead(notiId);
        return ApiResponse.ok();
    }

    @PutMapping("/read-all")
    public ApiResponse<Void> markAllRead() {
        service.markAllRead();
        return ApiResponse.ok();
    }
}
