package com.ruoyi.web.controller.system;

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.ss.userWithdraw.domain.UserWithdraw;
import com.ruoyi.ss.userWithdraw.domain.UserWithdrawQuery;
import com.ruoyi.ss.userWithdraw.domain.UserWithdrawVO;
import com.ruoyi.ss.userWithdraw.service.IUserWithdrawService;
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 qzz
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/system/userWithdraw")
public class UserWithdrawController extends BaseController
{
    @Autowired
    private IUserWithdrawService rlUserWithdrawService;

    /**
     * 查询用户提现渠道列表
     */
    @PreAuthorize("@ss.hasPermi('system:userWithdraw:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserWithdrawQuery rlUserWithdraw)
    {
        startPage();
        List<UserWithdrawVO> list = rlUserWithdrawService.selectRlUserWithdrawList(rlUserWithdraw);
        return getDataTable(list);
    }

//    /**
//     * 导出用户提现渠道列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:userWithdraw:export')")
//    @Log(title = "用户提现渠道", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, UserWithdrawQuery rlUserWithdraw)
//    {
//        List<UserWithdrawVO> list = rlUserWithdrawService.selectRlUserWithdrawList(rlUserWithdraw);
//        ExcelUtil<UserWithdraw> util = new ExcelUtil<UserWithdraw>(UserWithdraw.class);
//        util.exportExcel(response, list, "用户提现渠道数据");
//    }

    /**
     * 获取用户提现渠道详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:userWithdraw:query')")
    @GetMapping(value = "/{userChannelId}")
    public AjaxResult getInfo(@PathVariable("userChannelId") Long userChannelId)
    {
        return success(rlUserWithdrawService.selectRlUserWithdrawByUserChannelId(userChannelId));
    }

    /**
     * 新增用户提现渠道
     */
    @PreAuthorize("@ss.hasPermi('system:userWithdraw:add')")
    @Log(title = "用户提现渠道", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserWithdraw rlUserWithdraw)
    {
        return toAjax(rlUserWithdrawService.insertRlUserWithdraw(rlUserWithdraw));
    }

    /**
     * 修改用户提现渠道
     */
    @PreAuthorize("@ss.hasPermi('system:userWithdraw:edit')")
    @Log(title = "用户提现渠道", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserWithdraw rlUserWithdraw)
    {
        return toAjax(rlUserWithdrawService.updateRlUserWithdraw(rlUserWithdraw));
    }

    /**
     * 删除用户提现渠道
     */
    @PreAuthorize("@ss.hasPermi('system:userWithdraw:remove')")
    @Log(title = "用户提现渠道", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userChannelIds}")
    public AjaxResult remove(@PathVariable Long[] userChannelIds)
    {
        return toAjax(rlUserWithdrawService.deleteRlUserWithdrawByUserChannelIds(userChannelIds));
    }
}
