openapi: 3.0.0
info:
  title: 保险管理系统 - 数据仓库API
  description: 保险管理系统数据仓库模块的API接口文档
  version: 1.0.0
  contact:
    name: 开发团队
    email: dev@example.com

servers:
  - url: http://localhost:3000/api
    description: 本地开发环境

paths:
  /data-warehouse/overview:
    get:
      tags:
        - 数据仓库
      summary: 获取数据仓库概览
      description: 获取保险业务的总体概览数据，包括申请数、保单数、理赔数、保费收入等关键指标
      security:
        - bearerAuth: []
      responses:
        '200':
          description: 成功获取概览数据
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      totalApplications:
                        type: integer
                        description: 总申请数
                        example: 137
                      totalPolicies:
                        type: integer
                        description: 总保单数
                        example: 26
                      totalClaims:
                        type: integer
                        description: 总理赔数
                        example: 7
                      totalPremium:
                        type: number
                        format: float
                        description: 总保费收入
                        example: 125000.50
                      totalClaimAmount:
                        type: number
                        format: float
                        description: 总理赔支出
                        example: 35000.00
                      activePolicies:
                        type: integer
                        description: 活跃保单数
                        example: 20
                      pendingApplications:
                        type: integer
                        description: 待处理申请数
                        example: 15
                      pendingClaims:
                        type: integer
                        description: 待处理理赔数
                        example: 3
                      profitLoss:
                        type: number
                        format: float
                        description: 盈亏情况（保费收入-理赔支出）
                        example: 90000.50
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'

  /data-warehouse/insurance-type-distribution:
    get:
      tags:
        - 数据仓库
      summary: 获取保险类型分布
      description: 获取各保险类型的申请数量分布统计
      security:
        - bearerAuth: []
      responses:
        '200':
          description: 成功获取保险类型分布数据
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        type:
                          type: string
                          description: 保险类型名称
                          example: "牛保险"
                        count:
                          type: integer
                          description: 申请数量
                          example: 45
                        percentage:
                          type: string
                          description: 占比百分比
                          example: "32.85"
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'

  /data-warehouse/application-status-distribution:
    get:
      tags:
        - 数据仓库
      summary: 获取申请状态分布
      description: 获取保险申请各状态的数量分布统计
      security:
        - bearerAuth: []
      responses:
        '200':
          description: 成功获取申请状态分布数据
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        status:
                          type: string
                          description: 申请状态
                          enum: [pending, initial_approved, under_review, approved, rejected, paid]
                          example: "pending"
                        label:
                          type: string
                          description: 状态标签
                          example: "待初审"
                        count:
                          type: integer
                          description: 数量
                          example: 25
                        percentage:
                          type: string
                          description: 占比百分比
                          example: "18.25"
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'

  /data-warehouse/trend-data:
    get:
      tags:
        - 数据仓库
      summary: 获取趋势数据
      description: 获取指定天数内的申请、保单、理赔趋势数据
      security:
        - bearerAuth: []
      parameters:
        - name: days
          in: query
          description: 查询天数，默认7天
          required: false
          schema:
            type: integer
            default: 7
            minimum: 1
            maximum: 365
            example: 7
      responses:
        '200':
          description: 成功获取趋势数据
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      applications:
                        type: array
                        description: 申请趋势数据
                        items:
                          type: object
                          properties:
                            date:
                              type: string
                              format: date
                              description: 日期
                              example: "2024-01-15"
                            count:
                              type: integer
                              description: 当日数量
                              example: 5
                      policies:
                        type: array
                        description: 保单趋势数据
                        items:
                          type: object
                          properties:
                            date:
                              type: string
                              format: date
                              description: 日期
                              example: "2024-01-15"
                            count:
                              type: integer
                              description: 当日数量
                              example: 3
                      claims:
                        type: array
                        description: 理赔趋势数据
                        items:
                          type: object
                          properties:
                            date:
                              type: string
                              format: date
                              description: 日期
                              example: "2024-01-15"
                            count:
                              type: integer
                              description: 当日数量
                              example: 1
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'

  /data-warehouse/claim-stats:
    get:
      tags:
        - 数据仓库
      summary: 获取理赔统计
      description: 获取理赔状态分布和月度理赔趋势统计数据
      security:
        - bearerAuth: []
      responses:
        '200':
          description: 成功获取理赔统计数据
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      statusDistribution:
                        type: array
                        description: 理赔状态分布
                        items:
                          type: object
                          properties:
                            status:
                              type: string
                              description: 理赔状态
                              enum: [pending, approved, rejected, processing, paid]
                              example: "pending"
                            label:
                              type: string
                              description: 状态标签
                              example: "待审核"
                            count:
                              type: integer
                              description: 数量
                              example: 5
                            totalAmount:
                              type: number
                              format: float
                              description: 总金额
                              example: 15000.00
                      monthlyTrend:
                        type: array
                        description: 月度理赔趋势
                        items:
                          type: object
                          properties:
                            month:
                              type: string
                              description: 月份（YYYY-MM格式）
                              example: "2024-01"
                            count:
                              type: integer
                              description: 理赔数量
                              example: 8
                            totalAmount:
                              type: number
                              format: float
                              description: 理赔总金额
                              example: 25000.00
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

  responses:
    Unauthorized:
      description: 未授权访问
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              message:
                type: string
                example: "未授权访问"

    InternalServerError:
      description: 服务器内部错误
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              message:
                type: string
                example: "服务器内部错误"
              error:
                type: string
                example: "具体错误信息"

  schemas:
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          description: 错误消息
        error:
          type: string
          description: 详细错误信息

tags:
  - name: 数据仓库
    description: 数据仓库相关接口，提供业务数据的统计分析功能