package com.playlet.web.controller.app;

import com.github.pagehelper.PageInfo;
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.PlayletItem;
import com.playlet.system.domain.PlayletUserAccount;
import com.playlet.system.service.IPlayletUserAccountService;
import com.playlet.web.service.app.PlayletUserAccountAppService;
import io.swagger.annotations.ApiOperation;
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-25 15:30
 * @Author: 但星霖
 * @Version: v1.0
 * @Description: 短剧用户提现账户Controller
 */
@Controller
@RequestMapping("/app/account")
public class PlayletUserAccountAppController extends BaseController {
    private String prefix = "system/account";

    @Autowired
    private PlayletUserAccountAppService playletUserAccountAppService;

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

    /**
     * 查询用户提现基础列表
     */
    @ResponseBody
    @PostMapping("/getAccountList")
    @ApiOperation(value = "分页查询短剧基础列表")
    public Result<PageInfo<PlayletUserAccount>> getAccountList(@RequestBody PlayletUserAccount playletUserAccount,
                                                            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return Result.success(playletUserAccountAppService.getAccountList(playletUserAccount, pageNum, pageSize));
    }

    /**
     * 查询短剧用户提现账户列表
     */
    @RequiresPermissions("system:account:list")
    @PostMapping("/list")
    @ResponseBody
    @ApiOperation(value = "查询短剧用户提现账户列表")
    public TableDataInfo list(PlayletUserAccount playletUserAccount) {
        startPage();
        List<PlayletUserAccount> list = playletUserAccountAppService.selectPlayletUserAccountList(playletUserAccount);
        return getDataTable(list);
    }

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

    /**
     * 新增保存短剧用户提现账户
     */
    @RequiresPermissions("system:account:add")
    @Log(title = "短剧用户提现账户", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    @ApiOperation(value = "新增保存短剧用户提现账户")
    public AjaxResult addSave(PlayletUserAccount playletUserAccount) {
        return toAjax(playletUserAccountAppService.insertPlayletUserAccount(playletUserAccount));
    }

    /**
     * 修改短剧用户提现账户
     */
    @RequiresPermissions("system:account:edit")
    @GetMapping("/edit/{id}")
    @ApiOperation(value = "修改短剧用户提现账户")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        PlayletUserAccount playletUserAccount = playletUserAccountAppService.selectPlayletUserAccountById(id);
        mmap.put("playletUserAccount", playletUserAccount);
        return prefix + "/edit";
    }

    /**
     * 修改保存短剧用户提现账户
     */
    @RequiresPermissions("system:account:edit")
    @Log(title = "短剧用户提现账户", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    @ApiOperation(value = "修改保存短剧用户提现账户")
    public AjaxResult editSave(PlayletUserAccount playletUserAccount) {
        return toAjax(playletUserAccountAppService.updatePlayletUserAccount(playletUserAccount));
    }

    /**
     * 删除短剧用户提现账户
     */
    @RequiresPermissions("system:account:remove")
    @Log(title = "短剧用户提现账户", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    @ApiOperation(value = "删除短剧用户提现账户")
    public AjaxResult remove(String ids) {
        return toAjax(playletUserAccountAppService.deletePlayletUserAccountByIds(ids));
    }
}
