package com.tasteby.controller;

import com.tasteby.security.AuthUtil;
import com.tasteby.service.CacheService;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/admin")
public class AdminCacheController {

    private final CacheService cacheService;

    public AdminCacheController(CacheService cacheService) {
        this.cacheService = cacheService;
    }

    @PostMapping("/cache-flush")
    public Map<String, Object> flushCache() {
        AuthUtil.requireAdmin();
        cacheService.flush();
        return Map.of("ok", true);
    }
}
