package com.ruoyi.web.controller.ai;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ai.domain.AiCustomer;
import com.ruoyi.ai.service.IAiCustomerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * AI-客户配置Controller
 * 
 * @author shi
 * @date 2025-11-26
 */
@RestController
@RequestMapping("/ai/customer")
public class AiCustomerController extends BaseController
{
    @Autowired
    private IAiCustomerService aiCustomerService;

    /**
     * 查询AI-客户配置列表
     */
    @PreAuthorize("@ss.hasPermi('ai:customer:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiCustomer aiCustomer)
    {
        startPage();
        List<AiCustomer> list = aiCustomerService.selectAiCustomerList(aiCustomer);
        return getDataTable(list);
    }

    /**
     * 导出AI-客户配置列表
     */
    @PreAuthorize("@ss.hasPermi('ai:customer:export')")
    @Log(title = "AI-客户配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiCustomer aiCustomer)
    {
        List<AiCustomer> list = aiCustomerService.selectAiCustomerList(aiCustomer);
        ExcelUtil<AiCustomer> util = new ExcelUtil<AiCustomer>(AiCustomer.class);
        util.exportExcel(response, list, "AI-客户配置数据");
    }

    /**
     * 获取AI-客户配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('ai:customer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiCustomerService.selectAiCustomerById(id));
    }

    /**
     * 新增AI-客户配置
     */
    @PreAuthorize("@ss.hasPermi('ai:customer:add')")
    @Log(title = "AI-客户配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiCustomer aiCustomer)
    {
        return toAjax(aiCustomerService.insertAiCustomer(aiCustomer));
    }

    /**
     * 修改AI-客户配置
     */
    @PreAuthorize("@ss.hasPermi('ai:customer:edit')")
    @Log(title = "AI-客户配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiCustomer aiCustomer)
    {
        return toAjax(aiCustomerService.updateAiCustomer(aiCustomer));
    }

    /**
     * 删除AI-客户配置
     */
    @PreAuthorize("@ss.hasPermi('ai:customer:remove')")
    @Log(title = "AI-客户配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiCustomerService.deleteAiCustomerByIds(ids));
    }
}
