package com.ruoyi.web.controller.ai;

import com.ruoyi.ai.domain.AiSampleAmountRecord;
import com.ruoyi.ai.service.IAiSampleAmountRecordService;
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/sample-amount-record")
public class AiSampleAmountRecordController extends BaseController
{
    @Autowired
    private IAiSampleAmountRecordService aiSampleAmountRecordService;

    /**
     * 查询体验金领取记录列表
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmountRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiSampleAmountRecord aiSampleAmountRecord)
    {
        startPage();
        List<AiSampleAmountRecord> list = aiSampleAmountRecordService.selectAiSampleAmountRecordList(aiSampleAmountRecord);
        return getDataTable(list);
    }

    /**
     * 导出体验金领取记录列表
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmountRecord:export')")
    @Log(title = "体验金领取记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiSampleAmountRecord aiSampleAmountRecord)
    {
        List<AiSampleAmountRecord> list = aiSampleAmountRecordService.selectAiSampleAmountRecordList(aiSampleAmountRecord);
        ExcelUtil<AiSampleAmountRecord> util = new ExcelUtil<AiSampleAmountRecord>(AiSampleAmountRecord.class);
        util.exportExcel(response, list, "体验金领取记录数据");
    }

    /**
     * 获取体验金领取记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmountRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiSampleAmountRecordService.selectAiSampleAmountRecordById(id));
    }

    /**
     * 新增体验金领取记录
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmountRecord:add')")
    @Log(title = "体验金领取记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiSampleAmountRecord aiSampleAmountRecord)
    {
        return toAjax(aiSampleAmountRecordService.insertAiSampleAmountRecord(aiSampleAmountRecord));
    }

    /**
     * 修改体验金领取记录
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmountRecord:edit')")
    @Log(title = "体验金领取记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiSampleAmountRecord aiSampleAmountRecord)
    {
        return toAjax(aiSampleAmountRecordService.updateAiSampleAmountRecord(aiSampleAmountRecord));
    }

    /**
     * 删除体验金领取记录
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmountRecord:remove')")
    @Log(title = "体验金领取记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiSampleAmountRecordService.deleteAiSampleAmountRecordByIds(ids));
    }
}
