package com.ruoyi.web.controller.ai;

import com.ruoyi.ai.domain.AiRebateRecord;
import com.ruoyi.ai.service.IAiRebateRecordService;
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.SecurityUtils;
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/rebate-record")
public class AiRebateRecordController extends BaseController
{
    @Autowired
    private IAiRebateRecordService aiRebateRecordService;

    /**
     * 查询返佣记录列表
     */
    @PreAuthorize("@ss.hasPermi('ai:rebateRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiRebateRecord aiRebateRecord)
    {
        startPage();
        List<AiRebateRecord> list = aiRebateRecordService.selectAiRebateRecordList(aiRebateRecord);
        return getDataTable(list);
    }



    /**
     * 导出返佣记录列表
     */
    @PreAuthorize("@ss.hasPermi('ai:rebateRecord:export')")
    @Log(title = "返佣记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiRebateRecord aiRebateRecord)
    {
        List<AiRebateRecord> list = aiRebateRecordService.selectAiRebateRecordList(aiRebateRecord);
        ExcelUtil<AiRebateRecord> util = new ExcelUtil<AiRebateRecord>(AiRebateRecord.class);
        util.exportExcel(response, list, "返佣记录数据");
    }

    /**
     * 获取返佣记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ai:rebateRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiRebateRecordService.selectAiRebateRecordById(id));
    }

    /**
     * 新增返佣记录
     */
    @PreAuthorize("@ss.hasPermi('ai:rebateRecord:add')")
    @Log(title = "返佣记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiRebateRecord aiRebateRecord)
    {
        return toAjax(aiRebateRecordService.insertAiRebateRecord(aiRebateRecord));
    }

    /**
     * 修改返佣记录
     */
    @PreAuthorize("@ss.hasPermi('ai:rebateRecord:edit')")
    @Log(title = "返佣记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiRebateRecord aiRebateRecord)
    {
        return toAjax(aiRebateRecordService.updateAiRebateRecord(aiRebateRecord));
    }

    /**
     * 删除返佣记录
     */
    @PreAuthorize("@ss.hasPermi('ai:rebateRecord:remove')")
    @Log(title = "返佣记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiRebateRecordService.deleteAiRebateRecordByIds(ids));
    }
}
