package com.sonic.cow.controller.api;

import com.sonic.common.rpc.Result;
import com.sonic.cow.domain.input.AiCreateGenSupContentInput;
import com.sonic.cow.domain.input.GenAiUserContentV1Input;
import com.sonic.cow.service.GenAiUserContentService;
import com.sonic.cow.service.GenSupContentService;
import com.sonic.sdk.api.annotation.IgnoreAuth;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 内容接口
 *
 * @author code
 */
@RestController
@Slf4j
public class ContentApi {

    @Autowired
    private GenSupContentService genSupContentService;
    @Autowired
    private GenAiUserContentService genAiUserContentService;

    @IgnoreAuth
    @ApiOperation(value = "文本生成语音", tags = {"API-接口"})
    @PostMapping("/api/gen/sup-content")
    public Result<List<String>> genSupContent(@RequestBody AiCreateGenSupContentInput input) {
        return Result.success(genSupContentService.aiCreateGenSupContent(input.getUserId(), input.getAiId()));
    }

    @IgnoreAuth
    @ApiOperation(value = "一键生成", tags = {"API-接口"})
    @PostMapping("/api/gen/user-content")
    public Result<String> genUserContent(@RequestBody GenAiUserContentV1Input input) throws Exception {
        return Result.success(genAiUserContentService.genAiUserContentV1(-1L, input).getContent());
    }

}

