package com.fs.aicall.config.bean;

import com.fs.aicall.service.AiCallService;
import com.fs.company.domain.CompanyVoiceApi;
import com.fs.company.service.ICompanyVoiceApiService;
import com.fs.company.service.impl.CompanyVoiceApiServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
public class AiCallBeanServiceConfig {
    @Autowired
    private ICompanyVoiceApiService companyVoiceApiService;

    @Bean
    public AiCallService aiCallService() {
        CompanyVoiceApi param = new CompanyVoiceApi();
        param.setApiType("2");
        List<CompanyVoiceApi> list = companyVoiceApiService.selectCompanyVoiceApiList(param);
        if(list.isEmpty()) return null;
        return AiCallService.builder().config(list.get(0)).build();
    }
}
