package vip.xiaonuo.money.controller;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.money.entity.MoneyBorrowWarning;
import vip.xiaonuo.money.entity.vo.MoneyBankNameVo;
import vip.xiaonuo.money.entity.vo.MoneyBorrowPriceVo;
import vip.xiaonuo.money.param.MoneyBorrowDetailParam;
import vip.xiaonuo.money.param.MoneyBorrowParam;
import vip.xiaonuo.money.param.MoneyBusinessParam;
import vip.xiaonuo.money.param.MoneyInOutParam;
import vip.xiaonuo.money.service.IMoneyBorrowWarningService;
import vip.xiaonuo.money.service.IMoneyBusinessService;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 财务临近还款期预警 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-20
 */

@Api(tags = "临近还款期预警控制器")
@ApiSupport(author = "wang", order = 1)
@RestController
@Validated
public class MoneyBorrowWarningController {

    @Autowired
    private IMoneyBorrowWarningService borrowWarningService;


    @ApiOperationSupport(order = 1)
    @ApiOperation("临近还款")
    @PostMapping("/money-borrow-warning/listBusiness")
    public CommonResult<List<MoneyBorrowWarning>> listBorrowWarning(@RequestBody MoneyInOutParam inOutParam) {
        return CommonResult.data(borrowWarningService.listBorrowWarning(inOutParam));
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation("借款总金额")
    @PostMapping("/money-borrow-warning/getMoneyCount")
    public CommonResult<JSONObject> getMoneyCount(@RequestBody MoneyBorrowParam borrowParam) {
        return CommonResult.data(borrowWarningService.getMoneyCount(borrowParam));
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation("借款金额分析")
    @PostMapping("/money-borrow-warning/bankRank")
    public CommonResult<List<MoneyBankNameVo>> bankRank(@RequestBody MoneyBorrowParam borrowParam) {
        return CommonResult.data(borrowWarningService.bankRank(borrowParam));
    }

    @ApiOperationSupport(order = 4)
    @ApiOperation("年月借款分析")
    @PostMapping("/money-borrow-warning/borrowMoney")
    public CommonResult<List<MoneyBorrowPriceVo>> borrowMoney(@RequestBody MoneyBorrowParam borrowParam) {
        return CommonResult.data(borrowWarningService.borrowMoney(borrowParam));
    }

    @ApiOperationSupport(order = 5)
    @ApiOperation("借款明细表")
    @PostMapping("/money-borrow-warning/listBorrowDetail")
    public CommonResult<Page<MoneyBorrowWarning>> listBorrowDetail(@RequestBody MoneyBorrowDetailParam detailParam) {
        return CommonResult.data(borrowWarningService.listBorrowDetail(detailParam));
    }

    @ApiOperationSupport(order = 6)
    @ApiOperation("借款添加")
    @PostMapping("/money-borrow-warning/add")
    public CommonResult add(@RequestBody MoneyBorrowWarning moneyBorrowWarning) {
        return borrowWarningService.add(moneyBorrowWarning);
    }

    @ApiOperationSupport(order = 7)
    @ApiOperation("借款修改")
    @PostMapping("/money-borrow-warning/edit")
    public CommonResult edit(@RequestBody MoneyBorrowWarning moneyBorrowWarning) {
        borrowWarningService.update(moneyBorrowWarning);
        return CommonResult.ok();
    }

    @ApiOperationSupport(order = 8)
    @ApiOperation("借款删除")
    @PostMapping("/money-borrow-warning/delete")
    public CommonResult remove(@RequestBody Map<String, String> paramsMap) {
        borrowWarningService.remove(paramsMap);
        return CommonResult.ok();
    }

    @ApiOperationSupport(order = 9)
    @ApiOperation("借款银行列表")
    @PostMapping("/money-borrow-warning/listBank")
    public CommonResult<List<MoneyBorrowWarning>> listBank(@RequestBody Map<String, String> paramsMap) {
        return CommonResult.data(borrowWarningService.listBank(paramsMap));
    }
}
