package com.usky.ai.controller.web;

import com.usky.ai.service.EdgeMediaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TaskPreviewController {

    @Autowired
    private EdgeMediaService edgeMediaService;

    @GetMapping("/api/task/preview/{boardId}/{algTaskSession}")
    public ResponseEntity<String> getTaskPreview(
            @PathVariable String boardId,
            @PathVariable String algTaskSession) {
        try {
            String imageUrl = edgeMediaService.getTaskPreviewUrl(boardId, algTaskSession);
            return ResponseEntity.ok(imageUrl);
        } catch (Exception e) {
            return ResponseEntity.badRequest().body("Failed to get task preview: " + e.getMessage());
        }
    }
}