import { z } from '@hono/zod-openapi';
import { WorkStatus } from '@d8d/allin-enums';

/**
 * 工作历史项Schema
 */
export const WorkHistoryItemSchema = z.object({
  订单ID: z.coerce.number().int().positive().openapi({
    description: '订单ID',
    example: 123
  }),
  订单名称: z.string().nullable().openapi({
    description: '订单名称',
    example: '2024年第一季度用工订单'
  }),
  入职日期: z.coerce.date().nullable().openapi({
    description: '入职日期',
    example: '2024-01-15T00:00:00.000Z'
  }),
  实际入职日期: z.coerce.date().nullable().openapi({
    description: '实际入职日期',
    example: '2024-01-16T00:00:00.000Z'
  }),
  离职日期: z.coerce.date().nullable().openapi({
    description: '离职日期',
    example: '2024-06-30T00:00:00.000Z'
  }),
  工作状态: z.string().openapi({
    description: '工作状态（中文标签）',
    example: '在职'
  }),
  个人薪资: z.coerce.number().openapi({
    description: '个人薪资',
    example: 5000.00
  })
}).openapi('WorkHistoryItem');

/**
 * 工作历史响应Schema
 */
export const WorkHistoryResponseSchema = z.object({
  工作历史: z.array(WorkHistoryItemSchema).openapi({
    description: '工作历史列表'
  })
}).openapi('WorkHistoryResponse');

/**
 * 薪资历史项Schema
 */
export const SalaryHistoryItemSchema = z.object({
  月份: z.coerce.date().nullable().openapi({
    description: '薪资月份',
    example: '2024-01-01T00:00:00.000Z'
  }),
  基本工资: z.coerce.number().openapi({
    description: '基本工资',
    example: 5000.00
  }),
  补贴: z.coerce.number().openapi({
    description: '补贴金额',
    example: 500.00
  }),
  扣款: z.coerce.number().openapi({
    description: '扣款金额',
    example: 200.00
  }),
  实发工资: z.coerce.number().openapi({
    description: '实发工资',
    example: 5300.00
  })
}).openapi('SalaryHistoryItem');

/**
 * 薪资历史响应Schema
 */
export const SalaryHistoryResponseSchema = z.object({
  薪资历史: z.array(SalaryHistoryItemSchema).openapi({
    description: '薪资历史列表'
  })
}).openapi('SalaryHistoryResponse');

/**
 * 征信信息项Schema
 */
export const CreditInfoItemSchema = z.object({
  文件ID: z.string().openapi({
    description: '文件ID',
    example: 'file_123456'
  }),
  文件URL: z.string().nullable().openapi({
    description: '文件URL',
    example: 'https://example.com/files/123456'
  }),
  上传时间: z.coerce.date().nullable().openapi({
    description: '上传时间',
    example: '2024-01-15T10:30:00.000Z'
  }),
  文件类型: z.string().nullable().openapi({
    description: '文件类型',
    example: 'image/png'
  }),
  银行卡号: z.string().nullable().openapi({
    description: '银行卡号',
    example: '622848********1234'
  }),
  持卡人姓名: z.string().nullable().openapi({
    description: '持卡人姓名',
    example: '张三'
  }),
  银行名称: z.coerce.number().int().nullable().openapi({
    description: '银行名称ID',
    example: 1
  })
}).openapi('CreditInfoItem');

/**
 * 征信信息响应Schema
 */
export const CreditInfoResponseSchema = z.object({
  征信信息: z.array(CreditInfoItemSchema).openapi({
    description: '征信信息列表'
  })
}).openapi('CreditInfoResponse');

/**
 * 视频关联项Schema
 */
export const PersonVideoItemSchema = z.object({
  视频类型: z.string().openapi({
    description: '视频类型',
    example: 'salary_video'
  }),
  文件ID: z.string().openapi({
    description: '文件ID',
    example: 'file_123456'
  }),
  文件URL: z.string().nullable().openapi({
    description: '文件URL',
    example: 'https://example.com/files/123456'
  }),
  上传时间: z.coerce.date().nullable().openapi({
    description: '上传时间',
    example: '2024-01-15T10:30:00.000Z'
  }),
  文件类型: z.string().nullable().openapi({
    description: '文件类型',
    example: 'video/mp4'
  }),
  关联订单ID: z.coerce.number().int().positive().nullable().openapi({
    description: '关联订单ID',
    example: 123
  })
}).openapi('PersonVideoItem');

/**
 * 视频关联响应Schema
 */
export const PersonVideosResponseSchema = z.object({
  视频列表: z.array(PersonVideoItemSchema).openapi({
    description: '视频列表'
  })
}).openapi('PersonVideosResponse');

/**
 * 企业专用人才列表项Schema
 */
export const CompanyPersonListItemSchema = z.object({
  personId: z.coerce.number().int().positive().openapi({
    description: '残疾人ID',
    example: 123
  }),
  name: z.string().openapi({
    description: '姓名',
    example: '张三'
  }),
  gender: z.string().openapi({
    description: '性别',
    example: 'male'
  }),
  idCard: z.string().openapi({
    description: '身份证号',
    example: '330102199001011234'
  }),
  disabilityType: z.string().openapi({
    description: '残疾类型',
    example: '肢体残疾'
  }),
  disabilityLevel: z.string().openapi({
    description: '残疾等级',
    example: '二级'
  }),
  phone: z.string().nullable().openapi({
    description: '手机号',
    example: '13800138000'
  }),
  birthDate: z.coerce.date().nullable().openapi({
    description: '出生日期',
    example: '1990-01-01T00:00:00.000Z'
  }),
  salaryDetail: z.coerce.number().nullable().openapi({
    description: '薪资详情',
    example: 5000.00
  }),
  jobStatus: z.string().openapi({
    description: '工作状态（中文标签）',
    example: '在职'
  }),
  workStatus: z.nativeEnum(WorkStatus).openapi({
    description: '工作状态枚举值',
    example: WorkStatus.WORKING
  }),
  workStatusLabel: z.string().openapi({
    description: '工作状态中文标签',
    example: '在职'
  }),
  latestJoinDate: z.coerce.date().nullable().openapi({
    description: '最新入职日期',
    example: '2024-12-15T00:00:00.000Z'
  }),
  orderName: z.string().nullable().openapi({
    description: '订单名称',
    example: '2024年第四季度用工订单'
  })
}).openapi('CompanyPersonListItem');

/**
 * 企业专用人才列表响应Schema
 */
export const CompanyPersonListResponseSchema = z.object({
  data: z.array(CompanyPersonListItemSchema).openapi({
    description: '企业人才列表数据'
  }),
  pagination: z.object({
    page: z.coerce.number().int().positive().openapi({
      description: '当前页码',
      example: 1
    }),
    limit: z.coerce.number().int().positive().openapi({
      description: '每页记录数',
      example: 10
    }),
    total: z.coerce.number().int().nonnegative().openapi({
      description: '总记录数',
      example: 45
    }),
    totalPages: z.coerce.number().int().nonnegative().openapi({
      description: '总页数',
      example: 5
    })
  }).openapi('PaginationInfo')
}).openapi('CompanyPersonListResponse');

/**
 * 企业专用人才查询参数Schema
 */
export const CompanyPersonListQuerySchema = z.object({
  search: z.string().optional().openapi({
    description: '搜索关键词（姓名、残疾证号）',
    example: '张三'
  }),
  disabilityType: z.string().optional().openapi({
    description: '残疾类型筛选',
    example: '肢体残疾'
  }),
  jobStatus: z.union([z.nativeEnum(WorkStatus), z.string()]).optional().openapi({
    description: '工作状态筛选：支持WorkStatus枚举值（working/pre_working/resigned/not_working）或中文标签（在职/待入职/离职/未就业）',
    example: WorkStatus.WORKING
  }),
  page: z.coerce.number().int().positive().default(1).openapi({
    description: '页码，默认1',
    example: 1
  }),
  limit: z.coerce.number().int().positive().default(10).openapi({
    description: '每页记录数，默认10',
    example: 10
  })
}).openapi('CompanyPersonListQuery');

/**
 * 企业专用人才详情Schema
 */
export const CompanyPersonDetailSchema = z.object({
  personId: z.coerce.number().int().positive().openapi({
    description: '残疾人ID',
    example: 123
  }),
  name: z.string().openapi({
    description: '姓名',
    example: '张三'
  }),
  gender: z.string().openapi({
    description: '性别',
    example: 'male'
  }),
  idCard: z.string().openapi({
    description: '身份证号',
    example: '330102199001011234'
  }),
  disabilityType: z.string().openapi({
    description: '残疾类型',
    example: '肢体残疾'
  }),
  disabilityLevel: z.string().openapi({
    description: '残疾等级',
    example: '二级'
  }),
  birthDate: z.coerce.date().nullable().openapi({
    description: '出生日期',
    example: '1990-01-01T00:00:00.000Z'
  }),
  salaryDetail: z.coerce.number().nullable().openapi({
    description: '薪资详情',
    example: 5000.00
  }),
  phone: z.string().nullable().openapi({
    description: '手机号',
    example: '13800138000'
  }),
  jobStatus: z.string().openapi({
    description: '工作状态（中文标签）',
    example: '在职'
  }),
  workStatus: z.nativeEnum(WorkStatus).openapi({
    description: '工作状态枚举值',
    example: WorkStatus.WORKING
  }),
  workStatusLabel: z.string().openapi({
    description: '工作状态中文标签',
    example: '在职'
  }),
  bankCards: z.array(z.object({
    cardId: z.coerce.number().int().positive().openapi({
      description: '银行卡ID',
      example: 1
    }),
    bankName: z.string().openapi({
      description: '银行名称',
      example: '中国工商银行'
    }),
    cardNumber: z.string().openapi({
      description: '银行卡号',
      example: '6222021234567890123'
    }),
    isDefault: z.boolean().openapi({
      description: '是否默认银行卡',
      example: true
    })
  })).openapi({
    description: '银行卡列表'
  }),
  photos: z.array(z.object({
    fileId: z.coerce.number().int().positive().openapi({
      description: '文件ID',
      example: 1
    }),
    fileName: z.string().openapi({
      description: '文件名',
      example: '身份证正面照.jpg'
    }),
    fileUrl: z.string().openapi({
      description: '文件URL',
      example: 'https://minio.example.com/files/身份证正面照.jpg'
    })
  })).openapi({
    description: '照片列表'
  })
}).openapi('CompanyPersonDetail');