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.PlayletUserWithdrawDepositRecord;
import com.playlet.system.service.IPlayletUserWithdrawDepositRecordService;
import com.playlet.web.service.app.IPlayletUserWithdrawDepositRecordAppService;
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-29 23:59
 * @Author: 但星霖
 * @Version: v1.0
 * @Description: 用户交易记录appController
 */
@Controller
@RequestMapping("/app/userWithdrawRecord")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PlayletUserWithdrawDepositRecordAppController extends BaseController {
    private String prefix = "system/record";

    private final IPlayletUserWithdrawDepositRecordAppService service;

    @RequiresPermissions("system:record:view")
    @GetMapping()
    public String record() {
        return prefix + "/record";
    }
    
    @ResponseBody
    @PostMapping("/getWithdrawDepositList")
    @ApiOperation(value = "分页查询用户提现记录列表")
    public Result<PageInfo<PlayletUserWithdrawDepositRecord>> getWithdrawDepositList(@RequestBody PlayletUserWithdrawDepositRecord playletUserWithdrawDepositRecord,
                                                                @RequestParam(value = "pageNum") Integer pageNum,
                                                                @RequestParam(value = "pageSize") Integer pageSize) {
        return Result.success(service.getWithdrawDepositList(playletUserWithdrawDepositRecord, pageNum, pageSize));
    }

    /**
     * 查询用户交易记录列表
     */
    @PostMapping("/list")
    @ResponseBody
    @ApiOperation(value = "查询用户交易记录列表")
    public TableDataInfo list(PlayletUserWithdrawDepositRecord playletUserWithdrawDepositRecord) {
        startPage();
        List<PlayletUserWithdrawDepositRecord> list = service.selectPlayletUserWithdrawDepositRecordList(playletUserWithdrawDepositRecord);
        return getDataTable(list);
    }


    /**
     * 新增用户交易记录
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存用户交易记录
     */
    @Log(title = "用户交易记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    @ApiOperation(value = "新增保存用户交易记录")
    public AjaxResult addSave(PlayletUserWithdrawDepositRecord playletUserWithdrawDepositRecord) {
        return toAjax(service.insertPlayletUserWithdrawDepositRecord(playletUserWithdrawDepositRecord));
    }

    /**
     * 修改用户交易记录
     */
    @GetMapping("/edit/{id}")
    @ApiOperation(value = "修改用户交易记录")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        PlayletUserWithdrawDepositRecord playletUserWithdrawDepositRecord = service.selectPlayletUserWithdrawDepositRecordById(id);
        mmap.put("playletUserWithdrawDepositRecord", playletUserWithdrawDepositRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户交易记录
     */
    @Log(title = "用户交易记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    @ApiOperation(value = "修改保存用户交易记录")
    public AjaxResult editSave(PlayletUserWithdrawDepositRecord playletUserWithdrawDepositRecord) {
        return toAjax(service.updatePlayletUserWithdrawDepositRecord(playletUserWithdrawDepositRecord));
    }

    /**
     * 删除用户交易记录
     */
    @Log(title = "用户交易记录", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    @ApiOperation(value = "删除用户交易记录")
    public AjaxResult remove(String ids) {
        return toAjax(service.deletePlayletUserWithdrawDepositRecordByIds(ids));
    }
}
