// 财务数据接口类型定义
export interface FinancialData {
  code: 200
  msg: '查询成功'
  rows: Array<{
    assetTotalNet: Array<{
      id: number
      year: number
      assetTotal: number // 资产总额（单位：元）
      assetNet: number   // 资产净额（单位：元）
      dataDeadline: string
      createTime: string
      updateTime: string
    }>
    profitTotalNet: Array<{
      id: number
      year: number
      profitTotal: number // 利润总额（单位：元）
      profitNet: number   // 净利润（单位：元）
      dataDeadline: string
      createTime: string
      updateTime: string
    }>
    incomeStatement: Array<{
      id: number
      year: number
      income: number      // 收入（单位：元）
      dataDeadline: string
      createTime: string
      updateTime: string
    }>
    assetLiabilityRatio: Array<{
      id: number
      year: number
      assetLiabilityRatio: number // 资产负债率（单位：%）
      dataDeadline: string
      createTime: string
      updateTime: string
    }>
  }>
}

class DashService {
  /**
   * 获取财务数据
   * 这是一个公开API，返回固定的mock数据
   */
  async getFinancialData(): Promise<FinancialData> {
    // 使用固定的mock数据，不需要数据库访问
    const mockData: FinancialData = {
      code: 200,
      msg: '查询成功',
      rows: [
        {
          assetTotalNet: [
            {
              id: 1,
              year: 2024,
              assetTotal: 150000000, // 1.5亿
              assetNet: 120000000,   // 1.2亿
              dataDeadline: '2024-12-31',
              createTime: '2024-01-01 00:00:00',
              updateTime: '2024-12-31 23:59:59'
            },
            {
              id: 2,
              year: 2023,
              assetTotal: 130000000, // 1.3亿
              assetNet: 100000000,   // 1.0亿
              dataDeadline: '2023-12-31',
              createTime: '2023-01-01 00:00:00',
              updateTime: '2023-12-31 23:59:59'
            }
          ],
          profitTotalNet: [
            {
              id: 1,
              year: 2024,
              profitTotal: 25000000, // 2500万
              profitNet: 20000000,   // 2000万
              dataDeadline: '2024-12-31',
              createTime: '2024-01-01 00:00:00',
              updateTime: '2024-12-31 23:59:59'
            },
            {
              id: 2,
              year: 2023,
              profitTotal: 20000000, // 2000万
              profitNet: 15000000,   // 1500万
              dataDeadline: '2023-12-31',
              createTime: '2023-01-01 00:00:00',
              updateTime: '2023-12-31 23:59:59'
            }
          ],
          incomeStatement: [
            {
              id: 1,
              year: 2024,
              income: 80000000, // 8000万
              dataDeadline: '2024-12-31',
              createTime: '2024-01-01 00:00:00',
              updateTime: '2024-12-31 23:59:59'
            },
            {
              id: 2,
              year: 2023,
              income: 65000000, // 6500万
              dataDeadline: '2023-12-31',
              createTime: '2023-01-01 00:00:00',
              updateTime: '2023-12-31 23:59:59'
            }
          ],
          assetLiabilityRatio: [
            {
              id: 1,
              year: 2024,
              assetLiabilityRatio: 45.2, // 45.2%
              dataDeadline: '2024-12-31',
              createTime: '2024-01-01 00:00:00',
              updateTime: '2024-12-31 23:59:59'
            },
            {
              id: 2,
              year: 2023,
              assetLiabilityRatio: 48.7, // 48.7%
              dataDeadline: '2023-12-31',
              createTime: '2023-01-01 00:00:00',
              updateTime: '2023-12-31 23:59:59'
            }
          ]
        }
      ]
    }

    return mockData
  }
}

export const dashService = new DashService()