package com.fs.company.controller;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.company.domain.CompanyVoiceDialog;
import com.fs.company.service.ICompanyVoiceDialogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * AI外呼话术Controller
 * 
 * @author fs
 * @date 2024-12-04
 */
@RestController
@RequestMapping("/company/companyVoiceDialog")
public class CompanyVoiceDialogController extends BaseController
{
    @Autowired
    private ICompanyVoiceDialogService companyVoiceDialogService;

    /**
     * 查询AI外呼话术列表
     */
    @PreAuthorize("@ss.hasPermi('system:companyVoiceDialog:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyVoiceDialog companyVoiceDialog)
    {
        startPage();
        List<CompanyVoiceDialog> list = companyVoiceDialogService.selectCompanyVoiceDialogList(companyVoiceDialog);
        return getDataTable(list);
    }

    /**
     * 导出AI外呼话术列表
     */
    @PreAuthorize("@ss.hasPermi('system:companyVoiceDialog:export')")
    @Log(title = "AI外呼话术", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyVoiceDialog companyVoiceDialog)
    {
        List<CompanyVoiceDialog> list = companyVoiceDialogService.selectCompanyVoiceDialogList(companyVoiceDialog);
        ExcelUtil<CompanyVoiceDialog> util = new ExcelUtil<CompanyVoiceDialog>(CompanyVoiceDialog.class);
        return util.exportExcel(list, "dialog");
    }

    /**
     * 获取AI外呼话术详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:companyVoiceDialog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(companyVoiceDialogService.selectCompanyVoiceDialogById(id));
    }

    /**
     * 新增AI外呼话术
     */
    @PreAuthorize("@ss.hasPermi('system:companyVoiceDialog:add')")
    @Log(title = "AI外呼话术", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyVoiceDialog companyVoiceDialog)
    {
        return toAjax(companyVoiceDialogService.insertCompanyVoiceDialog(companyVoiceDialog));
    }

    /**
     * 修改AI外呼话术
     */
    @PreAuthorize("@ss.hasPermi('system:companyVoiceDialog:edit')")
    @Log(title = "AI外呼话术", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyVoiceDialog companyVoiceDialog)
    {
        return toAjax(companyVoiceDialogService.updateCompanyVoiceDialog(companyVoiceDialog));
    }

    /**
     * 删除AI外呼话术
     */
    @PreAuthorize("@ss.hasPermi('system:companyVoiceDialog:remove')")
    @Log(title = "AI外呼话术", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(companyVoiceDialogService.deleteCompanyVoiceDialogByIds(ids));
    }
    /**
     * 获取话术配置链接
     */
    @PreAuthorize("@ss.hasPermi('system:companyVoiceDialog:list')")
    @Log(title = "话术配置链接", businessType = BusinessType.DELETE)
	@GetMapping("/getConfigUrl")
    public AjaxResult getConfigUrl(Long id){
        return AjaxResult.success("", companyVoiceDialogService.getConfigUrl(id));
    }
}
