package com.chushang.loan.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.chushang.common.core.web.AjaxResult;
import com.chushang.common.log.annotation.SysLog;
import com.chushang.common.log.enums.BusinessType;
import com.chushang.common.mybatis.utils.PageResult;
import com.chushang.loan.domin.dto.LoanApproval;
import com.chushang.loan.domin.entity.LoanEntity;
import com.chushang.loan.domin.query.LoanFormQuery;
import com.chushang.loan.service.ILoanService;
import com.chushang.security.annotation.InnerAuth;
import com.chushang.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/loan")
public class LoanController {


    @Autowired
    private ILoanService iLoanService;
    @PostMapping("/qcode")
    public AjaxResult submitFormData(@RequestBody @Validated LoanFormQuery formData) throws Exception{
        return AjaxResult.success(iLoanService.qcCode(formData));
    }
    @GetMapping("/find")
    @RequiresPermissions("loan:loan:find")
    public AjaxResult queryLoan(LoanEntity query) {
        return AjaxResult.success(iLoanService.queryLoan(query));
    }
    /**
     * 查询统计多少人审核通过以及放款金额
     */
    @GetMapping("/data")
    @RequiresPermissions("loan:loan:data")
    public AjaxResult data( LoanEntity query) {
        return AjaxResult.success(iLoanService.queryData(query));
    }
    /**
     * 审批
     */
    @PostMapping("/approval")
    @SysLog(value = "审批贷款", businessType = BusinessType.UPDATE)
    @RequiresPermissions("loan:loan:approval")
    public AjaxResult approval(@RequestBody @Validated LoanApproval approval) {
        return AjaxResult.success(iLoanService.approval(approval));
    }
}
