package cn.com.ty.lift.ud.payment.controller;

import cn.com.ty.lift.ud.payment.controller.query.UserWithdrawQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.service.IService;

import cn.com.ty.lift.ud.chat.controller.model.ChatSessionReq;
import cn.com.ty.lift.ud.common.BaseController;
import cn.com.ty.lift.ud.payment.mapper.entity.UserWithdrawEntity;
import cn.com.ty.lift.ud.payment.service.IUserWithdrawService;
import cn.com.xwy.boot.web.dto.RestResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 用户提现申请 API Jing
 * 
 * @author Xson
 * @date 2020-04-23
 */
@Api(tags = "用户提现申请 API- 盛文静")
@RestController
@RequestMapping("/api/userWithdraws")
public class UserWithdrawController extends BaseController<UserWithdrawEntity, UserWithdrawQuery> {

    private final Logger log = LoggerFactory.getLogger(UserWithdrawController.class);

    private @Autowired IUserWithdrawService userWithdrawService;

    @Override
    protected IService<UserWithdrawEntity> getService() {
        return userWithdrawService;
    }

    @PostMapping("/query-page")
    @ApiOperation(value = "分页查询")
    @Override
    public RestResponse getCondition(@RequestBody UserWithdrawQuery request) {
        return userWithdrawService.selectByExample(request);
    }

    @PutMapping("/delete-batch")
    @ApiOperation(value = "批量删除提现申请")
    public RestResponse deleteUpdate(@RequestBody ChatSessionReq req) {
        return userWithdrawService.deleteUpdate(req);
    }

    @PostMapping("/examine")
    @ApiOperation(value = "提现审批")
    public RestResponse examine(@RequestBody UserWithdrawQuery req) {
        return userWithdrawService.examine(req);
    }

    @PostMapping("/insetWithdrwa")
    @ApiOperation(value = "新增提现")
    public RestResponse insetWithdrwa(@RequestBody UserWithdrawEntity req) {
        return userWithdrawService.insetWithdrwa(req);
    }


    @PostMapping("/isOver")
    @ApiOperation(value = "判断用户当月提现次数是否超过设置值")
    public Integer isOver(@RequestBody UserWithdrawEntity req) {
        return userWithdrawService.isOver(req);
    }
}