package com.ruoyi.frequency.userwithdrawalway.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.userwithdrawalway.entity.UserWithdrawalWay;
import com.ruoyi.frequency.userwithdrawalway.service.UserWithdrawalWayService;
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/userwithdrawalway")
public class UserWithdrawalWayController extends BaseController
{
    @Autowired
    private UserWithdrawalWayService userWithdrawalWayService;

    /**
     * 查询用户提现方式列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalway:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserWithdrawalWay userWithdrawalWay)
    {
        startPage();
        List<UserWithdrawalWay> list = userWithdrawalWayService.selectUserWithdrawalWayList(userWithdrawalWay);
        return getDataTable(list);
    }

    /**
     * 导出用户提现方式列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalway:export')")
    @Log(title = "用户提现方式", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(UserWithdrawalWay userWithdrawalWay)
    {
        List<UserWithdrawalWay> list = userWithdrawalWayService.selectUserWithdrawalWayList(userWithdrawalWay);
        ExcelUtil<UserWithdrawalWay> util = new ExcelUtil<UserWithdrawalWay>(UserWithdrawalWay.class);
        return util.exportExcel(list, "用户提现方式数据");
    }

    /**
     * 获取用户提现方式详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalway:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(userWithdrawalWayService.selectUserWithdrawalWayById(id));
    }

    /**
     * 新增用户提现方式
     */
    @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalway:add')")
    @Log(title = "用户提现方式", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserWithdrawalWay userWithdrawalWay)
    {
        return toAjax(userWithdrawalWayService.insertUserWithdrawalWay(userWithdrawalWay));
    }

    /**
     * 修改用户提现方式
     */
    @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalway:edit')")
    @Log(title = "用户提现方式", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserWithdrawalWay userWithdrawalWay)
    {
        return toAjax(userWithdrawalWayService.updateUserWithdrawalWay(userWithdrawalWay));
    }

    /**
     * 删除用户提现方式
     */
    @PreAuthorize("@ss.hasPermi('frequency:userwithdrawalway:remove')")
    @Log(title = "用户提现方式", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userWithdrawalWayService.deleteUserWithdrawalWayByIds(ids));
    }
}
