package com.backendsys.modules.crt.controller;

import com.backendsys.modules.common.config.security.annotations.Anonymous;
import com.backendsys.modules.common.utils.Result;
import com.backendsys.modules.crt.entity.CrtDramaProjectStoryboard;
import com.backendsys.modules.crt.service.CrtGenerateService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
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;

@Validated
@RestController
@Tag(name = "短剧创作-生成")
public class CrtGenerateController {

    @Autowired
    private CrtGenerateService crtGenerateService;

    @PreAuthorize("@sr.hasPermission('36.3')")
    @Operation(summary = "查询任务队列")
    @GetMapping("/api/crt/generate/getQueue")
    public Result getQueue() {
        return Result.success().put("data", crtGenerateService.getQueue(8000));
    }

    @PreAuthorize("@sr.hasPermission('36.3')")
    @Operation(summary = "生成图片")
    @PostMapping("/api/crt/generate/image")
    public Result generateImage(@Validated(CrtDramaProjectStoryboard.GenerateImage.class) @RequestBody CrtDramaProjectStoryboard crtDramaProjectStoryboard) {
        return Result.success().put("data", crtGenerateService.generateImage(crtDramaProjectStoryboard));
    }

    @PreAuthorize("@sr.hasPermission('36.3')")
    @Operation(summary = "获取分集生图记录")
    @GetMapping("/api/crt/getGenerateImage")
    public Result getGenerateImage(@Validated(CrtDramaProjectStoryboard.GenerateImageList.class) CrtDramaProjectStoryboard crtDramaProjectStoryboard) {
        return Result.success().put("data", crtGenerateService.selectGenerateImage(crtDramaProjectStoryboard));
    }

    // 生成视频

}
