import { z } from '@hono/zod-openapi';

/**
 * 人才就业信息Schema
 * 用于人才小程序查询就业信息相关接口
 */

// 当前就业状态响应Schema
export const EmploymentStatusResponseSchema = z.object({
  companyName: z.string().openapi({
    description: '企业名称',
    example: '某某科技有限公司'
  }),
  orderId: z.number().openapi({
    description: '订单ID',
    example: 1
  }),
  orderName: z.string().nullable().openapi({
    description: '订单名称(岗位名称)',
    example: '包装工'
  }),
  positionName: z.string().nullable().openapi({
    description: '岗位名称(同订单名称)',
    example: '包装工'
  }),
  joinDate: z.string().openapi({
    description: '入职日期,格式: YYYY-MM-DD',
    example: '2025-01-15'
  }),
  workStatus: z.string().openapi({
    description: '工作状态',
    enum: ['not_working', 'pre_working', 'working', 'resigned'],
    example: 'working'
  }),
  salaryLevel: z.number().openapi({
    description: '薪资水平',
    example: 3500.00
  }),
  actualStartDate: z.string().nullable().openapi({
    description: '实际入职日期,格式: YYYY-MM-DD',
    example: '2025-01-15'
  })
}).openapi('EmploymentStatusResponse');

// 空就业状态Schema (用于无就业记录时返回null)
export const EmploymentStatusNullableSchema = EmploymentStatusResponseSchema.nullable().openapi({
  description: '当前就业状态(可能为null表示未就业)',
  example: null
});

// 薪资记录Schema
export const SalaryRecordSchema = z.object({
  orderId: z.number().openapi({
    description: '订单ID',
    example: 1
  }),
  orderName: z.string().nullable().openapi({
    description: '订单名称',
    example: '包装工'
  }),
  companyName: z.string().nullable().openapi({
    description: '企业名称',
    example: '某某科技有限公司'
  }),
  salaryAmount: z.number().openapi({
    description: '薪资金额',
    example: 3500.00
  }),
  joinDate: z.string().openapi({
    description: '入职日期,格式: YYYY-MM-DD',
    example: '2025-01-15'
  }),
  month: z.string().openapi({
    description: '月份,格式: YYYY-MM',
    example: '2025-01'
  })
}).openapi('SalaryRecord');

// 薪资记录响应Schema
export const SalaryRecordsResponseSchema = z.object({
  data: z.array(SalaryRecordSchema).openapi({
    description: '薪资记录列表'
  }),
  total: z.number().openapi({
    description: '总记录数',
    example: 10
  })
}).openapi('SalaryRecordsResponse');

// 就业历史项Schema
export const EmploymentHistoryItemSchema = z.object({
  orderId: z.number().openapi({
    description: '订单ID',
    example: 1
  }),
  orderName: z.string().nullable().openapi({
    description: '订单名称',
    example: '包装工'
  }),
  companyName: z.string().nullable().openapi({
    description: '企业名称',
    example: '某某科技有限公司'
  }),
  positionName: z.string().nullable().openapi({
    description: '岗位名称',
    example: '包装工'
  }),
  joinDate: z.string().openapi({
    description: '入职日期,格式: YYYY-MM-DD',
    example: '2025-01-15'
  }),
  leaveDate: z.string().nullable().openapi({
    description: '离职日期,格式: YYYY-MM-DD',
    example: null
  }),
  workStatus: z.string().openapi({
    description: '工作状态',
    enum: ['not_working', 'pre_working', 'working', 'resigned'],
    example: 'working'
  }),
  salaryLevel: z.number().openapi({
    description: '薪资水平',
    example: 3500.00
  })
}).openapi('EmploymentHistoryItem');

// 就业历史响应Schema
export const EmploymentHistoryResponseSchema = z.object({
  data: z.array(EmploymentHistoryItemSchema).openapi({
    description: '就业历史列表'
  }),
  total: z.number().openapi({
    description: '总记录数',
    example: 5
  })
}).openapi('EmploymentHistoryResponse');

// 薪资视频Schema
export const SalaryVideoSchema = z.object({
  id: z.number().openapi({
    description: '视频ID',
    example: 1
  }),
  assetType: z.string().openapi({
    description: '资产类型',
    enum: ['salary_video', 'tax_video'],
    example: 'salary_video'
  }),
  assetFileType: z.string().openapi({
    description: '资产文件类型',
    example: 'video'
  }),
  fileUrl: z.string().nullable().openapi({
    description: '文件URL',
    example: 'https://example.com/files/video.mp4'
  }),
  fileName: z.string().nullable().openapi({
    description: '文件名',
    example: '工资视频_2025-01.mp4'
  }),
  status: z.string().openapi({
    description: '审核状态',
    enum: ['pending', 'verified', 'rejected'],
    example: 'verified'
  }),
  relatedTime: z.string().openapi({
    description: '关联时间,格式: ISO 8601',
    example: '2025-01-15T10:30:00Z'
  }),
  month: z.string().openapi({
    description: '月份,格式: YYYY-MM',
    example: '2025-01'
  })
}).openapi('SalaryVideo');

// 薪资视频响应Schema
export const SalaryVideosResponseSchema = z.object({
  data: z.array(SalaryVideoSchema).openapi({
    description: '薪资视频列表'
  }),
  total: z.number().openapi({
    description: '总记录数',
    example: 3
  })
}).openapi('SalaryVideosResponse');

// 查询参数Schema - 薪资查询
export const SalaryQuerySchema = z.object({
  month: z.string().regex(/^\d{4}-\d{2}$/).optional().openapi({
    description: '月份过滤,格式: YYYY-MM',
    example: '2025-01'
  }),
  skip: z.coerce.number().int().min(0).optional().openapi({
    description: '跳过的记录数',
    example: 0
  }),
  take: z.coerce.number().int().min(1).max(100).optional().openapi({
    description: '每页记录数',
    example: 10
  })
}).openapi('SalaryQuery');

// 查询参数Schema - 就业历史查询
export const EmploymentHistoryQuerySchema = z.object({
  skip: z.coerce.number().int().min(0).optional().openapi({
    description: '跳过的记录数',
    example: 0
  }),
  take: z.coerce.number().int().min(1).max(100).optional().openapi({
    description: '每页记录数',
    example: 20
  })
}).openapi('EmploymentHistoryQuery');

// 查询参数Schema - 薪资视频查询
export const SalaryVideoQuerySchema = z.object({
  assetType: z.enum(['salary_video', 'tax_video']).optional().openapi({
    description: '视频类型过滤',
    example: 'salary_video'
  }),
  month: z.string().regex(/^\d{4}-\d{2}$/).optional().openapi({
    description: '月份过滤,格式: YYYY-MM',
    example: '2025-01'
  }),
  skip: z.coerce.number().int().min(0).optional().openapi({
    description: '跳过的记录数',
    example: 0
  }),
  take: z.coerce.number().int().min(1).max(100).optional().openapi({
    description: '每页记录数',
    example: 10
  })
}).openapi('SalaryVideoQuery');
