package com.playlet.web.controller.system;

import java.util.List;

import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.playlet.common.annotation.Log;
import com.playlet.common.enums.BusinessType;
import com.playlet.system.domain.PlayletWithdrawApproval;
import com.playlet.system.service.IPlayletWithdrawApprovalService;
import com.playlet.common.core.controller.BaseController;
import com.playlet.common.core.domain.AjaxResult;
import com.playlet.common.utils.poi.ExcelUtil;
import com.playlet.common.core.page.TableDataInfo;

/**
 * @Date: 2024-03-30 10:21
 * @Author: 但星霖
 * @Version: v1.0
 * @Description: 提现审批Controller
 */
@Controller
@RequestMapping("/system/withdrawApproval")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PlayletWithdrawApprovalController extends BaseController {
    private String prefix = "system/approval";
    private final IPlayletWithdrawApprovalService playletWithdrawApprovalService;

    @RequiresPermissions("system:approval:view")
    @GetMapping()
    public String approval() {
        return prefix + "/approval";
    }

    /**
     * 查询提现审批列表
     */
    @RequiresPermissions("system:approval:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PlayletWithdrawApproval playletWithdrawApproval) {
        startPage();
        List<PlayletWithdrawApproval> list = playletWithdrawApprovalService.selectPlayletWithdrawApprovalList(playletWithdrawApproval);
        return getDataTable(list);
    }

    /**
     * 导出提现审批列表
     */
    @RequiresPermissions("system:approval:export")
    @Log(title = "提现审批", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PlayletWithdrawApproval playletWithdrawApproval) {
        List<PlayletWithdrawApproval> list = playletWithdrawApprovalService.selectPlayletWithdrawApprovalList(playletWithdrawApproval);
        ExcelUtil<PlayletWithdrawApproval> util = new ExcelUtil<PlayletWithdrawApproval>(PlayletWithdrawApproval.class);
        return util.exportExcel(list, "提现审批数据");
    }

    /**
     * 新增提现审批
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存提现审批
     */
    @RequiresPermissions("system:approval:add")
    @Log(title = "提现审批", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PlayletWithdrawApproval playletWithdrawApproval) {
        return toAjax(playletWithdrawApprovalService.insertPlayletWithdrawApproval(playletWithdrawApproval));
    }

    /**
     * 修改提现审批
     */
    @RequiresPermissions("system:approval:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        PlayletWithdrawApproval playletWithdrawApproval = playletWithdrawApprovalService.selectPlayletWithdrawApprovalById(id);
        mmap.put("playletWithdrawApproval", playletWithdrawApproval);
        return prefix + "/edit";
    }

    /**
     * 修改保存提现审批
     */
    @RequiresPermissions("system:approval:edit")
    @Log(title = "提现审批", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PlayletWithdrawApproval playletWithdrawApproval) {
        return toAjax(playletWithdrawApprovalService.updatePlayletWithdrawApproval(playletWithdrawApproval));
    }

    /**
     * 删除提现审批
     */
    @RequiresPermissions("system:approval:remove")
    @Log(title = "提现审批", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(playletWithdrawApprovalService.deletePlayletWithdrawApprovalByIds(ids));
    }
}
