package com.ruoyi.web.controller.ai;

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

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 客服管理Controller
 * 
 * @author shi
 * @date 2025-11-13
 */
@RestController
@RequestMapping("/ai/service")
public class AiCustomerServiceController extends BaseController
{
    @Autowired
    private IAiCustomerServiceService aiCustomerServiceService;

    /**
     * 查询客服管理列表
     */
    @PreAuthorize("@ss.hasPermi('ai:service:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiCustomerService aiCustomerService)
    {
        startPage();
        List<AiCustomerService> list = aiCustomerServiceService.selectAiCustomerServiceList(aiCustomerService);
        return getDataTable(list);
    }

    /**
     * 导出客服管理列表
     */
    @PreAuthorize("@ss.hasPermi('ai:service:export')")
    @Log(title = "客服管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiCustomerService aiCustomerService)
    {
        List<AiCustomerService> list = aiCustomerServiceService.selectAiCustomerServiceList(aiCustomerService);
        ExcelUtil<AiCustomerService> util = new ExcelUtil<AiCustomerService>(AiCustomerService.class);
        util.exportExcel(response, list, "客服管理数据");
    }

    /**
     * 获取客服管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('ai:service:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiCustomerServiceService.selectAiCustomerServiceById(id));
    }

    /**
     * 新增客服管理
     */
    @PreAuthorize("@ss.hasPermi('ai:service:add')")
    @Log(title = "客服管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiCustomerService aiCustomerService)
    {
        return toAjax(aiCustomerServiceService.insertAiCustomerService(aiCustomerService));
    }

    /**
     * 修改客服管理
     */
    @PreAuthorize("@ss.hasPermi('ai:service:edit')")
    @Log(title = "客服管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiCustomerService aiCustomerService)
    {
        return toAjax(aiCustomerServiceService.updateAiCustomerService(aiCustomerService));
    }

    /**
     * 删除客服管理
     */
    @PreAuthorize("@ss.hasPermi('ai:service:remove')")
    @Log(title = "客服管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiCustomerServiceService.deleteAiCustomerServiceByIds(ids));
    }
}
