package com.playlet.web.controller.system;


import java.util.List;

import com.playlet.common.core.domain.Result;
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.*;
import com.playlet.common.annotation.Log;
import com.playlet.common.enums.BusinessType;
import com.playlet.system.domain.PlayletUserWithdrawalPassword;
import com.playlet.system.service.IPlayletUserWithdrawalPasswordService;
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 12:27
 * @Author: 但星霖
 * @Version: v1.0
 * @Description: 用户提现密码Controller
 */
@Controller
@RequestMapping("/system/userWithdrawalPassword")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PlayletUserWithdrawalPasswordController extends BaseController {
    private String prefix = "system/password";

    private IPlayletUserWithdrawalPasswordService playletUserWithdrawalPasswordService;

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

    /**
     * 查询用户提现密码列表
     */
    @RequiresPermissions("system:password:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PlayletUserWithdrawalPassword playletUserWithdrawalPassword) {
        startPage();
        List<PlayletUserWithdrawalPassword> list = playletUserWithdrawalPasswordService.selectPlayletUserWithdrawalPasswordList(playletUserWithdrawalPassword);
        return getDataTable(list);
    }

    /**
     * 导出用户提现密码列表
     */
    @RequiresPermissions("system:password:export")
    @Log(title = "用户提现密码", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PlayletUserWithdrawalPassword playletUserWithdrawalPassword) {
        List<PlayletUserWithdrawalPassword> list = playletUserWithdrawalPasswordService.selectPlayletUserWithdrawalPasswordList(playletUserWithdrawalPassword);
        ExcelUtil<PlayletUserWithdrawalPassword> util = new ExcelUtil<PlayletUserWithdrawalPassword>(PlayletUserWithdrawalPassword.class);
        return util.exportExcel(list, "用户提现密码数据");
    }

    /**
     * 新增用户提现密码
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存用户提现密码
     */
    @RequiresPermissions("system:password:add")
    @Log(title = "用户提现密码", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PlayletUserWithdrawalPassword playletUserWithdrawalPassword) {
        return toAjax(playletUserWithdrawalPasswordService.insertPlayletUserWithdrawalPassword(playletUserWithdrawalPassword));
    }

    @ResponseBody
    @PostMapping("/validatePassword")
    public Result<Boolean> statisticsTime(@RequestBody PlayletUserWithdrawalPassword playletUserWithdrawalPassword) {
        return Result.success(playletUserWithdrawalPasswordService.validatePassword(playletUserWithdrawalPassword));
    }

    /**
     * 修改用户提现密码
     */
    @RequiresPermissions("system:password:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        PlayletUserWithdrawalPassword playletUserWithdrawalPassword = playletUserWithdrawalPasswordService.selectPlayletUserWithdrawalPasswordById(id);
        mmap.put("playletUserWithdrawalPassword", playletUserWithdrawalPassword);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户提现密码
     */
    @RequiresPermissions("system:password:edit")
    @Log(title = "用户提现密码", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PlayletUserWithdrawalPassword playletUserWithdrawalPassword) {
        return toAjax(playletUserWithdrawalPasswordService.updatePlayletUserWithdrawalPassword(playletUserWithdrawalPassword));
    }

    /**
     * 删除用户提现密码
     */
    @RequiresPermissions("system:password:remove")
    @Log(title = "用户提现密码", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(playletUserWithdrawalPasswordService.deletePlayletUserWithdrawalPasswordByIds(ids));
    }
}
