package com.playlet.web.controller.app;

import com.github.pagehelper.PageInfo;
import com.playlet.common.core.domain.Result;
import com.playlet.system.domain.PlayletUserWithdrawDepositRecord;
import com.playlet.web.service.app.IPlayletUserWithdrawDepositRecordAppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Date: 2024-03-29 23:59
 * @Author: 但星霖
 * @Version: v1.0
 * @Description: 用户交易记录appController
 */
@Controller
@Api(tags = "小程序*用户交易记录")
@RequestMapping("/app/userWithdrawRecord")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PlayletUserWithdrawDepositRecordAppController {

    private final IPlayletUserWithdrawDepositRecordAppService depositRecordAppService;
    
    @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(depositRecordAppService.getWithdrawDepositList(playletUserWithdrawDepositRecord, pageNum, pageSize));
    }

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


    /**
     * 新增保存用户交易记录
     */
    @PostMapping("/add")
    @ResponseBody
    @ApiOperation(value = "新增保存用户交易记录")
    public Result<String> addSave(@RequestBody PlayletUserWithdrawDepositRecord playletUserWithdrawDepositRecord) {
        depositRecordAppService.insertPlayletUserWithdrawDepositRecord(playletUserWithdrawDepositRecord);
        return Result.success();
    }

    /**
     * 修改保存用户交易记录
     */
    @PostMapping("/edit")
    @ResponseBody
    @ApiOperation(value = "修改保存用户交易记录")
    public Result<String> editSave(@RequestBody PlayletUserWithdrawDepositRecord playletUserWithdrawDepositRecord) {
        depositRecordAppService.updatePlayletUserWithdrawDepositRecord(playletUserWithdrawDepositRecord);
        return Result.success();
    }

    /**
     * 删除用户交易记录
     */
    @PostMapping("/remove")
    @ResponseBody
    @ApiOperation(value = "删除用户交易记录")
    public Result<String> remove(@RequestParam(value = "id") Long id) {
        depositRecordAppService.deletePlayletUserWithdrawDepositRecordById(id);
        return Result.success();
    }

}
