package com.ruoyi.web.controller.ai;

import com.ruoyi.ai.domain.AiRechargeGiftRecord;
import com.ruoyi.ai.service.IAiRechargeGiftRecordService;
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-20
 */
@RestController
@RequestMapping("/ai/recharge-gift-record")
public class AiRechargeGiftRecordController extends BaseController
{
    @Autowired
    private IAiRechargeGiftRecordService aiRechargeGiftRecordService;

    /**
     * 查询充值赠送记录列表
     */
    @PreAuthorize("@ss.hasPermi('ai:rechargeGiftRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiRechargeGiftRecord aiRechargeGiftRecord)
    {
        startPage();
        List<AiRechargeGiftRecord> list = aiRechargeGiftRecordService.selectAiRechargeGiftRecordList(aiRechargeGiftRecord);
        return getDataTable(list);
    }

    /**
     * 导出充值赠送记录列表
     */
    @PreAuthorize("@ss.hasPermi('ai:rechargeGiftRecord:export')")
    @Log(title = "充值赠送记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiRechargeGiftRecord aiRechargeGiftRecord)
    {
        List<AiRechargeGiftRecord> list = aiRechargeGiftRecordService.selectAiRechargeGiftRecordList(aiRechargeGiftRecord);
        ExcelUtil<AiRechargeGiftRecord> util = new ExcelUtil<AiRechargeGiftRecord>(AiRechargeGiftRecord.class);
        util.exportExcel(response, list, "充值赠送记录数据");
    }

    /**
     * 获取充值赠送记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ai:rechargeGiftRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiRechargeGiftRecordService.selectAiRechargeGiftRecordById(id));
    }

    /**
     * 新增充值赠送记录
     */
    @PreAuthorize("@ss.hasPermi('ai:rechargeGiftRecord:add')")
    @Log(title = "充值赠送记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiRechargeGiftRecord aiRechargeGiftRecord)
    {
        return toAjax(aiRechargeGiftRecordService.insertAiRechargeGiftRecord(aiRechargeGiftRecord));
    }

    /**
     * 修改充值赠送记录
     */
    @PreAuthorize("@ss.hasPermi('ai:rechargeGiftRecord:edit')")
    @Log(title = "充值赠送记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiRechargeGiftRecord aiRechargeGiftRecord)
    {
        return toAjax(aiRechargeGiftRecordService.updateAiRechargeGiftRecord(aiRechargeGiftRecord));
    }

    /**
     * 删除充值赠送记录
     */
    @PreAuthorize("@ss.hasPermi('ai:rechargeGiftRecord:remove')")
    @Log(title = "充值赠送记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiRechargeGiftRecordService.deleteAiRechargeGiftRecordByIds(ids));
    }
}
