package com.playlet.web.controller.app;

import com.github.pagehelper.PageInfo;
import com.playlet.common.core.domain.Result;
import com.playlet.system.domain.PlayletUserAccount;
import com.playlet.web.service.app.PlayletUserAccountAppService;
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-25 15:30
 * @Author: 但星霖
 * @Version: v1.0
 * @Description: 短剧用户提现账户Controller
 */
@Controller
@RequestMapping("/app/account")
@Api(tags = "短剧*用户提现账户")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PlayletUserAccountAppController {

    private final PlayletUserAccountAppService playletUserAccountAppService;

    /**
     * 查询用户提现基础列表
     */
    @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));
    }

    /**
     * 查询短剧用户提现账户列表
     */
    @PostMapping("/list")
    @ResponseBody
    @ApiOperation(value = "查询短剧用户提现账户列表")
    public Result<List<PlayletUserAccount>> list(@RequestBody PlayletUserAccount playletUserAccount) {
        return Result.success(playletUserAccountAppService.selectPlayletUserAccountList(playletUserAccount));
    }

    /**
     * 新增保存短剧用户提现账户
     */
    @PostMapping("/add")
    @ResponseBody
    @ApiOperation(value = "新增保存短剧用户提现账户")
    public Result<String> addSave(@RequestBody PlayletUserAccount playletUserAccount) {
        playletUserAccountAppService.insertPlayletUserAccount(playletUserAccount);
        return Result.success();
    }

    /**
     * 修改保存短剧用户提现账户
     */
    @ResponseBody
    @PostMapping("/edit")
    @ApiOperation(value = "修改保存短剧用户提现账户")
    public Result<String> editSave(@RequestBody PlayletUserAccount playletUserAccount) {
        playletUserAccountAppService.updatePlayletUserAccount(playletUserAccount);
        return Result.success();
    }

    /**
     * 删除短剧用户提现账户
     */
    @ResponseBody
    @PostMapping("/remove")
    @ApiOperation(value = "删除短剧用户提现账户")
    public Result<String> remove(@RequestParam(value = "id") Long id) {
        playletUserAccountAppService.deletePlayletUserAccountById(id);
        return Result.success();
    }
}
