| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- import { z } from '@hono/zod-openapi';
- import { OrderStatus, WorkStatus } from '@d8d/allin-enums';
- import { DisabledPersonSchema } from '@d8d/allin-disability-module/schemas';
- // 资产类型枚举 - 从实体移到schema,供前端使用
- export enum AssetType {
- TAX = 'tax',
- SALARY = 'salary',
- JOB_RESULT = 'job_result',
- CONTRACT_SIGN = 'contract_sign',
- DISABILITY_CERT = 'disability_cert',
- OTHER = 'other',
- SALARY_VIDEO = 'salary_video',
- TAX_VIDEO = 'tax_video',
- CHECKIN_VIDEO = 'checkin_video',
- WORK_VIDEO = 'work_video',
- }
- // 资产文件类型枚举 - 从实体移到schema,供前端使用
- export enum AssetFileType {
- IMAGE = 'image',
- VIDEO = 'video',
- }
- // 用工订单实体Schema
- export const EmploymentOrderSchema = z.object({
- id: z.number().int().positive().openapi({
- description: '订单ID',
- example: 1
- }),
- orderName: z.string().max(50).nullable().optional().openapi({
- description: '订单名称',
- example: '2024年Q1用工订单'
- }),
- platformId: z.number().int().positive().openapi({
- description: '用人平台ID',
- example: 1
- }),
- companyId: z.number().int().positive().openapi({
- description: '用人单位ID',
- example: 1
- }),
- channelId: z.number().int().positive().nullable().optional().openapi({
- description: '渠道ID',
- example: 1
- }),
- expectedStartDate: z.coerce.date().nullable().optional().openapi({
- description: '预计开始日期',
- example: '2024-01-01T00:00:00Z'
- }),
- actualStartDate: z.coerce.date().nullable().optional().openapi({
- description: '实际开始日期',
- example: '2024-01-01T00:00:00Z'
- }),
- actualEndDate: z.coerce.date().nullable().optional().openapi({
- description: '实际结束日期',
- example: '2024-12-31T00:00:00Z'
- }),
- orderStatus: z.nativeEnum(OrderStatus).default(OrderStatus.DRAFT).openapi({
- description: '订单状态:draft-草稿, confirmed-已确认, in_progress-进行中, completed-已完成, cancelled-已取消',
- example: OrderStatus.DRAFT
- }),
- workStatus: z.nativeEnum(WorkStatus).default(WorkStatus.NOT_WORKING).openapi({
- description: '工作状态:not_working-未就业, pre_working-待就业, working-已就业, resigned-已离职',
- example: WorkStatus.NOT_WORKING
- }),
- createTime: z.coerce.date().openapi({
- description: '创建时间',
- example: '2024-01-01T00:00:00Z'
- }),
- updateTime: z.coerce.date().openapi({
- description: '更新时间',
- example: '2024-01-01T00:00:00Z'
- }),
- orderPersons: z.array(z.lazy(() => OrderPersonSchema)).optional().openapi({
- description: '订单关联人员列表',
- example: []
- })
- });
- // 创建用工订单DTO
- export const CreateEmploymentOrderSchema = z.object({
- orderName: z.string().max(50).optional().openapi({
- description: '订单名称',
- example: '2024年Q1用工订单'
- }),
- platformId: z.coerce.number().int().positive().openapi({
- description: '用人平台ID',
- example: 1
- }),
- companyId: z.coerce.number().int().positive().openapi({
- description: '用人单位ID',
- example: 1
- }),
- channelId: z.coerce.number().int().positive().optional().openapi({
- description: '渠道ID',
- example: 1
- }),
- expectedStartDate: z.coerce.date().optional().openapi({
- description: '预计开始日期',
- example: '2024-01-01T00:00:00Z'
- }),
- actualStartDate: z.coerce.date().optional().openapi({
- description: '实际开始日期',
- example: '2024-01-01T00:00:00Z'
- }),
- actualEndDate: z.coerce.date().optional().openapi({
- description: '实际结束日期',
- example: '2024-12-31T00:00:00Z'
- }),
- orderStatus: z.nativeEnum(OrderStatus).default(OrderStatus.DRAFT).optional().openapi({
- description: '订单状态:draft-草稿, confirmed-已确认, in_progress-进行中, completed-已完成, cancelled-已取消',
- example: OrderStatus.DRAFT
- }),
- workStatus: z.nativeEnum(WorkStatus).default(WorkStatus.NOT_WORKING).optional().openapi({
- description: '工作状态:not_working-未就业, pre_working-待就业, working-已就业, resigned-已离职',
- example: WorkStatus.NOT_WORKING
- })
- });
- // 更新用工订单DTO
- export const UpdateEmploymentOrderSchema = z.object({
- id: z.coerce.number().int().positive().openapi({
- description: '订单ID',
- example: 1
- }),
- orderName: z.string().max(50).optional().openapi({
- description: '订单名称',
- example: '2024年Q1用工订单'
- }),
- platformId: z.coerce.number().int().positive().optional().openapi({
- description: '用人平台ID',
- example: 1
- }),
- companyId: z.coerce.number().int().positive().optional().openapi({
- description: '用人单位ID',
- example: 1
- }),
- channelId: z.coerce.number().int().positive().optional().openapi({
- description: '渠道ID',
- example: 1
- }),
- expectedStartDate: z.coerce.date().optional().openapi({
- description: '预计开始日期',
- example: '2024-01-01T00:00:00Z'
- }),
- actualStartDate: z.coerce.date().optional().openapi({
- description: '实际开始日期',
- example: '2024-01-01T00:00:00Z'
- }),
- actualEndDate: z.coerce.date().optional().openapi({
- description: '实际结束日期',
- example: '2024-12-31T00:00:00Z'
- }),
- orderStatus: z.nativeEnum(OrderStatus).optional().openapi({
- description: '订单状态:draft-草稿, confirmed-已确认, in_progress-进行中, completed-已完成, cancelled-已取消',
- example: OrderStatus.DRAFT
- }),
- workStatus: z.nativeEnum(WorkStatus).optional().openapi({
- description: '工作状态:not_working-未就业, pre_working-待就业, working-已就业, resigned-已离职',
- example: WorkStatus.NOT_WORKING
- })
- });
- // 订单人员关联实体Schema
- export const OrderPersonSchema = z.object({
- id: z.number().int().positive().openapi({
- description: '关联ID',
- example: 1
- }),
- orderId: z.number().int().positive().openapi({
- description: '订单ID',
- example: 1
- }),
- personId: z.number().int().positive().openapi({
- description: '残疾人ID',
- example: 1
- }),
- joinDate: z.coerce.date().openapi({
- description: '入职日期',
- example: '2024-01-01T00:00:00Z'
- }),
- actualStartDate: z.coerce.date().nullable().optional().openapi({
- description: '实际入职日期',
- example: '2024-01-15T00:00:00Z'
- }),
- leaveDate: z.coerce.date().nullable().optional().openapi({
- description: '离职日期',
- example: '2024-12-31T00:00:00Z'
- }),
- workStatus: z.nativeEnum(WorkStatus).default(WorkStatus.NOT_WORKING).openapi({
- description: '工作状态:not_working-未就业, pre_working-待就业, working-已就业, resigned-已离职',
- example: WorkStatus.NOT_WORKING
- }),
- salaryDetail: z.coerce.number().positive().openapi({
- description: '个人薪资',
- example: 5000.00
- }),
- // 残疾人员的详细信息
- person: DisabledPersonSchema.pick({
- id: true,
- name: true,
- gender: true,
- disabilityType: true,
- phone: true,
- disabilityId: true
- }).partial().nullable().optional().openapi({
- description: '残疾人员详细信息'
- })
- });
- // 创建订单人员关联DTO
- export const CreateOrderPersonSchema = z.object({
- orderId: z.coerce.number().int().positive().openapi({
- description: '订单ID',
- example: 1
- }),
- personId: z.coerce.number().int().positive().openapi({
- description: '残疾人ID',
- example: 1
- }),
- joinDate: z.coerce.date().openapi({
- description: '入职日期',
- example: '2024-01-01T00:00:00Z'
- }),
- leaveDate: z.coerce.date().optional().openapi({
- description: '离职日期',
- example: '2024-12-31T00:00:00Z'
- }),
- workStatus: z.nativeEnum(WorkStatus).default(WorkStatus.NOT_WORKING).optional().openapi({
- description: '工作状态:not_working-未就业, pre_working-待就业, working-已就业, resigned-已离职',
- example: WorkStatus.NOT_WORKING
- }),
- salaryDetail: z.coerce.number().positive().openapi({
- description: '个人薪资',
- example: 5000.00
- })
- });
- // 批量添加人员DTO(不需要orderId,从URL参数获取)
- export const BatchAddPersonItemSchema = z.object({
- personId: z.coerce.number().int().positive().openapi({
- description: '残疾人ID',
- example: 1
- }),
- joinDate: z.coerce.date().openapi({
- description: '入职日期',
- example: '2024-01-01T00:00:00Z'
- }),
- leaveDate: z.coerce.date().optional().openapi({
- description: '离职日期',
- example: '2024-12-31T00:00:00Z'
- }),
- workStatus: z.nativeEnum(WorkStatus).default(WorkStatus.NOT_WORKING).optional().openapi({
- description: '工作状态:not_working-未就业, pre_working-待就业, working-已就业, resigned-已离职',
- example: WorkStatus.NOT_WORKING
- }),
- salaryDetail: z.coerce.number().positive().openapi({
- description: '个人薪资',
- example: 5000.00
- })
- });
- // 订单人员资产实体Schema
- export const OrderPersonAssetSchema = z.object({
- id: z.number().int().positive().openapi({
- description: '关联ID',
- example: 1
- }),
- orderId: z.number().int().positive().openapi({
- description: '订单ID',
- example: 1
- }),
- personId: z.number().int().positive().openapi({
- description: '残疾人ID',
- example: 1
- }),
- assetType: z.nativeEnum(AssetType).openapi({
- description: '资产类型:tax-税务, salary-薪资, job_result-工作成果, contract_sign-合同签署, disability_cert-残疾证明, other-其他, salary_video-工资视频, tax_video-个税视频, checkin_video-打卡视频, work_video-工作视频',
- example: AssetType.SALARY
- }),
- assetFileType: z.nativeEnum(AssetFileType).openapi({
- description: '资产文件类型:image-图片, video-视频',
- example: AssetFileType.IMAGE
- }),
- fileId: z.number().int().positive().openapi({
- description: '文件ID,引用files表',
- example: 1
- }),
- relatedTime: z.coerce.date().openapi({
- description: '关联时间',
- example: '2024-01-01T00:00:00Z'
- }),
- updateTime: z.coerce.date().openapi({
- description: '更新时间',
- example: '2024-01-01T00:00:00Z'
- })
- });
- // 创建订单人员资产DTO
- export const CreateOrderPersonAssetSchema = z.object({
- orderId: z.coerce.number().int().positive().openapi({
- description: '订单ID',
- example: 1
- }),
- personId: z.coerce.number().int().positive().openapi({
- description: '残疾人ID',
- example: 1
- }),
- assetType: z.nativeEnum(AssetType).openapi({
- description: '资产类型:tax-税务, salary-薪资, job_result-工作成果, contract_sign-合同签署, disability_cert-残疾证明, other-其他, salary_video-工资视频, tax_video-个税视频, checkin_video-打卡视频, work_video-工作视频',
- example: AssetType.SALARY
- }),
- assetFileType: z.nativeEnum(AssetFileType).openapi({
- description: '资产文件类型:image-图片, video-视频',
- example: AssetFileType.IMAGE
- }),
- fileId: z.coerce.number().int().positive().openapi({
- description: '文件ID,引用files表',
- example: 1
- }),
- relatedTime: z.coerce.date().optional().openapi({
- description: '关联时间',
- example: '2024-01-01T00:00:00Z'
- })
- });
- // 分页查询参数Schema
- export const PaginationQuerySchema = z.object({
- skip: z.coerce.number().int().min(0).default(0).optional().openapi({
- description: '跳过记录数',
- example: 0
- }),
- take: z.coerce.number().int().min(1).max(100).default(10).optional().openapi({
- description: '获取记录数',
- example: 10
- })
- });
- // 删除订单DTO
- export const DeleteOrderSchema = z.object({
- id: z.number().int().positive().openapi({
- description: '订单ID',
- example: 1
- })
- });
- // 删除订单人员DTO
- export const DeleteOrderPersonSchema = z.object({
- id: z.number().int().positive().openapi({
- description: '关联ID',
- example: 1
- })
- });
- // 删除订单人员资产DTO
- export const DeleteOrderPersonAssetSchema = z.object({
- id: z.number().int().positive().openapi({
- description: '关联ID',
- example: 1
- })
- });
- // 类型定义
- export type EmploymentOrder = z.infer<typeof EmploymentOrderSchema>;
- export type CreateEmploymentOrderDto = z.infer<typeof CreateEmploymentOrderSchema>;
- export type UpdateEmploymentOrderDto = z.infer<typeof UpdateEmploymentOrderSchema>;
- export type OrderPerson = z.infer<typeof OrderPersonSchema>;
- export type CreateOrderPersonDto = z.infer<typeof CreateOrderPersonSchema>;
- export type OrderPersonAsset = z.infer<typeof OrderPersonAssetSchema>;
- export type CreateOrderPersonAssetDto = z.infer<typeof CreateOrderPersonAssetSchema>;
- export type PaginationQuery = z.infer<typeof PaginationQuerySchema>;
- export type DeleteOrderDto = z.infer<typeof DeleteOrderSchema>;
- export type DeleteOrderPersonDto = z.infer<typeof DeleteOrderPersonSchema>;
- export type DeleteOrderPersonAssetDto = z.infer<typeof DeleteOrderPersonAssetSchema>;
- export type UpdatePersonWorkStatusDto = z.infer<typeof UpdatePersonWorkStatusSchema>;
- // 查询订单参数Schema
- export const QueryOrderSchema = z.object({
- orderName: z.string().optional().openapi({
- description: '订单名称',
- example: '2024年Q1用工订单'
- }),
- platformId: z.coerce.number().int().positive().optional().openapi({
- description: '用人平台ID',
- example: 1
- }),
- companyId: z.coerce.number().int().positive().optional().openapi({
- description: '用人单位ID',
- example: 1
- }),
- channelId: z.coerce.number().int().positive().optional().openapi({
- description: '渠道ID',
- example: 1
- }),
- orderStatus: z.nativeEnum(OrderStatus).optional().openapi({
- description: '订单状态',
- example: OrderStatus.DRAFT
- }),
- startDate: z.string().optional().openapi({
- description: '开始日期(YYYY-MM-DD格式)',
- example: '2024-01-01'
- }),
- endDate: z.string().optional().openapi({
- description: '结束日期(YYYY-MM-DD格式)',
- example: '2024-12-31'
- }),
- page: z.coerce.number().int().min(1).default(1).optional().openapi({
- description: '页码',
- example: 1
- }),
- limit: z.coerce.number().int().min(1).max(100).default(10).optional().openapi({
- description: '每页数量',
- example: 10
- })
- });
- // 查询订单人员资产参数Schema
- export const QueryOrderPersonAssetSchema = z.object({
- orderId: z.coerce.number().int().positive().optional().openapi({
- description: '订单ID',
- example: 1
- }),
- personId: z.coerce.number().int().positive().optional().openapi({
- description: '人员ID',
- example: 1
- }),
- assetType: z.nativeEnum(AssetType).optional().openapi({
- description: '资产类型:tax-税务, salary-薪资, job_result-工作成果, contract_sign-合同签署, disability_cert-残疾证明, other-其他, salary_video-工资视频, tax_video-个税视频, checkin_video-打卡视频, work_video-工作视频',
- example: AssetType.SALARY
- }),
- assetFileType: z.nativeEnum(AssetFileType).optional().openapi({
- description: '资产文件类型',
- example: AssetFileType.IMAGE
- }),
- page: z.coerce.number().int().min(1).default(1).optional().openapi({
- description: '页码',
- example: 1
- }),
- limit: z.coerce.number().int().min(1).max(100).default(10).optional().openapi({
- description: '每页数量',
- example: 10
- })
- });
- // 为兼容性添加别名导出
- export const CreateOrderSchema = CreateEmploymentOrderSchema;
- export const UpdateOrderSchema = UpdateEmploymentOrderSchema;
- export const BatchAddPersonsSchema = z.object({
- persons: z.array(BatchAddPersonItemSchema).openapi({
- description: '人员列表',
- example: [{ personId: 1, joinDate: '2024-01-01T00:00:00Z', salaryDetail: 5000 }]
- })
- });
- // 更新订单人员工作状态DTO
- export const UpdatePersonWorkStatusSchema = z.object({
- orderId: z.coerce.number().int().positive().openapi({
- description: '订单ID',
- example: 1
- }),
- personId: z.coerce.number().int().positive().openapi({
- description: '人员ID',
- example: 1
- }),
- workStatus: z.nativeEnum(WorkStatus).openapi({
- description: '工作状态:not_working-未就业, pre_working-待就业, working-已就业, resigned-已离职',
- example: WorkStatus.WORKING
- })
- });
|