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

import cn.com.ty.lift.ud.payment.controller.query.UserBillQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

import cn.com.ty.lift.ud.common.BaseController;
import cn.com.ty.lift.ud.payment.mapper.entity.UserBillEntity;
import cn.com.ty.lift.ud.payment.service.IUserBillService;
import cn.com.xwy.boot.web.dto.RestResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.math.BigDecimal;

/**
 * 用户账单流水 API Jing
 * 
 * @author Xson
 * @date 2020-04-23
 */
@Api(tags = "用户账单流水 API- 盛文静")
@RestController
@RequestMapping("/api/userBills")
public class UserBillController extends BaseController<UserBillEntity, UserBillQuery> {

    private final Logger log = LoggerFactory.getLogger(UserBillController.class);
    
    private @Autowired IUserBillService userBillService;

    @Override
    protected IService<UserBillEntity> getService() {
        return userBillService;
    }
    
    @PostMapping("/query-page")
    @ApiOperation(value = "分页查询")
    @Override
    public RestResponse getCondition(@RequestBody UserBillQuery request) {
        return userBillService.selectByExample(request);
    }

    @GetMapping("/query")
    @ApiOperation(value = "获取详情")
    @Override
    public RestResponse get(Long id) {
        RestResponse rtn = userBillService.getDetail(id);

        return rtn;
    }

    @GetMapping("/query-balance/{userId}")
    @ApiOperation(value = "测试 - 查询最近一次的余额")
    public BigDecimal getBalance(@PathVariable("userId") Long userId) {

        BigDecimal balance = userBillService.getLatestBalance(userId);
        return balance;
    }


   
}