package com.playlet.web.controller.app;


import com.playlet.common.annotation.Log;
import com.playlet.common.core.controller.BaseController;
import com.playlet.common.core.domain.AjaxResult;
import com.playlet.common.core.domain.Result;
import com.playlet.common.core.page.TableDataInfo;
import com.playlet.common.enums.BusinessType;
import com.playlet.common.utils.poi.ExcelUtil;
import com.playlet.system.domain.PlayletUserWithdrawalPassword;
import com.playlet.system.service.IPlayletUserWithdrawalPasswordService;
import com.playlet.web.service.app.IPlayletUserWithdrawalPasswordAppService;
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 java.util.List;

/**
 * @Date: 2024-03-30 12:27
 * @Author: 但星霖
 * @Version: v1.0
 * @Description: 用户提现密码app Controller
 */
@Controller
@RequestMapping("/app/userWithdrawalPassword")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PlayletUserWithdrawalPasswordAppController extends BaseController {
    private String prefix = "system/password";
    private final IPlayletUserWithdrawalPasswordAppService appService;

    @GetMapping()
    public String password() {
        return prefix + "/password";
    }

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

    /**
     * 新增保存用户提现密码
     */
    @Log(title = "用户提现密码", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    @ApiOperation(value = "新增保存用户提现密码")
    public AjaxResult addSave(PlayletUserWithdrawalPassword playletUserWithdrawalPassword) {
        return toAjax(appService.insertData(playletUserWithdrawalPassword));
    }

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

    /**
     * 修改保存用户提现密码
     */
    @Log(title = "用户提现密码", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    @ApiOperation(value = "修改保存用户提现密码")
    public AjaxResult editSave(PlayletUserWithdrawalPassword playletUserWithdrawalPassword) {
        return toAjax(appService.updateData(playletUserWithdrawalPassword));
    }

    @ApiOperation(value = "用户确认密码")
    @ResponseBody
    @PostMapping("/validatePassword")
    public Result<Boolean> statisticsTime(@RequestBody PlayletUserWithdrawalPassword playletUserWithdrawalPassword) {
        return Result.success(appService.validatePassword(playletUserWithdrawalPassword));
    }
}
