| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- import { z } from '@hono/zod-openapi';
- // 统计项通用Schema
- export const StatItemSchema = z.object({
- key: z.string().openapi({
- description: '统计项键名',
- example: '视力残疾'
- }),
- value: z.number().int().min(0).openapi({
- description: '统计数量',
- example: 10
- }),
- percentage: z.number().min(0).max(100).openapi({
- description: '占比百分比',
- example: 25.5
- })
- });
- // 年龄分组Schema
- export const AgeGroupSchema = z.enum(['18-25', '26-35', '36-45', '46+']).openapi({
- description: '年龄分组'
- });
- // 薪资范围分组Schema
- export const SalaryRangeSchema = z.enum(['<3000', '3000-5000', '5000-8000', '8000-12000', '12000+']).openapi({
- description: '薪资范围分组'
- });
- // 残疾类型分布响应Schema
- export const DisabilityTypeDistributionResponseSchema = z.object({
- companyId: z.number().int().positive().openapi({
- description: '企业ID',
- example: 1
- }),
- stats: z.array(StatItemSchema).openapi({
- description: '残疾类型分布统计'
- }),
- total: z.number().int().min(0).openapi({
- description: '总人数',
- example: 100
- })
- });
- // 性别分布响应Schema
- export const GenderDistributionResponseSchema = z.object({
- companyId: z.number().int().positive().openapi({
- description: '企业ID',
- example: 1
- }),
- stats: z.array(StatItemSchema).openapi({
- description: '性别分布统计'
- }),
- total: z.number().int().min(0).openapi({
- description: '总人数',
- example: 100
- })
- });
- // 年龄分布响应Schema
- export const AgeDistributionResponseSchema = z.object({
- companyId: z.number().int().positive().openapi({
- description: '企业ID',
- example: 1
- }),
- stats: z.array(
- StatItemSchema.extend({
- key: AgeGroupSchema
- })
- ).openapi({
- description: '年龄分布统计'
- }),
- total: z.number().int().min(0).openapi({
- description: '总人数',
- example: 100
- })
- });
- // 户籍分布项Schema(省市级)
- export const HouseholdStatItemSchema = StatItemSchema.extend({
- province: z.string().openapi({
- description: '省份',
- example: '江苏省'
- }),
- city: z.string().optional().openapi({
- description: '城市',
- example: '南京市'
- })
- });
- // 户籍分布响应Schema
- export const HouseholdDistributionResponseSchema = z.object({
- companyId: z.number().int().positive().openapi({
- description: '企业ID',
- example: 1
- }),
- stats: z.array(HouseholdStatItemSchema).openapi({
- description: '户籍分布统计'
- }),
- total: z.number().int().min(0).openapi({
- description: '总人数',
- example: 100
- })
- });
- // 在职状态分布响应Schema
- export const JobStatusDistributionResponseSchema = z.object({
- companyId: z.number().int().positive().openapi({
- description: '企业ID',
- example: 1
- }),
- stats: z.array(StatItemSchema).openapi({
- description: '在职状态分布统计'
- }),
- total: z.number().int().min(0).openapi({
- description: '总人数',
- example: 100
- })
- });
- // 薪资分布响应Schema
- export const SalaryDistributionResponseSchema = z.object({
- companyId: z.number().int().positive().openapi({
- description: '企业ID',
- example: 1
- }),
- stats: z.array(
- StatItemSchema.extend({
- key: SalaryRangeSchema
- })
- ).openapi({
- description: '薪资分布统计'
- }),
- total: z.number().int().min(0).openapi({
- description: '总人数',
- example: 100
- })
- });
- // 通用查询参数Schema
- export const StatisticsQuerySchema = z.object({
- companyId: z.coerce.number().int().positive().optional().openapi({
- description: '企业ID(从认证用户获取,可覆盖)',
- example: 1
- })
- });
- // 类型定义
- export type StatItem = z.infer<typeof StatItemSchema>;
- export type AgeGroup = z.infer<typeof AgeGroupSchema>;
- export type SalaryRange = z.infer<typeof SalaryRangeSchema>;
- export type DisabilityTypeDistributionResponse = z.infer<typeof DisabilityTypeDistributionResponseSchema>;
- export type GenderDistributionResponse = z.infer<typeof GenderDistributionResponseSchema>;
- export type AgeDistributionResponse = z.infer<typeof AgeDistributionResponseSchema>;
- export type HouseholdStatItem = z.infer<typeof HouseholdStatItemSchema>;
- export type HouseholdDistributionResponse = z.infer<typeof HouseholdDistributionResponseSchema>;
- export type JobStatusDistributionResponse = z.infer<typeof JobStatusDistributionResponseSchema>;
- export type SalaryDistributionResponse = z.infer<typeof SalaryDistributionResponseSchema>;
- export type StatisticsQuery = z.infer<typeof StatisticsQuerySchema>;
|