| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, JoinColumn, Index } from 'typeorm';
- import { EmploymentOrder } from './employment-order.entity';
- import { DisabledPerson } from '@d8d/allin-disability-module/entities';
- import { WorkStatus } from '@d8d/allin-enums';
- @Entity('order_person', { comment: '订单人员关联表' })
- @Index(['personId', 'workStatus']) // 人才工作历史查询优化
- @Index(['orderId']) // 通过订单查询优化
- export class OrderPerson {
- @PrimaryGeneratedColumn({
- name: 'op_id',
- type: 'int',
- unsigned: true,
- comment: '关联ID'
- })
- id!: number;
- @Column({
- name: 'order_id',
- type: 'int',
- nullable: false,
- comment: '订单ID'
- })
- orderId!: number;
- @Column({
- name: 'person_id',
- type: 'int',
- nullable: false,
- comment: '残疾人ID'
- })
- personId!: number;
- @Column({
- name: 'join_date',
- type: 'date',
- nullable: false,
- comment: '入职日期'
- })
- joinDate!: Date;
- @Column({
- name: 'actual_start_date',
- type: 'date',
- nullable: true,
- comment: '实际入职日期'
- })
- actualStartDate?: Date;
- @Column({
- name: 'leave_date',
- type: 'date',
- nullable: true,
- comment: '离职日期'
- })
- leaveDate?: Date;
- @Column({
- name: 'work_status',
- type: 'enum',
- enum: WorkStatus,
- default: WorkStatus.NOT_WORKING,
- comment: '工作状态:not_working-未就业, pre_working-待就业, working-已就业, resigned-已离职'
- })
- workStatus!: WorkStatus;
- @Column({
- name: 'salary_detail',
- type: 'decimal',
- precision: 10,
- scale: 2,
- nullable: false,
- comment: '个人薪资'
- })
- salaryDetail!: number;
- // 关系定义 - 与订单的关联
- @ManyToOne(() => EmploymentOrder, (order) => order.orderPersons, { onDelete: 'CASCADE' })
- @JoinColumn({ name: 'order_id' })
- order!: EmploymentOrder;
- // 与残疾人员的关联
- @ManyToOne(() => DisabledPerson, { onDelete: 'CASCADE' })
- @JoinColumn({ name: 'person_id' })
- person!: DisabledPerson;
- constructor(partial?: Partial<OrderPerson>) {
- Object.assign(this, partial);
- }
- }
|