package com.backendsys.modules.sdk.volcengine.controller;

import com.backendsys.modules.common.config.security.annotations.Anonymous;
import com.backendsys.modules.common.utils.Result;
import com.backendsys.modules.sdk.volcengine.entity.VisualFaceFusionMovie;
import com.backendsys.modules.sdk.volcengine.entity.VisualFaceSwapV2;
import com.backendsys.modules.sdk.volcengine.entity.VolcengineImage2VideoParams;
import com.backendsys.modules.sdk.volcengine.service.VolcengineImage2VideoService;
import com.backendsys.modules.sdk.volcengine.service.VolcengineService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class VolcengineDemoController {

    @Autowired
    private VolcengineService volcengineService;

    @Autowired
    private VolcengineImage2VideoService volcengineImage2VideoService;

    @Anonymous
    @Operation(summary = "人像融合3.6(最新版)(图像)")
    @PostMapping("/api/volcegine/faceSwapV2")
    public Result FaceSwapV2(@RequestBody VisualFaceSwapV2 visualFaceSwapV2) {
        System.out.println(visualFaceSwapV2);
        return Result.success().put("data", volcengineService.faceSwapV2(visualFaceSwapV2));
    }

    @Anonymous
    @Operation(summary = "人脸融合(视频)")
    @PostMapping("/api/volcegine/faceFusionMovieSync")
    public Result faceFusionMovieSync(@RequestBody VisualFaceFusionMovie visualFaceFusionMovie) {
        System.out.println(visualFaceFusionMovie);
        return Result.success().put("data", volcengineService.faceFusionMovie(visualFaceFusionMovie));
    }

    @Anonymous
    @Operation(summary = "人脸融合(视频)-查询结果")
    @GetMapping("/api/volcegine/faceFusionMovieGetResult")
    public Result faceFusionMovieGetResult(String task_id) {
        return Result.success().put("data", volcengineService.faceFusionMovieGetResult(task_id));
    }

    @Anonymous
    @Operation(summary = "【图生视频】创建任务")
    @PostMapping("/api/volcegine/image2Video")
    public Result image2Video(@RequestBody VolcengineImage2VideoParams params) {
        return Result.success().put("data", volcengineImage2VideoService.image2Video(params));
    }

    @Anonymous
    @Operation(summary = "【图生视频】查询任务（单个）")
    @GetMapping("/api/volcegine/queryImage2VideoTask")
    public Result queryImage2VideoTask(String taskId) {
        return Result.success().put("data", volcengineImage2VideoService.queryImage2VideoTask(taskId));
    }

    @Anonymous
    @Operation(summary = "【图生视频】查询任务列表")
    @GetMapping("/api/volcegine/queryImage2VideoTaskList")
    public Result queryImage2VideoTaskList(String taskIds) {
        return Result.success().put("data", volcengineImage2VideoService.queryImage2VideoTaskList(taskIds));
    }

}
