package com.tasteby.controller;

import com.tasteby.domain.SiteVisitStats;
import com.tasteby.service.StatsService;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/stats")
public class StatsController {

    private final StatsService statsService;

    public StatsController(StatsService statsService) {
        this.statsService = statsService;
    }

    @PostMapping("/visit")
    public Map<String, Object> recordVisit() {
        statsService.recordVisit();
        return Map.of("ok", true);
    }

    @GetMapping("/visits")
    public SiteVisitStats getVisits() {
        return statsService.getVisits();
    }
}
