package com.ruoyi.web.controller.ai;

import com.ruoyi.ai.domain.AiRechargeGiftGear;
import com.ruoyi.ai.service.IAiRechargeGiftGearService;
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/gear")
public class AiRechargeGiftGearController extends BaseController
{
    @Autowired
    private IAiRechargeGiftGearService aiRechargeGiftGearService;

    /**
     * 查询充值赠送活动档位配置列表
     */
    @PreAuthorize("@ss.hasPermi('ai:gear:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiRechargeGiftGear aiRechargeGiftGear)
    {
        startPage();
        List<AiRechargeGiftGear> list = aiRechargeGiftGearService.selectAiRechargeGiftGearList(aiRechargeGiftGear);
        return getDataTable(list);
    }

    /**
     * 导出充值赠送活动档位配置列表
     */
    @PreAuthorize("@ss.hasPermi('ai:gear:export')")
    @Log(title = "充值赠送活动档位配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiRechargeGiftGear aiRechargeGiftGear)
    {
        List<AiRechargeGiftGear> list = aiRechargeGiftGearService.selectAiRechargeGiftGearList(aiRechargeGiftGear);
        ExcelUtil<AiRechargeGiftGear> util = new ExcelUtil<AiRechargeGiftGear>(AiRechargeGiftGear.class);
        util.exportExcel(response, list, "充值赠送活动档位配置数据");
    }

    /**
     * 获取充值赠送活动档位配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('ai:gear:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiRechargeGiftGearService.selectAiRechargeGiftGearById(id));
    }

    /**
     * 新增充值赠送活动档位配置
     */
    @PreAuthorize("@ss.hasPermi('ai:gear:add')")
    @Log(title = "充值赠送活动档位配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiRechargeGiftGear aiRechargeGiftGear)
    {
        return toAjax(aiRechargeGiftGearService.insertAiRechargeGiftGear(aiRechargeGiftGear));
    }

    /**
     * 修改充值赠送活动档位配置
     */
    @PreAuthorize("@ss.hasPermi('ai:gear:edit')")
    @Log(title = "充值赠送活动档位配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiRechargeGiftGear aiRechargeGiftGear)
    {
        return toAjax(aiRechargeGiftGearService.updateAiRechargeGiftGear(aiRechargeGiftGear));
    }

    /**
     * 删除充值赠送活动档位配置
     */
    @PreAuthorize("@ss.hasPermi('ai:gear:remove')")
    @Log(title = "充值赠送活动档位配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiRechargeGiftGearService.deleteAiRechargeGiftGearByIds(ids));
    }
}
