package com.ruoyi.web.controller.ai;

import com.ruoyi.ai.domain.AiRecharge;
import com.ruoyi.ai.service.IAiRechargeService;
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/recharge")
public class AiRechargeController extends BaseController
{
    @Autowired
    private IAiRechargeService aiRechargeService;

    /**
     * 查询充值管理列表
     */
    @PreAuthorize("@ss.hasPermi('ai:recharge:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiRecharge aiRecharge)
    {
        startPage();
        List<AiRecharge> list = aiRechargeService.selectAiRechargeList(aiRecharge);
        return getDataTable(list);
    }


    /**
     * 导出充值管理列表
     */
    @PreAuthorize("@ss.hasPermi('ai:recharge:export')")
    @Log(title = "充值管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiRecharge aiRecharge)
    {
        List<AiRecharge> list = aiRechargeService.selectAiRechargeList(aiRecharge);
        ExcelUtil<AiRecharge> util = new ExcelUtil<AiRecharge>(AiRecharge.class);
        util.exportExcel(response, list, "充值管理数据");
    }

    /**
     * 获取充值管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('ai:recharge:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiRechargeService.selectAiRechargeById(id));
    }

    /**
     * 新增充值管理
     */
    @PreAuthorize("@ss.hasPermi('ai:recharge:add')")
    @Log(title = "充值管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiRecharge aiRecharge)
    {
        return toAjax(aiRechargeService.insertAiRecharge(aiRecharge));
    }

    /**
     * 修改充值管理
     */
    @PreAuthorize("@ss.hasPermi('ai:recharge:edit')")
    @Log(title = "充值管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiRecharge aiRecharge)
    {
        return toAjax(aiRechargeService.updateAiRecharge(aiRecharge));
    }

    /**
     * 删除充值管理
     */
    @PreAuthorize("@ss.hasPermi('ai:recharge:remove')")
    @Log(title = "充值管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiRechargeService.deleteAiRechargeByIds(ids));
    }
}
