/**
 * 银行监管相关 API 接口
 */

import request from '@/common/utils/request'

export const financeApi = {
  /**
   * 获取贷款列表
   * @param {Object} params 查询参数
   */
  getLoanList(params) {
    return request.get('/finance/loans', { params })
  },

  /**
   * 获取贷款详情
   * @param {number} id 贷款ID
   */
  getLoanDetail(id) {
    return request.get(`/finance/loans/${id}`)
  },

  /**
   * 申请贷款
   * @param {Object} loanData 贷款申请数据
   */
  applyLoan(loanData) {
    return request.post('/finance/loans/apply', loanData)
  },

  /**
   * 审批贷款
   * @param {number} id 贷款ID
   * @param {Object} approvalData 审批数据
   */
  approveLoan(id, approvalData) {
    return request.post(`/finance/loans/${id}/approve`, approvalData)
  },

  /**
   * 拒绝贷款
   * @param {number} id 贷款ID
   * @param {Object} rejectData 拒绝数据
   */
  rejectLoan(id, rejectData) {
    return request.post(`/finance/loans/${id}/reject`, rejectData)
  },

  /**
   * 放款
   * @param {number} id 贷款ID
   * @param {Object} disbursementData 放款数据
   */
  disburseLoan(id, disbursementData) {
    return request.post(`/finance/loans/${id}/disburse`, disbursementData)
  },

  /**
   * 还款
   * @param {number} id 贷款ID
   * @param {Object} repaymentData 还款数据
   */
  repayLoan(id, repaymentData) {
    return request.post(`/finance/loans/${id}/repay`, repaymentData)
  },

  /**
   * 获取还款计划
   * @param {number} loanId 贷款ID
   */
  getRepaymentPlan(loanId) {
    return request.get(`/finance/loans/${loanId}/repayment-plan`)
  },

  /**
   * 获取还款记录
   * @param {number} loanId 贷款ID
   * @param {Object} params 查询参数
   */
  getRepaymentHistory(loanId, params) {
    return request.get(`/finance/loans/${loanId}/repayment-history`, { params })
  },

  /**
   * 获取风险评估
   * @param {Object} assessmentData 评估数据
   */
  getRiskAssessment(assessmentData) {
    return request.post('/finance/risk-assessment', assessmentData)
  },

  /**
   * 获取信用报告
   * @param {number} userId 用户ID
   */
  getCreditReport(userId) {
    return request.get(`/finance/credit-report/${userId}`)
  },

  /**
   * 获取抵押物列表
   * @param {Object} params 查询参数
   */
  getCollateralList(params) {
    return request.get('/finance/collaterals', { params })
  },

  /**
   * 添加抵押物
   * @param {Object} collateralData 抵押物数据
   */
  addCollateral(collateralData) {
    return request.post('/finance/collaterals', collateralData)
  },

  /**
   * 评估抵押物
   * @param {number} id 抵押物ID
   * @param {Object} evaluationData 评估数据
   */
  evaluateCollateral(id, evaluationData) {
    return request.post(`/finance/collaterals/${id}/evaluate`, evaluationData)
  },

  /**
   * 获取担保人列表
   * @param {Object} params 查询参数
   */
  getGuarantorList(params) {
    return request.get('/finance/guarantors', { params })
  },

  /**
   * 添加担保人
   * @param {Object} guarantorData 担保人数据
   */
  addGuarantor(guarantorData) {
    return request.post('/finance/guarantors', guarantorData)
  },

  /**
   * 验证担保人
   * @param {number} id 担保人ID
   * @param {Object} verificationData 验证数据
   */
  verifyGuarantor(id, verificationData) {
    return request.post(`/finance/guarantors/${id}/verify`, verificationData)
  },

  /**
   * 获取监管报告
   * @param {Object} params 查询参数
   */
  getSupervisionReports(params) {
    return request.get('/finance/supervision-reports', { params })
  },

  /**
   * 生成监管报告
   * @param {Object} reportData 报告数据
   */
  generateSupervisionReport(reportData) {
    return request.post('/finance/supervision-reports/generate', reportData)
  },

  /**
   * 获取合规检查记录
   * @param {Object} params 查询参数
   */
  getComplianceChecks(params) {
    return request.get('/finance/compliance-checks', { params })
  },

  /**
   * 执行合规检查
   * @param {Object} checkData 检查数据
   */
  performComplianceCheck(checkData) {
    return request.post('/finance/compliance-checks', checkData)
  },

  /**
   * 获取审计日志
   * @param {Object} params 查询参数
   */
  getAuditLogs(params) {
    return request.get('/finance/audit-logs', { params })
  },

  /**
   * 获取统计数据
   * @param {Object} params 查询参数
   */
  getFinanceStats(params) {
    return request.get('/finance/statistics', { params })
  },

  /**
   * 获取风险预警
   * @param {Object} params 查询参数
   */
  getRiskAlerts(params) {
    return request.get('/finance/risk-alerts', { params })
  },

  /**
   * 处理风险预警
   * @param {number} id 预警ID
   * @param {Object} handleData 处理数据
   */
  handleRiskAlert(id, handleData) {
    return request.post(`/finance/risk-alerts/${id}/handle`, handleData)
  },

  /**
   * 获取利率配置
   */
  getInterestRates() {
    return request.get('/finance/interest-rates')
  },

  /**
   * 更新利率配置
   * @param {Object} rateData 利率数据
   */
  updateInterestRates(rateData) {
    return request.put('/finance/interest-rates', rateData)
  },

  /**
   * 获取贷款产品
   */
  getLoanProducts() {
    return request.get('/finance/loan-products')
  },

  /**
   * 创建贷款产品
   * @param {Object} productData 产品数据
   */
  createLoanProduct(productData) {
    return request.post('/finance/loan-products', productData)
  },

  /**
   * 更新贷款产品
   * @param {number} id 产品ID
   * @param {Object} productData 产品数据
   */
  updateLoanProduct(id, productData) {
    return request.put(`/finance/loan-products/${id}`, productData)
  },

  /**
   * 获取银行账户信息
   * @param {number} userId 用户ID
   */
  getBankAccounts(userId) {
    return request.get(`/finance/bank-accounts/${userId}`)
  },

  /**
   * 绑定银行账户
   * @param {Object} accountData 账户数据
   */
  bindBankAccount(accountData) {
    return request.post('/finance/bank-accounts/bind', accountData)
  },

  /**
   * 解绑银行账户
   * @param {number} accountId 账户ID
   */
  unbindBankAccount(accountId) {
    return request.delete(`/finance/bank-accounts/${accountId}`)
  },

  /**
   * 验证银行账户
   * @param {number} accountId 账户ID
   * @param {Object} verificationData 验证数据
   */
  verifyBankAccount(accountId, verificationData) {
    return request.post(`/finance/bank-accounts/${accountId}/verify`, verificationData)
  }
}