package com.ruoyi.web.controller.ai;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.ai.domain.AiSampleAmount;
import com.ruoyi.ai.service.IAiSampleAmountService;
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/amount")
public class AiSampleAmountController extends BaseController
{
    @Autowired
    private IAiSampleAmountService aiSampleAmountService;

    /**
     * 查询体验金活动管理列表
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmount:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiSampleAmount aiSampleAmount)
    {
        startPage();
        List<AiSampleAmount> list = aiSampleAmountService.selectAiSampleAmountList(aiSampleAmount);
        return getDataTable(list);
    }

    /**
     * 导出体验金活动管理列表
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmount:export')")
    @Log(title = "体验金活动管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiSampleAmount aiSampleAmount)
    {
        List<AiSampleAmount> list = aiSampleAmountService.selectAiSampleAmountList(aiSampleAmount);
        ExcelUtil<AiSampleAmount> util = new ExcelUtil<AiSampleAmount>(AiSampleAmount.class);
        util.exportExcel(response, list, "体验金活动管理数据");
    }

    /**
     * 获取体验金活动管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiSampleAmountService.selectAiSampleAmountById(id));
    }

    /**
     * 新增体验金活动管理
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmount:add')")
    @Log(title = "体验金活动管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiSampleAmount aiSampleAmount)
    {
        return toAjax(aiSampleAmountService.insertAiSampleAmount(aiSampleAmount));
    }

    /**
     * 修改体验金活动管理
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmount:edit')")
    @Log(title = "体验金活动管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiSampleAmount aiSampleAmount)
    {
        return toAjax(aiSampleAmountService.updateAiSampleAmount(aiSampleAmount));
    }

    /**
     * 修改体验金活动管理
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmount:edit')")
    @Log(title = "体验金活动管理", businessType = BusinessType.UPDATE)
    @PutMapping("/changeUserStatus")
    public AjaxResult changeUserStatus(@RequestBody AiSampleAmount aiSampleAmount)
    {
        return toAjax(aiSampleAmountService.changeUserStatus(aiSampleAmount));
    }

    /**
     * 删除体验金活动管理
     */
    @PreAuthorize("@ss.hasPermi('ai:sampleAmount:remove')")
    @Log(title = "体验金活动管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiSampleAmountService.deleteAiSampleAmountByIds(ids));
    }
}
