package com.backendsys.modules.ai.media.controller;

import com.backendsys.modules.ai.media.entity.MediaTtv;
import com.backendsys.modules.ai.media.service.MediaTtvService;
import com.backendsys.modules.common.config.security.utils.SecurityUtil;
import com.backendsys.modules.common.utils.Result;
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 = "AI成片")
public class MediaTtvController {

    @Autowired
    private MediaTtvService mediaTtvService;

    @Operation(summary = "生成图文语音视频")
    @PreAuthorize("@sr.hasPermission('34')")
    @PostMapping("/api/ai/media/ttv/generate")
    public Result generateMediaTtv(@Validated(MediaTtv.Generate.class) @RequestBody MediaTtv mediaTtv) {
        mediaTtv.setUser_id(SecurityUtil.getUserId());
        return Result.success().put("data", mediaTtvService.generateMediaTtv(mediaTtv));
    }

    @Operation(summary = "查询图文语音视频")
    @PreAuthorize("@sr.hasPermission('34')")
    @GetMapping("/api/ai/media/ttv/query")
    public Result queryMediaTtv(@Validated(MediaTtv.Query.class) MediaTtv mediaTtv) {
        return Result.success().put("data", mediaTtvService.queryMediaTtv(mediaTtv));
    }

}
