package com.ruoyi.frequency.withdrawalconfig.controller;

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 com.ruoyi.frequency.withdrawalconfig.entity.WithdrawalConfig;
import com.ruoyi.frequency.withdrawalconfig.service.WithdrawalConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 提现配置Controller
 * 
 * @author liwenlong
 * @date 2023-07-20
 */
@RestController
@RequestMapping("/frequency/withdrawalconfig")
public class WithdrawalConfigController extends BaseController
{
    @Autowired
    private WithdrawalConfigService withdrawalConfigService;

    /**
     * 查询提现配置列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:withdrawalconfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(WithdrawalConfig withdrawalConfig)
    {
        startPage();
        List<WithdrawalConfig> list = withdrawalConfigService.selectWithdrawalConfigList(withdrawalConfig);
        return getDataTable(list);
    }

    /**
     * 导出提现配置列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:withdrawalconfig:export')")
    @Log(title = "提现配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WithdrawalConfig withdrawalConfig)
    {
        List<WithdrawalConfig> list = withdrawalConfigService.selectWithdrawalConfigList(withdrawalConfig);
        ExcelUtil<WithdrawalConfig> util = new ExcelUtil<WithdrawalConfig>(WithdrawalConfig.class);
        return util.exportExcel(list, "提现配置数据");
    }

    /**
     * 获取提现配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:withdrawalconfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(withdrawalConfigService.selectWithdrawalConfigById(id));
    }

    /**
     * 新增提现配置
     */
    @PreAuthorize("@ss.hasPermi('frequency:withdrawalconfig:add')")
    @Log(title = "提现配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WithdrawalConfig withdrawalConfig)
    {
        return toAjax(withdrawalConfigService.insertWithdrawalConfig(withdrawalConfig));
    }

    /**
     * 修改提现配置
     */
    @PreAuthorize("@ss.hasPermi('frequency:withdrawalconfig:edit')")
    @Log(title = "提现配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WithdrawalConfig withdrawalConfig)
    {
        return toAjax(withdrawalConfigService.updateWithdrawalConfig(withdrawalConfig));
    }

    /**
     * 删除提现配置
     */
    @PreAuthorize("@ss.hasPermi('frequency:withdrawalconfig:remove')")
    @Log(title = "提现配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(withdrawalConfigService.deleteWithdrawalConfigByIds(ids));
    }
}
