package com.ruoyi.cc.controller;

import java.util.Date;
import java.util.List;

import com.ruoyi.cc.domain.CcExtNum;
import com.ruoyi.cc.service.ICcExtNumService;
import com.ruoyi.common.core.domain.entity.SysUser;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cc.domain.CcCustDialogAsr;
import com.ruoyi.cc.service.ICcCustDialogAsrService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人工客服对话asr转写结果Controller
 * 
 * @author ruoyi
 * @date 2025-09-04
 */
@Controller
@RequestMapping("/cc/custDialog")
public class CcCustDialogAsrController extends BaseController
{
    private String prefix = "cc/custDialog";

    @Autowired
    private ICcCustDialogAsrService ccCustDialogAsrService;
    @Autowired
    private ICcExtNumService ccExtNumService;

    /**
     * 查询人工客服对话asr转写结果列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CcCustDialogAsr ccCustDialogAsr)
    {
        startPage();
        List<CcCustDialogAsr> list = ccCustDialogAsrService.selectCcCustDialogAsrList(ccCustDialogAsr);
        return getDataTable(list);
    }

    /**
     * 新增保存人工客服对话asr转写结果
     */
    @Log(title = "人工客服对话asr转写结果", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CcCustDialogAsr ccCustDialogAsr)
    {
        SysUser currentUser = getSysUser();
        ccCustDialogAsr.setUserId(currentUser.getUserId().toString());
        ccCustDialogAsr.setUserLoginName(currentUser.getLoginName());
        ccCustDialogAsr.setUserRealName(currentUser.getUserName());
        CcExtNum ccExtNum = ccExtNumService.selectCcExtNumByUserCode(currentUser.getLoginName());
        if (null != ccExtNum) {
            ccCustDialogAsr.setExtnum(ccExtNum.getExtNum().toString());
        }
        ccCustDialogAsr.setCreateTime(new Date());
        return toAjax(ccCustDialogAsrService.insertCcCustDialogAsr(ccCustDialogAsr));
    }

    /**
     * 修改保存人工客服对话asr转写结果
     */
    @Log(title = "人工客服对话asr转写结果", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CcCustDialogAsr ccCustDialogAsr)
    {
        return toAjax(ccCustDialogAsrService.updateCcCustDialogAsr(ccCustDialogAsr));
    }

    /**
     * 删除人工客服对话asr转写结果
     */
    @Log(title = "人工客服对话asr转写结果", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ccCustDialogAsrService.deleteCcCustDialogAsrByIds(ids));
    }
}
