package com.ruoyi.controller;

import com.ruoyi.annotations.UserLoginToken;
import com.ruoyi.controller.req.BondPayReq;
import com.ruoyi.controller.req.BondRecordPageReq;
import com.ruoyi.frequency.bondrecord.service.BondRecordService;
import com.ruoyi.response.ResponseData;
import com.ruoyi.vo.BodyIdReq;
import com.ruoyi.vo.RyController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 保证金
 */
@CrossOrigin
@RestController
@RequestMapping("/api/bond")
@Api(tags = "保证金")
public class ApiBondController extends RyController {

    @Autowired
    private BondRecordService bondRecordService;


    @PostMapping("bondPay")
    @UserLoginToken
    @ApiOperation(value = "缴纳保证金", notes = "缴纳保证金")
    public ResponseData bondPay(@Valid @RequestBody BondPayReq req) {
        return bondRecordService.bondPay(req, getUserVo());
    }


    @PostMapping("bondRecordPage")
    @UserLoginToken
    @ApiOperation(value = "缴纳保证金记录", notes = "缴纳保证金记录")
    public ResponseData bondRecordPage(@Valid @RequestBody BondRecordPageReq req) {
        return bondRecordService.bondRecordPage(req, getUserVo());
    }

    @PostMapping("bondRecordDetail")
    @UserLoginToken
    @ApiOperation(value = "缴纳保证金记录详情", notes = "缴纳保证金记录详情")
    public ResponseData bondRecordDetail(@Valid @RequestBody BodyIdReq req) {
        return bondRecordService.bondRecordDetail(req.getId(), getUserVo());
    }


}
