package com.ruoyi.web.controller.ss;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ss.channelWithdraw.domain.ChannelWithdraw;
import com.ruoyi.ss.channelWithdraw.domain.ChannelWithdrawVO;
import com.ruoyi.ss.channelWithdraw.domain.ChannelWithdrawQuery;
import com.ruoyi.ss.channelWithdraw.service.ChannelWithdrawService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提现渠道Controller
 *
 * @author ruoyi
 * @date 2024-08-02
 */
@RestController
@RequestMapping("/ss/channelWithdraw")
public class ChannelWithdrawController extends BaseController
{
    @Autowired
    private ChannelWithdrawService channelWithdrawService;

    /**
     * 查询提现渠道列表
     */
    @PreAuthorize("@ss.hasPermi('ss:channelWithdraw:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChannelWithdrawQuery query)
    {
        startPage();
        startOrderBy();
        List<ChannelWithdrawVO> list = channelWithdrawService.selectChannelWithdrawList(query);
        return getDataTable(list);
    }

    /**
     * 导出提现渠道列表
     */
    @PreAuthorize("@ss.hasPermi('ss:channelWithdraw:export')")
    @Log(title = "提现渠道", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChannelWithdrawQuery query)
    {
        List<ChannelWithdrawVO> list = channelWithdrawService.selectChannelWithdrawList(query);
        ExcelUtil<ChannelWithdrawVO> util = new ExcelUtil<ChannelWithdrawVO>(ChannelWithdrawVO.class);
        util.exportExcel(response, list, "提现渠道数据");
    }

    /**
     * 获取提现渠道详细信息
     */
    @PreAuthorize("@ss.hasPermi('ss:channelWithdraw:query')")
    @GetMapping(value = "/{channelId}")
    public AjaxResult getInfo(@PathVariable("channelId") Long channelId)
    {
        return success(channelWithdrawService.selectChannelWithdrawByChannelId(channelId));
    }

    /**
     * 新增提现渠道
     */
    @PreAuthorize("@ss.hasPermi('ss:channelWithdraw:add')")
    @Log(title = "提现渠道", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChannelWithdraw channelWithdraw)
    {
        return toAjax(channelWithdrawService.insertChannelWithdraw(channelWithdraw));
    }

    /**
     * 修改提现渠道
     */
    @PreAuthorize("@ss.hasPermi('ss:channelWithdraw:edit')")
    @Log(title = "提现渠道", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChannelWithdraw channelWithdraw)
    {
        return toAjax(channelWithdrawService.updateChannelWithdraw(channelWithdraw));
    }

    /**
     * 删除提现渠道
     */
    @PreAuthorize("@ss.hasPermi('ss:channelWithdraw:remove')")
    @Log(title = "提现渠道", businessType = BusinessType.DELETE)
	@DeleteMapping("/{channelIds}")
    public AjaxResult remove(@PathVariable Long[] channelIds)
    {
        return toAjax(channelWithdrawService.deleteChannelWithdrawByChannelIds(channelIds));
    }
}
